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 |
|---|---|---|---|---|
tools/SPARK2005/packages/polypaver/pp_lf_elementary.ads | michalkonecny/polypaver | 1 | 21279 | -- A SPARK wrapper for some elementary functions.
-- The PolyPaver SPARK pre-processor will replace any call
-- of these functions with their equivalent from package
-- PP_LF_Rounded, supplying a value for the additional Prec parameter.
package PP_LF_Elementary is
function Pi return Long_Float;
function Exp (X : Long_Float) return Long_Float;
function Sqrt (X : Long_Float) return Long_Float;
end PP_LF_Elementary;
|
libsrc/graphics/vg5k/clsgraph.asm | Toysoft/z88dk | 8 | 95670 | <reponame>Toysoft/z88dk
;
; Philips VG-5000 Graphics Functions
;
; cls () -- clear screen
;
; <NAME> - Oct 2015
;
;
; $Id: clsgraph.asm,v 1.3 2017-01-02 22:57:59 aralbrec Exp $
;
SECTION code_clib
PUBLIC cleargraphics
PUBLIC _cleargraphics
EXTERN base_graphics
.cleargraphics
._cleargraphics
; ld d,' '
; ld e,7 ; white on black
ld h,25+6
.loop2
ld l,40
.loop1
push hl
ld de,128+32+64+16+64*256
dec l
call 92h
pop hl
dec l
jr nz,loop1
dec h
ld a,h
cp 7
jr nz,loop2
ld h,0
ld l,40
.loop3
push hl
ld de,128+32+64+16+64*256
dec l
call 92h
pop hl
dec l
jr nz,loop3
ret
|
src/text/gl-text-utf8.ads | Roldak/OpenGLAda | 79 | 30742 | <filename>src/text/gl-text-utf8.ads<gh_stars>10-100
private package GL.Text.UTF8 is
type Code_Point is mod 2**32;
subtype UTF8_Code_Point is Code_Point range 0 .. 16#10FFFF#;
procedure Read (Buffer : String; Position : in out Positive;
Result : out UTF8_Code_Point);
end GL.Text.UTF8;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_229.asm | ljhsiun2/medusa | 9 | 161519 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x54c3, %r10
nop
nop
nop
nop
nop
sub $29157, %r14
mov $0x6162636465666768, %r9
movq %r9, %xmm4
and $0xffffffffffffffc0, %r10
vmovntdq %ymm4, (%r10)
nop
nop
nop
nop
nop
add %rdx, %rdx
lea addresses_UC_ht+0xb9d3, %rsi
lea addresses_D_ht+0x3dd3, %rdi
nop
nop
add %r10, %r10
mov $90, %rcx
rep movsl
nop
cmp %rdi, %rdi
lea addresses_normal_ht+0xefd3, %rsi
lea addresses_WC_ht+0x18053, %rdi
nop
nop
nop
nop
nop
xor %r11, %r11
mov $11, %rcx
rep movsl
nop
nop
nop
nop
nop
xor %rdx, %rdx
lea addresses_WT_ht+0x1a1ef, %r11
add $32292, %rcx
mov (%r11), %r14d
nop
nop
nop
xor %r14, %r14
lea addresses_A_ht+0xa413, %r10
sub %rsi, %rsi
mov $0x6162636465666768, %r11
movq %r11, %xmm4
vmovups %ymm4, (%r10)
nop
nop
nop
nop
nop
sub %r14, %r14
lea addresses_WC_ht+0x127d3, %rsi
lea addresses_WC_ht+0x117d3, %rdi
nop
nop
nop
xor $17456, %rdx
mov $102, %rcx
rep movsq
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_WT_ht+0x76d3, %rsi
nop
cmp %r9, %r9
mov $0x6162636465666768, %r11
movq %r11, %xmm5
and $0xffffffffffffffc0, %rsi
movntdq %xmm5, (%rsi)
nop
nop
nop
nop
nop
inc %r9
lea addresses_UC_ht+0xa13, %r9
nop
nop
cmp %rdi, %rdi
movb (%r9), %r10b
nop
nop
xor $53614, %rcx
lea addresses_WC_ht+0x17eb, %rdi
add $41487, %rcx
movb $0x61, (%rdi)
nop
nop
nop
add %r10, %r10
lea addresses_WT_ht+0x161f3, %r14
and %r11, %r11
movups (%r14), %xmm2
vpextrq $1, %xmm2, %r10
nop
nop
nop
nop
xor $52693, %rsi
lea addresses_D_ht+0x18553, %rdx
nop
add %rdi, %rdi
mov $0x6162636465666768, %r10
movq %r10, (%rdx)
add %rsi, %rsi
lea addresses_normal_ht+0x19ed3, %rsi
nop
nop
nop
nop
nop
cmp %r10, %r10
mov $0x6162636465666768, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%rsi)
nop
nop
nop
xor $3445, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_D+0x18313, %rsi
lea addresses_PSE+0x16363, %rdi
nop
nop
nop
nop
nop
xor $52737, %rbx
mov $58, %rcx
rep movsb
mfence
// Faulty Load
lea addresses_UC+0xbfd3, %r11
nop
add %r13, %r13
vmovups (%r11), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $0, %xmm2, %rsi
lea oracles, %r11
and $0xff, %rsi
shlq $12, %rsi
mov (%r11,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_PSE', 'congruent': 4, 'same': False}}
[Faulty Load]
{'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': True, 'same': False, 'congruent': 7}}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 3}}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 8}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
multithread/ada/synchronous_concurrent.ads | octonion/examples | 4 | 24056 | <gh_stars>1-10
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Synchronous_Concurrent is
task Printer is
entry Put(Item : in String);
entry Get_Count(Count : out Natural);
end Printer;
end Synchronous_Concurrent;
|
oeis/072/A072154.asm | neoneye/loda-programs | 11 | 11815 | <reponame>neoneye/loda-programs
; A072154: Coordination sequence for the planar net 4.6.12.
; Submitted by <NAME>(s3)
; 1,3,5,7,9,12,15,17,19,21,24,27,29,31,33,36,39,41,43,45,48,51,53,55,57,60,63,65,67,69,72,75,77,79,81,84,87,89,91,93,96,99,101,103,105,108,111,113,115,117,120,123,125,127,129,132,135,137,139,141,144,147,149,151,153,156,159,161,163,165,168,171,173,175,177,180,183,185,187,189,192,195,197,199,201,204,207,209,211,213,216,219,221,223,225,228,231,233,235,237
mov $1,$0
div $1,5
add $1,2
add $1,$0
mov $3,$0
add $0,$1
sub $3,1
mov $2,$3
div $2,5
add $0,$2
sub $0,1
|
oeis/127/A127394.asm | neoneye/loda-programs | 11 | 15160 | ; A127394: Number of irreducible representations of Sp(2n,R) with same infinitesimal character as the trivial representation.
; Submitted by <NAME>
; 4,18,88,460,2544,14776,89632,565392,3695680,24959776,173752704,1244125888,9146568448,68933546880,531838104064,4195358822656,33800254620672,277843218452992,2328182040156160,19870770461838336,172610363453599744,1525013813211609088,13694911244804825088,124930280386953318400,1157076861298444877824,10874821464541445431296,103667282645684915372032,1001909489667977714778112,9813005786830266119946240,97362773548063771936915456,978231441402071054944436224,9949417725588238079866503168
add $0,1
mov $3,1
lpb $0
sub $0,1
mul $3,2
mov $2,$3
mul $2,$0
mul $3,2
add $3,$1
mov $1,$2
lpe
mov $0,$3
|
MySource/task1.asm | mdabdullahibnaharun/Assembly-Language | 0 | 167021 | <reponame>mdabdullahibnaharun/Assembly-Language<gh_stars>0
.model small
.stack 100h
.code
main proc
mov ah,01h
int 21h
mov bl,al
add bl,al
add bl,al
mov ah,01h
int 21h
add bl,al
mov ah,01h
int 21h
mov cl,bl
add cl,bl
sub bl,cl
sub bl,30h
mov dl,bl
mov ah,02h
int 21h
main endp
end main |
notes/FOT/FOTC/Polymorphism/List.agda | asr/fotc | 11 | 14525 | ------------------------------------------------------------------------------
-- Testing polymorphic lists using data types
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Polymorphism.List where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Bool.Type
open import FOTC.Data.List.Type
open import FOTC.Data.Nat.List.Type
open import FOTC.Data.Nat.Type
open import FOTC.Data.Nat.UnaryNumbers
------------------------------------------------------------------------------
-- "Heterogeneous" total lists
xs : D
xs = 0' ∷ true ∷ 1' ∷ false ∷ []
xs-List : List xs
xs-List = lcons 0' (lcons true (lcons 1' (lcons false lnil)))
-- Total lists of total natural numbers
ys : D
ys = 0' ∷ 1' ∷ 2' ∷ []
ys-ListN : ListN ys
ys-ListN =
lncons nzero (lncons (nsucc nzero) (lncons (nsucc (nsucc nzero)) lnnil))
-- Total lists of total Booleans
data ListB : D → Set where
lbnil : ListB []
lbcons : ∀ {b bs} → Bool b → ListB bs → ListB (b ∷ bs)
zs : D
zs = true ∷ false ∷ true ∷ []
zs-ListB : ListB zs
zs-ListB = lbcons btrue (lbcons bfalse (lbcons btrue lbnil))
------------------------------------------------------------------------------
-- Polymorphic lists.
data Plist (P : D → Set) : D → Set where
lnil : Plist P []
lcons : ∀ {x xs} → P x → Plist P xs → Plist P (x ∷ xs)
-- "Heterogeneous" total lists
List₁ : D → Set
List₁ = Plist (λ d → d ≡ d)
xs-List₁ : List₁ xs
xs-List₁ = lcons refl (lcons refl (lcons refl (lcons refl lnil)))
-- Total lists of total natural numbers
ListN₁ : D → Set
ListN₁ = Plist N
ys-ListN₁ : ListN₁ ys
ys-ListN₁ = lcons nzero (lcons (nsucc nzero) (lcons (nsucc (nsucc nzero)) lnil))
-- Total lists of total Booleans
ListB₁ : D → Set
ListB₁ = Plist Bool
zs-ListB₁ : ListB₁ zs
zs-ListB₁ = lcons btrue (lcons bfalse (lcons btrue lnil))
|
open_folder_ITerm2 copy.applescript | snoop2head/Macbook_TouchBar_Shortcuts | 1 | 3585 | for f in "$@"; do
open -a iTerm "$f"
done |
README/Safe/Cubical/Erased.agda | nad/equality | 3 | 14192 | ------------------------------------------------------------------------
-- Safe modules that use --erased-cubical
------------------------------------------------------------------------
{-# OPTIONS --safe --erased-cubical #-}
module README.Safe.Cubical.Erased where
-- Paths, extensionality and univalence.
import Equality.Path
-- Isomorphisms and equalities relating an arbitrary "equality with J"
-- to path equality, along with proofs of extensionality and
-- univalence for the "equality with J".
import Equality.Path.Isomorphisms
-- The cubical identity type.
import Equality.Id
-- Propositional equality, with some extra bells and whistles
-- definable in Cubical Agda.
import Equality.Propositional.Cubical
-- Some tactics aimed at making equational reasoning proofs more
-- readable for path equality.
import Tactic.By.Path
-- Some tactics aimed at making equational reasoning proofs more
-- readable for the cubical identity type.
import Tactic.By.Id
-- Some theory of Erased, developed using Cubical Agda.
import Erased.Cubical
-- Some theory of equivalences with erased "proofs", defined in terms
-- of partly erased contractible fibres, developed using Cubical Agda.
import Equivalence.Erased.Contractible-preimages.Cubical
-- Some theory of equivalences with erased "proofs", developed using
-- Cubical Agda.
import Equivalence.Erased.Cubical
-- A sequential colimit for which everything except for the "base
-- case" is erased.
import Colimit.Sequential.Very-erased
-- The sequential colimit HIT with an erased higher constructor.
import Colimit.Sequential.Erased
-- Sequential colimits.
import Colimit.Sequential
-- The one-step truncation HIT with an erased higher constructor.
import H-level.Truncation.Propositional.One-step.Erased
-- The one-step truncation.
import H-level.Truncation.Propositional.One-step
-- A non-recursive variant of H-level.Truncation.Propositional.Erased.
import H-level.Truncation.Propositional.Non-recursive.Erased
-- A variant of the propositional truncation operator with an erased
-- truncation constructor.
import H-level.Truncation.Propositional.Erased
-- Propositional truncation.
import H-level.Truncation.Propositional
-- A definition of the propositional truncation operator that does not
-- use recursive higher inductive types.
import H-level.Truncation.Propositional.Non-recursive
-- Some properties that hold for Erased do not hold for every
-- accessible modality.
import Erased.Counterexamples.Cubical
-- The "interval".
import Interval
-- Suspensions.
import Suspension
-- Spheres.
import Sphere
-- Pushouts, defined using a HIT.
import Pushout
-- Localisation.
import Localisation
-- Truncation, defined as a HIT.
import H-level.Truncation
-- Homotopy groups of pointed types.
import Pointed-type.Homotopy-group
-- Connectedness for pointed types.
import Pointed-type.Connected
-- A variant of set quotients with erased higher constructors.
import Quotient.Erased.Basics
-- Quotients (set-quotients), defined using a higher inductive type.
import Quotient
-- Two variants of the set quotients from Quotient.
import Quotient.Set-truncated-if-propositional
import Quotient.Higher-constructors-if-propositional
-- A variant of set quotients with erased higher constructors.
import Quotient.Erased
-- Cyclic groups.
import Group.Cyclic
-- Integers, defined using a quotient type.
import Integer.Quotient
-- The Eilenberg-MacLane space K(G, 1).
import Eilenberg-MacLane-space
-- Coherently constant functions.
import Coherently-constant
-- The "circle".
import Circle
-- The circle with an erased higher constructor.
import Circle.Erased
-- The torus, defined as a HIT.
import Torus
-- The figure of eight.
import Figure-of-eight
-- A variant of Nat.Wrapper.Cubical, defined using --erased-cubical.
import Nat.Wrapper.Cubical.Erased
-- A variant of the development in "Internalizing Representation
-- Independence with Univalence" (by Angiuli, Cavallo, Mörtberg and
-- Zeuner) with support for erasure.
import Structure-identity-principle.Erased
-- Truncated queues: any two queues representing the same sequence are
-- equal, and things are set up so that at compile-time (but not at
-- run-time) some queue operations compute in roughly the same way as
-- the corresponding list operations.
import Queue.Truncated
-- Queue instances for the queues in Queue.Truncated.
import Queue.Truncated.Instances
-- Quotiented queues: any two queues representing the same sequence
-- are equal.
import Queue.Quotiented
-- Queue instances for the queues in Queue.Quotiented.
import Queue.Quotiented.Instances
|
programs/oeis/040/A040559.asm | jmorken/loda | 1 | 165769 | ; A040559: Continued fraction for sqrt(584).
; 24,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48,6,48
pow $0,4
mov $1,$0
trn $0,4
sub $0,4
gcd $1,$0
mul $1,6
|
agda/Cham/Label.agda | riz0id/chemical-abstract-machine | 0 | 7902 | <reponame>riz0id/chemical-abstract-machine
{-# OPTIONS --without-K --safe #-}
module Cham.Label where
open import Cham.Name
data Label : Set where
_⁺ : Name → Label
_⁻ : Name → Label
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_1347.asm | ljhsiun2/medusa | 9 | 15001 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r15
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x9fbd, %r8
nop
nop
nop
nop
nop
cmp $32090, %r12
movb (%r8), %dl
nop
nop
nop
nop
cmp %r8, %r8
lea addresses_D_ht+0x1a1d, %r13
nop
nop
nop
cmp %rsi, %rsi
mov $0x6162636465666768, %r15
movq %r15, %xmm5
movups %xmm5, (%r13)
nop
nop
nop
add %r15, %r15
lea addresses_WC_ht+0x160d1, %rsi
lea addresses_WC_ht+0x1923d, %rdi
nop
sub %r8, %r8
mov $81, %rcx
rep movsw
nop
nop
xor %r13, %r13
lea addresses_normal_ht+0x132fd, %r15
clflush (%r15)
nop
nop
dec %r8
movb $0x61, (%r15)
nop
and $53692, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r15
push %r9
push %rax
push %rcx
push %rdi
// Store
lea addresses_A+0x1c415, %r14
nop
xor $28397, %rcx
movw $0x5152, (%r14)
nop
xor %rax, %rax
// Store
lea addresses_D+0x10bd, %rax
sub %r15, %r15
movw $0x5152, (%rax)
nop
nop
nop
nop
sub $36415, %rax
// Faulty Load
lea addresses_normal+0x18cbd, %rcx
nop
nop
xor %rdi, %rdi
mov (%rcx), %r13
lea oracles, %rcx
and $0xff, %r13
shlq $12, %r13
mov (%rcx,%r13,1), %r13
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_D', 'size': 2, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
test/src/vulkan-test.ads | persan/a-vulkan | 0 | 23075 | <filename>test/src/vulkan-test.ads
package Vulkan.Test is
end Vulkan.Test;
|
software/pcx86/bdsrc/cmd/gen.asm | fatman2021/basicdos | 0 | 176145 | ;
; BASIC-DOS Code Generator
;
; @author <NAME> <<EMAIL>>
; @copyright (c) 2020-2021 <NAME>
; @license MIT <https://basicdos.com/LICENSE.txt>
;
; This file is part of PCjs, a computer emulation software project at pcjs.org
;
include cmd.inc
include 8086.inc
CODE SEGMENT
EXTNEAR <allocCode,shrinkCode,freeCode,freeAllCode>
EXTNEAR <allocVars,allocFunc,freeFunc>
EXTNEAR <allocTempVars,updateTempVars,freeTempVars>
EXTNEAR <addVar,findVar,getVar,removeVar,setVar,setVarLong>
EXTNEAR <memError>
EXTNEAR <clearScreen,callDOS,printArgs,printEcho,printLine>
EXTNEAR <setColor,setFlags>
EXTWORD <KEYWORD_TOKENS,KEYOP_TOKENS>
EXTBYTE <OPDEFS_LONG,OPDEFS_STR,RELOPS>
EXTABS <TOK_ELSE,TOK_OFF,TOK_ON,TOK_THEN>
ASSUME CS:CODE, DS:DATA, ES:DATA, SS:DATA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genCode
;
; Inputs:
; AL = GEN flags (eg, GEN_BATCH)
; DS:BX -> heap
; DS:SI -> INPUTBUF (for single line) or null (for TBLKs)
;
; Outputs:
; None
;
; Modifies:
; Any
;
DEFPROC genCode
LOCVAR codeSeg,word ; code segment
LOCVAR defVarSeg,word ; default VBLK segment
LOCVAR defType,byte ; used by genDefInt, etc.
LOCVAR pCode,dword ; original start of generated code
ENTER
mov [codeSeg],cs
test al,GEN_BATCH
jz gc1
or al,GEN_ECHO
gc1: mov [bx].GEN_FLAGS,al
sub cx,cx
mov [bx].ERR_CODE,cl
mov [bx].LINE_NUM,cx
mov dx,ds
test si,si
jnz gc2
mov dx,[bx].TBLKDEF.BLK_NEXT
test dx,dx ; anything to run?
jz gc9 ; no (TODO: display a message?)
mov si,size TBLK
gc2: mov [bx].LINE_PTR.OFF,si
mov [bx].LINE_PTR.SEG,dx
mov [bx].LINE_LEN,cx ; CX = previous length (0)
call allocVars
jc gce
mov ax,[bx].VBLKDEF.BLK_NEXT
mov [defVarSeg],ax ; save the first (default) VBLK segment
call allocCode
jc gce
ASSUME ES:NOTHING ; ES:DI -> code block
mov [pCode].OFF,di
mov [pCode].SEG,es
mov ax,OP_MOV_BP_SP ; make it easy for endProgram
stosw ; to reset the stack and return
gc4: call getNextLine
cmc
jnc gc6
call genCommands ; generate code
jnc gc4
gc6: push ss
pop ds
ASSUME DS:DATA
jc gc7
mov al,OP_RETF ; terminate the code in the buffer
stosb
;
; The memory model for the generated code is simple: CS is the current
; code block, SS is the heap, DS is the first var block, and ES is scratch.
;
push bp
push ds
mov ds,[defVarSeg]
ASSUME DS:NOTHING
call [pCode] ; execute the code buffer
pop ds
ASSUME DS:DATA
pop bp
clc
gc7: pushf
call freeAllCode
popf
gc8: jnc gc9
mov bx,ds:[PSP_HEAP]
PRINTF <"Syntax error in line %d",13,10>,[bx].LINE_NUM
stc
jmp short gc9
gce: call memError
gc9: LEAVE
ret
ENDPROC genCode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genCommands
;
; Generate code for one or more commands.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genCommands
mov al,CLS_KEYWORD
call getNextToken
jb gcs1
je gcs9 ; out of tokens
mov cx,cs:[si].CTD_FUNC ;
cmp al,KEYWORD_BASIC ; BASIC keyword?
jb gcs2 ; no
jcxz gcs9 ; no command address
jmp short gcs3 ; call generator function
gcs1: sub ax,ax ; call genDOS w/o an ID
;
; For non-BASIC keywords, generate callDOS code with a pointer to the
; full command-line and the keyword handler. callDOS will then perform
; the traditional parse-and-execute logic.
;
gcs2: cbw ; AX = keyword ID
mov dx,cx ; DX = handler address
mov cx,offset genDOS
gcs3: call cx ; call dedicated generator function
mov es:[BLK_FREE],di
jnc genCommands
gcs9: ret
ENDPROC genCommands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genCLS
;
; Generate code for "CLS"
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genCLS
GENCALL clearScreen
ret
ENDPROC genCLS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genDOS
;
; Generate code for DOS commands.
;
; Inputs:
; AL = keyword ID
; DX = handler offset
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genDOS
push ax
GENPUSH dx ; push handler offset
pop dx
GENPUSH dx ; push keyword ID
mov si,ds:[PSP_HEAP]
mov ax,[bx - size TOKLET].TOKLET_OFF
lea cx,[si].LINEBUF
sub ax,cx ; AX = # bytes preceding command
mov cx,[si].LINE_LEN
sub cx,ax
push ax
GENPUSH cx ; push length of command line
mov cx,[si].LINE_PTR.OFF
pop ax
add cx,ax
mov dx,[si].LINE_PTR.SEG ; DX:CX -> command line
GENPUSH dx,cx ; push pointer to command line
GENCALL callDOS
mov [si].TOKLET_END,bx ; mark the tokens fully processed
ret
ENDPROC genDOS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genColor
;
; Generate code for "COLOR fgnd[,[bgnd[,[border]]"
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genColor
sub cx,cx
gco1: call genExpr
jb gco9
je gco8
inc cx
cmp al,',' ; was the last symbol a comma?
je gco1 ; yes, go back for more
gco8: GENPUSH cx
GENCALL setColor
gco9: ret
ENDPROC genColor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genDefFn
;
; Generate code for "DEF fn(parms)=expr".
;
; We rely on genExpr to generate the code for "expr", which requires us to
; create a temp var block containing all the variables in "parms", so that
; when genExpr calls findVar, it searches the temp var block first.
;
; Note that we do NOT require the function name to begin with "FN" like
; MSBASIC does.
;
; TODO: We shouldn't allow DEF to redefine a function that already exists,
; but since BAT files inherit existing var blocks, we permit it (see call to
; removeVar). Unfortunately, all removeVar does is mark the existing var
; data as DEAD, and addVar doesn't currently reuse DEAD space, so memory will
; grow until you force the var blocks to be deleted.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genDefFn
LOCVAR segVars,word
LOCVAR fnParms,byte
LOCVAR fnType,byte
LOCVAR fnBlock,byte
LOCVAR fnNameLen,word
LOCVAR fnNameOff,word
LOCVAR fnParmOff,word
;
; Unlike other "gen" functions, if this function generates anything, it
; goes into a new code block, not the current code block, so we save and
; restore ES:DI before the ENTER and after LEAVE (since we depend on LEAVE
; to "CLEANUP" any data left on the stack in the event of an error).
;
mov es:[BLK_FREE],di
push es
push di
ENTER
mov si,ds:[PSP_HEAP]
test [si].GEN_FLAGS,GEN_DEF
jnz gd1x ; nested DEF fn not allowed
or [si].GEN_FLAGS,GEN_DEF
mov al,CLS_VAR
call getNextToken
jbe gd1x
and ah,VAR_TYPE ; convert CLS_VAR_* to VAR_*
;
; We're going to save the VAR_FUNC var info on the stack until we have a
; complete description for addVar; we already have the return type (AH), but
; we also need the parameter count and the generated code for the expression.
;
sub dx,dx
mov [segVars],dx
mov [fnType],ah
mov [fnBlock],1
mov [fnParms],dl
mov [fnNameLen],cx
;
; Copy the function name onto the stack, because if this is a function block,
; the buffer containing the name will be overwritten before we can call addVar.
;
inc cx
and cl,NOT 1 ; increase length to next EVEN value
sub sp,cx
mov di,sp ; ES:DI is available for reuse
mov [fnNameOff],di
push ss ; since we saved them on entry above
pop es
rep movsb
;
; The parameter list is next, and it's optional.
;
call getNextSymbol
jbe gd3 ; assume it's a block
dec [fnBlock] ; switch assumption to non-block
cmp al,'='
je gd3 ; no parameters
cmp al,'('
jne gd1x ; command appears to be invalid
;
; Allocate a temp var block and then work through all the parameters.
;
call allocTempVars ; returns original var block in DX
mov [segVars],dx
sub dx,dx ; DX = parm offset
mov [fnParmOff],sp ; top of parm info on stack
gd1: mov al,CLS_VAR
call getNextToken
jz gd1x ; ran out of parameters
jb gd2
mov dl,ah
and dl,VAR_TYPE ; DL = parm type
mov ah,VAR_PARM
inc dh
jz gd1x ; too many parameters
push dx
call addVar
pop ax
push ax
jc gd1x ; unable to add the parameter
;
; AX contains the parm info that was in DX prior to calling addVar
; (AL = parm type, AH = parm offset). Store AX in the var data (DX:SI).
;
inc [fnParms]
call setVar
xchg dx,ax ; restore DX (done with the var data)
call getNextSymbol
jbe gd1x
cmp al,','
je gd1
cmp al,')'
je gd2
gd1x: jmp short gd3x
gd2: inc [fnBlock] ; revert to block assumption
call getNextSymbol
jbe gd2a ; no symbols, assumption is good
dec [fnBlock] ; more symbols, so revert to non-block
cmp al,'=' ; expression to follow?
jne gd3x ; no
;
; Time to add the original var block(s) back to the chain, so that genExpr
; has access to both the parameter variables we just added and all globals.
;
gd2a: mov dx,[segVars]
call updateTempVars
;
; Similar to what we did with allocTempVars (if there was a parameter list),
; we call allocFunc to create a fresh code buffer for genExpr.
;
gd3: call allocFunc
jc gd3x
push di
IFDEF MAXDEBUG
mov ax,OP_INT06
stosw
mov al,OP_INT03
stosb
ENDIF
mov al,OP_PUSH_BP
stosb
mov ax,OP_MOV_BP_SP
stosw
;
; At this point, if we're defining a "function expression", then all we
; do is call genExpr. Otherwise, if we're defining a "function block", then
; we must call genCommands and getNextLine in a loop until we encounter a
; RETURN command.
;
mov si,ds:[PSP_HEAP]
mov al,[fnParms] ; set DEF_PARMS in case
mov [si].DEF_PARMS,al ; genExpr encounters any VAR_PARMs
cmp [fnBlock],0 ; function expression?
jne gd3a ; no
call genExpr ; yes
jnc gd3c
gd3x: jmp short gd8
gd3a: push si
call getNextLine ; function block
jc gd3b ; ran out of lines before RETURN
call genCommands ; generate some code
gd3b: pop si
jc gd3x
test [si].GEN_FLAGS,GEN_DEF ; did a RETURN clear GEN_DEF?
jnz gd3a ; not yet
;
; genExpr generates code that leaves the result on the stack, so to wrap up
; this function call, we must generate code that pops that result into the
; return variable on the stack (which genFuncExpr allocated prior to the call).
;
gd3c: mov cl,[fnParms]
mov ch,0
add cx,cx
add cx,cx
add cx,6
call genPopBPOffset
inc cx
inc cx
call genPopBPOffset
mov ax,OP_POP_BP OR (OP_RETF_N SHL 8)
stosw
sub cx,8
xchg ax,cx
stosw
call shrinkCode
;
; ES contains the generated code, so we're ready to add the VAR_FUNC now.
; But first, call freeTempVars and restore var block to its original state,
; if we allocated a temp block for parameters.
;
cmp [segVars],0
je gd3d
call freeTempVars
gd3d: mov cx,[fnNameLen]
mov si,[fnNameOff] ; DS:SI -> function name on stack
call removeVar ; remove any existing function var
jc gd7 ; error (predefined)
mov ah,VAR_FUNC
mov al,[fnParms]
call addVar ; add new function var
jc gd7 ; error (eg, out of memory)
;
; DX:SI -> VAR_FUNC var data. Set the function return type and # parameters,
; followed by each of the parameters types and offsets.
;
mov di,[fnParmOff] ; DI = top of parm info on stack
mov ax,word ptr [fnType]
gd4: call setVar
dec [fnParms]
jl gd5
dec di
dec di
mov ax,[di] ; AH = parm offset
mov ah,PARM_REQUIRED ; which we replace with parm flags
jmp gd4
gd5: pop di ; ES:DI -> generated code
mov ax,di
call setVar
mov ax,es
call setVar ; function address updated
clc
jmp short gd9
gd7: call freeFunc ; on error, free the code block in ES
;
; Error paths converge here. Even if parameter info is still pushed on the
; stack, the LEAVE macro automatically cleans up the stack.
;
gd8: stc
gd9: LEAVE CLEANUP
pop di
pop es
RETURN
ENDPROC genDefFn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genDefInt
;
; Process "DEFINT". In BASIC-DOS, "DEFINT" really means "DEFLONG", but we'll
; continue using the original keyword.
;
; NOTE: Originally, I was concerned about parsing and updating letter ranges
; as we go, because if a syntax error occurs midway, we'll end up with partial
; changes. Then I tried the same thing in MSBASIC, and I ended up with partial
; changes. So there you go.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genDefInt
mov [defType],VAR_LONG
DEFLBL genDefVar,near
call getCharToken ; check for char
jbe gdi8
mov dl,al ; DL = 1st char of range
mov dh,al ; DH = last char of range
call getNextSymbol ; check for hyphen
jc gdi9 ; error
jz gdi3 ; no more tokens
cmp al,'-'
je gdi2
sub bx,size TOKLET ; we'll revisit this token below
jmp short gdi3
gdi2: call getCharToken ; check for another char
jbe gdi8
mov dh,al ; DH = new last char of range
cmp dh,dl ; is the range in order?
jb gdi8 ; no, report error
;
; For every letter from DL through DH, set DEFVARS[DL] to defType.
;
gdi3: push bx
mov cl,dh
sub cl,dl
mov ch,0
inc cx ; CX = # of letters to set
mov al,[defType] ; AL = new default for each letter
mov bx,ds:[PSP_HEAP]
lea bx,[bx].DEFVARS
sub dl,'A'
add bl,dl
adc bh,ch ; BX -> 1st letter
gdi3a: mov [bx],al
inc bx
loop gdi3a
pop bx
call getNextSymbol ; check for comma
jbe gdi9
cmp al,','
je genDefVar
gdi8: stc
gdi9: ret
DEFLBL getCharToken,near
mov al,CLS_VAR ; token must be CLS_VAR
call getNextToken
jbe gdi8
dec cx
jnz gdi8 ; and it must have a length of 1
inc cx
ret
ENDPROC genDefInt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genDefDbl
;
; Process "DEFDBL". In BASIC-DOS, floating-point will comes in only one
; flavor, and this is it; "DEFSNG" is allowed, but it's treated as "DEFDBL".
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genDefDbl
mov [defType],VAR_DOUBLE
jmp genDefVar
ENDPROC genDefDbl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genDefStr
;
; Process "DEFSTR".
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genDefStr
mov [defType],VAR_STR
jmp genDefVar
ENDPROC genDefStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genEcho
;
; Process "ECHO". If "ECHO ON" or "ECHO OFF", generate call to setFlags.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genEcho
mov al,CLS_KEYWORD
call getNextToken
jb gec9
jnz gec1
GENCALL printEcho
ret
gec1: cmp al,TOK_ON
jne gec2
mov ah,NOT CMD_NOECHO
jmp short gec8
gec2: cmp al,TOK_OFF
stc
jne gec9
mov ah,CMD_NOECHO
gec8: mov al,OP_MOV_AL
stosw ; "MOV AL,xx" where XX is value in AH
GENCALL setFlags
gec9: ret
ENDPROC genEcho
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genExpr
;
; Generate code for an expression. To help catch errors up front, maintain
; a count of values queued, compare that to the number of arguments expected
; by all the operators, and also maintain an open parentheses count.
;
; Inputs:
; DS:BX -> next TOKLET
; ES:DI -> next unused location in code block
;
; Outputs:
; AX = last result from getNextToken
; DL = expression type, DH = # tokens
; CF clear if successful, set if error
; ZF clear if expression existed, set if not
; ES:DI -> next unused location in code block
;
; Modifies:
; AX, BX, DX, DI
;
DEFPROC genExpr
LOCVAR exprToks,byte
LOCVAR exprType,byte
LOCVAR exprParms,byte
LOCVAR exprArgs,word
LOCVAR exprVals,word
LOCVAR exprParens,word
LOCVAR exprPrevOp,word
ENTER
push cx
push si
mov si,ds:[PSP_HEAP]
mov al,[si].DEF_PARMS
mov [exprParms],al ; parm count (only from genDefFn)
sub dx,dx
mov word ptr [exprType],dx ; exprType = VAR_NONE, exprToks = 0
mov [exprArgs],1 ; count of expected arguments
mov [exprVals],dx ; count of values queued
mov [exprParens],dx ; count of open parentheses
mov [exprPrevOp],dx ; previous operator (none)
push dx ; push end-of-operators marker (zero)
ge1: mov al,CLS_ANY ; CLS_NUM, CLS_SYM, CLS_VAR, CLS_STR
call getNextToken
jbe ge2x
inc [exprToks]
cmp ah,CLS_SYM ; 20h?
je ge1b ; process CLS_SYM below
;
; Non-operator (non-symbol) cases: keywords, variables, strings, and numbers.
;
mov byte ptr [exprPrevOp],-1; invalidate prevOp (intervening token)
cmp ah,CLS_KEYWORD ; 30h?
je ge2x ; keywords not allowed in expressions
cmp ah,CLS_VAR ; 10h? (variable with type?)
ASSERT NE ; (type should be fully qualified now)
ja ge2 ; yes
;
; Must be CLS_STR or CLS_NUM. Handle CLS_STR here and CLS_NUM below.
;
test ah,CLS_STR ; string?
jz ge3 ; no, must be number
mov al,VAR_STR ; AL = VAR_STR
call setExprType ; update expression type
jnz ge2x
sub cx,2 ; CX = string length
ASSERT NC
jcxz ge1a ; empty string
inc si ; DS:SI -> string contents
call genPushStr
jmp short ge2e
ge1a: DBGBRK
sub cx,cx ; for empty strings, push null ptr
sub dx,dx
call genPushImmLong
jmp short ge2e
ge1b: jmp short ge4
;
; Process CLS_VAR. We don't care if findVar succeeds or not, because
; even if it fails, it returns var type (AH) VAR_LONG with var data (DX:SI)
; set to a zero constant. However, var type (AH) must still be consistent
; with the expression type.
;
ge2: call findVar
cmp ah,VAR_PARM ; 20h?
jne ge2a ; no
;
; VAR_PARM variables are present only in temp var blocks created by genDefFn,
; so genDefFn must have called us with a parameter count.
;
mov cl,[exprParms]
call genFuncParm
jmp short ge2b
ge2a: cmp ah,VAR_FUNC ; C0h?
jne ge2c
call genFuncExpr ; process the function expression
ge2b: jnc ge2d ; AH = return type
jmp short ge3x
ge2c: call genPushVarLong
ge2d: mov al,ah ; AL = var type
call setExprType ; update expression type
jnz ge3x ; error
ge2e: inc [exprVals] ; count another queued value
jmp ge1
ge2x: jmp short ge3x
;
; Process CLS_NUM. Number is a constant and CX is its exact length.
;
; TODO: If the preceding character is a '-' and the top of the operator stack
; is 'N' (unary minus), consider decrementing SI and removing the operator.
; Why? Because it's better for ATOI32 to know up front that we're dealing with
; a negative number, because then it can do precise overflow checks.
;
ge3: mov al,VAR_LONG ; AL = VAR_LONG
call setExprType ; update expression type
jnz ge3x ; error
push bx
mov bl,10 ; BL = 10 (default base)
test ah,CLS_OCT OR CLS_HEX ; octal or hex value?
jz ge3a ; no
inc si ; yes, skip leading ampersand
shl ah,1
shl ah,1
shl ah,1
mov bl,ah ; BL = 8 or 16 (new base)
cmp byte ptr [si],'9' ; is next character a digit?
jbe ge3a ; yes
inc si ; no, skip it (must be 'O' or 'H')
ge3a: DOSUTIL ATOI32 ; DS:SI -> numeric string (length CX)
xchg cx,ax ; save result in DX:CX
pop bx
GENPUSH dx,cx
jmp ge2e ; go count another queued value
ge3x: jmp short ge8
;
; Process CLS_SYM. Before we try to validate the operator, we need to remap
; binary minus to unary minus. So, if we have a minus, and the previous token
; is undefined, or another operator, or a left paren, it's unary. Ditto for
; unary plus. The internal identifiers for unary '-' and '+' are 'N' and 'P'.
;
ge4: mov ah,'N'
cmp al,'-'
je ge4a
mov ah,'P'
cmp al,'+'
jne ge5
ge4a: mov cx,[exprPrevOp]
jcxz ge4b
cmp cl,')' ; do NOT remap if preceded by ')'
je ge5
cmp cl,-1 ; another operator (including '(')?
je ge5 ; no
ge4b: mov al,ah ; remap the operator
;
; Verify that the symbol is a valid operator.
;
ge5: call validateOp ; AL = operator to validate
jc ge7b ; error (reset AH to CLS_SYM)
mov [exprPrevOp],ax
sub si,si
jcxz ge7 ; handle no-arg operators below
dec cx
add [exprArgs],cx
mov si,dx ; SI = current evaluator
;
; Operator is valid, so peek at the operator stack and pop if the top
; operator precedence >= current operator precedence.
;
ge5a: pop dx ; "peek"
cmp dh,ah ; top precedence > current?
jb ge6 ; no
ja ge5b ; yes
test dh,1 ; unary operator?
jnz ge6 ; yes, hold off
ge5b: pop cx ; pop the evaluator as well
jcxz ge6c ; no evaluator (eg, left paren)
IFDEF MAXDEBUG
DPRINTF 'o',<"op %c, func @%08lx\r\n">,dx,cx,cs
ENDIF
GENCALL cx ; and generate call
jmp ge5a
ge6: push dx ; "unpeek"
ge6a: push si ; push current evaluator
push ax ; push current operator/precedence
ge6b: jmp ge1 ; next token
;
; We just popped an operator with no evaluator; if it's a left paren,
; we're done; otherwise, ignore it (eg, unary '+').
;
ge6c: cmp dl,'('
je ge6b
jmp ge5a
;
; When special (eg, zero arg) operators are encountered in the expression,
; they are handled here.
;
ge7: cmp al,'('
jne ge7a
inc [exprParens]
jmp ge6a
;
; When parsing one in a series of comma-delimited expressions, all of which
; may be parenthesized, we must treat the closing parenthesis no differently
; than the commas.
;
ge7a: ASSERT Z,<cmp al,')'>
dec [exprParens]
jge ge5a
ge7b: mov ah,CLS_SYM
;
; We have reached the (presumed) end of the expression, so start popping
; the operator stack.
;
ge8: pop cx
jcxz ge9 ; all done
IFDEF MAXDEBUG
pop ax
DPRINTF 'o',<"op %c, func @%08lx...\r\n">,cx,ax,cs
xchg cx,ax
ELSE
pop cx ; CX = evaluator
ENDIF
jcxz ge8
GENCALL cx
jmp ge8
;
; Verify the number of values queued matches the number of expected arguments.
;
ge9: mov cx,[exprVals]
cmp cx,[exprArgs]
stc
jne ge10
cmp [exprParens],0
stc
jg ge10
test cx,cx ; return ZF set if no values
ge10: mov dx,word ptr [exprType] ; DL = expression type, DH = # tokens
pop si
pop cx
LEAVE
RETURN
DEFLBL setExprType,near
cmp [exprType],al
je set9
cmp [exprType],0
jne set9
mov [exprType],al
set9: ret ; return ZF set if type is OK
ENDPROC genExpr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genFuncExpr
;
; Generate code for "func(parm1,parm2,...)". The func variable has already
; been parsed and DX:SI has been set to the corresponding function data.
;
; NOTE: Function data for predefined functions is actually at CS:SI, but
; since we must also support user-defined functions, we can't assume that.
; This is why we must use the loadFuncData helper function, instead of simple
; LODSW CS: instructions.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
; DX:SI -> function data
;
; Outputs:
; Carry clear if successful, AH = return type
;
; Modifies:
; Any
;
DEFPROC genFuncExpr
LOCVAR nFuncParms,byte
LOCVAR nFuncType,byte
LOCVAR pFuncData,dword
ENTER
sub cx,cx ; CX = 0 if no parms supplied
mov [pFuncData].OFF,si
mov [pFuncData].SEG,dx
call loadFuncData
mov word ptr [nFuncType],ax ; nFuncType = AL, nFuncParms = AH
;
; NOTE: peekNextSymbol can "fail" for any number of reasons, including
; the fact that not all operators that may follow an unparenthesized function
; reference are symbols (eg, "MOD"). So we must be very forgiving here.
;
call peekNextSymbol ; check for parenthesis
jbe gfe0
cmp al,'('
jne gfe0
inc cx ; CX = 1 if one or more parms supplied
call getNextSymbol ; consume the parenthesis
;
; For VAR_LONG functions, the generated stack frame needs to begin with room
; for a VAR_LONG return value; we use genPushLong instead of genPushZeroLong
; because it generates less code AND it doesn't matter what value gets pushed.
;
gfe0: ASSERT Z,<cmp [nFuncType],VAR_LONG>
call genPushLong
gfe1: dec [nFuncParms] ; more parameters?
jl gfe6 ; no
jcxz gfe3 ; yes, but no (more) have been supplied
call genExpr ; process parameter expression
jbe gfe3 ; no value supplied
push ax ; save last symbol from genExpr
call loadFuncData ; AL = parameter type
cmp al,dl ; does it match expression type?
pop ax ; restore last symbol
jne gfe9 ; no, error
cmp ah,CLS_SYM ; was last token a symbol?
jne gfe9 ; no, error
cmp al,')' ; yes, closing parenthesis?
jne gfe2 ; no
sub cx,cx ; zero number of remaining parms
jmp gfe1
gfe2: cmp al,',' ; comma?
jne gfe9 ; no, error
test cl,cl ; are more parameters allowed?
jz gfe9 ; no
jmp gfe1
;
; No parameter value was supplied, so if the parameter isn't optional,
; that's an error.
;
gfe3: call loadFuncData
cmp al,VAR_LONG ; TODO: currently supports default
stc ; parameter values for VAR_LONG only
jne gfe9
mov al,ah ; AL = default value
test al,al ; negative? (eg, PARM_REQUIRED)
jl gfe9 ; yes, parameter is NOT optional
cbw
cwd ; DX:AX = default value
xchg cx,ax ; DX:CX
call genPushImmLong ; push it
sub cx,cx
jmp gfe1 ; continue processing parameters
gfe6: jcxz gfe7
cmp al,')'
jne gfe9 ; something is malformed
gfe7: call loadFuncData ; AX = function address offset
xchg cx,ax
call loadFuncData ; AX = function address segment
xchg dx,ax
test dx,dx
jnz gfe8
mov dx,cs
gfe8: GENCALL dx,cx ; generate call to function DX:CX
mov ah,[nFuncType] ; AH = return type
jmp short gfe10 ; GENCALL should have cleared carry
gfe9: stc
gfe10: LEAVE
ret
DEFLBL loadFuncData,near
push ds
lds si,[pFuncData]
lodsw
mov [pFuncData].OFF,si
pop ds
ret
ENDPROC genFuncExpr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genFuncParm
;
; Generate code for accessing parameter N (of CL parameters).
;
; For example, if CL is 3 and the parameter # is 2, calculate the
; parameter offset ((count - parm #) * 4 + 6) and generate the code:
;
; push [bp+(offset+2)]
; push [bp+(offset+0)]
;
; Inputs:
; CL = parm count
; DX:SI -> parm data
; ES:DI -> code block
;
; Outputs:
; If carry clear, AH = parm type (from parm data)
;
; Modifies:
; AX, DI
;
DEFPROC genFuncParm
call getVar ; AL = parm type, AH = parm #
sub cl,ah
jc gfp9 ; parm # inconsistency
mov ah,al
push ax
mov ch,0
add cx,cx
add cx,cx
add cx,8 ; adjust CX for high word first
call genPushBPOffset
dec cx
dec cx ; then back down to the low word
call genPushBPOffset
pop ax
clc
gfp9: ret
ENDPROC genFuncParm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genGoto
;
; Generate code for "GOTO [line]"
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genGoto
mov al,CLS_NUM
call getNextToken
jbe gg9
DOSUTIL ATOI32D ; DS:SI -> decimal string
call findLabel
;
; If carry is clear, then we found the specified label # (ie, it must have
; been a backward reference), so we can generate the correct code immediately;
; AX contains the LBL_IP to use.
;
; If carry is set, then the label # must be a forward reference. findLabel
; automatically calls addLabel with LBL_RESOLVE set, so when the definition is
; finally found, this (and any other LBL_RESOLVE references) can be resolved.
;
; In the interim, we generate a 3-byte program termination sequence (reset
; the stack pointer and return); once the label definition is encountered, that
; 3-byte sequence will be overwritten with a 3-byte JMP (see addLabel).
;
jc gg7
xchg dx,ax
sub dx,di
sub dx,3 ; DX = 16-bit displacement
mov al,OP_JMP
stosb
xchg ax,dx
stosw
jmp short gg8
gg7: mov ax,OP_MOV_SP_BP ; placeholder for endProgram
stosw
mov al,OP_RETF
stosb
gg8: clc
gg9: ret
ENDPROC genGoto
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genIf
;
; Generate code for "IF [expr] THEN [commands] ELSE [commands]"
;
; "IF" is like a unary operator: generate code for the expression, pop the
; result, and jump to the "THEN" command block if non-zero or the "ELSE"
; command block if zero.
;
; Each block of commands must go back through genCommands, which is simple
; enough, unless there is another "IF" in the block, because any subsequent
; "ELSE" belongs to the second "IF", not the first.
;
; The general structure of the generated code will look like:
;
; call evalEQLong (assuming an expression with '=')
; pop ax
; pop dx
; or ax,dx
; jz elseBlock
; thenBlock:
; ; Generate code for "THEN" block
; ; ...
; jmp nextBlock (optional; only needed if there's an "ELSE" block)
; elseBlock:
; ; Generate code for "ELSE" block
; ; ...
; nextBlock:
;
; So when genCommands for the "THEN" block returns, we must update the
; "jz elseBlock" with the address of the next available location. Note that
; if the amount of generated code is larger than 127 bytes, we'll have to
; move the generated code to make room for "jnz $+5; jmp elseBlock" instead.
;
; Inputs:
; DS:BX -> TOKLETs
; ES:DI -> code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genIf
call genExpr
jbe gif9
cmp ah,CLS_KEYWORD
jne gif9
cmp al,TOK_THEN
jne gif9
mov ax,OP_POP_DX_AX
stosw
mov ax,OP_OR_AX_DX
stosw
mov ax,OP_JZ_SELF
stosw
;
; Before calling genCommands, we must peek at the next token and check for
; a line number, because there could be an implied GOTO (ie, "THEN 10" instead
; of "THEN GOTO 10").
;
push di ; ES:DI-1 -> JZ offset
call genCommands
gif8: pop ax ; AX = old DI
mov dx,di ; DX = new DI
sub dx,ax ; DX = # generated bytes for JZ to skip
ASSERT B,<cmp dx,128>
sub di,dx
mov es:[di-1],dl ; update the JZ offset
add di,dx
ASSERT NC
ret
gif9: stc
ret
ENDPROC genIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genLet
;
; Generate code to "LET" a variable equal some expression. We'll start with
; 32-bit integer ("long") variables. We'll also start with the assumption
; that it's OK to alloc the variable at "gen" time, so that the only code we
; have to generate (and execute later) is code that sets the variable, using
; its preallocated location.
;
; Inputs:
; BX = offset of next TOKLET
; ES:DI -> next unused location in code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genLet
mov al,CLS_VAR
call getNextToken
jbe gl9
and ah,VAR_TYPE ; convert CLS_VAR_* to VAR_*
call addVar ; DX:SI -> var data
jc gl9
cmp dx,[codeSeg] ; constants cannot be "let"
je gl9 ; TODO: Generate a better error message
push ax
call genPushVarPtr
call getNextSymbol
pop dx
jbe gl9
cmp al,'='
jne gl9
call genExpr
jc gl9
GENCALL setVarLong ; TODO: check expression type in DL
ret
gl9: stc
ret
ENDPROC genLet
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPrint
;
; Generate code to "PRINT" a series of values.
;
; Inputs:
; BX = offset of next TOKLET
; ES:DI -> next unused location in code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genPrint
GENPUSHB VAR_NONE ; push end-of-args marker
gp1: call genExpr
jnc gp2
test dh,dh ; if there were no tokens
stc ; then ignore the error
jnz gp9 ; (PRINT without args is allowed)
gp2: jz gp8
push ax
mov al,VAR_LONG ; AL = default type (40h)
cmp dl,al ; does that match the expression type?
je gp3 ; yes
mov al,VAR_STR ; must be VAR_STR then (80h)
ASSERT Z,<cmp dl,al> ; verify our assumption
gp3: GENPUSHB al
pop ax
mov ah,VAR_SEMI
cmp al,';' ; was the last symbol a semi-colon?
je gp6 ; yes
mov ah,VAR_COMMA
cmp al,',' ; how about a comma?
jne gp8 ; no
gp6: GENPUSHB ah ; "MOV AL,[VAR_SEMI or VAR_COMMA]"
jmp gp1 ; continue processing arguments
gp8: GENCALL printArgs ; all done
gp9: ret
ENDPROC genPrint
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genReturn
;
; Generate code to "RETURN [optional value]".
;
; Inputs:
; BX = offset of next TOKLET
; ES:DI -> next unused location in code block
;
; Outputs:
; Carry clear if successful, set if error
;
; Modifies:
; Any
;
DEFPROC genReturn
mov si,ds:[PSP_HEAP]
test [si].GEN_FLAGS,GEN_DEF
jz gr9
call genExpr
jc gr9
and [si].GEN_FLAGS,NOT GEN_DEF
gr9: ret
ENDPROC genReturn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; addLabel
;
; Inputs:
; AX = label #
; ES -> current code block
;
; Outputs:
; Carry clear if successful, set if error (eg, duplicate label)
;
; Modifies:
; CX, DX
;
DEFPROC addLabel
mov dx,di ; DX = current code gen offset
mov di,ss:[PSP_HEAP]
DPRINTF 'l',<"%#010P: line %d: adding label %d...\r\n">,ss:[di].LINE_NUM,ax
test dx,LBL_RESOLVE ; is this a label reference?
jnz al8 ; yes, just add it
;
; For label definitions, we scan the LBLREF table to ensure this
; definition is unique. We must also scan the table for any unresolved
; references and fix them up.
;
mov cx,es:[BLK_SIZE]
mov di,es:[CBLK_REFS]
sub cx,di
shr cx,1 ; CX = # of words on LBLREF table
al0: jcxz al8 ; table is empty
al1: repne scasw ; scan all words for label #
jne al8 ; nothing found
test di,(size LBLREF)-1 ; did we match the first LBLREF word?
jz al0 ; no (must have match LBL_IP instead)
test word ptr es:[di],LBL_RESOLVE
stc
jz al9 ; duplicate definition
;
; Generate code in the same fashion as genGoto, except that here, we're
; replacing a previously unresolved GOTO with a forward JMP (ie, positive
; displacement) to the location at DX.
;
push ax
push dx
push di
mov di,es:[di]
and di,NOT LBL_RESOLVE
sub dx,di
sub dx,3 ; DX = 16-bit displacement
mov al,OP_JMP
stosb
xchg ax,dx
stosw
pop di
pop dx
pop ax
jmp al1 ; keep looking for LBL_RESOLVE matches
al8: mov di,es:[CBLK_REFS]
sub di,size LBLREF
mov es:[CBLK_REFS],di
stosw ; LBL_NUM <- AX
xchg ax,dx
stosw ; LBL_IP <- DX
xchg ax,dx ; restore AX
mov di,dx ; restore DI
clc
al9: ret
ENDPROC addLabel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; findLabel
;
; Inputs:
; AX = label #
; ES -> current code block
;
; Outputs:
; Carry clear if found, AX = code gen offset for label
;
; Modifies:
; AX, CX, DX
;
DEFPROC findLabel
push di
mov di,ss:[PSP_HEAP]
DPRINTF 'l',<"%#010P: line %d: finding label %d...\r\n">,ss:[di].LINE_NUM,ax
mov cx,es:[BLK_SIZE]
mov di,es:[CBLK_REFS]
sub cx,di
jcxz fl8 ; table is empty
shr cx,1 ; CX = # of words on LBLREF table
fl1: repne scasw ; scan all words for label #
jne fl8 ; nothing found
test di,(size LBLREF)-1 ; did we match the first LBLREF word?
jz fl1 ; no (must have match LBL_IP instead)
test word ptr es:[di],LBL_RESOLVE
jnz fl1 ; this is a ref, not a definition
mov ax,es:[di] ; AX = LBL_IP for label
jmp short fl9
fl8: pop di
push di
add di,LBL_RESOLVE
call addLabel
stc
fl9: pop di
ret
ENDPROC findLabel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genCallCS
;
; Inputs:
; CS:CX -> function to call (or DX:CX if using genCallFar)
;
; Outputs:
; Carry clear
;
; Modifies:
; CX, DX, DI
;
DEFPROC genCallCS
mov dx,cs
DEFLBL genCallFar,near
push ax
mov al,OP_CALLF
stosb
xchg ax,cx
stosw
xchg ax,dx
stosw
pop ax
clc
ret
ENDPROC genCallCS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPopBPOffset
;
; Inputs:
; CX = offset
;
; Outputs:
; None
;
; Modifies:
; AX, DI
;
DEFPROC genPopBPOffset
cmp cx,7Fh
ja gpo1
mov ax,OP_POP_BP8
stosw
mov al,cl
stosb
ret
gpo1: mov ax,OP_POP_BP16
stosw
mov ax,cx
stosw
ret
ENDPROC genPopBPOffset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushBPOffset
;
; Inputs:
; CX = offset
;
; Outputs:
; None
;
; Modifies:
; AX, DI
;
DEFPROC genPushBPOffset
cmp cx,7Fh
ja gpu1
mov ax,OP_PUSH_BP8
stosw
mov al,cl
stosb
ret
gpu1: mov ax,OP_PUSH_BP16
stosw
mov ax,cx
stosw
ret
ENDPROC genPushBPOffset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushVarPtr
;
; Inputs:
; DX:SI = value to push
;
; Outputs:
; None
;
; Modifies:
; AX, DX, DI
;
DEFPROC genPushVarPtr
cmp dx,[defVarSeg]
je gpv1
call genPushImm
jmp short gpv2
gpv1: mov al,OP_PUSH_DS
stosb
gpv2: mov dx,si
DEFLBL genPushImm,near
mov al,OP_MOV_AX
stosb
xchg ax,dx
stosw
mov al,OP_PUSH_AX
stosb
ret
ENDPROC genPushVarPtr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushImmByte
;
; Inputs:
; AL = OP_MOV_AL
; AH = value to push
;
; Outputs:
; None
;
; Modifies:
; AX, DI
;
DEFPROC genPushImmByteAL
mov ah,al
DEFLBL genPushImmByteAH,near
mov al,OP_MOV_AL
DEFLBL genPushImmByte,near
stosw
mov al,OP_PUSH_AX
stosb
ret
ENDPROC genPushImmByteAL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushImmLong
;
; While the general case looks like this 8-byte sequence:
;
; MOV AX,yyyy
; PUSH AX
; MOV AX,xxxx
; PUSH AX
;
; if we determine that DX (yyyy) is a sign-extension of CX (xxxx),
; we can generate this 6-byte sequence instead:
;
; MOV AX,xxxx
; CWD
; PUSH DX
; PUSH AX
;
; and if CX (xxxx) is zero, it can be simplified to a 4-byte sequence
; (ie, genPushZeroLong):
;
; XOR AX,AX
; PUSH AX
; PUSH AX
;
; Inputs:
; DX:CX = value to push
;
; Outputs:
; None
;
; Modifies:
; AX, CX, DX, DI
;
DEFPROC genPushImmLong
IFDEF MAXDEBUG
DPRINTF 'o',<"num %ld\r\n">,cx,dx
ENDIF
xchg ax,dx ; AX has original DX
xchg ax,cx ; AX contains CX, CX has original DX
cwd ; DX is 0 or FFFFh
cmp dx,cx ; same as original DX?
xchg cx,ax ; AX contains original DX, CX restored
xchg dx,ax ; DX restored
jne gpi7 ; no, DX is not the same
jcxz genPushZeroLong ; jump if we can zero AX as well
mov al,OP_MOV_AX
stosb
xchg ax,cx
stosw
mov ax,OP_CWD OR (OP_PUSH_DX SHL 8)
stosw
jmp short gpi8
gpi7: mov al,OP_MOV_AX
stosb
xchg ax,dx
stosw
mov ax,OP_PUSH_AX OR (OP_MOV_AX SHL 8)
stosw
xchg ax,cx
stosw
gpi8: mov al,OP_PUSH_AX
stosb
ret
ENDPROC genPushImmLong
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushStr
;
; Copies the string at DS:SI with length CX into the code segment,
; pushing the far address of that string and then "leaping" over the string.
;
; Inputs:
; DS:SI -> string (with length CX)
;
; Outputs:
; None
;
; Modifies:
; AX, CX DI
;
DEFPROC genPushStr
mov ax,OP_PUSH_CS OR (OP_CALL SHL 8)
stosw
mov ax,cx
inc ax ; +1 for length byte
stosw
mov al,cl
stosb ; store the length byte
rep movsb ; followed by all the characters
ret
ENDPROC genPushStr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushZeroLong
;
; Inputs:
; None
;
; Outputs:
; None
;
; Modifies:
; AX, DI
;
DEFPROC genPushZeroLong
mov ax,OP_ZERO_AX
stosw
DEFLBL genPushLong,near
mov ax,OP_PUSH_AX OR (OP_PUSH_AX SHL 8)
stosw
ret
ENDPROC genPushZeroLong
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; genPushVarLong
;
; Generates code to push 4-byte variable data onto stack (eg, a VAR_LONG
; integer or a VAR_STR pointer).
;
; DX:SI points to the variable data, and if DX == defVarSeg, then the
; generated code can assume DS:SI; otherwise, we must generate code to load
; the segment as well.
;
; The generated code will then use a pair of LODSW instructions to load the
; variable data into AX:DX and push it on the stack (yes, ordinarily we'd use
; DX:AX, but that's not the natural order a pair of LODSW provides).
;
; Inputs:
; DX:SI -> var data
;
; Outputs:
; None
;
; Modifies:
; DX, SI, DI
;
DEFPROC genPushVarLong
push ax
cmp dx,[defVarSeg]
je gpl1
mov al,OP_MOV_AX
stosb
xchg ax,dx
stosw
mov ax,OP_MOV_ES_AX
stosw
gpl1: mov al,OP_MOV_SI ; "MOV SI,offset var data"
stosb
xchg ax,si
stosw
je gpl2
mov al,OP_SEG_ES
stosb
gpl2: mov ax,OP_LODSW OR (OP_XCHG_DX SHL 8)
stosw
je gpl3
mov al,OP_SEG_ES
stosb
gpl3: mov ax,OP_LODSW OR (OP_PUSH_AX SHL 8)
stosw
mov al,OP_PUSH_DX
stosb
pop ax
ret
ENDPROC genPushVarLong
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; getNextLine
;
; Inputs:
; DS = heap segment
;
; Outputs:
; If carry clear, DS:BX -> TOKLET array (TOKLET_END set to end)
;
; Modifies:
; Any
;
DEFPROC getNextLine
mov bx,ds:[PSP_HEAP] ; DS:BX -> heap
mov cx,[bx].LINE_LEN
lds si,[bx].LINE_PTR
ASSUME DS:NOTHING
mov dx,ds
mov ax,ss
cmp ax,dx ; is LINE_PTR in the heap?
jne gnl0 ; no
test cx,cx ; yes, we must be using INPUTBUF
stc ; have we already processed it?
jnz gnl4x ; yes
mov cl,[si].INP_CNT ; CX = length
lea si,[si].INP_DATA ; DS:SI -> line
jmp short gnl4
gnl0: add si,cx ; advance to the next line
gnl1: cmp si,ds:[BLK_FREE] ; still working the same TBLK?
jb gnl2 ; yes
mov dx,ds:[BLK_NEXT] ; no, advance to next TBLK in chain
cmp dx,1 ; is there another segment?
jb gnl4x ; no
mov ds,dx
mov si,size TBLK ; DS:SI -> next line
gnl2: inc ss:[bx].LINE_NUM
lodsw
test ax,ax ; is there a label #?
jz gnl3 ; no
call addLabel ; yes, add it to the LBLREF table
gnl3: lodsb ; AL = length byte
mov ah,0
xchg cx,ax ; CX = length of line
jcxz gnl1
;
; As a preliminary matter, if we're processing a BAT file, then generate
; code to print the line, unless it starts with a '@', in which case, skip
; over the '@'.
;
gnl4: DPRINTF 'b',<"%.*ls\r\n">,cx,si,ds
cmp byte ptr [si],'@'
jne gnl5
inc si
dec cx
jz gnl1
jmp short gnl6
gnl4x: jmp short gnl9
;
; One of the annoying things about the ECHO state is that, since we can't
; be sure what the state of ECHO will be at runtime, we must inject printLine
; before every line.
;
gnl5: test ss:[bx].GEN_FLAGS,GEN_ECHO
jz gnl6
push cx
lea cx,[si-1]
GENPUSH ds,cx ; DS:CX -> string (at the length byte)
GENCALL printLine
pop cx
;
; Ready to process the line of code at DS:SI with length CX.
;
gnl6: mov ss:[bx].LINE_PTR.OFF,si
mov ss:[bx].LINE_PTR.SEG,ds
mov ss:[bx].LINE_LEN,cx
push es
push di ; save code gen pointer
push ss
pop es ; ES = heap
;
; Copy the line (at DS:SI with length CX) to LINEBUF, so that we can use a
; single segment (DS) to address both LINEBUF and TOKENBUF once ES has been
; restored to the code gen segment.
;
push cx
push es
lea di,[bx].LINEBUF ; ES:DI -> LINEBUF
push di
rep movsb
xchg ax,cx ; AL = 0
stosb ; null-terminate for good measure
pop si
pop ds
pop cx ; DS:SI -> LINEBUF (with length CX)
lea di,[bx].TOKENBUF ; ES:DI -> TOKENBUF
DOSUTIL TOKEN2
mov bx,di
add bx,offset TOK_DATA ; DS:BX -> TOKLET array
pop di
pop es ; restore code gen pointer
jc gnl9
add ax,ax
add ax,ax
add ax,bx
mov si,ds:[PSP_HEAP]
mov [si].TOKLET_END,ax
gnl9: ret
ENDPROC getNextLine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; getNextSymbol
;
; Call getNextToken with AL = CLS_SYM, updating BX and preserving CX, DX, SI.
;
DEFPROC getNextSymbol
push cx
push si
mov al,CLS_SYM
call getNextToken
pop si
pop cx
ret
ENDPROC getNextSymbol
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; getNextToken
;
; Return the next token if it matches the criteria in AL (ignores whitespace).
;
; Inputs:
; AL = CLS bits
; DS:BX -> TOKLETs
;
; Outputs if next token matches:
; AH = CLS of token
; AL = 1st character of token (upper-cased)
; CX = length of token
; SI = offset of token (or offset of TOKDEF if CLS_KEYWORD)
; BX = offset of next TOKLET
; ZF and CF clear
;
; Outputs if NO matching next token:
; ZF set if no more tokens (AX is zero)
; CF set if no matching token (AH is CLS)
;
; Modifies:
; AX, BX, CX, SI
;
DEFPROC getNextToken
push dx
push di
gnt0: mov di,ds:[PSP_HEAP]
cmp bx,[di].TOKLET_END
jb gnt0a
sub ax,ax
jmp gnt9 ; no more tokens (ZF set, CF clear)
gnt0a: mov ah,[bx].TOKLET_CLS
test ah,al
jnz gnt1
cmp ah,CLS_WHITE ; whitespace token?
gnt0b: stc
jne gnt9 ; no (CF set)
add bx,size TOKLET ; yes, so ignore it
jmp gnt0
gnt1: cmp al,CLS_KEYWORD ; looking for keyword?
jne gnt1a ; no
cmp ah,CLS_VAR ; yes, undecorated CLS_VAR?
jne gnt0b ; no, can't be a keyword then
gnt1a: mov si,[bx].TOKLET_OFF
mov cl,[bx].TOKLET_LEN
mov ch,0
add bx,size TOKLET
mov dl,al ; DL = requested CLS
mov al,[si] ; AL = 1st character of token
cmp al,'a' ; ensure 1st character is upper-case
jb gnt2
sub al,20h
;
; Any CLS_VAR with additional bits specifying the variable type (eg,
; CLS_VAR_LONG, CLS_VAR_STR) is done. Any vanilla CLS_VAR, however, must
; be further identified. We now check for keyword operators (like NOT) and
; all other keywords. Failing that, we assume it's a variable, so we look
; up the variable's implicit type and update the CLS bits accordingly.
;
gnt2: cmp ah,CLS_VAR
jne gnt7
push ax
push dx
mov dx,offset KEYOP_TOKENS ; see if token is a KEYOP
DOSUTIL TOKID ; CS:DX -> TOKTBL
jc gnt2a
mov ah,CLS_SYM ; AL = TOKDEF_ID, SI -> TOKDEF
jnc gnt2b
gnt2a: mov dx,offset KEYWORD_TOKENS; see if token is a KEYWORD
DOSUTIL TOKID ; CS:DX -> TOKTBL
jc gnt2c
mov ah,CLS_KEYWORD ; AL = TOKDEF_ID, SI -> TOKDEF
gnt2b: pop dx
pop dx
jmp short gnt8
gnt2c: pop dx ; neither KEYOP nor KEYWORD
pop ax
cmp dl,CLS_KEYWORD ; and did we request a KEYWORD?
stc
je gnt9 ; yes, return error
push bx
push ax
lea bx,[di].DEFVARS
sub al,'A' ; convert 1st letter to DEFVARS index
xlat ; look up the default VAR type
test al,al ; has a default been set?
jnz gnt4 ; yes
mov al,VAR_LONG ; no, default to VAR_LONG
gnt4: mov ah,al
or ah,CLS_VAR
pop bx ; we're really popping AX
mov al,bl ; and restoring AL
pop bx
jmp short gnt8
;
; If we're about to return a CLS_SYM that happens to be a colon, then return
; ZF set (but not carry) to end the caller's token scan.
;
gnt7: cmp ah,CLS_SYM
jne gnt8
cmp al,':'
je gnt9
gnt8: or ah,0 ; return both ZF and CF clear
gnt9: pop di
pop dx
ret
ENDPROC getNextToken
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; peekNextSymbol
;
; Peek and return the next symbol, if any. TODO: Remove if no callers.
;
; Inputs and outputs are the same as getNextSymbol, but we also save the
; offset of the next TOKLET, in case the caller wants to consume the token.
;
; Modifies:
; AX
;
DEFPROC peekNextSymbol
push bx
call getNextSymbol
jmp short peekReturn
ENDPROC peekNextSymbol
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; peekNextToken
;
; Peek and return the next token, if it matches the criteria in AL.
;
; Inputs and outputs are the same as getNextToken, but we also save the
; offset of the next TOKLET, in case the caller wants to consume the token.
;
; Modifies:
; AX, CX, SI
;
DEFPROC peekNextToken
push bx
call getNextToken
DEFLBL peekReturn,near
push bx
mov bx,ds:[PSP_HEAP]
pop ds:[bx].TOKLET_NEXT ; save BX in TOKLET_NEXT in case the
pop bx ; caller wants to advance after peeking
ret
ENDPROC peekNextToken
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; validateOp
;
; This must also check for operators that are multi-character. It must remap
; "<>" and "><" to 'U', "<=" and "=<" to 'L', and ">=" and "=>" to 'G'.
;
; See RELOPS for the complete list of multi-character operators we remap.
;
; Inputs:
; AL = operator
;
; Outputs:
; If carry clear, AL = op, AH = precedence, CX = # args, DX = evaluator
;
; Modifies:
; AH, CX, DX
;
DEFPROC validateOp
push si
xchg dx,ax ; DL = operator to validate
mov al,CLS_SYM
call peekNextToken
jbe vo2
mov dh,al ; DX = potential 2-character operator
mov si,offset RELOPS
vo1: lods word ptr cs:[si]
test al,al
jz vo2
cmp ax,dx ; match?
lods byte ptr cs:[si]
jne vo1
mov bx,ds:[PSP_HEAP]
mov bx,[bx].TOKLET_NEXT ; load TOKLET saved by peekNextToken
xchg dx,ax ; DL = (new) operator to validate
vo2: mov ah,dl ; AH = operator to validate
mov si,offset OPDEFS_LONG
cmp [exprType],VAR_STR
jne vo3
mov si,offset OPDEFS_STR
vo3: lods byte ptr cs:[si]
test al,al
stc
jz vo9 ; not valid
cmp al,ah ; match?
je vo7 ; yes
add si,size OPDEF - 1
jmp vo3
vo7: lods byte ptr cs:[si] ; AL = precedence, AH = operator
sub cx,cx ; default to 0 args
cmp al,2 ; precedence <= 2?
jbe vo8 ; yes
inc cx ; no, so op requires at least 1 arg
test al,1 ; odd precedence?
jnz vo8 ; yes, just 1 arg
inc cx ; no, op requires 2 args
vo8: xchg dx,ax
lods word ptr cs:[si] ; AX = evaluator
xchg dx,ax ; DX = evaluator, AX = op/prec
vo9: xchg al,ah ; AL = operator, AH = precedence
pop si
ret
ENDPROC validateOp
CODE ENDS
end
|
src/sys/streams/util-streams-buffered-encoders.ads | RREE/ada-util | 60 | 25210 | <reponame>RREE/ada-util
-----------------------------------------------------------------------
-- util-streams-encoders -- Streams with encoding and decoding capabilities
-- Copyright (C) 2017, 2019, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Encoders;
-- == Encoding Streams ==
-- The <tt>Encoding_Stream</tt> tagged record represents a stream with encoding capabilities.
-- The stream passes the data to be written to the <tt>Transformer</tt> interface that
-- allows to make transformations on the data before being written.
--
-- Encode : Util.Streams.Buffered.Encoders.Encoding_Stream;
--
-- The encoding stream manages a buffer that is used to hold the encoded data before it is
-- written to the target stream. The <tt>Initialize</tt> procedure must be called to indicate
-- the target stream, the size of the buffer and the encoding format to be used.
--
-- Encode.Initialize (Output => File'Access, Size => 4096, Format => "base64");
--
generic
type Encoder is limited new Util.Encoders.Transformer with private;
package Util.Streams.Buffered.Encoders is
-- -----------------------
-- Encoding stream
-- -----------------------
-- The <b>Encoding_Stream</b> is an output stream which uses an encoder to
-- transform the data before writing it to the output. The transformer can
-- change the data by encoding it in Base64, Base16 or encrypting it.
type Encoder_Stream is limited new Util.Streams.Buffered.Input_Output_Buffer_Stream
with record
Transform : Encoder;
Flushed : Boolean := False;
end record;
-- Initialize the stream with a buffer of <b>Size</b> bytes.
procedure Initialize (Stream : in out Encoder_Stream;
Size : in Positive);
-- Initialize the stream to write on the given stream.
-- An internal buffer is allocated for writing the stream.
procedure Produces (Stream : in out Encoder_Stream;
Output : access Output_Stream'Class;
Size : in Positive);
-- Initialize the stream to read the given streams.
procedure Consumes (Stream : in out Encoder_Stream;
Input : access Input_Stream'Class;
Size : in Positive);
-- Close the sink.
overriding
procedure Close (Stream : in out Encoder_Stream);
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Encoder_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Read into the buffer as many bytes as possible and return in
-- `last` the position of the last byte read.
overriding
procedure Read (Stream : in out Encoder_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Flush the buffer by writing on the output stream.
-- Raises Data_Error if there is no output stream.
overriding
procedure Flush (Stream : in out Encoder_Stream);
overriding
procedure Finalize (Stream : in out Encoder_Stream);
-- Fill the buffer by reading the input stream.
-- Raises Data_Error if there is no input stream;
procedure Fill (Stream : in out Encoder_Stream);
end Util.Streams.Buffered.Encoders;
|
Transynther/x86/_processed/NONE/_zr_/i7-8650U_0xd2_notsx.log_1_111.asm | ljhsiun2/medusa | 9 | 243042 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %r9
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1bb68, %rsi
clflush (%rsi)
nop
xor %rax, %rax
mov (%rsi), %r13
nop
nop
nop
add %r8, %r8
lea addresses_WT_ht+0x4568, %r8
nop
nop
sub %rbx, %rbx
movb (%r8), %r9b
and $8259, %rsi
lea addresses_WC_ht+0x4908, %r9
clflush (%r9)
nop
nop
nop
nop
nop
and %r8, %r8
mov (%r9), %eax
nop
and $265, %rax
lea addresses_WC_ht+0x1526c, %rbp
nop
nop
nop
nop
nop
cmp $60131, %r13
mov $0x6162636465666768, %r8
movq %r8, (%rbp)
nop
sub %rbp, %rbp
lea addresses_UC_ht+0x14210, %rbx
nop
nop
nop
nop
nop
dec %rsi
mov (%rbx), %r13
nop
add $13469, %r13
lea addresses_A_ht+0x15768, %rbx
dec %r13
movb (%rbx), %al
nop
cmp %r8, %r8
lea addresses_A_ht+0x1e398, %rbx
nop
nop
nop
xor %r13, %r13
mov $0x6162636465666768, %r8
movq %r8, %xmm0
vmovups %ymm0, (%rbx)
nop
nop
cmp $26349, %rax
lea addresses_WT_ht+0x17908, %r8
nop
nop
dec %rbp
movl $0x61626364, (%r8)
nop
nop
nop
nop
add %rax, %rax
lea addresses_WT_ht+0x16268, %r8
sub %rsi, %rsi
movups (%r8), %xmm4
vpextrq $1, %xmm4, %r13
nop
sub $46186, %r9
lea addresses_WC_ht+0x1a924, %rbx
nop
nop
nop
cmp $28076, %r9
vmovups (%rbx), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %r8
nop
nop
sub $30518, %rbx
lea addresses_D_ht+0x82e8, %r9
nop
nop
dec %r13
mov (%r9), %bp
add %rbx, %rbx
lea addresses_UC_ht+0x12c1e, %rsi
nop
nop
nop
nop
cmp %r13, %r13
movb $0x61, (%rsi)
nop
nop
nop
xor %rbp, %rbp
lea addresses_D_ht+0x16108, %rax
inc %r13
mov $0x6162636465666768, %rbp
movq %rbp, %xmm6
movups %xmm6, (%rax)
nop
nop
nop
nop
sub %r8, %r8
lea addresses_normal_ht+0x2268, %rsi
nop
nop
nop
nop
and $54937, %rbx
mov (%rsi), %r13
nop
nop
nop
nop
sub %r9, %r9
lea addresses_normal_ht+0x18b90, %rsi
lea addresses_A_ht+0xd844, %rdi
clflush (%rdi)
nop
and $40165, %r9
mov $55, %rcx
rep movsq
nop
nop
nop
nop
nop
xor %r8, %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
// Store
mov $0x125be00000000168, %rcx
nop
nop
add %rsi, %rsi
mov $0x5152535455565758, %rdi
movq %rdi, %xmm6
movaps %xmm6, (%rcx)
xor $3552, %rax
// Load
lea addresses_WT+0x16d68, %r13
nop
nop
nop
and $36152, %r9
mov (%r13), %esi
nop
cmp %rcx, %rcx
// Store
mov $0xc68, %r9
nop
nop
add $43629, %rbx
movl $0x51525354, (%r9)
nop
nop
nop
nop
nop
and $40485, %r13
// Faulty Load
lea addresses_A+0x8d68, %rcx
nop
nop
nop
xor %rsi, %rsi
mov (%rcx), %r13w
lea oracles, %rsi
and $0xff, %r13
shlq $12, %r13
mov (%rsi,%r13,1), %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'00': 1}
00
*/
|
alloy4fun_models/trainstlt/models/3/qzQjdCxexo5XwmBRo.als | Kaixi26/org.alloytools.alloy | 0 | 3453 | open main
pred idqzQjdCxexo5XwmBRo_prop4 {
all disj t1,t2:Train | some (t1.pos &t2.pos ) implies lone ((t1.pos &t2.pos ).signal &Green)
}
pred __repair { idqzQjdCxexo5XwmBRo_prop4 }
check __repair { idqzQjdCxexo5XwmBRo_prop4 <=> prop4o } |
alloy4fun_models/trainstlt/models/2/DqLwSoA4CvKPJio4q.als | Kaixi26/org.alloytools.alloy | 0 | 1113 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idDqLwSoA4CvKPJio4q_prop3 {
always (no prox)
}
pred __repair { idDqLwSoA4CvKPJio4q_prop3 }
check __repair { idDqLwSoA4CvKPJio4q_prop3 <=> prop3o } |
llvm-gcc-4.2-2.9/gcc/ada/symbols-processing-vms-ia64.adb | vidkidz/crossbridge | 1 | 11543 | <filename>llvm-gcc-4.2-2.9/gcc/ada/symbols-processing-vms-ia64.adb
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y M B O L S . P R O C E S S I N G --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2005 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the VMS/IA64 version of this package
with Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
separate (Symbols)
package body Processing is
type String_Array is array (Positive range <>) of String_Access;
type Strings_Ptr is access String_Array;
procedure Free is
new Ada.Unchecked_Deallocation (String_Array, Strings_Ptr);
type Section_Header is record
Shname : Integer;
Shtype : Integer;
Shoffset : Integer;
Shsize : Integer;
Shlink : Integer;
end record;
type Section_Header_Array is array (Natural range <>) of Section_Header;
type Section_Header_Ptr is access Section_Header_Array;
procedure Free is
new Ada.Unchecked_Deallocation (Section_Header_Array, Section_Header_Ptr);
-------------
-- Process --
-------------
procedure Process
(Object_File : String;
Success : out Boolean)
is
B : Byte;
H : Integer;
W : Integer;
Str : String (1 .. 1000) := (others => ' ');
Str_Last : Natural;
Strings : Strings_Ptr;
Shoff : Integer;
Shnum : Integer;
Shentsize : Integer;
Shname : Integer;
Shtype : Integer;
Shoffset : Integer;
Shsize : Integer;
Shlink : Integer;
Symtab_Index : Natural := 0;
String_Table_Index : Natural := 0;
End_Symtab : Integer;
Stname : Integer;
Stinfo : Character;
Sttype : Integer;
Stbind : Integer;
Stshndx : Integer;
Section_Headers : Section_Header_Ptr;
Offset : Natural := 0;
procedure Get_Byte (B : out Byte);
procedure Get_Half (H : out Integer);
procedure Get_Word (W : out Integer);
procedure Reset;
procedure Get_Byte (B : out Byte) is
begin
Byte_IO.Read (File, B);
Offset := Offset + 1;
end Get_Byte;
procedure Get_Half (H : out Integer) is
C1, C2 : Character;
begin
Get_Byte (C1); Get_Byte (C2);
H :=
Integer'(Character'Pos (C2)) * 256 + Integer'(Character'Pos (C1));
end Get_Half;
procedure Get_Word (W : out Integer) is
H1, H2 : Integer;
begin
Get_Half (H1); Get_Half (H2);
W := H2 * 256 * 256 + H1;
end Get_Word;
procedure Reset is
begin
Offset := 0;
Byte_IO.Reset (File);
end Reset;
begin
-- Open the object file with Byte_IO. Return with Success = False if
-- this fails.
begin
Open (File, In_File, Object_File);
exception
when others =>
Put_Line
("*** Unable to open object file """ & Object_File & """");
Success := False;
return;
end;
-- Assume that the object file has a correct format
Success := True;
-- Skip ELF identification
while Offset < 16 loop
Get_Byte (B);
end loop;
-- Skip e_type
Get_Half (H);
-- Skip e_machine
Get_Half (H);
-- Skip e_version
Get_Word (W);
-- Skip e_entry
for J in 1 .. 8 loop
Get_Byte (B);
end loop;
-- Skip e_phoff
for J in 1 .. 8 loop
Get_Byte (B);
end loop;
Get_Word (Shoff);
-- Skip upper half of Shoff
for J in 1 .. 4 loop
Get_Byte (B);
end loop;
-- Skip e_flags
Get_Word (W);
-- Skip e_ehsize
Get_Half (H);
-- Skip e_phentsize
Get_Half (H);
-- Skip e_phnum
Get_Half (H);
Get_Half (Shentsize);
Get_Half (Shnum);
Section_Headers := new Section_Header_Array (0 .. Shnum - 1);
-- Go to Section Headers
while Offset < Shoff loop
Get_Byte (B);
end loop;
-- Reset Symtab_Index
Symtab_Index := 0;
for J in Section_Headers'Range loop
-- Get the data for each Section Header
Get_Word (Shname);
Get_Word (Shtype);
for K in 1 .. 16 loop
Get_Byte (B);
end loop;
Get_Word (Shoffset);
Get_Word (W);
Get_Word (Shsize);
Get_Word (W);
Get_Word (Shlink);
while (Offset - Shoff) mod Shentsize /= 0 loop
Get_Byte (B);
end loop;
-- If this is the Symbol Table Section Header, record its index
if Shtype = 2 then
Symtab_Index := J;
end if;
Section_Headers (J) := (Shname, Shtype, Shoffset, Shsize, Shlink);
end loop;
if Symtab_Index = 0 then
Success := False;
return;
end if;
End_Symtab :=
Section_Headers (Symtab_Index).Shoffset +
Section_Headers (Symtab_Index).Shsize;
String_Table_Index := Section_Headers (Symtab_Index).Shlink;
Strings :=
new String_Array (1 .. Section_Headers (String_Table_Index).Shsize);
-- Go get the String Table section for the Symbol Table
Reset;
while Offset < Section_Headers (String_Table_Index).Shoffset loop
Get_Byte (B);
end loop;
Offset := 0;
Get_Byte (B); -- zero
while Offset < Section_Headers (String_Table_Index).Shsize loop
Str_Last := 0;
loop
Get_Byte (B);
if B /= ASCII.NUL then
Str_Last := Str_Last + 1;
Str (Str_Last) := B;
else
Strings (Offset - Str_Last - 1) :=
new String'(Str (1 .. Str_Last));
exit;
end if;
end loop;
end loop;
-- Go get the Symbol Table
Reset;
while Offset < Section_Headers (Symtab_Index).Shoffset loop
Get_Byte (B);
end loop;
while Offset < End_Symtab loop
Get_Word (Stname);
Get_Byte (Stinfo);
Get_Byte (B);
Get_Half (Stshndx);
for J in 1 .. 4 loop
Get_Word (W);
end loop;
Sttype := Integer'(Character'Pos (Stinfo)) mod 16;
Stbind := Integer'(Character'Pos (Stinfo)) / 16;
if (Sttype = 1 or else Sttype = 2)
and then Stbind /= 0
and then Stshndx /= 0
then
declare
S_Data : Symbol_Data;
begin
S_Data.Name := new String'(Strings (Stname).all);
if Sttype = 1 then
S_Data.Kind := Data;
else
S_Data.Kind := Proc;
end if;
-- Put the new symbol in the table
Symbol_Table.Increment_Last (Complete_Symbols);
Complete_Symbols.Table
(Symbol_Table.Last (Complete_Symbols)) := S_Data;
end;
end if;
end loop;
-- The object file has been processed, close it
Close (File);
-- Free the allocated memory
Free (Section_Headers);
for J in Strings'Range loop
if Strings (J) /= null then
Free (Strings (J));
end if;
end loop;
Free (Strings);
exception
-- For any exception, output an error message, close the object file
-- and return with Success = False.
when Ada.IO_Exceptions.End_Error =>
Close (File);
when X : others =>
Put_Line ("unexpected exception raised while processing """
& Object_File & """");
Put_Line (Exception_Information (X));
Close (File);
Success := False;
end Process;
end Processing;
|
programs/oeis/000/A000703.asm | neoneye/loda | 22 | 170210 | <reponame>neoneye/loda
; A000703: Chromatic number (or Heawood number) of nonorientable surface with n crosscaps.
; 4,6,7,7,8,9,9,10,10,10,11,11,12,12,12,13,13,13,13,14,14,14,15,15,15,15,16,16,16,16,16,17,17,17,17,18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27
mov $2,$0
mul $0,2
add $0,$2
lpb $0
add $1,1
sub $0,$1
trn $0,1
lpe
add $1,4
mov $0,$1
|
src/simple_webapps-append_servers.adb | faelys/simple-webapps | 1 | 17601 | <filename>src/simple_webapps-append_servers.adb
------------------------------------------------------------------------------
-- Copyright (c) 2016, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Directories;
with Ada.Streams.Stream_IO;
with Ada.Strings.Fixed;
with Ada.IO_Exceptions;
with AWS.Messages;
with AWS.MIME;
with AWS.Parameters;
with AWS.Response.Set;
with Natools.File_Streams;
with Natools.GNAT_HMAC.SHA256;
with Natools.S_Expressions.Atom_Ref_Constructors;
with Natools.S_Expressions.Encodings;
with Natools.S_Expressions.File_Readers;
with Natools.S_Expressions.File_Writers;
with Natools.S_Expressions.Interpreter_Loop;
with Natools.S_Expressions.Printers.Pretty.Config;
with Natools.Time_IO.RFC_3339;
with Simple_Webapps.Commands.Append_Servers;
with Templates_Parser;
package body Simple_Webapps.Append_Servers is
package Commands renames Simple_Webapps.Commands.Append_Servers;
package Constructors renames Natools.S_Expressions.Atom_Ref_Constructors;
package HMAC renames Natools.GNAT_HMAC.SHA256;
function Simple_Response
(Code : AWS.Messages.Status_Code;
Template : String := "";
Location : String := "";
Allow : String := "")
return AWS.Response.Data;
procedure Set
(State : in out Endpoint;
Context : in String;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class);
procedure Set
(State : in out Endpoint_Maps.Unsafe_Maps.Map;
Context : in Sx.Printers.Pretty.Parameters;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class);
procedure Set
(State : in out Server_Data;
Context : in String;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class);
procedure Interpreter is new Sx.Interpreter_Loop
(Endpoint, String, Set);
procedure Interpreter is new Sx.Interpreter_Loop
(Endpoint_Maps.Unsafe_Maps.Map, Sx.Printers.Pretty.Parameters, Set);
procedure Interpreter is new Sx.Interpreter_Loop
(Server_Data, String, Set);
------------------------
-- Execution Endpoint --
------------------------
procedure Append_Data
(Self : in Endpoint;
Data : in Sx.Atom)
is
function Open_File (Name : String)
return Natools.File_Streams.File_Stream;
function Open_File (Name : String)
return Natools.File_Streams.File_Stream is
begin
return Natools.File_Streams.Open
(Ada.Streams.Stream_IO.Append_File, Name);
exception
when Ada.IO_Exceptions.Name_Error =>
return Natools.File_Streams.Create
(Ada.Streams.Stream_IO.Append_File, Name);
end Open_File;
File : Natools.File_Streams.File_Stream
:= Open_File (To_String (Self.Data_Path));
begin
File.Write (Data);
end Append_Data;
procedure Log_Invalid
(Self : in Endpoint;
Data : in Sx.Atom;
Given_Signature : in Sx.Atom;
Expected_Signature : in Sx.Atom) is
begin
if To_String (Self.Invalid_Log) = "" then
Log ("Invalid signature for data posted to "
& To_String (Self.Data_Path));
return;
end if;
declare
Log_File : Sx.File_Writers.Writer
:= Sx.File_Writers.Open (To_String (Self.Invalid_Log));
begin
Log_File.Set_Parameters (Self.Pretty_Printer);
Log_File.Open_List;
Log_File.Append_String (Natools.Time_IO.RFC_3339.Image
(Ada.Calendar.Clock, Subsecond_Digits => 3));
Log_File.Open_List;
Log_File.Append_String ("endpoint");
Log_File.Append_String (To_String (Self.Data_Path));
Log_File.Close_List;
Log_File.Open_List;
Log_File.Append_String ("data");
Log_File.Append_Atom (Data);
Log_File.Close_List;
Log_File.Open_List;
Log_File.Append_String ("expected-signature");
Log_File.Append_Atom (Expected_Signature);
Log_File.Close_List;
Log_File.Open_List;
Log_File.Append_String ("given-signature");
Log_File.Append_Atom (Given_Signature);
Log_File.Close_List;
Log_File.Close_List;
if Self.Pretty_Printer.Newline_At
(Sx.Printers.Pretty.Closing, Sx.Printers.Pretty.Opening)
then
Log_File.Newline;
end if;
end;
end Log_Invalid;
function Execute
(Self : in Endpoint;
Data : in Sx.Atom;
Signature : in Sx.Atom)
return Execution_Results.Data
is
use type Sx.Atom;
begin
Signature_Check :
declare
Expected_Signature : constant Sx.Atom
:= HMAC.Digest (Self.Key.Query, Data);
begin
if Expected_Signature /= Signature then
Log_Invalid (Self, Data, Signature, Expected_Signature);
return (State => Execution_Results.Invalid_Signature);
end if;
end Signature_Check;
case Self.Separator.Action is
when No_Separator =>
Append_Data (Self, Data);
when Force_Separator =>
Append_Data (Self, Data & Self.Separator.Data.Query);
when Separator_If_Needed =>
declare
use type Sx.Offset;
Sep : constant Sx.Atom := Self.Separator.Data.Query;
begin
if Data'Length >= Sep'Length
and then Data (Data'Last - Sep'Length + 1 .. Data'Last) = Sep
then
Append_Data (Self, Data);
else
Append_Data (Self, Data & Sep);
end if;
end;
end case;
return (State => Execution_Results.OK, Redirect => Self.Redirect);
end Execute;
procedure Set
(State : in out Endpoint;
Context : in String;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class)
is
Event : Sx.Events.Event;
use type Sx.Events.Event;
begin
case Commands.To_Endpoint_Command (Sx.To_String (Name)) is
when Commands.Endpoint_Error =>
Log ("Unknown command """ & Sx.To_String (Name)
& """ for endpoint """ & Context & '"');
when Commands.Data_Path =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Data_Path := Hold (Sx.To_String (Arguments.Current_Atom));
end if;
when Commands.Force_Separator =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Separator
:= (Action => Force_Separator,
Data => Constructors.Create (Arguments.Current_Atom));
end if;
when Commands.Invalid_Log =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Invalid_Log
:= Hold (Sx.To_String (Arguments.Current_Atom));
Arguments.Next (Event);
case (Event) is
when Sx.Events.Add_Atom | Sx.Events.Open_List =>
Sx.Printers.Pretty.Config.Update
(State.Pretty_Printer, Arguments);
when Sx.Events.Close_List | Sx.Events.End_Of_Input
| Sx.Events.Error =>
null;
end case;
end if;
when Commands.Key =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Key := Constructors.Create (Arguments.Current_Atom);
end if;
when Commands.No_Separator =>
State.Separator := (Action => No_Separator);
when Commands.Redirect =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Redirect := Hold (Sx.To_String (Arguments.Current_Atom));
end if;
when Commands.Separator_If_Needed =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Separator
:= (Action => Separator_If_Needed,
Data => Constructors.Create (Arguments.Current_Atom));
end if;
end case;
end Set;
-----------------------------
-- Server-Wide Subprograms --
-----------------------------
procedure Set
(State : in out Endpoint_Maps.Unsafe_Maps.Map;
Context : in Sx.Printers.Pretty.Parameters;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class)
is
use type Sx.Events.Event;
S_Name : constant String := Sx.To_String (Name);
Item : Endpoint;
begin
Item.Pretty_Printer := Context;
Interpreter (Arguments, Item, S_Name);
if Item.Key.Is_Empty or else To_String (Item.Data_Path) = "" then
return;
end if;
State.Include (S_Name, Item);
end Set;
procedure Set
(State : in out Server_Data;
Context : in String;
Name : in Sx.Atom;
Arguments : in out Sx.Lockable.Descriptor'Class)
is
use type Sx.Events.Event;
begin
case Commands.To_Server_Command (Sx.To_String (Name)) is
when Commands.Server_Error =>
Log ("Unknown command """ & Sx.To_String (Name)
& """ for server data in """ & Context & '"');
when Commands.Default_Printer =>
Sx.Printers.Pretty.Config.Update
(State.Default_Printer, Arguments);
when Commands.Endpoints =>
declare
New_Map : Endpoint_Maps.Unsafe_Maps.Map;
begin
Interpreter (Arguments, New_Map, State.Default_Printer);
State.Endpoints := Endpoint_Maps.Create (New_Map);
end;
when Commands.Static_Path =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Static_Path
:= Hold (Sx.To_String (Arguments.Current_Atom));
end if;
when Commands.Template =>
if Arguments.Current_Event = Sx.Events.Add_Atom then
State.Template := Hold (Sx.To_String (Arguments.Current_Atom));
end if;
end case;
end Set;
-----------------
-- AWS Handler --
-----------------
overriding function Dispatch
(Dispatcher : in Handler;
Request : in AWS.Status.Data)
return AWS.Response.Data
is
Accessor : constant Server_Refs.Accessor := Dispatcher.Ref.Query;
URI : constant String := AWS.Status.URI (Request);
Cursor : constant Endpoint_Maps.Cursor := Accessor.Endpoints.Find (URI);
use type AWS.Status.Request_Method;
begin
if not Endpoint_Maps.Has_Element (Cursor) then
Dispatch_Static_File :
declare
Path : constant String := To_String (Accessor.Static_Path) & URI;
begin
if Ada.Strings.Fixed.Index (URI, "/.") /= 0
or else not Ada.Directories.Exists (Path)
then
return Simple_Response
(AWS.Messages.S404, To_String (Accessor.Template));
elsif AWS.Status.Method (Request) /= AWS.Status.GET then
return Simple_Response
(AWS.Messages.S405,
To_String (Accessor.Template),
Allow => "GET");
else
return AWS.Response.File (AWS.MIME.Content_Type (Path), Path);
end if;
end Dispatch_Static_File;
end if;
if AWS.Status.Method (Request) /= AWS.Status.POST then
return Simple_Response
(AWS.Messages.S405, To_String (Accessor.Template), Allow => "POST");
end if;
declare
Parameters : constant AWS.Parameters.List
:= AWS.Status.Parameters (Request);
Data : constant Sx.Atom
:= Sx.To_Atom (AWS.Parameters.Get (Parameters, "data"));
Signature : constant Sx.Atom
:= Sx.To_Atom (AWS.Parameters.Get (Parameters, "signature"));
Result : constant Execution_Results.Data := Execute
(Accessor.Endpoints.Constant_Reference (Cursor),
Data,
Sx.Encodings.Decode_Hex (Signature));
begin
case Result.State is
when Execution_Results.OK =>
if To_String (Result.Redirect) /= "" then
return Simple_Response
(AWS.Messages.S303, To_String (Accessor.Template),
Location => To_String (Result.Redirect));
else
return Simple_Response
(AWS.Messages.S200, To_String (Accessor.Template));
end if;
when Execution_Results.Invalid_Signature =>
return Simple_Response
(AWS.Messages.S403, To_String (Accessor.Template));
when Execution_Results.File_Error =>
return Simple_Response
(AWS.Messages.S500, To_String (Accessor.Template));
end case;
end;
end Dispatch;
overriding function Clone (Dispatcher : in Handler) return Handler is
begin
return Dispatcher;
end Clone;
not overriding procedure Reset
(Dispatcher : in out Handler;
Config_File : in String)
is
Reader : Sx.File_Readers.S_Reader
:= Sx.File_Readers.Reader (Config_File);
begin
Reset (Dispatcher, Reader, Config_File);
end Reset;
not overriding procedure Reset
(Dispatcher : in out Handler;
Config : in out Natools.S_Expressions.Lockable.Descriptor'Class;
File_Name : in String)
is
New_Server : constant Server_Refs.Data_Access := new Server_Data;
New_Ref : constant Server_Refs.Immutable_Reference
:= Server_Refs.Create (New_Server);
begin
Interpreter (Config, New_Server.all, File_Name);
Dispatcher.Ref := New_Ref;
end Reset;
function Simple_Response
(Code : AWS.Messages.Status_Code;
Template : String := "";
Location : String := "";
Allow : String := "")
return AWS.Response.Data
is
function Response_Body return String;
Image : constant String := AWS.Messages.Image (Code);
Message : constant String := AWS.Messages.Reason_Phrase (Code);
function Response_Body return String is
begin
if Template = "" then
return "<html><head><title>" & Image & ' ' & Message
& "</title></head>"
& "<body><h1>" & Image & ' ' & Message & "</h1></body></html>";
else
return Templates_Parser.Parse (Template,
(Templates_Parser.Assoc ("CODE", Image),
Templates_Parser.Assoc ("MESSAGE", Message)));
end if;
end Response_Body;
Result : AWS.Response.Data := AWS.Response.Build
("text/html", Response_Body, Code);
begin
if Allow /= "" then
AWS.Response.Set.Add_Header
(Result,
AWS.Messages.Allow_Token,
Allow);
end if;
if Location /= "" then
AWS.Response.Set.Add_Header
(Result,
AWS.Messages.Location_Token,
Location);
end if;
return Result;
end Simple_Response;
end Simple_Webapps.Append_Servers;
|
src/Internals/protypo-code_trees-interpreter-statements.ads | fintatarta/protypo | 0 | 19332 | <gh_stars>0
private
package Protypo.Code_Trees.Interpreter.Statements is
procedure Run (Status : Interpreter_Access;
Program : not null Node_Access)
with
Pre => Program.Class in Statement_Classes;
procedure Run (Status : Interpreter_Access;
Program : Node_Vectors.Vector);
procedure Do_Procedure_Call (Status : Interpreter_Access;
Name : Unbounded_id;
Params : Node_Vectors.Vector);
-- Why do we export this? Because the "capture" in the expression
-- evaluation package needs to call a procedure
end Protypo.Code_Trees.Interpreter.Statements;
|
alloy4fun_models/trashltl/models/3/2vKd5DAkFNnF7dMcX.als | Kaixi26/org.alloytools.alloy | 0 | 933 | open main
pred id2vKd5DAkFNnF7dMcX_prop4 {
some f: File | f not in Protected and eventually always f in Trash
}
pred __repair { id2vKd5DAkFNnF7dMcX_prop4 }
check __repair { id2vKd5DAkFNnF7dMcX_prop4 <=> prop4o } |
test/asset/agda-stdlib-1.0/Data/Product/N-ary/Categorical.agda | omega12345/agda-mode | 0 | 14934 | <reponame>omega12345/agda-mode
------------------------------------------------------------------------
-- The Agda standard library
--
-- A categorical view of N-ary products
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Product.N-ary.Categorical where
open import Agda.Builtin.Nat
open import Data.Product hiding (map)
open import Data.Product.N-ary
open import Function
open import Category.Functor
open import Category.Applicative
open import Category.Monad
------------------------------------------------------------------------
-- Functor and applicative
functor : ∀ {ℓ} n → RawFunctor {ℓ} (_^ n)
functor n = record { _<$>_ = λ f → map f n }
applicative : ∀ {ℓ} n → RawApplicative {ℓ} (_^ n)
applicative n = record
{ pure = replicate n
; _⊛_ = ap n
}
------------------------------------------------------------------------
-- Get access to other monadic functions
module _ {f F} (App : RawApplicative {f} F) where
open RawApplicative App
sequenceA : ∀ {n A} → F A ^ n → F (A ^ n)
sequenceA {0} _ = pure _
sequenceA {1} fa = fa
sequenceA {2+ n} (fa , fas) = _,_ <$> fa ⊛ sequenceA fas
mapA : ∀ {n a} {A : Set a} {B} → (A → F B) → A ^ n → F (B ^ n)
mapA f = sequenceA ∘ map f _
forA : ∀ {n a} {A : Set a} {B} → A ^ n → (A → F B) → F (B ^ n)
forA = flip mapA
module _ {m M} (Mon : RawMonad {m} M) where
private App = RawMonad.rawIApplicative Mon
sequenceM : ∀ {n A} → M A ^ n → M (A ^ n)
sequenceM = sequenceA App
mapM : ∀ {n a} {A : Set a} {B} → (A → M B) → A ^ n → M (B ^ n)
mapM = mapA App
forM : ∀ {n a} {A : Set a} {B} → A ^ n → (A → M B) → M (B ^ n)
forM = forA App
|
programs/oeis/026/A026806.asm | karttu/loda | 0 | 83732 | ; A026806: a(n) = number of numbers k such that only one partition of n has least part k.
; 1,2,1,2,2,2,2,3,2,3,3,3,3,4,3,4,4,4,4,5,4,5,5,5,5,6,5,6,6,6,6,7,6,7,7,7,7,8,7,8,8,8,8,9,8,9,9,9,9,10,9,10,10,10,10,11,10,11,11,11,11,12,11,12,12,12,12,13,12,13,13,13,13,14,13,14,14,14,14,15,14,15,15,15,15
add $0,7
mov $1,$0
div $0,2
mul $1,2
div $1,6
sub $0,$1
mov $1,$0
|
Task/The-Twelve-Days-of-Christmas/AppleScript/the-twelve-days-of-christmas-2.applescript | LaudateCorpus1/RosettaCodeData | 1 | 3850 | use framework "Foundation"
property pstrGifts : "A partridge in a pear tree, Two turtle doves, Three French hens, " & ¬
"Four calling birds, Five golden rings, Six geese a-laying, " & ¬
"Seven swans a-swimming, Eight maids a-milking, Nine ladies dancing, " & ¬
"Ten lords a-leaping, Eleven pipers piping, Twelve drummers drumming"
property pstrOrdinals : "first, second, third, fourth, fifth, " & ¬
"sixth, seventh, eighth, ninth, tenth, eleventh, twelfth"
-- DAYS OF XMAS ------------------------------------------------------------
-- daysOfXmas :: () -> String
on daysOfXmas()
-- csv :: String -> [String]
script csv
on |λ|(str)
splitOn(", ", str)
end |λ|
end script
set {gifts, ordinals} to map(csv, [pstrGifts, pstrOrdinals])
-- verseOfTheDay :: Int -> String
script verseOfTheDay
-- dayGift :: Int -> String
script dayGift
on |λ|(n, i)
set strGift to item n of gifts
if n = 1 then
set strFirst to strGift & " !"
if i is not 1 then
"And " & toLower(text 1 of strFirst) & text 2 thru -1 of strFirst
else
strFirst
end if
else if n = 5 then
toUpper(strGift)
else
strGift
end if
end |λ|
end script
on |λ|(intDay)
"On the " & item intDay of ordinals & " day of Xmas, my true love gave to me ..." & ¬
linefeed & intercalate("," & linefeed, ¬
map(dayGift, enumFromTo(intDay, 1)))
end |λ|
end script
intercalate(linefeed & linefeed, ¬
map(verseOfTheDay, enumFromTo(1, length of ordinals)))
end daysOfXmas
-- TEST ---------------------------------------------------------------------
on run
daysOfXmas()
end run
-- GENERIC FUNCTIONS --------------------------------------------------------
-- enumFromTo :: Int -> Int -> [Int]
on enumFromTo(m, n)
if m > n then
set d to -1
else
set d to 1
end if
set lst to {}
repeat with i from m to n by d
set end of lst to i
end repeat
return lst
end enumFromTo
-- intercalate :: Text -> [Text] -> Text
on intercalate(strText, lstText)
set {dlm, my text item delimiters} to {my text item delimiters, strText}
set strJoined to lstText as text
set my text item delimiters to dlm
return strJoined
end intercalate
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|(item i of xs, i, xs)
end repeat
return lst
end tell
end map
-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
if class of f is script then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- splitOn :: Text -> Text -> [Text]
on splitOn(strDelim, strMain)
set {dlm, my text item delimiters} to {my text item delimiters, strDelim}
set lstParts to text items of strMain
set my text item delimiters to dlm
return lstParts
end splitOn
-- toLower :: String -> String
on toLower(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toLower
-- toUpper :: String -> String
on toUpper(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
uppercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toUpper
|
Data/INPUT_ADD.asm | Anikcb/Microprocessor | 0 | 244850 | <filename>Data/INPUT_ADD.asm
.Model Small
.Stack 100h
.Data
.Code
main Proc
MOV ax, @data
MOV ds, ax
MOV AH, 1
INT 21h
MOV bl, al
SUB bl, 48
MOV AH, 2
MOV DL, 10
INT 21H
MOV AH, 2
MOV DL, 13
INT 21H
MOV AH, 1
INT 21h
MOV bh, al
SUB BH, 48
ADD bl, bh
;SUB bl, 60
MOV AH, 2
MOV DL, 10
INT 21H
MOV AH, 2
MOV DL, 13
INT 21H
mov CX, 8
PRINT: MOV AL, 2
MOV DL, '0'
TEST BL, 10000000b
JZ Zero
mov DL, '1'
Zero: INT 21h
SHL BL, 1
LOOP PRINT
MOV AH, 2
MOV DL, 'b'
INT 21H
Exit:
MOV AH, 4ch
INT 21h
main ENDP
END main
|
constants/item_constants.asm | opiter09/ASM-Machina | 1 | 175879 | <reponame>opiter09/ASM-Machina<filename>constants/item_constants.asm
; item ids
; indexes for:
; - ItemNames (see data/items/names.asm)
; - ItemPrices (see data/items/prices.asm)
; - TechnicalMachinePrices (see data/items/tm_prices.asm)
; - KeyItemFlags (see data/items/key_items.asm)
; - ItemUsePtrTable (see engine/items/item_effects.asm)
const_def
const NO_ITEM ; $00
const MASTER_BALL ; $01
const ULTRA_BALL ; $02
const GREAT_BALL ; $03
const POKE_BALL ; $04
const TOWN_MAP ; $05
const BICYCLE ; $06
const SURFBOARD ; $07 buggy?
const SAFARI_BALL ; $08
const POKEDEX ; $09
const MOON_STONE ; $0A
const ANTIDOTE ; $0B
const BURN_HEAL ; $0C
const ICE_HEAL ; $0D
const AWAKENING ; $0E
const PARLYZ_HEAL ; $0F
const FULL_RESTORE ; $10
const MAX_POTION ; $11
const HYPER_POTION ; $12
const SUPER_POTION ; $13
const POTION ; $14
const BOULDERBADGE ; $15
const CASCADEBADGE ; $16
SAFARI_BAIT EQU $15 ; overload
SAFARI_ROCK EQU $16 ; overload
const THUNDERBADGE ; $17
const RAINBOWBADGE ; $18
const SOULBADGE ; $19
const MARSHBADGE ; $1A
const VOLCANOBADGE ; $1B
const EARTHBADGE ; $1C
const ESCAPE_ROPE ; $1D
const REPEL ; $1E
const OLD_AMBER ; $1F
const FIRE_STONE ; $20
const THUNDER_STONE ; $21
const WATER_STONE ; $22
const HP_UP ; $23
const PROTEIN ; $24
const IRON ; $25
const CARBOS ; $26
const CALCIUM ; $27
const RARE_CANDY ; $28
const DOME_FOSSIL ; $29
const HELIX_FOSSIL ; $2A
const SECRET_KEY ; $2B
;const UNUSED_ITEM ; $2C "?????"
const HEAL_PARTY ; $2C
const BIKE_VOUCHER ; $2D
const X_ACCURACY ; $2E
const LEAF_STONE ; $2F
const CARD_KEY ; $30
const NUGGET ; $31
const PP_UP_2 ; $32
const POKE_DOLL ; $33
const FULL_HEAL ; $34
const REVIVE ; $35
const MAX_REVIVE ; $36
const GUARD_SPEC ; $37
const SUPER_REPEL ; $38
const MAX_REPEL ; $39
const DIRE_HIT ; $3A
const COIN ; $3B
const FRESH_WATER ; $3C
const SODA_POP ; $3D
const LEMONADE ; $3E
const S_S_TICKET ; $3F
const GOLD_TEETH ; $40
const X_ATTACK ; $41
const X_DEFEND ; $42
const X_SPEED ; $43
const X_SPECIAL ; $44
const COIN_CASE ; $45
const OAKS_PARCEL ; $46
const ITEMFINDER ; $47
const SILPH_SCOPE ; $48
const POKE_FLUTE ; $49
const LIFT_KEY ; $4A
const EXP_ALL ; $4B
const OLD_ROD ; $4C
const GOOD_ROD ; $4D
const SUPER_ROD ; $4E
const PP_UP ; $4F
const ETHER ; $50
const MAX_ETHER ; $51
const ELIXER ; $52
const MAX_ELIXER ; $53
NUM_ITEMS EQU const_value - 1
; elevator floors use item IDs
const FLOOR_B2F ; $54
const FLOOR_B1F ; $55
const FLOOR_1F ; $56
const FLOOR_2F ; $57
const FLOOR_3F ; $58
const FLOOR_4F ; $59
const FLOOR_5F ; $5A
const FLOOR_6F ; $5B
const FLOOR_7F ; $5C
const FLOOR_8F ; $5D
const FLOOR_9F ; $5E
const FLOOR_10F ; $5F
const FLOOR_11F ; $60
const FLOOR_B4F ; $61
NUM_FLOORS EQU const_value - 1 - NUM_ITEMS
const_next $C4
; HMs are defined before TMs, so the actual number of TM definitions
; is not yet available. The TM quantity is hard-coded here and must
; match the actual number below.
NUM_TMS EQU 50
__tmhm_value__ = NUM_TMS + 1
add_tmnum: MACRO
\1_TMNUM EQU __tmhm_value__
__tmhm_value__ = __tmhm_value__ + 1
ENDM
add_hm: MACRO
; Defines three constants:
; - HM_\1: the item id, starting at $C4
; - \1_TMNUM: the learnable TM/HM flag, starting at 51
; - HM##_MOVE: alias for the move id, equal to the value of \1
const HM_\1
HM_VALUE = __tmhm_value__ - NUM_TMS
HM{02d:HM_VALUE}_MOVE EQU \1
add_tmnum \1
ENDM
HM01 EQU const_value
add_hm CUT ; $C4
add_hm FLY ; $C5
add_hm SURF ; $C6
add_hm STRENGTH ; $C7
add_hm FLASH ; $C8
NUM_HMS EQU const_value - HM01
__tmhm_value__ = 1
add_tm: MACRO
; Defines three constants:
; - TM_\1: the item id, starting at $C9
; - \1_TMNUM: the learnable TM/HM flag, starting at 1
; - TM##_MOVE: alias for the move id, equal to the value of \1
const TM_\1
TM{02d:__tmhm_value__}_MOVE EQU \1
add_tmnum \1
ENDM
TM01 EQU const_value
add_tm MEGA_PUNCH ; $C9
add_tm RAZOR_WIND ; $CA
add_tm SWORDS_DANCE ; $CB
add_tm WHIRLWIND ; $CC
add_tm MEGA_KICK ; $CD
add_tm TOXIC ; $CE
add_tm NIGHT_SHADE ; $CF
add_tm BODY_SLAM ; $D0
add_tm TAKE_DOWN ; $D1
add_tm DOUBLE_EDGE ; $D2
add_tm BUBBLEBEAM ; $D3
add_tm WATER_GUN ; $D4
add_tm ICE_BEAM ; $D5
add_tm BLIZZARD ; $D6
add_tm HYPER_BEAM ; $D7
add_tm PAY_DAY ; $D8
add_tm SUBMISSION ; $D9
add_tm COUNTER ; $DA
add_tm SEISMIC_TOSS ; $DB
add_tm RAGE ; $DC
add_tm MEGA_DRAIN ; $DD
add_tm SOLARBEAM ; $DE
add_tm DRAGON_RAGE ; $DF
add_tm THUNDERBOLT ; $E0
add_tm THUNDER ; $E1
add_tm EARTHQUAKE ; $E2
add_tm FISSURE ; $E3
add_tm DIG ; $E4
add_tm PSYCHIC_M ; $E5
add_tm TELEPORT ; $E6
add_tm MIMIC ; $E7
add_tm DOUBLE_TEAM ; $E8
add_tm REFLECT ; $E9
add_tm BIDE ; $EA
add_tm METRONOME ; $EB
add_tm SELFDESTRUCT ; $EC
add_tm EGG_BOMB ; $ED
add_tm FIRE_BLAST ; $EE
add_tm SWIFT ; $EF
add_tm SKULL_BASH ; $F0
add_tm SOFTBOILED ; $F1
add_tm DREAM_EATER ; $F2
add_tm SKY_ATTACK ; $F3
add_tm REST ; $F4
add_tm THUNDER_WAVE ; $F5
add_tm PSYWAVE ; $F6
add_tm EXPLOSION ; $F7
add_tm ROCK_SLIDE ; $F8
add_tm TRI_ATTACK ; $F9
add_tm SUBSTITUTE ; $FA
ASSERT NUM_TMS == const_value - TM01, "NUM_TMS ({d:NUM_TMS}) does not match the number of add_tm definitions"
NUM_TM_HM EQU NUM_TMS + NUM_HMS
; 50 TMs + 5 HMs = 55 learnable TM/HM flags per Pokémon.
; These fit in 7 bytes, with one unused bit left over.
__tmhm_value__ = NUM_TM_HM + 1
UNUSED_TMNUM EQU __tmhm_value__
|
source/boot/paging.asm | kaiserschmarrn0/takao | 0 | 247163 | %include "source/boot/constants.asm"
[bits 32]
section .bss
align 4096
pagemap:
.pml4:
resb 4096
.pdptLow:
resb 4096
.pdptHigh:
resb 4096
.pd:
resb 4096
.pt:
resb 4096 * 16 ; 16 page tables == 32 MiB mapped
.end:
section .text
global enablePaging:function (enablePaging.end - enablePaging)
enablePaging:
; Zero out page tables
xor eax, eax
mov edi, pagemap - kernelPhysicalOffset
mov ecx, (pagemap.end - pagemap) / 4
rep stosd
; Set up page tables
mov eax, 0x03
mov edi, pagemap.pt - kernelPhysicalOffset
mov ecx, 512 * 16
.loop0:
stosd
push eax
xor eax, eax
stosd
pop eax
add eax, 0x1000
loop .loop0
; set up page directories
mov eax, pagemap.pt - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pd - kernelPhysicalOffset
mov ecx, 16
.loop1:
stosd
push eax
xor eax, eax
stosd
pop eax
add eax, 0x1000
loop .loop1
; set up pdpt
mov eax, pagemap.pd - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pdptLow - kernelPhysicalOffset
stosd
xor eax, eax
stosd
mov eax, pagemap.pd - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pdptHigh - kernelPhysicalOffset + 511 * 8
stosd
xor eax, eax
stosd
; set up pml4
mov eax, pagemap.pdptLow - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pml4 - kernelPhysicalOffset
stosd
xor eax, eax
stosd
mov eax, pagemap.pdptLow - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pml4 - kernelPhysicalOffset + 256 * 8
stosd
xor eax, eax
stosd
mov eax, pagemap.pdptHigh - kernelPhysicalOffset
or eax, 0x03
mov edi, pagemap.pml4 - kernelPhysicalOffset + 511 * 8
stosd
xor eax, eax
stosd
; Before enabling paging, we will enable the Physical address extention
; (aka PAE)
mov eax, cr4
or eax, 1 << 5
mov cr4, eax
; And now, with PAE enabled we can finally enable paging in all its glory.
mov eax, pagemap - kernelPhysicalOffset
mov cr3, eax
mov eax, cr0
or eax, 1 << 31
mov cr0, eax
ret
.end:
|
oeis/205/A205795.asm | neoneye/loda-programs | 11 | 28923 | ; A205795: Sums of coefficients of polynomials from 5n-th moments of X ~ Hypergeometric(4m, 5m, m).
; Submitted by <NAME>
; 24,2880,43545600,5230697472000,2432902008176640000,3102242008666197196800000,8841761993739701954543616000000,49205466506600690141269768273920000000,485663859076129603777149565235783270400000000,7911522544013240381082219675638737768808448000000000
mov $2,1
mov $3,$0
mul $3,5
lpb $3
mul $2,$3
lpb $2,2
mov $26,$0
cmp $26,0
add $0,$26
div $2,$0
mul $2,$3
div $3,$0
lpe
sub $3,1
lpe
mov $0,$2
mul $0,24
|
models/amalgam/tests/test_por_split.als | transclosure/Amalgam | 4 | 4928 | <reponame>transclosure/Amalgam
sig Node {edges: set Node }
-- single provenance: a->b in edges fails
-- expect a forked path because have to try instantiating a with all existing nodes
-- diff. eval. disregards skolem constants, so either direction works:
-- suppose asking @why 0->1 in edges?
-- if a=0,b=1 derive via a->b in edges; if a=1;b=0 derive via b->a in edges
pred testSplit1 {
some a, b: Node | {
a != b
a->b in edges
b->a in edges
}
}
run testSplit1 for 4
-- should be split into 2 distinct provenances
-- one shows a->b in edges failing
-- another shows b->a in ~edges failing
-- ISSUE: the 2 provenances are indistinguishable. why are we never highlighting the 2 lines?
pred testSplit2 {
some a, b: Node | {
a != b
a->b in edges
b->a in ~edges
}
}
run testSplit2 for 4
|
examples/AIM4/bag/Prelude.agda | asr/agda-kanso | 1 | 2836 |
module Prelude where
id : {a : Set} -> a -> a
id x = x
infixr 0 _$_
_$_ : {a b : Set} -> (a -> b) -> a -> b
f $ x = f x
data Bool : Set where
True : Bool
False : Bool
_&&_ : Bool -> Bool -> Bool
True && b = b
False && _ = False
data Pair (a b : Set) : Set where
pair : a -> b -> Pair a b
fst : {a b : Set} -> Pair a b -> a
fst (pair x y) = x
snd : {a b : Set} -> Pair a b -> b
snd (pair x y) = y
data Either (a b : Set) : Set where
left : a -> Either a b
right : b -> Either a b
data Maybe (a : Set) : Set where
Nothing : Maybe a
Just : a -> Maybe a
data Unit : Set where
unit : Unit
data Absurd : Set where
absurdElim : {whatever : Set} -> Absurd -> whatever
absurdElim ()
-- data Pi {a : Set} (f : a -> Set) : Set where
-- pi : ((x : a) -> f x) -> Pi f
--
-- apply : {a : Set} -> {f : a -> Set} -> Pi f -> (x : a) -> f x
-- apply (pi f) x = f x
T : Bool -> Set
T True = Unit
T False = Absurd
andT : {x y : Bool} -> T x -> T y -> T (x && y)
andT {True} {True} _ _ = unit
andT {True} {False} _ ()
andT {False} {_} () _
T' : {a : Set} -> (a -> a -> Bool) -> (a -> a -> Set)
T' f x y = T (f x y)
data Not (a : Set) : Set where
not : (a -> Absurd) -> Not a
-- Not : Set -> Set
-- Not a = a -> Absurd
contrapositive : {a b : Set} -> (a -> b) -> Not b -> Not a
contrapositive p (not nb) = not (\a -> nb (p a))
private
notDistribOut' : {a b : Set} -> Not a -> Not b -> Either a b -> Absurd
notDistribOut' (not na) _ (left a) = na a
notDistribOut' _ (not nb) (right b) = nb b
notDistribOut : {a b : Set} -> Not a -> Not b -> Not (Either a b)
notDistribOut na nb = not (notDistribOut' na nb)
notDistribIn : {a b : Set} -> Not (Either a b) -> Pair (Not a) (Not b)
notDistribIn (not nab) = pair (not (\a -> nab (left a)))
(not (\b -> nab (right b)))
data _<->_ (a b : Set) : Set where
iff : (a -> b) -> (b -> a) -> a <-> b
iffLeft : {a b : Set} -> (a <-> b) -> (a -> b)
iffLeft (iff l _) = l
iffRight : {a b : Set} -> (a <-> b) -> (b -> a)
iffRight (iff _ r) = r
Dec : (A : Set) -> Set
Dec A = Either A (Not A)
|
enemy_controller.asm | StevenMonty/MARS-Invaders | 0 | 82359 | <filename>enemy_controller.asm
## This file implements the functions that control the enemy
.include "enemy_struct.asm"
.include "convenience.asm"
.globl draw_enemy
.globl enemy_update
.globl enemy_spawn
.globl detect_collision
.data
collide: .asciiz "collision detected\n"
one: .asciiz "made it past first branch\n"
two: .asciiz "made it past second branch\n"
line: .asciiz " \n"
collision_debug: .byte
1 1 1 1 1
1 -1 -1 -1 1
1 -1 -1 -1 1
1 -1 -1 -1 1
1 1 1 1 1
# array of enemy structs (active, x, y) update method loops through and if active then increments its y position
.text
draw_enemy:
enter s0
li s0, 0 # int i = 0
_draw_loop:
beq s0, 5, _draw_exit # while i < 5 (number of enemies)
la t5, enemy_array # load the enemy array into t5
mul t1, s0, 12 # current enemy num * size between enemies
add t5, t5, t1 # add the offset from prev instruction to the array address to get the current enemy
lw t2, active(t5) # load the current enemys active status into t2
beqz t2, _inactive # if inactive, skip to bottom of the loop, draw nothing
lw a0, x_pos(t5)
lw a1, y_pos(t5)
la a2, enemy_image # pointer to the image
jal display_blit_5x5_trans
j loop_cont
_inactive:
lw a0, x_pos(t5)
lw a1, y_pos(t5)
# beq a1, 53, loop_cont # if end of screen, skip
la a2, impact_image
jal display_blit_5x5_trans
loop_cont:
inc s0 # i++
j _draw_loop
_draw_exit:
leave s0
enemy_update:
enter s0
li s0, 0 # int i = 0
lw t1, level # get level number
addi t1, t1, 8 # 8 FPS is the base number, add the level number to increase enemy speed
lw t0, frame_counter # get the current frame
rem t0, t0, t1 # get the remainder of the current frame divided by the level
bne t0, 0, _update_exit # if the remainder is not 0, then exit. This only makes the enemies move every 4 frames
_update_loop:
beq s0, 5, _update_exit # while i < 5 (number of enemies)
# iterate through the array of enemies and increment its y pos
la t5, enemy_array # load the enemy array into t5
mul t1, s0, 12 # current enemy num * size between enemies
add t5, t5, t1 # add the offset from prev instruction to the array address to get the current enemy address
lw t0, active(t5) # if enemy is inactive, jump to next loop iteration
beqz t0, cont
lw t0, y_pos(t5) # load the current y position
addi t0, t0, 1 # add one to move enemy down one pixel
beq t0, 53, inactive # if enemy y reaches 50, they are off the screen and become inactive
sw t0, y_pos(t5) # store the new y position to the array
j cont # if this line is reached, then the enemy is still active and the inactive routine is skipped
inactive:
li t1, 0
sw t1, active(t5) # set the enemy as inactive so that they are no longer drawn
lw t2, lives
dec t2 # ******TODO********
sw t2, lives # if enemy reaches bottom of screen, the player loses a life
cont:
inc s0 # i++
b _update_loop
_update_exit:
leave s0
detect_collision: # a0 - address of the enemy # TODO - ADD THE COLLISION ANIMATION
enter s0, s1, s2, s7
li s7, 0 # int i = 0
detection_loop:
la t5, enemy_array # load the enemy array into t5
mul t1, s7, 12 # current enemy num * size between enemies
add t5, t5, t1 # add the offset from prev instruction to the array address to get the current enemy address
lw t0, active(t5)
beq t0, 0, _loop_cont
lw s0, x_pos(t5) # load the x position of current enemy ship
lw s1, y_pos(t5) # load the y position of current enemy ship
addi, s2, s0, 4 # add the ship width to the x pos of the enemy
addi s3, s1, 4 # add the ship depth to the y pos of the enemy
bullet: # collision with bullet
lw t0, bullet_x
lw t1, bullet_y
lw t3, bullet_active
beq t3, 0, player # if bullet is inactive, skip rest of sub routine
addi t0, t0, 2 # add offset of the bullet being a 5x5 object but only displaying 1 pixel
move t3, s0 # sprite coords start in the top left corner
addi t3, t3, 4 # add ship width to the x pos of the enemy
blt t0, s0, player # if the bullet x < lower ship x, skip to player check
bgt t0, t3, player # if the bullet x > upper ship x, skip to player check (allows for any pixel of ship to be hit)
bgt t1, s3, player # if the bullet y > ship y, bullet has not reached enemy yet
li t2, 0
sw t2, active(t5) # make ship go inactive on collision
sw t2, bullet_active # make the bullet go inactive on collision
lw t3, score
inc t3 # increment the score on ship destruction
sw t3, score
player: # collision with player
lw t0, x_coord # load player x lower bound
lw t1, y_coord # load player y
addi t2, t0, 4 # add width of the player x to get upper bound
addi t3, t1, 4 # add depth of the player to the y
blt t2, s0, _loop_cont # if player upper x bound is < enemy lower x bound, no collision
bgt t0, s2, _loop_cont # if player upper y bound is > enemy lower y bound, no collision
bgt t1, s3, _loop_cont # if player lower x bound is > enemy upper x bound, no collision
# move a0, s0
# move a1, s1
# la a2, collision_debug
# jal display_blit_5x5_trans
lw t2, lives
dec t2 # decrement the player lives on collision
sw t2, lives
li t3, 0
sw t3, active(t5) # set enemy inactive on collision
_loop_cont:
inc s7 # i++
blt s7, 5, detection_loop # while i < 5
leave s0, s1, s2, s7
enemy_spawn: # iterate through the array of enemies and if one is inactive, then spawn a new one at a random x pos
enter s0
lw t0, frame_counter # get the current frame
rem t0, t0, 10 # get the remainder of the current frame divided by 10
bne t0, 0, _spawn_exit # if the remainder is not 0, then exit. This allows enemies to spawn every 10 frames
li s0, 0 # int i = 0
spawn_loop:
beq s0, 5, _spawn_exit # while i < 5
li v0, 42 # random int gen
li a0, 0 # gen #1
li a1, 60 # upper bound
syscall # return random int to v0
blt a0, 3, spawn_cont
la t5, enemy_array # load the enemy array into t5
mul t1, s0, 12 # current enemy num * size between enemies
add t5, t5, t1 # add the offset from prev instruction to the array address to get the current enemy
lw t0, active(t5) # load the active flag for the current enemy
beq t0, 1, spawn_cont # if enemy is alredy active, skip
li t0, 1 # enemy active
move t1, a0 # move the random int into the inital y position
li t2, 0 # x = 0, top of screen
sw t0, active(t5) # store new values
sw t1, x_pos(t5)
sw t2, y_pos(t5)
spawn_cont:
inc s0
j spawn_loop
_spawn_exit:
leave s0
|
Practice/Assignments assembly class/34.asm | WardunIslam/CSE331L_Section_7_Summer_2020_NSU | 0 | 26835 | <gh_stars>0
; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt
org 100h
L1: NOP
L2: MOV AX, 0000H
MOV DS, AX
MOV BX, 0000H
MOV AH, DS:[BX]
MOV BX, 0001H
MOV AL, DS:[BX]
MOV BX, 0002H
MOV CL, DS:[BX]
L3: CMP AL, AH
JGE L5
L4: CMP AH, CL
JGE L8
JMP L9
L5: CMP AL, CL
JGE L7
JMP L9
L6: MOV AH, 02
MOV DL, 'Y'
INT 21H
L7: MOV DL, AL
JMP L10
L8: MOV DL, AH
JMP L10
L9: MOV DL, CL
L10: HLT
ret
|
PRG/objects/2-5.asm | narfman0/smb3_pp1 | 0 | 241156 | <reponame>narfman0/smb3_pp1
.byte $00 ; Unknown purpose
.byte OBJ_CHAINCHOMP, $09, $19
.byte OBJ_CHAINCHOMP, $19, $19
.byte OBJ_REDTROOPA, $22, $17
.byte OBJ_CHAINCHOMP, $34, $19
.byte OBJ_GOOMBA, $34, $13
.byte OBJ_GOOMBA, $35, $19
.byte OBJ_GOOMBA, $43, $11
.byte OBJ_GOOMBA, $43, $17
.byte OBJ_REDTROOPA, $52, $11
.byte OBJ_REDTROOPA, $52, $13
.byte OBJ_REDTROOPA, $64, $13
.byte OBJ_REDTROOPA, $69, $15
.byte OBJ_REDTROOPA, $6F, $17
.byte OBJ_ENDLEVELCARD, $98, $15
.byte OBJ_CHAINCHOMP, $9A, $19
.byte $FF ; Terminator
|
libsrc/strings/memchr_callee.asm | andydansby/z88dk-mk2 | 1 | 102788 | <reponame>andydansby/z88dk-mk2
; void __CALLEE__ *memchr_callee(char *s, char c, uint n)
; return ptr to first occurence of c in s
; 12.1999 djm, 12.2006 aralbrec
XLIB memchr_callee
XDEF ASMDISP_MEMCHR_CALLEE
LIB rcmx_cpir
.memchr_callee
pop hl
pop bc
pop de
ex (sp),hl
ld a,e
; enter : hl = char *s
; a = char c
; bc = uint n
; exit : found: hl = ptr to c in s, Z flag set
; else : hl = 0, NZ flag set
; uses : f, bc, hl
.asmentry
cpir
dec hl
ret z
ld h,b
ld l,c
ret
DEFC ASMDISP_MEMCHR_CALLEE = asmentry - memchr_callee
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0xca_notsx.log_3137_161.asm | ljhsiun2/medusa | 9 | 174279 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0xb9f2, %rsi
lea addresses_A_ht+0x10ca2, %rdi
nop
nop
nop
nop
nop
sub $21783, %r15
mov $113, %rcx
rep movsl
nop
nop
inc %rbp
lea addresses_UC_ht+0x6912, %rsi
lea addresses_A_ht+0xbf12, %rdi
nop
nop
nop
and %rbx, %rbx
mov $52, %rcx
rep movsb
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_D_ht+0x51f2, %rsi
lea addresses_WT_ht+0x14612, %rdi
nop
nop
nop
nop
sub $42718, %r14
mov $118, %rcx
rep movsw
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_WC_ht+0x8192, %rsi
lea addresses_UC_ht+0xe9d2, %rdi
xor $57477, %rbp
mov $25, %rcx
rep movsw
nop
nop
nop
dec %rcx
lea addresses_D_ht+0x1932a, %rsi
lea addresses_normal_ht+0x7c02, %rdi
nop
nop
nop
nop
nop
and $62244, %r9
mov $122, %rcx
rep movsb
nop
add %rbx, %rbx
lea addresses_WT_ht+0x19b12, %rcx
add %rbx, %rbx
movb (%rcx), %r9b
nop
nop
nop
nop
xor $62917, %rdi
lea addresses_A_ht+0x50a6, %rbp
nop
nop
nop
nop
nop
add %r14, %r14
movw $0x6162, (%rbp)
nop
nop
sub %rsi, %rsi
lea addresses_normal_ht+0xa512, %rsi
lea addresses_D_ht+0x19112, %rdi
clflush (%rdi)
nop
nop
xor $10076, %rbx
mov $9, %rcx
rep movsw
nop
nop
nop
nop
nop
sub %rbp, %rbp
lea addresses_D_ht+0xe512, %rsi
lea addresses_A_ht+0x18912, %rdi
nop
nop
nop
add %rbx, %rbx
mov $15, %rcx
rep movsl
nop
nop
nop
sub $35913, %rbp
lea addresses_UC_ht+0x18912, %rsi
lea addresses_A_ht+0x9592, %rdi
nop
nop
nop
nop
xor %rbx, %rbx
mov $21, %rcx
rep movsq
nop
and %r14, %r14
lea addresses_WT_ht+0xaba9, %r14
nop
nop
sub %rbp, %rbp
movw $0x6162, (%r14)
nop
nop
add %r15, %r15
lea addresses_WC_ht+0x189a2, %rbp
nop
nop
nop
add $54067, %rsi
mov $0x6162636465666768, %r15
movq %r15, %xmm4
vmovups %ymm4, (%rbp)
nop
nop
nop
nop
sub %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
// Store
mov $0x730d6700000004d7, %rsi
nop
nop
nop
and %rcx, %rcx
mov $0x5152535455565758, %r15
movq %r15, (%rsi)
nop
nop
nop
nop
inc %r12
// Faulty Load
lea addresses_WT+0x1e112, %rbx
nop
nop
nop
nop
nop
add %rdi, %rdi
movb (%rbx), %r12b
lea oracles, %rsi
and $0xff, %r12
shlq $12, %r12
mov (%rsi,%r12,1), %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': False, 'type': 'addresses_NC'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 3, 'same': True, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 6, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'39': 3137}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
Cubical/HITs/CumulativeHierarchy.agda | thomas-lamiaux/cubical | 1 | 15999 | {-# OPTIONS --safe #-}
module Cubical.HITs.CumulativeHierarchy where
open import Cubical.HITs.CumulativeHierarchy.Base public
hiding (elim; elimProp)
open import Cubical.HITs.CumulativeHierarchy.Properties public
open import Cubical.HITs.CumulativeHierarchy.Constructions public
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48.log_21829_2528.asm | ljhsiun2/medusa | 9 | 26403 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x9c56, %rsi
lea addresses_D_ht+0x1371e, %rdi
nop
nop
add $26834, %r12
mov $121, %rcx
rep movsq
nop
nop
nop
nop
nop
inc %rax
lea addresses_D_ht+0x11606, %rdx
nop
nop
nop
add $25422, %r15
movb $0x61, (%rdx)
xor %rcx, %rcx
lea addresses_A_ht+0x23b6, %rax
xor %r15, %r15
movups (%rax), %xmm3
vpextrq $1, %xmm3, %rsi
nop
nop
nop
nop
nop
dec %rax
lea addresses_D_ht+0x1dbb2, %rsi
and $27844, %rdx
movl $0x61626364, (%rsi)
nop
nop
nop
inc %rdi
lea addresses_WC_ht+0x1286, %rcx
nop
nop
nop
sub $767, %rsi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm7
and $0xffffffffffffffc0, %rcx
movaps %xmm7, (%rcx)
nop
nop
nop
nop
dec %r15
lea addresses_UC_ht+0x1e282, %r12
nop
add $28908, %rdx
mov (%r12), %rdi
nop
xor %rdi, %rdi
lea addresses_normal_ht+0x15786, %rdx
nop
nop
nop
inc %rax
mov $0x6162636465666768, %r12
movq %r12, (%rdx)
nop
nop
xor %rdi, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %r9
push %rax
push %rdx
// Faulty Load
lea addresses_A+0x456, %rax
nop
nop
nop
xor %r9, %r9
vmovups (%rax), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r14
lea oracles, %rax
and $0xff, %r14
shlq $12, %r14
mov (%rax,%r14,1), %r14
pop %rdx
pop %rax
pop %r9
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
test_bla.asm | acastrauss/compiler_project | 0 | 27868 |
main:
PUSH %14
MOV %15,%14
@main_body:
ADDS $95,$358,%0
SUBS %0,$27,%0
ADDS %0,$55,%0
SUBS %0,$457,%0
ADDS %0,$1225,%0
SUBS %0,$3874,%0
ADDS %0,$5550,%0
MOV %0,%13
JMP @main_exit
@main_exit:
MOV %14,%15
POP %14
RET |
TypeTheory/Lecture/Stream.agda | hbasold/Sandbox | 0 | 14151 | {-# OPTIONS --without-K #-}
module Stream where
open import Level as Level using (zero)
import Relation.Binary as BinRel
open import Relation.Binary as BinRel hiding (Setoid; Rel)
open import Relation.Binary.PropositionalEquality as PE
Setoid = BinRel.Setoid Level.zero Level.zero
open import Data.Nat using (ℕ; zero; suc)
open import PropsAsTypes
record Stream (A : Set) : Set where
coinductive
field
hd : A
tl : Stream A
open Stream public
coiter : {X A : Set} → (X → A × X) → (X → Stream A)
coiter c x .hd = π₁ (c x)
coiter c x .tl = coiter c (π₂ (c x))
δ : ∀{A} → ℕ → Stream A → Stream A
δ 0 s = s
δ (suc n) s = δ n (s .tl)
_at_ : ∀{A} → Stream A → ℕ → A
s at n = (δ n s) .hd
module Bisim (A : Set) where
infix 2 _~_
record _~_ (s t : Stream A) : Prop where
coinductive
field
hd≡ : s .hd ≡ t .hd
tl~ : s .tl ~ t .tl
open _~_ public
isBisim : Rel (Stream A) → Prop
isBisim _R_ = ∀ s t → s R t → (s .hd ≡ t .hd) ∧ (s .tl R t .tl)
∃-bisim→~ : ∀ {_R_} → isBisim _R_ →
∀ (s t : Stream A) → s R t → s ~ t
∃-bisim→~ R-isBisim s t q .hd≡ = ∧-elim₁ (R-isBisim s t q)
∃-bisim→~ R-isBisim s t q .tl~ =
∃-bisim→~ R-isBisim (s .tl) (t .tl) (∧-elim₂ (R-isBisim s t q))
bisim→ext-≡ : ∀ {s t} → s ~ t → (∀ n → s at n ≡ t at n)
bisim→ext-≡ p zero = p .hd≡
bisim→ext-≡ p (suc n) = bisim→ext-≡ (p .tl~) n
s-bisim-refl : ∀ {s : Stream A} → s ~ s
s-bisim-refl .hd≡ = PE.refl
s-bisim-refl {s} .tl~ = s-bisim-refl {s .tl}
s-bisim-sym : ∀ {s t : Stream A} → s ~ t → t ~ s
s-bisim-sym p .hd≡ = PE.sym (p .hd≡)
s-bisim-sym p .tl~ = s-bisim-sym (p .tl~)
s-bisim-trans : ∀ {r s t : Stream A} → r ~ s → s ~ t → r ~ t
s-bisim-trans p q .hd≡ = PE.trans (p .hd≡) (q .hd≡)
s-bisim-trans p q .tl~ = s-bisim-trans (p .tl~) (q .tl~)
stream-setoid : Setoid
stream-setoid = record
{ Carrier = Stream A
; _≈_ = _~_
; isEquivalence = record
{ refl = s-bisim-refl
; sym = s-bisim-sym
; trans = s-bisim-trans
}
}
import Relation.Binary.EqReasoning as EqR
module ~-Reasoning where
module _ where
open EqR (stream-setoid) public
hiding (_≡⟨_⟩_) renaming (_≈⟨_⟩_ to _~⟨_⟩_; begin_ to begin_; _∎ to _∎)
|
Properties/src/properties.adb | marcbejerano/ada-tools | 2 | 5237 | -- @(#)File: properties.adb
-- @(#)Last changed: Mar 18 2015 10:30:00
-- @(#)Purpose: Java properties file support
-- @(#)Author: <NAME> <<EMAIL>>
-- @(#)Copyright: Copyright (C) 2015, <NAME>, All Rights Reserved
-- @(#)Product: None
-- @(#)License: BSD3
--
-- Copyright (c) 2015, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of ada-tools 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.
with Ada.Calendar; use Ada.Calendar;
with Ada.Strings;
with Ada.Strings.Unbounded.Hash;
with GNAT.Calendar.Time_IO; use GNAT.Calendar.Time_IO;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
package body Properties is
use type Hash_Table.Cursor;
--
-- Escape all of the characters that may be interpreted as tokens
-- by the loader with a backslash (\) character. For the keys,
-- all spaces inside the key name are escaped. For keys and values,
-- all characters in the set [# ! = :] are also prefixed. For
-- values, only the leading whitespace is escaped.
-- @param str String to escape
-- @param is_key_string Flag indicating this is a key and not a value
-- @return Escaped string
--
function Escape(str: in Unbounded_String; is_key_string: in Boolean := true) return Unbounded_String is
result : Unbounded_String;
ch : Character;
is_leading : Boolean := true;
begin
for idx in 1 .. Length(str) loop
ch := Element(str, idx);
if ch = '#' or ch = '!' or ch = ' ' or ch = '\' or ch = ':' or ch = '=' then
if is_key_string or (not is_key_string and ch = ' ' and is_leading) then
Append(result, '\');
end if;
end if;
if is_leading and ch /= ' ' then
is_leading := false;
end if;
Append(result, ch);
end loop;
return result;
end Escape;
--
-- Hash the given key into a Hash object.
-- @param key Key to hash
-- @return Hash object
--
function Key_Hashed(key: in Unbounded_String) return Hash_Type is
begin
return Hash(key);
end Key_Hashed;
--
-- Properties tagged record Copy function. This function will take into
-- account the added data member containing the default values.
-- @param Source Properties object
-- @param Capacity
function Copy(Source: Properties; Capacity: Count_Type := 0) return Properties is
props: Properties;
begin
props := Source;
return props;
end Copy;
--
-- Create an empty Properties object.
-- @return Properties object
--
function Create return Properties is
props: Properties;
begin
return props;
end Create;
--
-- Create a Properties object with initial data provided by the
-- given default container.
-- @param defaults Default container of property data
-- @return Properties object
--
function Create(defaults: in Properties) return Properties is
props: Properties;
begin
props.defaults := Hash_Table.Map(defaults);
return props;
end Create;
--
-- Get the named property from the properties container. If the requested
-- key does not exist in the container then an empty string will be returned.
-- @param props Properties container
-- @param key Key of property to retrieve
-- @return Value for the given key or an empty string
--
function Get_Property(props: in Properties;
key: in Unbounded_String;
default: in Unbounded_String := To_Unbounded_String("")) return String is
begin
if props.Find(key) = Hash_Table.No_Element then
if props.defaults.Find(key) /= Hash_Table.No_Element then
return To_String(props.defaults.Element(key));
else
return To_String(default);
end if;
else
return To_String(props.Element(key));
end if;
end Get_Property;
--
-- Get the named property from the properties container. If the requested
-- key does not exist in the container then an empty string will be returned.
-- @param props Properties container
-- @param key Key of property to retrieve
-- @return Value for the given key or an empty string
--
function Get_Property(props: in Properties; key: in String) return String is
begin
return props.Get_Property(To_Unbounded_String(key));
end Get_Property;
--
-- Get the named property from the properties container. If the requested
-- key does not exist in the container then the default value will be returned.
-- @param props Properties container
-- @param key Key of property to retrieve
-- @return Value for the given key or the default value.
--
function Get_Property(props: in Properties; key: in String; default: in String) return String is
begin
return props.Get_Property(To_Unbounded_String(key), To_Unbounded_String(default));
end Get_Property;
--
-- Set the given property to the specified value.
-- @param props Properties container
-- @param key Key of the desired property
-- @param value Value for the desired property
--
procedure Set_Property(props: in out Properties; key: in Unbounded_String; value: in Unbounded_String) is
begin
if props.Find(Key) /= Hash_Table.No_Element then
props.Replace(Key => key, New_Item => value);
else
props.Insert(Key => key, New_Item => value);
end if;
end Set_Property;
--
-- Set the given property to the specified value.
-- @param props Properties container
-- @param key Key of the desired property
-- @param value Value for the desired property
--
procedure Set_Property(props: in out Properties; key: in String; value: in String) is
begin
props.Set_Property(To_Unbounded_String(key), To_Unbounded_String(value));
end Set_Property;
--
-- Output all of the properties in standard key=value format to the specified
-- output file.
-- @param props Properties object
-- @param output Output file
--
procedure List(props: in Properties; output: File_Type) is
curs: Hash_Table.Cursor;
key: Unbounded_String;
value: Unbounded_String;
begin
curs := props.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
value := props.Element(key);
Put_Line(output, To_String(key) & "=" & To_String(value));
curs := Hash_Table.Next(curs);
end loop;
end List;
--
-- Return a collection of all of the property names (Keys) in the
-- Properties object.
-- @param props Properties object
-- @return Collection of property names (Keys)
--
function Property_Names(props: in Properties) return Key_Vector.Vector is
keys: Key_Vector.Vector;
curs: Hash_Table.Cursor;
key: Unbounded_String;
begin
curs := props.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
keys.Append(key);
curs := Hash_Table.Next(curs);
end loop;
return keys;
end Property_Names;
--
-- Return a collection of all of the property names (Keys) including all
-- non-matching keys from the default Properties object.
-- @param props Properties object
-- @return Collection of property names (Keys)
--
function String_Property_Names(props: in Properties) return Key_Vector.Vector is
keys: Key_Vector.Vector;
curs: Hash_Table.Cursor;
key: Unbounded_String;
begin
curs := props.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
keys.Append(key);
curs := Hash_Table.Next(curs);
end loop;
curs := props.defaults.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
if props.Find(key) = Hash_Table.No_Element then
keys.Append(key);
end if;
curs := Hash_Table.Next(curs);
end loop;
return keys;
end String_Property_Names;
--
-- Store the contents of the Properties object to the output
-- file in a format suitable for using the load() procedure.
-- @param props Properties object
-- @param output Output file handle
-- @param comments Comments (if any)
--
procedure Store(props: in Properties; output: File_Type; comments: in String := "") is
now: constant Time := Clock;
curs: Hash_Table.Cursor;
key: Unbounded_String;
begin
if comments'Length > 0 then
Put_Line(output, "#" & comments);
end if;
Put_Line(output, "#" & Image(now, "%c"));
curs := props.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
Put_Line(output, Escape(key) & "=" & Escape(props.Element(key), false));
curs := Hash_Table.Next(curs);
end loop;
end Store;
--
-- Store the contents of the Properties object to the output
-- file in a format suitable for using the load() procedure.
-- @param props Properties object
-- @param filename Name of file to create
-- @param comments Comments (if any)
--
procedure Store(props: in Properties; filename: in String; comments: in String := "") is
output: File_Type;
begin
Create(output, Out_File, filename);
props.Store(output, comments);
Close(output);
end Store;
--
-- Store the contents of the Properties object to the output
-- file in a format suitable for using the load_from_XML() procedure.
-- @param props Properties object
-- @param output Output file handle
-- @param comments Comments (if any)
--
procedure Store_To_XML(props: Properties; output: File_Type; comments: in String := "") is
curs: Hash_Table.Cursor;
key: Unbounded_String;
begin
Put_Line(output, "<?xml version=""1.0"" encoding=""UTF-8""?>");
Put_Line(output, "<!DOCTYPE properties SYSTEM ""http://java.sun.com/dtd/properties.dtd"">");
Put_Line(output, "<properties>");
if comments'Length /= 0 then
Put_Line(output, "<comment>" & comments & "</comment>");
end if;
curs := props.First;
while curs /= Hash_Table.No_Element loop
key := Hash_Table.Key(curs);
Put_Line(output, "<entry key=""" &
Escape(key) &
""">" &
Escape(props.Element(key), false) &
"</entry>");
curs := Hash_Table.Next(curs);
end loop;
Put_Line(output, "</properties>");
end Store_To_XML;
--
-- Store the contents of the Properties object to the output
-- file in a format suitable for using the load_from_XML() procedure.
-- @param props Properties object
-- @param filename Name of file to create
-- @param comments Comments (if any)
--
procedure Store_To_XML(props: Properties; filename: in String; comments: in String := "") is
output: File_Type;
begin
Create(output, Out_File, filename);
props.Store_To_XML(output, comments);
Close(output);
end Store_To_XML;
--
-- Load the properties from the given input file object into
-- the Properties object. All of the rules specified by the
-- Java SE 7 Properties class are enforced.<br>
-- http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html
-- @param props Properties object
-- @param input Input file object
--
procedure Load(props: in out Properties; input: File_Type) is
line: Unbounded_String;
cpos: Natural;
begin
props.Clear;
while not End_Of_File(input) loop
Get_Line(input, line);
Trim(line, Ada.Strings.Both);
if Length(line) > 0 then
if Element(line, 1) /= '#' and Element(line, 1) /= '!' then
declare
c: Character;
is_key: Natural := 0;
key, value: Unbounded_String;
begin
cpos := 1;
while cpos <= Length(line) loop
c := Element(line, cpos);
if c = '\' then
if cpos = Length(line) then
Get_Line(input, line);
Trim(line, Ada.Strings.Both);
cpos := 0;
else
cpos := cpos + 1;
c := Element(line, cpos);
if is_key = 0 then
Append(key, c);
else
is_key := 2;
Append(value, c);
end if;
end if;
elsif is_key < 2 and (c = ':' or c = '=' or c = ' ') then
is_key := 1;
else
if is_key = 0 then
Append(key, c);
else
is_key := 2;
Append(value, c);
end if;
end if;
cpos := cpos + 1;
end loop;
props.Set_Property(key, value);
end;
end if;
end if;
end loop;
end Load;
--
-- Load the properties from the given input file object into
-- the Properties object. All of the rules specified by the
-- Java SE 7 Properties class are enforced.<br>
-- http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html
-- @param props Properties object
-- @param input Input file object
--
procedure Load(props: in out Properties; filename: in String) is
input: File_Type;
begin
Open(input, In_File, filename);
props.Load(input);
Close(input);
end Load;
procedure Load_From_XML(props: in out Properties; input: File_Type) is
begin
props.Clear;
end Load_From_XML;
procedure Load_From_XML(props: in out Properties; filename: in String) is
input: File_Type;
begin
Open(input, In_File, filename);
props.Load_From_XML(input);
Close(input);
end Load_From_XML;
end Properties;
|
test/Fail/Issue4995.agda | cruhland/agda | 1,989 | 10478 | <filename>test/Fail/Issue4995.agda
open import Agda.Builtin.Equality
cong : ∀ {A B : Set} → (f : A → B) → ∀ {x y} → x ≡ y → f x ≡ f y
cong f refl = refl
data ⊥ : Set where
data N : Set where
ze : N
su : (⊥ → N) → N
foo : N
foo = su (\ ())
postulate
ext : ∀ {A : Set} → (f g : ⊥ → A) → f ≡ g
foo-suc : foo ≡ su (\ _ → foo)
foo-suc = cong su (ext (λ ()) (λ _ → foo))
-- bad!
no-cycle : ∀ {n} → n ≡ su (\ _ → n) → ⊥
no-cycle ()
false : ⊥
false = no-cycle foo-suc
|
tests/testAdd.asm | trailofbits/codereason | 129 | 161752 | BITS 32
_s:
mov eax, ecx
add eax, 1
ret
|
ladspa/examples/amp-stereo.adb | Lucretia/aplug | 2 | 9028 | <gh_stars>1-10
-- with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Interfaces.C.Pointers;
with System;
package body Amp.Stereo is
use type LADSPA.Data_Ptr;
use type LADSPA.Handles;
type Amplifiers is
record
Gain_Value : LADSPA.Data_Ptr;
Input_Buffer_1 : LADSPA.Data_Ptr;
Output_Buffer_1 : LADSPA.Data_Ptr;
Input_Buffer_2 : LADSPA.Data_Ptr;
Output_Buffer_2 : LADSPA.Data_Ptr;
end record;
type Amplifier_Ptr is access all Amplifiers with
Convention => C;
function Convert is new Ada.Unchecked_Conversion (Source => LADSPA.Handles, Target => Amplifier_Ptr);
function Convert is new Ada.Unchecked_Conversion (Source => Amplifier_Ptr, Target => LADSPA.Handles);
procedure Free is new Ada.Unchecked_Deallocation (Object => Amplifiers, Name => Amplifier_Ptr);
-- Create and destroy handles (access to Amplifiers).
function Instantiate (Descriptor : access constant LADSPA.Descriptors;
Sample_Rate : C.unsigned_long) return LADSPA.Handles
is
use type LADSPA.Descriptors;
begin
return Convert (new Amplifiers);
end Instantiate;
procedure Clean_Up (Instance : in LADSPA.Handles) is
Amp : Amplifier_Ptr := null;
begin
if Instance /= null then
Amp := Convert (Instance);
if Amp /= null then
Free (Amp);
-- else
-- Put_Line ("Clean_Up - Amp is null");
end if;
-- else
-- Put_Line ("Clean_Up - Instance is null");
end if;
end Clean_Up;
procedure Connect_Port (Instance : in LADSPA.Handles;
Port : in C.unsigned_long;
Data_Location : in LADSPA.Data_Ptr) is
Amp : Amplifier_Ptr := Convert (Instance);
Actual_Port : constant Port_Numbers := Port_Numbers'Val (Port);
use type LADSPA.Handles;
begin
if Instance /= null then
if Amp /= null then
case Actual_Port is
when Gain =>
Amp.Gain_Value := Data_Location;
when Input_1 =>
Amp.Input_Buffer_1 := Data_Location;
when Output_1 =>
Amp.Output_Buffer_1 := Data_Location;
when Input_2 =>
Amp.Input_Buffer_2 := Data_Location;
when Output_2 =>
Amp.Output_Buffer_2 := Data_Location;
end case;
end if;
end if;
end Connect_Port;
-- procedure Activate (Instance : in out LADSPA.Handles) is
-- begin
-- Put_Line (">>> " & C.unsigned_long'Image (Stereo_Descriptor.Port_Count));
-- null;
-- end Activate;
-- procedure Deactivate (Instance : in out Handles) is
-- begin
-- null;
-- end;
-- WARNING: Cannot do IO or memory allocations here.
procedure Run (Instance : in LADSPA.Handles; Sample_Count : in C.unsigned_long) is
Amp : Amplifier_Ptr := Convert (Instance);
Gain : constant LADSPA.Data := Amp.Gain_Value.all;
package Amp_Ptrs is new Interfaces.C.Pointers
(Index => C.unsigned_long,
Element => LADSPA.Data,
Element_Array => LADSPA.Data_Array,
Default_Terminator => 0.0);
Input_Left : Amp_Ptrs.Pointer := Amp_Ptrs.Pointer (Amp.Input_Buffer_1);
Output_Left : Amp_Ptrs.Pointer := Amp_Ptrs.Pointer (Amp.Output_Buffer_1);
Input_Right : Amp_Ptrs.Pointer := Amp_Ptrs.Pointer (Amp.Input_Buffer_2);
Output_Right : Amp_Ptrs.Pointer := Amp_Ptrs.Pointer (Amp.Output_Buffer_2);
use type LADSPA.Data;
begin
for Index in 0 .. Sample_Count loop
Output_Left.all := Input_Left.all * Gain;
Output_Right.all := Input_Right.all * Gain;
Amp_Ptrs.Increment (Input_Left);
Amp_Ptrs.Increment (Output_Left);
Amp_Ptrs.Increment (Input_Right);
Amp_Ptrs.Increment (Output_Right);
end loop;
exception
when others =>
null; -- Silently catch for now.
end Run;
-- procedure Run_Adding (Instance : in out Handles; Sample_Count : in unsigned_long) is
-- begin
-- null;
-- end;
-- procedure Run_Adding_Gain (Instance : in out Handles; Gain : in Data) is
-- begin
-- null;
-- end;
overriding procedure Finalize (Self : in out Stereo_Descriptors) is
C_Str : C.Strings.chars_ptr;
begin
for C_Str_Index in Port_Numbers loop
C_Str := Stereo_Port_Names (C_Str_Index);
C.Strings.Free (C_Str);
end loop;
end Finalize;
end Amp.Stereo; |
src/prototyping/term/examples/Record.agda | larrytheliquid/agda | 1 | 3713 | {-# OPTIONS --type-in-type #-}
module Record where
open import Prelude
record Sigma (A : Set)(B : A -> Set) : Set
record Sigma A B where
constructor pair
field
fst : A
snd : B fst
open Sigma
data Unit : Set
data Unit where
tt : Unit
Cat : Set
Cat =
Sigma Set (\ Obj ->
Sigma (Obj -> Obj -> Set) (\ Hom ->
Sigma ((X : _) -> Hom X X) (\ id ->
Sigma ((X Y Z : _) -> Hom Y Z -> Hom X Y -> Hom X Z) (\ comp ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ (id Y) f == f) (\ idl ->
Sigma ((X Y : _)(f : Hom X Y) -> comp _ _ _ f (id X) == f) (\ idr ->
Sigma ((W X Y Z : _)
(f : Hom W X)(g : Hom X Y)(h : Hom Y Z) ->
comp _ _ _ (comp _ _ _ h g) f ==
comp _ _ _ h (comp _ _ _ g f)) (\ assoc ->
Unit)))))))
Obj : (C : Cat) -> Set
Obj C = fst C
Hom : (C : Cat) -> Obj C -> Obj C -> Set
Hom C = fst (snd C)
id : (C : Cat) -> (X : _) -> Hom C X X
id C = fst (snd (snd C))
comp : (C : Cat) -> (X Y Z : _) -> Hom C Y Z -> Hom C X Y -> Hom C X Z
comp C = fst (snd (snd (snd C)))
idl : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ (id C Y) f == f
idl C = fst (snd (snd (snd (snd C))))
idr : (C : Cat) -> (X Y : _)(f : Hom C X Y) ->
comp C _ _ _ f (id C X) == f
idr C = fst (snd (snd (snd (snd (snd C)))))
assoc : (C : Cat) ->
(W X Y Z : _) (f : Hom C W X)(g : Hom C X Y)(h : Hom C Y Z) ->
comp C _ _ _ (comp C _ _ _ h g) f ==
comp C _ _ _ h (comp C _ _ _ g f)
assoc C = fst (snd (snd (snd (snd (snd (snd C))))))
|
Transynther/x86/_processed/NONE/_st_/i9-9900K_12_0xca.log_21829_1293.asm | ljhsiun2/medusa | 9 | 24966 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r8
push %rdi
lea addresses_WC_ht+0x154fb, %rdi
nop
nop
dec %r11
movb (%rdi), %r8b
nop
nop
nop
nop
nop
xor %r12, %r12
pop %rdi
pop %r8
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r8
push %rax
push %rdi
push %rdx
// Store
lea addresses_WC+0x18cc5, %rax
nop
nop
nop
xor $57866, %r13
movl $0x51525354, (%rax)
nop
nop
add %r13, %r13
// Faulty Load
lea addresses_WT+0x1ecc5, %r8
nop
add %rdx, %rdx
mov (%r8), %r13
lea oracles, %r8
and $0xff, %r13
shlq $12, %r13
mov (%r8,%r13,1), %r13
pop %rdx
pop %rdi
pop %rax
pop %r8
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': True, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 10}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'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/Processors/LaTeX/latex_writer.adb | fintatarta/eugen | 0 | 6630 | pragma Ada_2012;
with Ada.Strings.Fixed;
package body Latex_Writer is
-- The result of function 'Image associated to discrete types has
-- a space at the beginning. That space is quite annoying and needs
-- to be trimmed. This function is here so that everyone can use it
function Chop (X : String) return String
is (Ada.Strings.Fixed.Trim (X, Ada.Strings.Both));
function Image (X : Integer) return String
is (Chop (Integer'Image (X)));
-------------------------
-- Print_Default_Macro --
-------------------------
procedure Print_Default_Macro (Output : File_Access;
Command_Name : String;
Definition : String;
N_Parameters : Natural)
is
begin
Put (File =>
Output.all,
Item =>
"\ifdef{" & Command_Name & "}"
& "{}"
& "{\newcommand{" & Command_Name & "}");
if N_Parameters > 0 then
Put (Output.all, "[" & Image (N_Parameters) & "]");
end if;
Put_Line (Output.all, "{" & Definition & "}}");
end Print_Default_Macro;
------------
-- Within --
------------
procedure Within
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access);
Parameter : String := "")
is
begin
Put (Output.all, "\begin{" & Env_Name & "}");
if Parameter /= "" then
Put (Output.all, "{" & Parameter & "}");
end if;
New_Line (Output.all);
Callback (Output);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
end Within;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler))
is
Arg : constant Parameter_List (2 .. 1) := (others => <>);
begin
Within_Table_Like (Output => Output,
Env_Name => Env_Name,
Callback => Callback,
Parameters => Arg);
end Within_Table_Like;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Parameter : String)
is
begin
Within_Table_Like (Output => Output,
Env_Name => Env_Name,
Callback => Callback,
Parameters => (1 => To_Unbounded_String (Parameter)));
end Within_Table_Like;
-----------------------
-- Within_Table_Like --
-----------------------
procedure Within_Table_Like
(Output : File_Access;
Env_Name : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Parameters : Parameter_List)
is
T : Table_Handler := Table_Handler'(State => Begin_Row,
Output => Output,
Default_Style => To_Unbounded_String (""),
Default_Head => To_Unbounded_String (""));
begin
Put (Output.all, "\begin{" & Env_Name & "}");
for K in Parameters'Range loop
Put (Output.all, "{" & To_String (Parameters (K)) & "}");
end loop;
New_Line (Output.all);
Callback (Output, T);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
end Within_Table_Like;
------------------
-- Within_Table --
------------------
procedure Within_Table
(Output : File_Access;
Table_Spec : String;
Callback : access procedure (Output : File_Access;
Table : in out Table_Handler);
Default_Style : String := "";
Default_Head : String := "";
Caption : String := "";
Width : String := "\textwidth")
is
use Ada.Strings.Fixed;
T : Table_Handler := Table_Handler'(State => Begin_Row,
Output => Output,
Default_Style => To_Unbounded_String (Default_Style),
Default_Head => To_Unbounded_String (Default_Head));
Use_Tabularx : constant Boolean := Index (Table_Spec, "X") > 0;
Env_Name : constant String :=
(if Use_Tabularx then "tabularx" else "tabular");
Width_Spec : constant String := (if Use_Tabularx then "{" & Width & "}" else "");
begin
if Caption /= "" then
Put_Line (Output.all, "\begin{table}");
Put_Line (Output.all, "\caption{" & Caption & "}");
end if;
Put_Line (Output.all, "\centering");
Put_Line (Output.all,
"\begin{" & Env_Name & "}"
& Width_Spec
& "{" & Table_Spec & "}");
Callback (Output, T);
New_Line (Output.all);
Put_Line (Output.all, "\end{" & Env_Name & "}");
if Caption /= "" then
Put_Line (Output.all, "\end{table}");
end if;
end Within_Table;
-----------------
-- Apply_Style --
-----------------
function Apply_Style (Content : String;
Style : Style_Spec;
Default_Style : Unbounded_String)
return String
is
begin
if Style /= "" then
return String (Style) & "{" & Content & "}";
elsif Default_Style /= "" then
return To_String (Default_Style) & "{" & Content & "}";
else
return Content;
end if;
end Apply_Style;
procedure Put_If_In_State (Table : in out Table_Handler;
Content : String;
State : Table_State)
is
begin
if Table.State = State then
Put (Table.Output.all, Content);
end if;
end Put_If_In_State;
---------
-- Put --
---------
procedure Put
(Table : in out Table_Handler; Content : String; Style : String := "")
is
begin
Put_If_In_State (Table, " & ", Middle_Row);
Put (Table.Output.all, Apply_Style (Content, Style_Spec (Style), Table.Default_Style));
Table.State := Middle_Row;
end Put;
-------------
-- New_Row --
-------------
procedure New_Row (Table : in out Table_Handler) is
begin
Put_Line (Table.Output.all, "\\");
Table.State := Begin_Row;
end New_Row;
-----------
-- hline --
-----------
procedure Hline (Table : in out Table_Handler;
Full : Boolean := True) is
begin
Put_If_In_State (Table, "\\", Middle_Row);
if Full then
Put_Line (Table.Output.all, "\hline");
end if;
Table.State := Begin_Row;
end Hline;
procedure Cline (Table : in out Table_Handler; From, To : Positive)
is
begin
Put_If_In_State (Table, "\\", Middle_Row);
Put_Line (Table.Output.all, "\cline{" & Image (From) & "-" & Image (To) & "}");
Table.State := Begin_Row;
end Cline;
-----------------
-- Multicolumn --
-----------------
procedure Multicolumn (Table : in out Table_Handler;
Span : Positive;
Spec : String;
Content : String)
is
begin
Put_If_In_State (Table, "&", Middle_Row);
Put (Table.Output.all, "\multicolumn{" & Image (Span) & "}{" & Spec & "}");
Put_Line (Table.Output.all, "{" & Content & "}");
Table.State := Middle_Row;
end Multicolumn;
----------
-- Head --
----------
procedure Head (Table : in out Table_Handler;
Content : String;
Bar : Bar_Position := Default;
Style : String := "")
is
True_Bar : constant Bar_Position :=
(if Bar /= Default
then
Bar
elsif Table.State = Begin_Row then
Both
else
Right);
function Bar_Maybe (X : Boolean) return String
is (if X then "|" else "");
begin
Table.Multicolumn (Span => 1,
Content => Apply_Style (Content => Content,
Style => Style_Spec (Style),
Default_Style => Table.Default_Head),
Spec =>
Bar_Maybe (True_Bar = Left or True_Bar = Both) &
"c" &
Bar_Maybe (True_Bar = Right or True_Bar = Both));
end Head;
----------
-- Hbox --
----------
function Hbox (Content : String;
Size : Latex_Length := Zero;
Align : Align_Type := Center)
return String
is
begin
return "\hbox to "
& Image (Size)
& "{"
& (case Align is
when Center | Left => "\hss",
when Right => "")
& "{" & Content & "}"
& (case Align is
when Center | Right => "\hss",
when Left => "")
& "}";
end Hbox;
end Latex_Writer;
|
language/src/main/java/ninja/soroosh/hashem/lang/parser/HashemLanguage.g4 | niima/mr-hashemi | 0 | 5310 | /*
* The parser and lexer need to be generated using "mx create-sl-parser".
*/
grammar HashemLanguage;
@parser::header
{
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import ninja.soroosh.hashem.lang.nodes.*;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.RootCallTarget;
import ninja.soroosh.hashem.lang.HashemLanguage;
import ninja.soroosh.hashem.lang.nodes.HashemExpressionNode;
import ninja.soroosh.hashem.lang.nodes.HashemRootNode;
import ninja.soroosh.hashem.lang.nodes.HashemStatementNode;
}
@lexer::header
{
// DO NOT MODIFY - generated from HashemLanguage.g4
}
@parser::members
{
private HashemNodeFactory factory;
private Source source;
private static final class BailoutErrorListener extends BaseErrorListener {
private final Source source;
BailoutErrorListener(Source source) {
this.source = source;
}
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg);
}
}
public void SemErr(Token token, String message) {
assert token != null;
throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message);
}
private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) {
int col = charPositionInLine + 1;
String location = "-- line " + line + " col " + col + ": ";
int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0);
throw new HashemParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message));
}
public static Map<String, RootCallTarget> parseHashemiLang(HashemLanguage language, Source source) {
HashemLanguageLexer lexer = new HashemLanguageLexer(CharStreams.fromString(source.getCharacters().toString()));
HashemLanguageParser parser = new HashemLanguageParser(new CommonTokenStream(lexer));
lexer.removeErrorListeners();
parser.removeErrorListeners();
BailoutErrorListener listener = new BailoutErrorListener(source);
lexer.addErrorListener(listener);
parser.addErrorListener(listener);
parser.factory = new HashemNodeFactory(language, source);
parser.source = source;
parser.hashemlanguage();
return parser.factory.getAllFunctions();
}
}
// parser
hashemlanguage
:
function function* EOF
;
function
:
'bebin'
IDENTIFIER
s='('
{ factory.startFunction($IDENTIFIER, $s); }
(
IDENTIFIER { factory.addFormalParameter($IDENTIFIER); }
(
','
IDENTIFIER { factory.addFormalParameter($IDENTIFIER); }
)*
)?
')'
body=block[false] { factory.finishFunction($body.result); }
;
block [boolean inLoop] returns [HashemStatementNode result]
: { factory.startBlock();
List<HashemStatementNode> body = new ArrayList<>(); }
s='{'
(
statement[inLoop] { body.add($statement.result); }
)*
e='}'
{ $result = factory.finishBlock(body, $s.getStartIndex(), $e.getStopIndex() - $s.getStartIndex() + 1); }
;
statement [boolean inLoop] returns [HashemStatementNode result]
:
(
while_statement { $result = $while_statement.result; }
|
b='khob' { if (inLoop) { $result = factory.createBreak($b); } else { SemErr($b, "break used outside of loop"); } }
';'
|
c='badi' { if (inLoop) { $result = factory.createContinue($c); } else { SemErr($c, "continue used outside of loop"); } }
';'
|
if_statement[inLoop] { $result = $if_statement.result; }
|
return_statement { $result = $return_statement.result; }
|
expression ';' { $result = $expression.result; }
|
d='debugger' { $result = factory.createDebugger($d); }
';'
)
;
while_statement returns [HashemStatementNode result]
:
w='ta'
'('
condition=expression
') bood'
body=block[true] { $result = factory.createWhile($w, $condition.result, $body.result); }
;
if_statement [boolean inLoop] returns [HashemStatementNode result]
:
i='age'
'('
condition=expression
') bood'
then=block[inLoop] { HashemStatementNode elsePart = null; }
(
'na?'
block[inLoop] { elsePart = $block.result; }
)? { $result = factory.createIf($i, $condition.result, $then.result, elsePart); }
;
return_statement returns [HashemStatementNode result]
:
r='bede' { HashemExpressionNode value = null; }
(
expression { value = $expression.result; }
)? { $result = factory.createReturn($r, value); }
';'
;
expression returns [HashemExpressionNode result]
:
logic_term { $result = $logic_term.result; }
(
op='||'
logic_term { $result = factory.createBinary($op, $result, $logic_term.result); }
)*
;
logic_term returns [HashemExpressionNode result]
:
logic_factor { $result = $logic_factor.result; }
(
op='&&'
logic_factor { $result = factory.createBinary($op, $result, $logic_factor.result); }
)*
;
logic_factor returns [HashemExpressionNode result]
:
arithmetic { $result = $arithmetic.result; }
(
op=('<' | '<=' | '>' | '>=' | '==' | '!=' )
arithmetic { $result = factory.createBinary($op, $result, $arithmetic.result); }
)?
;
arithmetic returns [HashemExpressionNode result]
:
term { $result = $term.result; }
(
op=('+' | '-')
term { $result = factory.createBinary($op, $result, $term.result); }
)*
;
term returns [HashemExpressionNode result]
:
factor { $result = $factor.result; }
(
op=('*' | '/')
factor { $result = factory.createBinary($op, $result, $factor.result); }
)*
;
factor returns [HashemExpressionNode result]
:
(
IDENTIFIER { HashemExpressionNode assignmentName = factory.createStringLiteral($IDENTIFIER, false); }
(
member_expression[null, null, assignmentName] { $result = $member_expression.result; }
|
{ $result = factory.createRead(assignmentName); }
)
|
STRING_LITERAL { $result = factory.createStringLiteral($STRING_LITERAL, true); }
|
NUMERIC_LITERAL { $result = factory.createNumericLiteral($NUMERIC_LITERAL); }
|
s='('
expr=expression
e=')' { $result = factory.createParenExpression($expr.result, $s.getStartIndex(), $e.getStopIndex() - $s.getStartIndex() + 1); }
)
;
member_expression [HashemExpressionNode r, HashemExpressionNode assignmentReceiver, HashemExpressionNode assignmentName] returns [HashemExpressionNode result]
: { HashemExpressionNode receiver = r;
HashemExpressionNode nestedAssignmentName = null; }
(
'(' { List<HashemExpressionNode> parameters = new ArrayList<>();
if (receiver == null) {
receiver = factory.createRead(assignmentName);
} }
(
expression { parameters.add($expression.result); }
(
','
expression { parameters.add($expression.result); }
)*
)?
e=')'
{ $result = factory.createCall(receiver, parameters, $e); }
|
'='
expression { if (assignmentName == null) {
SemErr($expression.start, "invalid assignment target");
} else if (assignmentReceiver == null) {
$result = factory.createAssignment(assignmentName, $expression.result);
} else {
$result = factory.createWriteProperty(assignmentReceiver, assignmentName, $expression.result);
} }
|
'.' { if (receiver == null) {
receiver = factory.createRead(assignmentName);
} }
IDENTIFIER
{ nestedAssignmentName = factory.createStringLiteral($IDENTIFIER, false);
$result = factory.createReadProperty(receiver, nestedAssignmentName); }
|
'[' { if (receiver == null) {
receiver = factory.createRead(assignmentName);
} }
expression
{ nestedAssignmentName = $expression.result;
$result = factory.createReadProperty(receiver, nestedAssignmentName); }
']'
)
(
member_expression[$result, receiver, nestedAssignmentName] { $result = $member_expression.result; }
)?
;
// lexer
WS : [ \t\r\n\u000C]+ -> skip;
COMMENT : '/*' .*? '*/' -> skip;
LINE_COMMENT : '//' ~[\r\n]* -> skip;
fragment LETTER : [A-Z] | [a-z] | '_' | '$';
fragment NON_ZERO_DIGIT : [1-9];
fragment DIGIT : [0-9];
fragment HEX_DIGIT : [0-9] | [a-f] | [A-F];
fragment OCT_DIGIT : [0-7];
fragment BINARY_DIGIT : '0' | '1';
fragment TAB : '\t';
fragment STRING_CHAR : ~('"' | '\\' | '\r' | '\n');
IDENTIFIER : LETTER (LETTER | DIGIT)*;
STRING_LITERAL : '"' STRING_CHAR* '"';
NUMERIC_LITERAL : '0' | NON_ZERO_DIGIT DIGIT*;
|
1A/S5/PIM/projet/src/arbre_genealogique.ads | MOUDDENEHamza/ENSEEIHT | 4 | 26669 | <filename>1A/S5/PIM/projet/src/arbre_genealogique.ads<gh_stars>1-10
-------------------------------------------------------------------------------
-- Fichier : arbre_genealogique.ads
-- Auteur : <NAME> & <NAME>
-- Objectif : Spécification du module Arbre_Genealogique
-- Crée : <NAME> 10 2019
--------------------------------------------------------------------------------
with Arbre_Binaire;
with Ensemble;
with Registre; use Registre;
package Arbre_Genealogique is
type T_ABG is private; -- Type Arbre genealogique.
type T_List is array(1..10) of Integer;
type T_Node is record
ID : Integer;
Cohabitant : T_List;
Half_Brother : T_List;
end record;
-- Instancier Ensemble avec T_Element comme Integer.
package Ens is
New Ensemble (T_Element => T_Node);
use Ens;
ARBRE_VIDE_EXCEPTION : Exception; -- Arbre est vDATAe.
ARBRE_NON_VIDE_EXCEPTION : Exception; -- Arbre n'est pas vDATAe.
ID_PRESENT_EXCEPTION : Exception; -- ID Present.
ID_ABSENT_EXCEPTION : Exception; -- ID Absent.
DEUX_PARENTS_PRESENTS_EXCEPTION : Exception; -- Deux parents existants.
----------------------------------Constuctor--------------------------------
-- Nom : Initialize_List
-- Sémantique : Initialiser List. Tree est List.
-- Paramètres :
-- List -- List que l'on va initialiser.
function Initialize_List (List : out T_List) return T_List;
-- Nom : Initialize_Data
-- Sémantique : Initialiser Data. Tree est Data.
-- Paramètres :
-- Tree --Tree que l'on va initialiser.
procedure Initialize_Data (Data : out T_Node; ID : in Integer);
-- Nom : Initialize_Genealogical_Tree
-- Sémantique : Initialiser un arbre genéalogique. L'arbre est vide.
-- Paramètres :
-- Ab -- Ab que l'on va initialiser.
procedure Initialize_Genealogical_Tree (Ab : out T_ABG);
-- Nom : Creer_Arbre_Minimal
-- Sémantique : Initialiser un Ab. L'Ab contient la racine.
-- Exception : ARBRE_NON_VDATAE_EXCEPTION.
-- Paramètre :
-- Ab -- L'Ab que l'on va initialiser avec sa racine.
procedure Creer_Arbre_Minimal (Ab : out T_ABG; DATA : in T_Node);
-- Nom : Ajouter_Parent
-- Sémantique : Ajouter un parent (mère ou père) à un noeud donné.
-- Exception :
-- ARBRE_VDATAE_EXCEPTION.
-- DATA_ABSENT_EXCEPTION.
-- DEUX_PARENTS_PRESENTS_EXCEPTION.
-- Paramètre :
-- Ab -- L'Ab auquel on va ajouter un parent.
-- ID -- ID de l'individu qu'on va lui ajouter un parent.
-- New_ID -- ID du parent.
-- Flag -- Un entier binaire pour désigner si c'est un père ou une mère.
procedure Ajouter_Parent (Ab : in out T_ABG; New_Data : in T_Node; ID, Flag : in Integer);
-----------------------------------Getters----------------------------------
-- Nom : Get_ID
-- Sémantique : Obtenir l'ID de Node.
-- Type_De_Retour : Integer est l'ID du noeud.
-- Paramètres
-- Ab : L'arbre qu'on va parcourir.
function Get_ID (Ab : in T_ABG) return Integer;
-- Nom : Get_Cohabitant
-- Sémantique : Obtenir la liste des concubains.
-- Type_De_Retour : T_List est la liste des concubains.
-- Paramètres
-- Ab : Arbre qu'on va parcourir.
function Get_Cohabitant (Ab : in T_ABG) return T_List;
-- Nom : Get_Half_Brother.
-- Sémantique : Obtenir l'ensemble des demi-frères.
-- Type_De_Retour : T_List est la liste des demi_frères.
-- Paramètres
-- Ab : Arbre qu'on va parcourir.
function Get_Half_Brother (Ab : in T_ABG) return T_List;
-- Nom : Get_ID_Father
-- Sémantique : Obtenir l'ensemble des demi-frères.
-- Type_De_Retour : Integer est l'ID du père.
-- Paramètres
-- Ab : Arbre qu'on va parcourir.
function Get_ID_Father (Ab : in T_ABG) return Integer;
-- Nom : Get_ID_Father
-- Sémantique : Obtenir l'ensemble des demi-frères.
-- Type_De_Retour : Integer est l'ID du mère.
-- Paramètres
-- Ab : Arbre qu'on va parcourir.
function Get_ID_Mother (Ab : in T_ABG) return Integer;
----------------------------------------------------------------------------
-- Nom : Is_Present_ID
-- Sémantique : Vérifier qu'un ID passé en paramètre est dans l'arbre.
-- Type_De_Retour : Boolean -- True si l'ID est dans Tree, False sinon.
-- Paramètres :
-- Tree -- Tree que l'on va parcourir.
-- ID -- L'DATA pour lequel on voudra savoir s'il est dans Tree.
function Is_Present_ID (Tree : in T_ABG; ID : in Integer) return Boolean;
-- Nom : Generate_ID
-- Sémantique : Générer un ID unique.
-- Type_De_Retour : Integer -- l'ID généré
-- Paramètre :
-- Ab : L'Ab que l'on va parcourir.
function Generate_ID (Ab : in T_ABG) return Integer;
-- Nom : Get_Child_ID
-- Sémantique : Obtenir l'ID du fils.
-- Type_De_Retour : Integer -- Integer l'ID du fils.
-- Paramètres :
-- Ab -- Tree que l'on va parcourir.
-- Parent_ID -- L'ID du parent passé en paramètre.
function Get_Child_ID (Ab : in T_ABG; Parent_ID : in Integer) return Integer;
-- Nom : Nombre_Ancetres
-- Sémantique : Obtenir le nombre d'ancêtres connus (lui compris) d'un indivDATAu donné.
-- Type_De_Retour : Integer -- nombre d'ancêtres, entier strictement positif
-- Exception : DATA_ABSENT_EXCEPTION.
-- Paramètres :
-- Ab : L'Ab que l'on va parcourir.
-- ID : ID unique d'un indivDATAu dans l'Ab.
function Nombre_Ancetres (Ab : in T_ABG; ID : in Integer) return Integer;
-- Nom : Ancetres_N_Generation
-- Sémantique : Obtenir l'ensemble des ancêtres situé à une certaine génération d'un noeud donné.
-- Type_De_Retour : T_Ensemble : Retourne un ensemble non vDATAe d'ancêtres.
-- Exception : ID_ABSENT_EXCEPTION.
-- Paramètres :
-- Ab -- L'Ab que l'on va parcourir.
-- ID -- DATAentifiant unique d'un indivDATAu dans l'Ab.
-- Generation -- le niveau d'ancêtres que l'on cherche.
procedure Ancetres_N_Generation (Ab : in T_ABG; ID, Generation : in Integer);
-- Nom : Afficher_Arbre_Noeud
-- Sémantique : Afficher l'arbre à partir d'un noeud donné.
-- Paramètres :
-- Ab -- L'Ab que l'on va parcourir.
-- DATA -- DATAentifiant unique d'un indivDATAu dans l'Ab.
procedure Afficher_Arbre_Noeud (Ab : in T_ABG; ID : in Integer);
-- Nom : Supprimer
-- Sémantique : Supprimer, pour un arbre, un noeud et ses ancêtres.
-- Exception : DATA_ABSENT_EXCEPTION.
-- Paramètres :
-- Ab -- L'Ab que l'on va parcourir.
-- DATA -- DATAentifiant unique d'un indivDATAu dans l'Ab.
procedure Supprimer (Ab : in out T_ABG; ID : in Integer);
-- Nom : Individus_1_Parent_Connu
-- Sémantique : Obtenir l'ensemble des individus qui n'ont qu'un parent connu.
-- Type_De_Retour : T_Ensemble -- ensemble vide ou non vide de parents.
-- Paramètre :
-- Ab -- L'Ab que l'on va parcourir.
procedure Individus_1_Parent_Connu (Ab : in T_ABG);
-- Nom : Individus_2_Parent_Connu
-- Sémantique : Obtenir l'ensemble des individus dont les deux parents sont connus.
-- Type_De_Retour : T_Ensemble -- ensemble vide ou non vide de parents.
-- Paramètre :
-- Ab -- L'Ab que l'on va parcourir.
procedure Individus_2_Parent_Connu (Ab : in T_ABG);
-- Nom : Ensemble_Feuilles
-- Sémantique : Obtenir l'ensemble des individus dont les deux parents sont inconnus.
-- Type_De_Retour : T_Ensemble -- ensemble vide ou non vide de parents.
-- Paramètre :
-- Ab -- L'Ab que l'on va parcourir.
procedure Ensemble_Feuilles (Ab : in T_ABG);
-- Nom : Ancetres_Sur_N_Generation
-- Sémantique : Identifier les ancêtres d'un individu donné sur N generations données par un noeud donné.
-- Type_De_Retour : T_Ensemble -- ensemble vide ou non vide de parents.
-- Exception : ID_ABSENT_EXCEPTION.
-- Paramètres :
-- Ab -- L'Ab que l'on va parcourir.
-- ID -- Identifiant unique d'un indivDATAu dans l'Ab.
-- Generation -- Le niveau d'ancêtres que l'on cherche.
procedure Ancetres_Sur_N_Generation (Ab : in T_ABG; ID, Generation : in Integer);
-- Nom : Ancetres_Homonymes
-- Sémantique : Vérifier que deux individus n et m ont un ou plusieurs ancêtres homonymes (mêmes non et prénom).
-- Type_De_Retour : Boolean -- True si ID1 et ID2 ont des ancêtres homonymes, sinon False.
-- Exception : ID_ABSENT_EXCEPTION.
-- Paramètres :
-- Ab -- L'Ab que l'on va parcourir.
-- R -- Le registre des arbres genealogiques.
-- ID1|2 -- iDentifiant unique d'un indivDATAu dans l'Ab.
function Ancetres_Homonymes (Ab1, Ab2 : in T_ABG; R : in T_Registre; ID1, ID2 : in Integer) return Boolean;
private
-- Instancier Arbre_Binaire avec T_DATA comme Integer.
package Ab_Genealogique is
New Arbre_Binaire (T_DATA => T_Node);
use Ab_Genealogique;
type T_ABG is new T_BT;
end Arbre_Genealogique;
|
antlr4-test/src/main/java/com/warningrc/test/antlr4/script/Coupon.g4 | warningrc/learn-java | 1 | 6884 | grammar Coupon;
build : matchOrder1;
matchOrder1 : '{' matchOrder '}';
matchOrder : rangeType
|| rangeType ',' productLines ',' productTypes
|| rangeType ',' productTypes ',' productLines
|| productLines ',' rangeType ',' productTypes
|| productLines ',' productTypes ',' rangeType
|| productTypes ',' rangeType ',' productLines
|| productTypes ',' productLines ',' rangeType ;
rangeType: '"rangeType"' ':' rangeType;
productLines: '"productLines"' ':' '[' (STRING)? ']';
productTypes: '"productTypes"' ':' '[' (STRING)? ']';
OR : 'or' | 'OR' | '||' ;
AND : 'and' | 'AND' | '&&' ;
STRING: (~[\: \t\(\)])+;
NUMBER: (~[\: \t\(\)])+;
WS : [ \t\r\n]+ -> skip ; |
oeis/097/A097335.asm | neoneye/loda-programs | 11 | 12459 | <reponame>neoneye/loda-programs
; A097335: Sum k=0..n, C(n-k, floor(k/2))3^k.
; Submitted by <NAME>
; 1,4,4,13,49,85,202,643,1408,3226,9013,21685,50719,131836,327001,783472,1969996,4913005,11964253,29694217,73911262,181589539,448837492,1114038850,2748344701,6787882129,16814231779,41549334088,102640273249
lpb $0
sub $0,1
mul $1,3
add $1,1
mov $3,$1
mul $3,3
add $4,1
mov $1,$4
add $2,$3
mov $4,$2
sub $4,$3
lpe
mov $0,$1
mul $0,3
add $0,1
|
programs/oeis/024/A024038.asm | neoneye/loda | 22 | 98439 | ; A024038: a(n) = 4^n - n^2.
; 1,3,12,55,240,999,4060,16335,65472,262063,1048476,4194183,16777072,67108695,268435260,1073741599,4294967040,17179868895,68719476412,274877906583,1099511627376,4398046510663,17592186043932,70368744177135,281474976710080,1125899906841999,4503599627369820,18014398509481255,72057594037927152,288230376151710903,1152921504606846076,4611686018427386943,18446744073709550592,73786976294838205375,295147905179352824700,1180591620717411302199,4722366482869645212400,18889465931478580853415,75557863725914323417692,302231454903657293675023,1208925819614629174704576,4835703278458516698823023,19342813113834066795297052,77371252455336267181193415,309485009821345068724779120,1237940039285380274899122199,4951760157141521099596494780,19807040628566084398385985375,79228162514264337593543948032,316912650057057350374175798943,1267650600228229401496703202876,5070602400912917605986812818903,20282409603651670423947251283312,81129638414606681695789005141255,324518553658426726783156020573340,1298074214633706907132624082301999,5192296858534827628530496329216960,20769187434139310514121985316877135,83076749736557242056487941267518172,332306998946228968225951765070082663
mov $1,4
pow $1,$0
mov $2,$0
mul $2,$0
sub $1,$2
mov $0,$1
|
alloy4fun_models/trainstlt/models/4/3r6mBBJnNqtz5Sxmm.als | Kaixi26/org.alloytools.alloy | 0 | 1878 | <gh_stars>0
open main
pred id3r6mBBJnNqtz5Sxmm_prop5 {
always all t: Train | t.prox not in Exit implies t.pos' in t.pos + t.pos.prox
}
pred __repair { id3r6mBBJnNqtz5Sxmm_prop5 }
check __repair { id3r6mBBJnNqtz5Sxmm_prop5 <=> prop5o } |
Source/Apps/Startup.asm | davidknoll/RomWBW | 194 | 24446 | <reponame>davidknoll/RomWBW
;===============================================================================
; STARTUP - Application run automatically at OS startup
;
;===============================================================================
;
; Author: <NAME> (<EMAIL>)
;_______________________________________________________________________________
;
; Usage:
; MODE [/?]
;
; Operation:
; Determines if STARTUP.CMD exists on startup drive, user 0. If it is
; found, it is run via SUBMIT.
;_______________________________________________________________________________
;
; Change Log:
; 2017-12-01 [WBW] Initial release
;_______________________________________________________________________________
;
; ToDo:
; 1) Detect OS type (CP/M or ZSYS) and run different batch files as a result.
;_______________________________________________________________________________
;
;===============================================================================
; Definitions
;===============================================================================
;
stksiz .equ $40 ; Working stack size
;
restart .equ $0000 ; CP/M restart vector
bdos .equ $0005 ; BDOS invocation vector
;
ident .equ $FFFE ; loc of RomWBW HBIOS ident ptr
;
rmj .equ 2 ; intended CBIOS version - major
rmn .equ 9 ; intended CBIOS version - minor
;
bf_cioinit .equ $04 ; HBIOS: CIOINIT function
bf_cioquery .equ $05 ; HBIOS: CIOQUERY function
bf_ciodevice .equ $06 ; HBIOS: CIODEVICE function
bf_sysget .equ $F8 ; HBIOS: SYSGET function
;
;===============================================================================
; Code Section
;===============================================================================
;
.org $100
;
; setup stack (save old value)
ld (stksav),sp ; save stack
ld sp,stack ; set new stack
;
; initialization
call init ; initialize
jr nz,exit ; abort if init fails
;
; process
call process ; do main processing
jr nz,exit ; abort on error
;
exit: ; clean up and return to command processor
call crlf ; formatting
ld sp,(stksav) ; restore stack
;jp restart ; return to CP/M via restart
ret ; return to CP/M w/o restart
;
; Initialization
;
init:
;
initx
; initialization complete
xor a ; signal success
ret ; return
;
; Process
;
process:
; skip to start of first parm
ld ix,$81 ; point to start of parm area (past len byte)
call nonblank ; skip to next non-blank char
jp z,runcmd ; no parms, do command processing
;
process1:
; process options (if any)
cp '/' ; option prefix?
jp nz,erruse ; invalid option introducer
call option ; process option
ret nz ; some options mean we are done (e.g., "/?")
inc ix ; skip option character
call nonblank ; skip whitespace
jr nz,process1 ; continue option checking
jp runcmd ; end of parms, do cmd processing
;
;
;
runcmd:
call ldfil ; load executable
ret nz ; abort on error
;
xor a
ret
;
; Load file for execution
;
ldfil:
ld c,15 ; BDOS function: Open File
ld de,fcb ; pointer to FCB
call bdos ; do it
inc a ; check for err, 0xFF --> 0x00
jp z,errfil ; handle file not found err
;
ld c,16 ; BDOS function: Close File
ld de,fcb ; pointer to FCB
call bdos ; do it
inc a ; check for err, 0xFF --> 0x00
jp z,errfil ; handle file close err
;
xor a ; signal success
ret ; done
;
; Handle options
;
option:
;
inc ix ; next char
ld a,(ix) ; get it
cp '?' ; is it a '?' as expected?
jp z,usage ; yes, display usage
jp errprm ; anything else is an error
;
; Display usage
;
usage:
;
call crlf ; formatting
ld de,msgban ; point to version message part 1
call prtstr ; print it
call crlf2 ; blank line
ld de,msguse ; point to usage message
call prtstr ; print it
or $FF ; signal no action performed
ret ; and return
;
; Print character in A without destroying any registers
;
prtchr:
push bc ; save registers
push de
push hl
ld e,a ; character to print in E
ld c,$02 ; BDOS function to output a character
call bdos ; do it
pop hl ; restore registers
pop de
pop bc
ret
;
prtdot:
;
; shortcut to print a dot preserving all regs
push af ; save af
ld a,'.' ; load dot char
call prtchr ; print it
pop af ; restore af
ret ; done
;
; Print a zero terminated string at (DE) without destroying any registers
;
prtstr:
push de
;
prtstr1:
ld a,(de) ; get next char
or a
jr z,prtstr2
call prtchr
inc de
jr prtstr1
;
prtstr2:
pop de ; restore registers
ret
;
; Print the value in A in hex without destroying any registers
;
prthex:
push af ; save AF
push de ; save DE
call hexascii ; convert value in A to hex chars in DE
ld a,d ; get the high order hex char
call prtchr ; print it
ld a,e ; get the low order hex char
call prtchr ; print it
pop de ; restore DE
pop af ; restore AF
ret ; done
;
; print the hex word value in bc
;
prthexword:
push af
ld a,b
call prthex
ld a,c
call prthex
pop af
ret
;
; print the hex dword value in de:hl
;
prthex32:
push bc
push de
pop bc
call prthexword
push hl
pop bc
call prthexword
pop bc
ret
;
; Convert binary value in A to ascii hex characters in DE
;
hexascii:
ld d,a ; save A in D
call hexconv ; convert low nibble of A to hex
ld e,a ; save it in E
ld a,d ; get original value back
rlca ; rotate high order nibble to low bits
rlca
rlca
rlca
call hexconv ; convert nibble
ld d,a ; save it in D
ret ; done
;
; Convert low nibble of A to ascii hex
;
hexconv:
and $0F ; low nibble only
add a,$90
daa
adc a,$40
daa
ret
;
; Print value of A or HL in decimal with leading zero suppression
; Use prtdecb for A or prtdecw for HL
;
prtdecb:
push hl
ld h,0
ld l,a
call prtdecw ; print it
pop hl
ret
;
prtdecw:
push af
push bc
push de
push hl
call prtdec0
pop hl
pop de
pop bc
pop af
ret
;
prtdec0:
ld e,'0'
ld bc,-10000
call prtdec1
ld bc,-1000
call prtdec1
ld bc,-100
call prtdec1
ld c,-10
call prtdec1
ld e,0
ld c,-1
prtdec1:
ld a,'0' - 1
prtdec2:
inc a
add hl,bc
jr c,prtdec2
sbc hl,bc
cp e
ret z
ld e,0
call prtchr
ret
;
; Start a new line
;
crlf2:
call crlf ; two of them
crlf:
push af ; preserve AF
ld a,13 ; <CR>
call prtchr ; print it
ld a,10 ; <LF>
call prtchr ; print it
pop af ; restore AF
ret
;
; Get the next non-blank character from (HL).
;
nonblank:
ld a,(ix) ; load next character
or a ; string ends with a null
ret z ; if null, return pointing to null
cp ' ' ; check for blank
ret nz ; return if not blank
inc ix ; if blank, increment character pointer
jr nonblank ; and loop
;
; Convert character in A to uppercase
;
ucase:
cp 'a' ; if below 'a'
ret c ; ... do nothing and return
cp 'z' + 1 ; if above 'z'
ret nc ; ... do nothing and return
res 5,a ; clear bit 5 to make lower case -> upper case
ret ; and return
;
; Add the value in A to HL (HL := HL + A)
;
addhl:
add a,l ; A := A + L
ld l,a ; Put result back in L
ret nc ; if no carry, we are done
inc h ; if carry, increment H
ret ; and return
;
; Jump indirect to address in HL
;
jphl:
jp (hl)
;
; Errors
;
erruse: ; command usage error (syntax)
ld de,msguse
jr err
;
errprm: ; command parameter error (syntax)
ld de,msgprm
jr err
;
errfil: ; STARTUP.CMD file not present
ld de,msgfil
jr err
;
err: ; print error string and return error signal
call crlf ; print newline
;
err1: ; without the leading crlf
call prtstr ; print error string
;
err2: ; without the string
; call crlf ; print newline
or $FF ; signal error
ret ; done
;
;===============================================================================
; Storage Section
;===============================================================================
;
fcb .db 0 ; Drive code, 0 = current drive
.db "START " ; File name, 8 chars
.db "COM" ; File type, 3 chars
.fill 36-($-fcb),0 ; zero fill remainder of fcb
;
cmdblk .db cmdlen ; length
cmdtxt .db " B:SUBMIT START"
.db 0 ; null terminator
cmdlen .equ $ - cmdtxt
cmdend .equ $
;
stksav .dw 0 ; stack pointer saved at start
.fill stksiz,0 ; stack
stack .equ $ ; stack top
;
; Messages
;
msgban .db "STARTUP v1.0, 01-Dec-2017",13,10
.db "Copyright (C) 2017, <NAME>, GNU GPL v3",0
msguse .db "Usage: STARTUP [/?]",0
msgprm .db "Parameter error (STARTUP /? for usage)",0
msgfil .db "STARTUP.CMD file missing",0
;
.end
|
test/Succeed/Issue4006.agda | cruhland/agda | 1,989 | 10225 | <filename>test/Succeed/Issue4006.agda
data I : Set where
i : I
variable
x : I
abstract
data D : I → Set where
d : D i
accepted : {x : I} → D x → Set₁
accepted {x = i} d = Set
rejected : D x → Set₁
rejected {x = i} d = Set
|
dino/lcs/enemy/C8.asm | zengfr/arcade_game_romhacking_sourcecode_top_secret_data | 6 | 21755 | <filename>dino/lcs/enemy/C8.asm
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D3C move.l D0, (A4)+
004D3E move.l D0, (A4)+
03FE98 move.l D0, ($c8,A6) [enemy+ 8, enemy+ A]
03FE9C move.l D0, D2 [enemy+C8, enemy+CA]
041464 jmp $120e.l
041470 move.b #$1, ($a0,A6) [enemy+C8]
041560 clr.b ($c8,A6)
041564 tst.b ($24,A6)
04FDEA clr.w ($c8,A6)
04FDEE lea ($bc,A6), A0
04FE56 subq.w #1, ($c8,A6)
04FE5A bcc $4fe68 [enemy+C8]
04FE5C move.w #$12c, ($c8,A6)
04FE62 move.b #$1, ($502,A5) [enemy+C8]
05860A move.w ($6a,A6), ($c8,A6)
058610 moveq #$f, D0 [enemy+C8]
058AE0 move.w ($c8,A6), D0
058AE4 move.w ($6c,A6), D1 [enemy+C8]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
ioctl/IokGetHotKey.asm | osfree-project/FamilyAPI | 1 | 599 | <filename>ioctl/IokGetHotKey.asm
;--------------------------------------------------------
; Category 4 Function 76H Get Session Manager Hot Key
;--------------------------------------------------------
;
;
;
IOKGETHOTKEY PROC NEAR
RET
IOKGETHOTKEY ENDP
|
programs/oeis/013/A013928.asm | jmorken/loda | 1 | 13745 | <gh_stars>1-10
; A013928: Number of (positive) squarefree numbers < n.
; 0,1,2,3,3,4,5,6,6,6,7,8,8,9,10,11,11,12,12,13,13,14,15,16,16,16,17,17,17,18,19,20,20,21,22,23,23,24,25,26,26,27,28,29,29,29,30,31,31,31,31,32,32,33,33,34,34,35,36,37,37,38,39,39,39,40,41,42,42,43,44,45,45,46,47,47,47,48,49,50,50,50,51,52,52,53,54,55,55,56,56,57,57,58,59,60,60,61,61,61,61,62,63,64,64,65,66,67,67,68,69,70,70,71,72,73,73,73,74,75,75,75,76,77,77,77,77,78,78,79,80,81,81,82,83,83,83,84,85,86,86,87,88,89,89,90,91,91,91,92,92,93,93,93,94,95,95,96,97,98,98,99,99,100,100,101,102,103,103,103,104,104,104,105,106,106,106,107,108,109,109,110,111,112,112,113,114,115,115,115,116,117,117,118,119,120,120,121,121,122,122,123,124,125,125,126,127,127,127,128,129,130,130,131,132,133,133,134,135,136,136,137,138,139,139,139,140,141,141,142,143,144,144,145,145,146,146,147,148,149,149,150,150,150,150,150,151,152,152,153
mov $27,$0
mov $29,$0
add $29,1
lpb $29
clr $0,27
mov $0,$27
sub $29,1
sub $0,$29
sub $0,1
cal $0,8683 ; Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0.
sub $2,$0
add $5,$2
gcd $5,8
sub $5,5
mov $1,$5
mul $1,$5
sub $1,9
div $1,6
add $28,$1
lpe
mov $1,$28
sub $1,1
|
programs/oeis/173/A173072.asm | neoneye/loda | 22 | 242500 | <gh_stars>10-100
; A173072: n-th prime minus n-th even number.
; 2,1,1,1,3,3,5,5,7,11,11,15,17,17,19,23,27,27,31,33,33,37,39,43,49,51,51,53,53,55,67,69,73,73,81,81,85,89,91,95,99,99,107,107,109,109,119,129,131,131,133,137,137,145,149,153,157,157,161,163,163,171,183,185
mov $1,$0
seq $0,40 ; The prime numbers.
mul $1,2
sub $0,$1
|
dv3/qlf/lg5b.asm | olifink/smsqe | 0 | 175644 | ; DV3 QL5B Logical to Physical Translate V3.00 1992 <NAME>
section dv3
xdef qlf_lg5b
xdef qlf_ls5b
include 'dev8_keys_ql5b'
include 'dev8_dv3_keys'
include 'dev8_dv3_qlf_keys'
include 'dev8_keys_err'
;+++
; DV3 QL5B logical group / sector to physical sector translate.
; Cylinder / head / sector format only.
;
; d0 cr logical group / physical sector
; d1 c p sector in logical group
; d7 c p drive ID / number
; a3 c p pointer to linkage
; a4 c p pointer to drive definition
;
; status return arbitrary
;
;---
qlf_lg5b
mulu ddf_asect(a4),d0
add.l d1,d0 ; physical sector number
;+++
; DV3 QL5B logical to physical sector translate.
; Cylinder / head / sector format only.
;
; d0 cr logical sector / physical sector
; d7 c p drive ID / number
; a3 c p pointer to linkage
; a4 c p pointer to drive definition
;
; status return arbitrary
;
;---
qlf_ls5b
qlg.reg reg d1/d2
movem.l qlg.reg,-(sp)
divu q5a_scyl+qdf_map(a4),d0 ; sector+side / cylinder
move.w d0,d2 ; cylinder (track)
swap d0
move.w d0,d1 ; sector
add.w #q5a_lgph+qdf_map,d1
move.b (a4,d1.w),d1 ; translated sector
move.b d1,d0
add.w d0,d0 ; set side
and.w #$7f,d1 ; (remove side from sector number)
mulu q5a_soff+qdf_map(a4),d2 ; sector offset (skew)
add.w d1,d2
divu q5a_strk+qdf_map(a4),d2 ; in range
swap d2
addq.b #1,d2 ; +1 for IBM standard
move.b d2,d0 ; sector
movem.l (sp)+,qlg.reg
rts
end
|
alloy4fun_models/trashltl/models/15/iZi9niCoirTSutdiG.als | Kaixi26/org.alloytools.alloy | 0 | 2356 | open main
pred idiZi9niCoirTSutdiG_prop16 {
all p:Protected | historically p in Protected
}
pred __repair { idiZi9niCoirTSutdiG_prop16 }
check __repair { idiZi9niCoirTSutdiG_prop16 <=> prop16o } |
demo2.adb | MatrixMike/AdaDemo1 | 1 | 15009 | with Ada.Text_IO;
use Ada.Text_IO;
procedure Demo2 is
-- type Arr_Type is array(1..1000) of String;
procedure proceed(Arg1: in Arr_Type) is
begin
-- <program body>
Put_Line("second line");
end proceed;
begin
-- call to proceed
Put_Line("second line");
end Demo2;
|
test-suite/programs/unit/or_0x03.asm | ocus/TinyASM_Haskell | 0 | 97157 | <reponame>ocus/TinyASM_Haskell
MOV [0] 6
OR [0] 13
DPRINT [0]
HALT
|
alloy4fun_models/trashltl/models/11/Z2ec4Mxgj5oF7FZsC.als | Kaixi26/org.alloytools.alloy | 0 | 4029 | <filename>alloy4fun_models/trashltl/models/11/Z2ec4Mxgj5oF7FZsC.als
open main
pred idZ2ec4Mxgj5oF7FZsC_prop12 {
eventually some f:File | f not in Trash implies always f in Trash'
}
pred __repair { idZ2ec4Mxgj5oF7FZsC_prop12 }
check __repair { idZ2ec4Mxgj5oF7FZsC_prop12 <=> prop12o } |
boot/loader/stage1/signature.asm | jocke-l/stark | 1 | 245992 | <reponame>jocke-l/stark
section .signature
signature:
db 0x55
db 0xaa
|
Relation/Path.agda | CodaFi/HoTT-Exercises | 0 | 4492 | module Relation.Path where
open import Relation.Path.Operation
|
raid/Setup/list/PartTable.asm | OS2World/DRV-VRAID | 0 | 12828 | title PartTable.cpp
.386
.387
includelib CPPOM30.LIB
includelib OS2386.LIB
CODE32 segment dword use32 public 'CODE'
CODE32 ends
DATA32 segment dword use32 public 'DATA'
DATA32 ends
CONST32_RO segment dword use32 public 'CONST'
CONST32_RO ends
BSS32 segment dword use32 public 'BSS'
BSS32 ends
EH_CODE segment dword use32 public 'CODE'
EH_CODE ends
CTOR_DTOR1 segment dword use32 public 'DATA'
CTOR_DTOR1 ends
CTOR_DTOR2 segment dword use32 public 'DATA'
CTOR_DTOR2 ends
CTOR_DTOR3 segment dword use32 public 'DATA'
CTOR_DTOR3 ends
EH_DATA segment para use32 public 'DATA'
EH_DATA ends
_VFT segment para use32 public 'DATA'
_VFT ends
DGROUP group BSS32, DATA32
assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
extrn Verbose:proc
extrn queryIndex__8VOS2DiskFv:proc
extrn __dl__FPv:proc
extrn memset:proc
extrn queryDPB__8VOS2DiskFv:proc
CONST32_RO segment
@CBE1 db "PartTable",0h
align 04h
@CBE2 db "disk %lu, sector %lu",0h
align 04h
@CBE3 db "can't read disk %lu, sec"
db "tor %lu - rc %lu",0h
align 04h
@CBE4 db "clearing invalid partiti"
db "on table (disk %lu, sect"
db "or %lu)",0h
@CBE5 db "can't write disk %lu, se"
db "ctor %lu - rc %lu",0h
align 04h
@CBE6 db "delPE(disk %lu, table %l"
db "u, type %#x, rel %lu, si"
db "ze %lu)",0h
@CBE7 db "addPE(disk %lu, table %l"
db "u, type %#x, rel %lu, si"
db "ze %lu)",0h
@CBE8 db "addPE(disk %lu, table %l"
db "u) - no free entry",0h
align 04h
@CBE9 db "addForeign(disk %lu, tab"
db "le %lu, type %#x, start "
db "%lu, size %lu)",0h
align 04h
@CBE10 db "addOwn(disk %lu, table %"
db "lu, type %#x, start %lu,"
db " size %lu)",0h
align 04h
@CBE11 db "size adjusted to %lu",0h
align 04h
@1vcid db "$Id: parttable.cpp,v 1.4"
db " 2000/04/10 01:33:40 vit"
db "us Exp $",0h
CONST32_RO ends
CODE32 segment
; 440 PartTable::addOwn(UCHAR type,UCHAR bootable,ULONG start,ULONG size)
public addOwn__9PartTableFUcT1UlT3
addOwn__9PartTableFUcT1UlT3 proc
push ebp
mov ebp,esp
push ebx
mov ebx,eax
push edi
mov [ebp+0ch],dl; type
push esi
movzx edx,dl
sub esp,018h
mov [ebp+010h],cl; bootable
mov [ebp-020h],edx; @CBE14
mov [ebp+08h],ebx; this
; 442 Verbose(2,"PartTable","addOwn(disk %lu, table %lu, type %#x,"
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebp+018h]; size
mov edx,[ebp-020h]; @CBE14
push dword ptr [ebp+014h]; start
mov edi,eax
mov eax,edx
push eax
mov ecx,offset FLAT:@CBE10
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push edi
mov eax,02h
sub esp,0ch
call Verbose
mov eax,ebx
add esp,020h
; 443 " start %lu, size %lu)",
; 444 disk->queryIndex(), secno, type, start, size);
; 445
; 446 if( rderr != 0 )
cmp dword ptr [eax+0214h],0h
je @BLBL54
; 447 return FALSE;
xor eax,eax
add esp,018h
pop esi
pop edi
pop ebx
pop ebp
ret
@BLBL54:
; 448
; 449 /* Normalize ending point to last sector of cylinder!
; 450 * .start is already correct. xxx */
; 451
; 452 DEVICEPARAMETERBLOCK dpb = disk->queryDPB();
mov eax,[ebp+08h]; this
lea edi,[ebp-01ch]; dpb
mov eax,[eax]
call queryDPB__8VOS2DiskFv
mov esi,eax
mov ecx,04h
; 453 ULONG const cylsize = dpb.cHeads * dpb.cSectorsPerTrack;
; 454 ULONG end = size + start;
; 455
; 456 if( (end % cylsize) != 0 )
xor edx,edx
; 452 DEVICEPARAMETERBLOCK dpb = disk->queryDPB();
rep movsd
; 456 if( (end % cylsize) != 0 )
movzx ebx,word ptr [ebp-016h]; dpb
movzx ecx,word ptr [ebp-018h]; dpb
imul ecx,ebx
mov ebx,[ebp+014h]; start
mov eax,[ebp+018h]; size
add eax,ebx
div ecx
test edx,edx
je @BLBL55
; 460 Verbose(2, "PartTable", "size adjusted to %lu", end - start);
imul eax,ecx
sub eax,ebx
push eax
; 461 size = end - start;
mov [ebp+018h],eax; size
; 460 Verbose(2, "PartTable", "size adjusted to %lu", end - start);
sub esp,0ch
mov ecx,offset FLAT:@CBE11
mov edx,offset FLAT:@CBE1
mov eax,02h
call Verbose
add esp,010h
; 462 }
@BLBL55:
; 463 return addForeign(type, bootable, start, size);
mov cl,[ebp+010h]; bootable
add esp,018h
mov dl,[ebp+0ch]; type
pop esi
mov eax,[ebp+08h]; this
pop edi
pop ebx
pop ebp
jmp addForeign__9PartTableFUcT1UlT3
addOwn__9PartTableFUcT1UlT3 endp
; 355 PartTable::addForeign(UCHAR type,UCHAR bootable,ULONG start,ULONG size)
public addForeign__9PartTableFUcT1UlT3
addForeign__9PartTableFUcT1UlT3 proc
push ebp
mov ebp,esp
push ebx
mov ebx,eax
push edi
mov [ebp+0ch],dl; type
push esi
movzx edx,dl
sub esp,038h
mov [ebp+010h],cl; bootable
mov [ebp-03ch],edx; @CBE15
mov [ebp+08h],ebx; this
; 357 Verbose(2,"PartTable","addForeign(disk %lu, table %lu, type %#x,"
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebp+018h]; size
mov edx,[ebp-03ch]; @CBE15
push dword ptr [ebp+014h]; start
mov edi,eax
mov eax,edx
push eax
mov ecx,offset FLAT:@CBE9
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push edi
mov eax,02h
sub esp,0ch
call Verbose
mov eax,ebx
add esp,020h
; 361 if( rderr != 0 )
cmp dword ptr [eax+0214h],0h
je @BLBL45
; 362 return FALSE;
xor eax,eax
add esp,038h
pop esi
pop edi
pop ebx
pop ebp
ret
@BLBL45:
; 364 DEVICEPARAMETERBLOCK dpb = disk->queryDPB();
mov eax,[ebp+08h]; this
lea edi,[ebp-038h]; dpb
mov eax,[eax]
call queryDPB__8VOS2DiskFv
mov esi,eax
mov ecx,04h
rep movsd
; 373 pe.BootIndicator = bootable;
mov dl,[ebp+010h]; bootable
mov [ebp-028h],dl; pe
; 375 cyl = (USHORT)(start / cylsize);
mov edx,[ebp+014h]; start
mov eax,edx
xor edx,edx
; 365 USHORT const spt = dpb.cSectorsPerTrack;
mov si,[ebp-032h]; dpb
; 366 ULONG const cylsize = dpb.cHeads * spt;
mov di,[ebp-034h]; dpb
movzx ebx,di
movzx ecx,si
imul ecx,ebx
; 375 cyl = (USHORT)(start / cylsize);
div ecx
; 366 ULONG const cylsize = dpb.cHeads * spt;
mov [ebp-010h],ecx; cylsize
; 375 cyl = (USHORT)(start / cylsize);
mov ecx,[ebp+014h]; start
xchg ecx,eax
xor edx,edx
; 365 USHORT const spt = dpb.cSectorsPerTrack;
mov [ebp-014h],si; spt
; 376 sc = (start % spt) + 1;
movzx esi,si
div esi
; 377 hd = (start / spt) % dpb.cHeads;
movzx edi,di
; 376 sc = (start % spt) + 1;
inc edx
mov [ebp-015h],dl; sc
xor edx,edx
; 375 cyl = (USHORT)(start / cylsize);
mov [ebp-012h],cx; cyl
; 377 hd = (start / spt) % dpb.cHeads;
div edi
mov [ebp-016h],dl; hd
; 378 if( cyl >= 1024 )
cmp cx,0400h
jb @BLBL46
; 380 pe.BegHead = dpb.cHeads - 1;
dec ebx
mov [ebp-027h],bl; pe
; 381 pe.BegSector = 0xE0;
mov byte ptr [ebp-026h],0e0h; pe
; 382 pe.BegCylinder = 0xFF; /* Cylinder 1023, Sector 0 */
mov byte ptr [ebp-025h],0ffh; pe
; 383 }
jmp @BLBL47
@BLBL46:
; 386 pe.BegHead = hd;
mov al,[ebp-016h]; hd
; 387 pe.BegSector = (UCH
; 387 AR)((HIUCHAR(cyl) << 6) | sc);
mov bx,[ebp-012h]; cyl
; 386 pe.BegHead = hd;
mov [ebp-027h],al; pe
; 387 pe.BegSector = (UCH
; 387 AR)((HIUCHAR(cyl) << 6) | sc);
movzx eax,bx
sar eax,08h
and eax,0ffh
sal al,06h
or al,[ebp-015h]; sc
; 388 pe.BegCylinder = LOUCHAR(cyl);
mov [ebp-025h],bl; pe
; 387 pe.BegSector = (UCH
; 387 AR)((HIUCHAR(cyl) << 6) | sc);
mov [ebp-026h],al; pe
; 389 }
@BLBL47:
; 394 cyl = (USHORT)(last / cylsize);
mov ecx,[ebp+018h]; size
add ecx,[ebp+014h]; start
dec ecx
mov eax,ecx
xor edx,edx
; 391 pe.SysIndicator = type;
mov bl,[ebp+0ch]; type
; 394 cyl = (USHORT)(last / cylsize);
div dword ptr [ebp-010h]; cylsize
; 391 pe.SysIndicator = type;
mov [ebp-024h],bl; pe
; 394 cyl = (USHORT)(last / cylsize);
xchg ecx,eax
; 395 sc = (last % spt) + 1;
xor edx,edx
movzx ebx,word ptr [ebp-014h]; spt
div ebx
; 396 hd = (last / spt) % dpb.cHeads;
mov bx,[ebp-034h]; dpb
; 395 sc = (last % spt) + 1;
inc edx
mov [ebp-015h],dl; sc
; 396 hd = (last / spt) % dpb.cHeads;
xor edx,edx
movzx edi,bx
div edi
; 394 cyl = (USHORT)(last / cylsize);
mov [ebp-012h],cx; cyl
; 396 hd = (last / spt) % dpb.cHeads;
mov [ebp-016h],dl; hd
; 397 if( cyl >= 1024 )
cmp cx,0400h
jb @BLBL48
; 400 pe.EndSector = 0xE0;
mov byte ptr [ebp-022h],0e0h; pe
; 399 pe.EndHead = dpb.cHeads - 1;
movzx ebx,bx
dec ebx
mov [ebp-023h],bl; pe
; 401 pe.EndCylinder = 0xFF; /* Cylinder 1023, Sector 0 */
mov byte ptr [ebp-021h],0ffh; pe
; 402 }
jmp @BLBL49
@BLBL48:
; 405 pe.EndHead = hd;
mov al,[ebp-016h]; hd
; 406 pe.EndSector = (UCHAR)((HIUCHAR(cyl) << 6) | sc);
mov bx,[ebp-012h]; cyl
; 405 pe.EndHead = hd;
mov [ebp-023h],al; pe
; 406 pe.EndSector = (UCHAR)((HIUCHAR(cyl) << 6) | sc);
movzx eax,bx
sar eax,08h
and eax,0ffh
sal al,06h
or al,[ebp-015h]; sc
; 407 pe.EndCylinder = LOUCHAR(cyl);
mov [ebp-021h],bl; pe
; 406 pe.EndSector = (UCHAR)((HIUCHAR(cyl) << 6) | sc);
mov [ebp-022h],al; pe
; 408 }
@BLBL49:
; 409 if( type == EXTENDED_PARTTYPE )
cmp byte ptr [ebp+0ch],05h; type
jne @BLBL50
; 410 pe.RelativeSectors = start - extstart; /* extended refer to the first */
mov ebx,[ebp+08h]; this
mov eax,[ebp+014h]; start
sub eax,[ebx+08h]
mov [ebp-020h],eax; pe
jmp @BLBL51
@BLBL50:
; 412 pe.RelativeSectors = start - secno;
mov ebx,[ebp+08h]; this
mov eax,[ebp+014h]; start
sub eax,[ebx+04h]
mov [ebp-020h],eax; pe
@BLBL51:
; 413 pe.NumSectors = size;
mov ebx,[ebp+018h]; size
; 415 return addPE(pe);
mov eax,[ebp+08h]; this
; 413 pe.NumSectors = size;
mov [ebp-01ch],ebx; pe
; 415 return addPE(pe);
lea edx,[ebp-028h]; pe
call addPE__9PartTableFRC15_PARTITIONENTRY
add esp,038h
pop esi
pop edi
pop ebx
pop ebp
ret
addForeign__9PartTableFUcT1UlT3 endp
; 306 PartTable::addPE(PARTITIONENTRY const &partentry)
public addPE__9PartTableFRC15_PARTITIONENTRY
addPE__9PartTableFRC15_PARTITIONENTRY proc
push ebp
mov ebp,esp
push ebx
mov ebx,eax
push edi
mov edi,edx
push esi
mov [ebp+0ch],edi; partentry
sub esp,0ch
mov [ebp+08h],ebx; this
; 308 Verbose(2,"PartTable","addPE(disk %lu, table %lu, type %#x, rel %lu, size %lu)",
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [edi+0ch]
movzx edx,byte ptr [edi+04h]
push dword ptr [edi+08h]
mov edi,eax
push edx
mov ecx,offset FLAT:@CBE7
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push edi
mov eax,02h
sub esp,0ch
call Verbose
mov eax,ebx
add esp,020h
; 313 if( rderr != 0 )
cmp dword ptr [eax+0214h],0h
je @BLBL35
; 314 return FALSE;
xor eax,eax
add esp,0ch
pop esi
pop edi
pop ebx
pop ebp
ret
@BLBL35:
; 317 for( int i = 0; i < 4; ++i )
mov esi,[ebp+08h]; this
; 316 int free = -1;
mov dword ptr [ebp-010h],0ffffffffh; free
; 317 for( int i = 0; i < 4; ++i )
mov dword ptr [ebp-014h],0h; i
xor edi,edi
xor ecx,ecx
@BLBL37:
; 318 if( bootrecord.PartitionTable[i].SysIndicator == 0 )
cmp byte ptr [esi+ecx+01ceh],0h
jne @BLBL40
; 320 free = i;
mov [ebp-010h],edi; free
; 321 break;
jmp @BLBL36
@BLBL40:
; 317 for( int i = 0; i < 4; ++i )
inc edi
add ecx,010h
cmp edi,04h
jl @BLBL37
@BLBL36:
mov [ebp-014h],edi; i
; 323 if( free == -1 )
cmp dword ptr [ebp-010h],0ffffffffh; free
jne @BLBL42
; 325 Verbose(1, "PartTable", "addPE(disk %lu, table %lu) - no free entry",
mov ebx,[ebp+08h]; this
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebx+04h]
mov ecx,offset FLAT:@CBE8
push eax
mov edx,offset FLAT:@CBE1
sub esp,0ch
mov eax,01h
call Verbose
add esp,014h
; 327 return FALSE; /* scanning assured a free entry? */
add esp,0ch
xor eax,eax
pop esi
pop edi
pop ebx
pop ebp
ret
@BLBL42:
; 330 bootrecord.PartitionTable[i] = partentry;
mov edi,[ebp-014h]; i
mov ebx,[ebp+08h]; this
sal edi,04h
add edi,ebx
mov esi,[ebp+0ch]; partentry
add edi,01cah
mov ecx,04h
; 332 return TRUE;
mov eax,01h
; 330 bootrecord.PartitionTable[i] = partentry;
rep movsd
; 331 modified = TRUE;
mov dword ptr [ebx+020ch],01h
; 332 return TRUE;
add esp,0ch
pop esi
pop edi
pop ebx
pop ebp
ret
addPE__9PartTableFRC15_PARTITIONENTRY endp
; 263 PartTable::delPE(PPARTITIONENTRY partentry)
public delPE__9PartTableFP15_PARTITIONENTRY
delPE__9PartTableFP15_PARTITIONENTRY proc
push ebx
mov ebx,eax
push edi
mov edi,edx
push esi
sub esp,010h
mov [esp+024h],edi; partentry
mov [esp+020h],ebx; this
; 265 Verbose(2,"PartTable","delPE(disk %lu, table %lu, type %#x, rel %lu, size %lu)",
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [edi+0ch]
movzx edx,byte ptr [edi+04h]
push dword ptr [edi+08h]
mov edi,eax
push edx
mov ecx,offset FLAT:@CBE6
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push edi
mov eax,02h
sub esp,0ch
call Verbose
mov eax,ebx
add esp,020h
; 270 if( rderr != 0 )
cmp dword ptr [eax+0214h],0h
je @BLBL26
; 271 return FALSE;
xor eax,eax
add esp,010h
pop esi
pop edi
pop ebx
ret
@BLBL26:
; 274 for( int i = 0; i < 4; ++i )
xor esi,esi
mov ecx,[esp+024h]; partentry
mov ebx,[esp+020h]; this
; 273 BOOL done = FALSE;
mov dword ptr [esp+0ch],0h; done
; 274 for( int i = 0; i < 4; ++i )
xor edi,edi
@BLBL28:
; 276 if( partentry == &bootrecord.PartitionTable[i] )
lea eax,dword ptr [ebx+edi+01cah]
cmp eax,ecx
jne @BLBL31
; 278 memset(&bootrecord.PartitionTable[i], 0, sizeof(*partentry));
xor edx,edx
mov ecx,010h
call memset
mov ecx,[esp+024h]; partentry
; 279 modified = TRUE;
mov dword ptr [ebx+020ch],01h
; 280 done = TRUE;
mov dword ptr [esp+0ch],01h; done
; 281 break;
jmp @BLBL27
@BLBL31:
; 274 for( int i = 0; i < 4; ++i )
inc esi
add edi,010h
cmp esi,04h
jl @BLBL28
@BLBL27:
; 284 return done;
mov eax,[esp+0ch]; done
add esp,010h
pop esi
pop edi
pop ebx
ret
delPE__9PartTableFP15_PARTITIONENTRY endp
; 143 PartTable::clear(void)
public clear__9PartTableFv
clear__9PartTableFv proc
push ebx
sub esp,0ch
; 145 if( rderr != 0 )
cmp dword ptr [eax+0214h],0h
je @BLBL12
; 146 return;
add esp,0ch
pop ebx
ret
@BLBL12:
mov ebx,eax
; 148 memset(&bootrecord, 0, sizeof(bootrecord));
mov ecx,0200h
lea eax,[ebx+0ch]
xor edx,edx
call memset
mov eax,ebx
; 149 bootrecord.Signature = 0xAA55;
mov word ptr [eax+020ah],0aa55h
; 150 valid = FALSE; /* only write if modified */
mov dword ptr [eax+0210h],0h
; 151 }
add esp,0ch
pop ebx
ret
clear__9PartTableFv endp
; 221 PartTable::flush()
public flush__9PartTableFv
flush__9PartTableFv proc
push ebx
push edi
push esi
sub esp,08h
; 223 if( rderr != 0 )
mov edx,[eax+0214h]
test edx,edx
je @BLBL20
mov eax,edx
; 224 return rderr; /* don't write if not read! */
add esp,08h
pop esi
pop edi
pop ebx
ret
@BLBL20:
; 225
; 226 APIRET rc = 0;
mov dword ptr [esp+04h],0h; rc
; 227 if( modified )
cmp dword ptr [eax+020ch],0h
je @BLBL21
mov edi,eax
; 228 {
; 229 rc = disk->write(secno, 1, &bootrecord);
mov ecx,01h
mov eax,[edi]
lea ebx,[edi+0ch]
push ebx
mov ebx,[eax]
sub esp,0ch
mov esi,[ebx+024h]
mov edx,[edi+04h]
add eax,esi
call dword ptr [ebx+020h]
add esp,010h
xchg edi,eax
mov [esp+04h],edi; rc
; 230 if( rc != 0 )
test edi,edi
je @BLBL22
mov ebx,eax
; 231 {
; 232 Verbose(1, "PartTable", "can't write disk %lu, sector %lu - rc %lu",
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push edi
mov ecx,offset FLAT:@CBE5
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push eax
mov eax,01h
sub esp,0ch
call Verbose
mov eax,ebx
add esp,018h
; 233 disk->queryIndex(), secno, rc);
; 234 }
jmp @BLBL21
@BLBL22:
; 235 else
; 236 {
; 237 modified = FALSE;
mov dword ptr [eax+020ch],0h
; 238 valid = TRUE;
mov dword ptr [eax+0210h],01h
; 239 }
; 240 }
@BLBL21:
; 241 return rc;
mov eax,[esp+04h]; rc
add esp,08h
pop esi
pop edi
pop ebx
ret
flush__9PartTableFv endp
; 134 PartTable::~PartTable()
public __dt__9PartTableFv
__dt__9PartTableFv proc
push ebx
mov ebx,eax
sub esp,08h
mov [esp+04h],edx; @CBE18
; 136 flush();
call flush__9PartTableFv
mov edx,[esp+04h]; @CBE18
mov eax,ebx
; 137 }
test dl,01h
je @BLBL9
call __dl__FPv
mov eax,ebx
@BLBL9:
add esp,08h
pop ebx
ret
__dt__9PartTableFv endp
; 99 PartTable::PartTable(VOS2Disk * d,ULONG n,ULONG first_extended_start)
public __ct__9PartTableFP8VOS2DiskUlT2
__ct__9PartTableFP8VOS2DiskUlT2 proc
push ebx
mov ebx,eax
sub esp,04h
; 101 disk = d;
mov [ebx],edx
; 102 secno = n;
mov [ebx+04h],ecx
; 103 rderr = 0;
mov dword ptr [ebx+0214h],0h
; 104 modified = FALSE;
mov dword ptr [ebx+020ch],0h
; 105 valid = TRUE;
mov dword ptr [ebx+0210h],01h
; 106 extstart = first_extended_start;
mov eax,[esp+018h]; first_extended_start
mov [ebx+08h],eax
; 109 entry = bootrecord.PartitionTable;
lea eax,[ebx+01cah]
mov [ebx+0218h],eax
; 111 Verbose(2, "PartTable", "disk %lu, sector %lu", disk->queryIndex(), secno);
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebx+04h]
mov ecx,offset FLAT:@CBE2
push eax
mov edx,offset FLAT:@CBE1
sub esp,0ch
mov eax,02h
call Verbose
; 113 readRecord();
mov eax,ebx
call readRecord__9PartTableFv
; 115 return;
add esp,018h
; 113 readRecord();
mov eax,ebx
; 115 return;
pop ebx
ret
__ct__9PartTableFP8VOS2DiskUlT2 endp
; 171 PartTable::readRecord(void)
public readRecord__9PartTableFv
readRecord__9PartTableFv proc
push ebx
mov ebx,eax
push edi
push esi
sub esp,01ch
mov [esp+02ch],ebx; this
; 173 DEVICEPARAMETERBLOCK dpb = disk->queryDPB();
mov eax,[ebx]
call queryDPB__8VOS2DiskFv
lea edi,[esp+0ch]; dpb
mov esi,eax
mov ecx,04h
rep movsd
; 174 USHORT const spt = dpb.cSectorsPerTrack;
; 175 ULONG const cylsize = dpb.cHeads * spt;
; 176
; 177 if( (secno % cylsize) != 0 )
movzx edx,word ptr [esp+012h]; dpb
movzx ecx,word ptr [esp+010h]; dpb
imul ecx,edx
mov eax,[ebx+04h]
xor edx,edx
div ecx
test edx,edx
je @BLBL15
; 178 {
; 179 secno /= cylsize;
mov [ebx+04h],eax
; 180 secno *= cylsize;
imul eax,ecx
mov [ebx+04h],eax
; 181 }
@BLBL15:
; 182
; 183 rderr = disk->read(secno, 1, &bootrecord);
mov ebx,[esp+02ch]; this
mov eax,[ebx]
lea ecx,[ebx+0ch]
push ecx
mov edi,[eax]
sub esp,0ch
mov esi,[edi+01ch]
mov edx,[ebx+04h]
mov ecx,01h
add eax,esi
call dword ptr [edi+018h]
add esp,010h
mov [ebx+0214h],eax
; 184 if( rderr != 0 )
test eax,eax
je @BLBL16
; 185 {
; 186 /* 'rderr' is now /0, the disk will never be written to. */
; 187
; 188 Verbose(1, "PartTable", "can't read disk %lu, sector %lu - rc %lu",
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebx+0214h]
mov ecx,offset FLAT:@CBE3
push dword ptr [ebx+04h]
mov edx,offset FLAT:@CBE1
push eax
mov eax,01h
sub esp,0ch
call Verbose
add esp,018h
; 189 disk->queryIndex(), secno, rderr);
; 190 }
@BLBL16:
; 191
; 192 if( bootrecord.Signature != 0xAA55 )
mov ebx,[esp+02ch]; this
cmp word ptr [ebx+020ah],0aa55h
je @BLBL17
; 193 {
; 194 Verbose(1, "PartTable",
mov eax,[ebx]
call queryIndex__8VOS2DiskFv
push dword ptr [ebx+04h]
mov ecx,offset FLAT:@CBE4
push eax
mov edx,offset FLAT:@CBE1
sub esp,0ch
mov eax,01h
call Verbose
; 195 "clearing invalid partition table (disk %lu, sector %lu)",
; 196 disk->queryIndex(), secno);
; 197 memset(&bootrecord, 0, sizeof(bootrecord));
mov ecx,0200h
xor edx,edx
lea eax,[ebx+0ch]
call memset
add esp,014h
; 198 bootrecord.Signature = 0xAA55;
mov word ptr [ebx+020ah],0aa55h
; 199 valid = FALSE; /* only write if modified */
mov dword ptr [ebx+0210h],0h
; 200 }
@BLBL17:
; 201 }
add esp,01ch
pop esi
pop edi
pop ebx
ret
readRecord__9PartTableFv endp
; 63 PartTable::PartTable(VOS2Disk * d,ULONG n,Boolean rd)
public __ct__9PartTableFP8VOS2DiskUl7Boolean
__ct__9PartTableFP8VOS2DiskUl7Boolean proc
push ebx
mov ebx,ecx
xchg ebx,eax
sub esp,04h
; 72 entry = bootrecord.PartitionTable;
lea ecx,[ebx+01cah]
; 63 PartTable::PartTable(VOS2Disk * d,ULONG n,Boolean rd)
mov [esp+0ch],ebx; this
; 65 disk = d;
mov [ebx],edx
; 66 secno = n;
mov [ebx+04h],eax
; 74 Verbose(2, "PartTable", "disk %lu, sector %lu", disk->queryIndex(), secno);
mov eax,[ebx]
; 67 rderr = 0;
mov dword ptr [ebx+0214h],0h
; 68 modified = FALSE;
mov dword ptr [ebx+020ch],0h
; 69 valid = TRUE;
mov dword ptr [ebx+0210h],01h
; 70 extstart = 0; /* not an extended partition */
mov dword ptr [ebx+08h],0h
; 72 entry = bootrecord.PartitionTable;
mov [ebx+0218h],ecx
; 74 Verbose(2, "PartTable", "disk %lu, sector %lu", disk->queryIndex(), secno);
call queryIndex__8VOS2DiskFv
push dword ptr [ebx+04h]
mov ecx,offset FLAT:@CBE2
push eax
mov edx,offset FLAT:@CBE1
sub esp,0ch
mov eax,02h
call Verbose
; 76 readRecord();
mov eax,ebx
call readRecord__9PartTableFv
add esp,014h
mov eax,ebx
; 77 if( rd == true )
cmp byte ptr [esp+018h],01h; rd
jne @BLBL3
; 78 rderr = 0xFFFF; /* any error will inhibit writing */
mov dword ptr [eax+0214h],0ffffh
@BLBL3:
; 79 return;
mov eax,[esp+0ch]; this
add esp,04h
pop ebx
ret
__ct__9PartTableFP8VOS2DiskUl7Boolean endp
CODE32 ends
end
|
vp8/common/arm/armv6/intra4x4_predict_v6.asm | freedesktop/gstreamer-sdk-libvpx | 28 | 23997 | <reponame>freedesktop/gstreamer-sdk-libvpx<filename>vp8/common/arm/armv6/intra4x4_predict_v6.asm
;
; Copyright (c) 2011 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
EXPORT |vp8_intra4x4_predict_armv6|
ARM
REQUIRE8
PRESERVE8
AREA ||.text||, CODE, READONLY, ALIGN=2
;void vp8_intra4x4_predict(unsigned char *src, int src_stride, int b_mode,
; unsigned char *dst, int dst_stride)
|vp8_intra4x4_predict_armv6| PROC
push {r4-r12, lr}
cmp r2, #10
addlt pc, pc, r2, lsl #2 ; position independent switch
pop {r4-r12, pc} ; default
b b_dc_pred
b b_tm_pred
b b_ve_pred
b b_he_pred
b b_ld_pred
b b_rd_pred
b b_vr_pred
b b_vl_pred
b b_hd_pred
b b_hu_pred
b_dc_pred
; load values
ldr r8, [r0, -r1] ; Above
ldrb r4, [r0, #-1]! ; Left[0]
mov r9, #0
ldrb r5, [r0, r1] ; Left[1]
ldrb r6, [r0, r1, lsl #1]! ; Left[2]
usad8 r12, r8, r9
ldrb r7, [r0, r1] ; Left[3]
; calculate dc
add r4, r4, r5
add r4, r4, r6
add r4, r4, r7
add r4, r4, r12
add r4, r4, #4
ldr r0, [sp, #40] ; load stride
mov r12, r4, asr #3 ; (expected_dc + 4) >> 3
add r12, r12, r12, lsl #8
add r3, r3, r0
add r12, r12, r12, lsl #16
; store values
str r12, [r3, -r0]
str r12, [r3]
str r12, [r3, r0]
str r12, [r3, r0, lsl #1]
pop {r4-r12, pc}
b_tm_pred
sub r10, r0, #1 ; Left
ldr r8, [r0, -r1] ; Above
ldrb r9, [r10, -r1] ; top_left
ldrb r4, [r0, #-1]! ; Left[0]
ldrb r5, [r10, r1]! ; Left[1]
ldrb r6, [r0, r1, lsl #1] ; Left[2]
ldrb r7, [r10, r1, lsl #1] ; Left[3]
ldr r0, [sp, #40] ; load stride
add r9, r9, r9, lsl #16 ; [tl|tl]
uxtb16 r10, r8 ; a[2|0]
uxtb16 r11, r8, ror #8 ; a[3|1]
ssub16 r10, r10, r9 ; a[2|0] - [tl|tl]
ssub16 r11, r11, r9 ; a[3|1] - [tl|tl]
add r4, r4, r4, lsl #16 ; l[0|0]
add r5, r5, r5, lsl #16 ; l[1|1]
add r6, r6, r6, lsl #16 ; l[2|2]
add r7, r7, r7, lsl #16 ; l[3|3]
sadd16 r1, r4, r10 ; l[0|0] + a[2|0] - [tl|tl]
sadd16 r2, r4, r11 ; l[0|0] + a[3|1] - [tl|tl]
usat16 r1, #8, r1
usat16 r2, #8, r2
sadd16 r4, r5, r10 ; l[1|1] + a[2|0] - [tl|tl]
sadd16 r5, r5, r11 ; l[1|1] + a[3|1] - [tl|tl]
add r12, r1, r2, lsl #8 ; [3|2|1|0]
str r12, [r3], r0
usat16 r4, #8, r4
usat16 r5, #8, r5
sadd16 r1, r6, r10 ; l[2|2] + a[2|0] - [tl|tl]
sadd16 r2, r6, r11 ; l[2|2] + a[3|1] - [tl|tl]
add r12, r4, r5, lsl #8 ; [3|2|1|0]
str r12, [r3], r0
usat16 r1, #8, r1
usat16 r2, #8, r2
sadd16 r4, r7, r10 ; l[3|3] + a[2|0] - [tl|tl]
sadd16 r5, r7, r11 ; l[3|3] + a[3|1] - [tl|tl]
add r12, r1, r2, lsl #8 ; [3|2|1|0]
usat16 r4, #8, r4
usat16 r5, #8, r5
str r12, [r3], r0
add r12, r4, r5, lsl #8 ; [3|2|1|0]
str r12, [r3], r0
pop {r4-r12, pc}
b_ve_pred
ldr r8, [r0, -r1]! ; a[3|2|1|0]
ldr r11, c00FF00FF
ldrb r9, [r0, #-1] ; top_left
ldrb r10, [r0, #4] ; a[4]
ldr r0, c00020002
uxtb16 r4, r8 ; a[2|0]
uxtb16 r5, r8, ror #8 ; a[3|1]
ldr r2, [sp, #40] ; stride
pkhbt r9, r9, r5, lsl #16 ; a[1|-1]
add r9, r9, r4, lsl #1 ;[a[1]+2*a[2] | tl+2*a[0] ]
uxtab16 r9, r9, r5 ;[a[1]+2*a[2]+a[3] | tl+2*a[0]+a[1] ]
uxtab16 r9, r9, r0 ;[a[1]+2*a[2]+a[3]+2| tl+2*a[0]+a[1]+2]
add r0, r0, r10, lsl #16 ;[a[4]+2 | 2]
add r0, r0, r4, asr #16 ;[a[4]+2 | a[2]+2]
add r0, r0, r5, lsl #1 ;[a[4]+2*a[3]+2 | a[2]+2*a[1]+2]
uadd16 r4, r4, r0 ;[a[4]+2*a[3]+a[2]+2|a[2]+2*a[1]+a[0]+2]
and r9, r11, r9, asr #2
and r4, r11, r4, asr #2
add r3, r3, r2 ; dst + dst_stride
add r9, r9, r4, lsl #8
; store values
str r9, [r3, -r2]
str r9, [r3]
str r9, [r3, r2]
str r9, [r3, r2, lsl #1]
pop {r4-r12, pc}
b_he_pred
sub r10, r0, #1 ; Left
ldrb r4, [r0, #-1]! ; Left[0]
ldrb r8, [r10, -r1] ; top_left
ldrb r5, [r10, r1]! ; Left[1]
ldrb r6, [r0, r1, lsl #1] ; Left[2]
ldrb r7, [r10, r1, lsl #1] ; Left[3]
add r8, r8, r4 ; tl + l[0]
add r9, r4, r5 ; l[0] + l[1]
add r10, r5, r6 ; l[1] + l[2]
add r11, r6, r7 ; l[2] + l[3]
mov r0, #2<<14
add r8, r8, r9 ; tl + 2*l[0] + l[1]
add r4, r9, r10 ; l[0] + 2*l[1] + l[2]
add r5, r10, r11 ; l[1] + 2*l[2] + l[3]
add r6, r11, r7, lsl #1 ; l[2] + 2*l[3] + l[3]
add r8, r0, r8, lsl #14 ; (tl + 2*l[0] + l[1])>>2 in top half
add r9, r0, r4, lsl #14 ; (l[0] + 2*l[1] + l[2])>>2 in top half
add r10,r0, r5, lsl #14 ; (l[1] + 2*l[2] + l[3])>>2 in top half
add r11,r0, r6, lsl #14 ; (l[2] + 2*l[3] + l[3])>>2 in top half
pkhtb r8, r8, r8, asr #16 ; l[-|0|-|0]
pkhtb r9, r9, r9, asr #16 ; l[-|1|-|1]
pkhtb r10, r10, r10, asr #16 ; l[-|2|-|2]
pkhtb r11, r11, r11, asr #16 ; l[-|3|-|3]
ldr r0, [sp, #40] ; stride
add r8, r8, r8, lsl #8 ; l[0|0|0|0]
add r9, r9, r9, lsl #8 ; l[1|1|1|1]
add r10, r10, r10, lsl #8 ; l[2|2|2|2]
add r11, r11, r11, lsl #8 ; l[3|3|3|3]
; store values
str r8, [r3], r0
str r9, [r3]
str r10, [r3, r0]
str r11, [r3, r0, lsl #1]
pop {r4-r12, pc}
b_ld_pred
ldr r4, [r0, -r1]! ; Above
ldr r12, c00020002
ldr r5, [r0, #4]
ldr lr, c00FF00FF
uxtb16 r6, r4 ; a[2|0]
uxtb16 r7, r4, ror #8 ; a[3|1]
uxtb16 r8, r5 ; a[6|4]
uxtb16 r9, r5, ror #8 ; a[7|5]
pkhtb r10, r6, r8 ; a[2|4]
pkhtb r11, r7, r9 ; a[3|5]
add r4, r6, r7, lsl #1 ; [a2+2*a3 | a0+2*a1]
add r4, r4, r10, ror #16 ; [a2+2*a3+a4 | a0+2*a1+a2]
uxtab16 r4, r4, r12 ; [a2+2*a3+a4+2 | a0+2*a1+a2+2]
add r5, r7, r10, ror #15 ; [a3+2*a4 | a1+2*a2]
add r5, r5, r11, ror #16 ; [a3+2*a4+a5 | a1+2*a2+a3]
uxtab16 r5, r5, r12 ; [a3+2*a4+a5+2 | a1+2*a2+a3+2]
pkhtb r7, r9, r8, asr #16
add r6, r8, r9, lsl #1 ; [a6+2*a7 | a4+2*a5]
uadd16 r6, r6, r7 ; [a6+2*a7+a7 | a4+2*a5+a6]
uxtab16 r6, r6, r12 ; [a6+2*a7+a7+2 | a4+2*a5+a6+2]
uxth r7, r9 ; [ a5]
add r7, r7, r8, asr #15 ; [ a5+2*a6]
add r7, r7, r9, asr #16 ; [ a5+2*a6+a7]
uxtah r7, r7, r12 ; [ a5+2*a6+a7+2]
ldr r0, [sp, #40] ; stride
; scale down
and r4, lr, r4, asr #2
and r5, lr, r5, asr #2
and r6, lr, r6, asr #2
mov r7, r7, asr #2
add r8, r4, r5, lsl #8 ; [3|2|1|0]
str r8, [r3], r0
mov r9, r8, lsr #8
add r9, r9, r6, lsl #24 ; [4|3|2|1]
str r9, [r3], r0
mov r10, r9, lsr #8
add r10, r10, r7, lsl #24 ; [5|4|3|2]
str r10, [r3], r0
mov r6, r6, lsr #16
mov r11, r10, lsr #8
add r11, r11, r6, lsl #24 ; [6|5|4|3]
str r11, [r3], r0
pop {r4-r12, pc}
b_rd_pred
sub r12, r0, r1 ; Above = src - src_stride
ldrb r7, [r0, #-1]! ; l[0] = pp[3]
ldr lr, [r12] ; Above = pp[8|7|6|5]
ldrb r8, [r12, #-1]! ; tl = pp[4]
ldrb r6, [r12, r1, lsl #1] ; l[1] = pp[2]
ldrb r5, [r0, r1, lsl #1] ; l[2] = pp[1]
ldrb r4, [r12, r1, lsl #2] ; l[3] = pp[0]
uxtb16 r9, lr ; p[7|5]
uxtb16 r10, lr, ror #8 ; p[8|6]
add r4, r4, r6, lsl #16 ; p[2|0]
add r5, r5, r7, lsl #16 ; p[3|1]
add r6, r6, r8, lsl #16 ; p[4|2]
pkhbt r7, r7, r9, lsl #16 ; p[5|3]
pkhbt r8, r8, r10, lsl #16 ; p[6|4]
ldr r12, c00020002
ldr lr, c00FF00FF
add r4, r4, r5, lsl #1 ; [p2+2*p3 | p0+2*p1]
add r4, r4, r6 ; [p2+2*p3+p4 | p0+2*p1+p2]
uxtab16 r4, r4, r12 ; [p2+2*p3+p4+2 | p0+2*p1+p2+2]
add r5, r5, r6, lsl #1 ; [p3+2*p4 | p1+2*p2]
add r5, r5, r7 ; [p3+2*p4+p5 | p1+2*p2+p3]
uxtab16 r5, r5, r12 ; [p3+2*p4+p5+2 | p1+2*p2+p3+2]
add r6, r7, r8, lsl #1 ; [p5+2*p6 | p3+2*p4]
add r6, r6, r9 ; [p5+2*p6+p7 | p3+2*p4+p5]
uxtab16 r6, r6, r12 ; [p5+2*p6+p7+2 | p3+2*p4+p5+2]
add r7, r8, r9, lsl #1 ; [p6+2*p7 | p4+2*p5]
add r7, r7, r10 ; [p6+2*p7+p8 | p4+2*p5+p6]
uxtab16 r7, r7, r12 ; [p6+2*p7+p8+2 | p4+2*p5+p6+2]
ldr r0, [sp, #40] ; stride
; scale down
and r7, lr, r7, asr #2
and r6, lr, r6, asr #2
and r5, lr, r5, asr #2
and r4, lr, r4, asr #2
add r8, r6, r7, lsl #8 ; [6|5|4|3]
str r8, [r3], r0
mov r9, r8, lsl #8 ; [5|4|3|-]
uxtab r9, r9, r4, ror #16 ; [5|4|3|2]
str r9, [r3], r0
mov r10, r9, lsl #8 ; [4|3|2|-]
uxtab r10, r10, r5 ; [4|3|2|1]
str r10, [r3], r0
mov r11, r10, lsl #8 ; [3|2|1|-]
uxtab r11, r11, r4 ; [3|2|1|0]
str r11, [r3], r0
pop {r4-r12, pc}
b_vr_pred
sub r12, r0, r1 ; Above = src - src_stride
ldrb r7, [r0, #-1]! ; l[0] = pp[3]
ldr lr, [r12] ; Above = pp[8|7|6|5]
ldrb r8, [r12, #-1]! ; tl = pp[4]
ldrb r6, [r12, r1, lsl #1] ; l[1] = pp[2]
ldrb r5, [r0, r1, lsl #1] ; l[2] = pp[1]
ldrb r4, [r12, r1, lsl #2] ; l[3] = pp[0]
add r5, r5, r7, lsl #16 ; p[3|1]
add r6, r6, r8, lsl #16 ; p[4|2]
uxtb16 r9, lr ; p[7|5]
uxtb16 r10, lr, ror #8 ; p[8|6]
pkhbt r7, r7, r9, lsl #16 ; p[5|3]
pkhbt r8, r8, r10, lsl #16 ; p[6|4]
ldr r4, c00010001
ldr r12, c00020002
ldr lr, c00FF00FF
add r5, r5, r6, lsl #1 ; [p3+2*p4 | p1+2*p2]
add r5, r5, r7 ; [p3+2*p4+p5 | p1+2*p2+p3]
uxtab16 r5, r5, r12 ; [p3+2*p4+p5+2 | p1+2*p2+p3+2]
add r6, r6, r7, lsl #1 ; [p4+2*p5 | p2+2*p3]
add r6, r6, r8 ; [p4+2*p5+p6 | p2+2*p3+p4]
uxtab16 r6, r6, r12 ; [p4+2*p5+p6+2 | p2+2*p3+p4+2]
uadd16 r11, r8, r9 ; [p6+p7 | p4+p5]
uhadd16 r11, r11, r4 ; [(p6+p7+1)>>1 | (p4+p5+1)>>1]
; [F|E]
add r7, r7, r8, lsl #1 ; [p5+2*p6 | p3+2*p4]
add r7, r7, r9 ; [p5+2*p6+p7 | p3+2*p4+p5]
uxtab16 r7, r7, r12 ; [p5+2*p6+p7+2 | p3+2*p4+p5+2]
uadd16 r2, r9, r10 ; [p7+p8 | p5+p6]
uhadd16 r2, r2, r4 ; [(p7+p8+1)>>1 | (p5+p6+1)>>1]
; [J|I]
add r8, r8, r9, lsl #1 ; [p6+2*p7 | p4+2*p5]
add r8, r8, r10 ; [p6+2*p7+p8 | p4+2*p5+p6]
uxtab16 r8, r8, r12 ; [p6+2*p7+p8+2 | p4+2*p5+p6+2]
ldr r0, [sp, #40] ; stride
; scale down
and r5, lr, r5, asr #2 ; [B|A]
and r6, lr, r6, asr #2 ; [D|C]
and r7, lr, r7, asr #2 ; [H|G]
and r8, lr, r8, asr #2 ; [L|K]
add r12, r11, r2, lsl #8 ; [J|F|I|E]
str r12, [r3], r0
add r12, r7, r8, lsl #8 ; [L|H|K|G]
str r12, [r3], r0
pkhbt r2, r6, r2, lsl #16 ; [-|I|-|C]
add r2, r2, r11, lsl #8 ; [F|I|E|C]
pkhtb r12, r6, r5 ; [-|D|-|A]
pkhtb r10, r7, r5, asr #16 ; [-|H|-|B]
str r2, [r3], r0
add r12, r12, r10, lsl #8 ; [H|D|B|A]
str r12, [r3], r0
pop {r4-r12, pc}
b_vl_pred
ldr r4, [r0, -r1]! ; [3|2|1|0]
ldr r12, c00020002
ldr r5, [r0, #4] ; [7|6|5|4]
ldr lr, c00FF00FF
ldr r2, c00010001
mov r0, r4, lsr #16 ; [-|-|3|2]
add r0, r0, r5, lsl #16 ; [5|4|3|2]
uxtb16 r6, r4 ; [2|0]
uxtb16 r7, r4, ror #8 ; [3|1]
uxtb16 r8, r0 ; [4|2]
uxtb16 r9, r0, ror #8 ; [5|3]
uxtb16 r10, r5 ; [6|4]
uxtb16 r11, r5, ror #8 ; [7|5]
uadd16 r4, r6, r7 ; [p2+p3 | p0+p1]
uhadd16 r4, r4, r2 ; [(p2+p3+1)>>1 | (p0+p1+1)>>1]
; [B|A]
add r5, r6, r7, lsl #1 ; [p2+2*p3 | p0+2*p1]
add r5, r5, r8 ; [p2+2*p3+p4 | p0+2*p1+p2]
uxtab16 r5, r5, r12 ; [p2+2*p3+p4+2 | p0+2*p1+p2+2]
uadd16 r6, r7, r8 ; [p3+p4 | p1+p2]
uhadd16 r6, r6, r2 ; [(p3+p4+1)>>1 | (p1+p2+1)>>1]
; [F|E]
add r7, r7, r8, lsl #1 ; [p3+2*p4 | p1+2*p2]
add r7, r7, r9 ; [p3+2*p4+p5 | p1+2*p2+p3]
uxtab16 r7, r7, r12 ; [p3+2*p4+p5+2 | p1+2*p2+p3+2]
add r8, r8, r9, lsl #1 ; [p4+2*p5 | p2+2*p3]
add r8, r8, r10 ; [p4+2*p5+p6 | p2+2*p3+p4]
uxtab16 r8, r8, r12 ; [p4+2*p5+p6+2 | p2+2*p3+p4+2]
add r9, r9, r10, lsl #1 ; [p5+2*p6 | p3+2*p4]
add r9, r9, r11 ; [p5+2*p6+p7 | p3+2*p4+p5]
uxtab16 r9, r9, r12 ; [p5+2*p6+p7+2 | p3+2*p4+p5+2]
ldr r0, [sp, #40] ; stride
; scale down
and r5, lr, r5, asr #2 ; [D|C]
and r7, lr, r7, asr #2 ; [H|G]
and r8, lr, r8, asr #2 ; [I|D]
and r9, lr, r9, asr #2 ; [J|H]
add r10, r4, r6, lsl #8 ; [F|B|E|A]
str r10, [r3], r0
add r5, r5, r7, lsl #8 ; [H|C|G|D]
str r5, [r3], r0
pkhtb r12, r8, r4, asr #16 ; [-|I|-|B]
pkhtb r10, r9, r8 ; [-|J|-|D]
add r12, r6, r12, lsl #8 ; [I|F|B|E]
str r12, [r3], r0
add r10, r7, r10, lsl #8 ; [J|H|D|G]
str r10, [r3], r0
pop {r4-r12, pc}
b_hd_pred
sub r12, r0, r1 ; Above = src - src_stride
ldrb r7, [r0, #-1]! ; l[0] = pp[3]
ldr lr, [r12] ; Above = pp[8|7|6|5]
ldrb r8, [r12, #-1]! ; tl = pp[4]
ldrb r6, [r0, r1] ; l[1] = pp[2]
ldrb r5, [r0, r1, lsl #1] ; l[2] = pp[1]
ldrb r4, [r12, r1, lsl #2] ; l[3] = pp[0]
uxtb16 r9, lr ; p[7|5]
uxtb16 r10, lr, ror #8 ; p[8|6]
add r4, r4, r5, lsl #16 ; p[1|0]
add r5, r5, r6, lsl #16 ; p[2|1]
add r6, r6, r7, lsl #16 ; p[3|2]
add r7, r7, r8, lsl #16 ; p[4|3]
ldr r12, c00020002
ldr lr, c00FF00FF
ldr r2, c00010001
pkhtb r8, r7, r9 ; p[4|5]
pkhtb r1, r9, r10 ; p[7|6]
pkhbt r10, r8, r10, lsl #16 ; p[6|5]
uadd16 r11, r4, r5 ; [p1+p2 | p0+p1]
uhadd16 r11, r11, r2 ; [(p1+p2+1)>>1 | (p0+p1+1)>>1]
; [B|A]
add r4, r4, r5, lsl #1 ; [p1+2*p2 | p0+2*p1]
add r4, r4, r6 ; [p1+2*p2+p3 | p0+2*p1+p2]
uxtab16 r4, r4, r12 ; [p1+2*p2+p3+2 | p0+2*p1+p2+2]
uadd16 r0, r6, r7 ; [p3+p4 | p2+p3]
uhadd16 r0, r0, r2 ; [(p3+p4+1)>>1 | (p2+p3+1)>>1]
; [F|E]
add r5, r6, r7, lsl #1 ; [p3+2*p4 | p2+2*p3]
add r5, r5, r8, ror #16 ; [p3+2*p4+p5 | p2+2*p3+p4]
uxtab16 r5, r5, r12 ; [p3+2*p4+p5+2 | p2+2*p3+p4+2]
add r6, r12, r8, ror #16 ; [p5+2 | p4+2]
add r6, r6, r10, lsl #1 ; [p5+2+2*p6 | p4+2+2*p5]
uxtab16 r6, r6, r1 ; [p5+2+2*p6+p7 | p4+2+2*p5+p6]
; scale down
and r4, lr, r4, asr #2 ; [D|C]
and r5, lr, r5, asr #2 ; [H|G]
and r6, lr, r6, asr #2 ; [J|I]
ldr lr, [sp, #40] ; stride
pkhtb r2, r0, r6 ; [-|F|-|I]
pkhtb r12, r6, r5, asr #16 ; [-|J|-|H]
add r12, r12, r2, lsl #8 ; [F|J|I|H]
add r2, r0, r5, lsl #8 ; [H|F|G|E]
mov r12, r12, ror #24 ; [J|I|H|F]
str r12, [r3], lr
mov r7, r11, asr #16 ; [-|-|-|B]
str r2, [r3], lr
add r7, r7, r0, lsl #16 ; [-|E|-|B]
add r7, r7, r4, asr #8 ; [-|E|D|B]
add r7, r7, r5, lsl #24 ; [G|E|D|B]
str r7, [r3], lr
add r5, r11, r4, lsl #8 ; [D|B|C|A]
str r5, [r3], lr
pop {r4-r12, pc}
b_hu_pred
ldrb r4, [r0, #-1]! ; Left[0]
ldr r12, c00020002
ldrb r5, [r0, r1]! ; Left[1]
ldr lr, c00FF00FF
ldrb r6, [r0, r1]! ; Left[2]
ldr r2, c00010001
ldrb r7, [r0, r1] ; Left[3]
add r4, r4, r5, lsl #16 ; [1|0]
add r5, r5, r6, lsl #16 ; [2|1]
add r9, r6, r7, lsl #16 ; [3|2]
uadd16 r8, r4, r5 ; [p1+p2 | p0+p1]
uhadd16 r8, r8, r2 ; [(p1+p2+1)>>1 | (p0+p1+1)>>1]
; [B|A]
add r4, r4, r5, lsl #1 ; [p1+2*p2 | p0+2*p1]
add r4, r4, r9 ; [p1+2*p2+p3 | p0+2*p1+p2]
uxtab16 r4, r4, r12 ; [p1+2*p2+p3+2 | p0+2*p1+p2+2]
ldr r2, [sp, #40] ; stride
and r4, lr, r4, asr #2 ; [D|C]
add r10, r6, r7 ; [p2+p3]
add r11, r10, r7, lsl #1 ; [p2+3*p3]
add r10, r10, #1
add r11, r11, #2
mov r10, r10, asr #1 ; [E]
mov r11, r11, asr #2 ; [F]
add r9, r7, r9, asr #8 ; [-|-|G|G]
add r0, r8, r4, lsl #8 ; [D|B|C|A]
add r7, r9, r9, lsl #16 ; [G|G|G|G]
str r0, [r3], r2
mov r1, r8, asr #16 ; [-|-|-|B]
add r1, r1, r4, asr #8 ; [-|-|D|B]
add r1, r1, r10, lsl #16 ; [-|E|D|B]
add r1, r1, r11, lsl #24 ; [F|E|D|B]
str r1, [r3], r2
add r10, r11, lsl #8 ; [-|-|F|E]
add r10, r10, r9, lsl #16 ; [G|G|F|E]
str r10, [r3]
str r7, [r3, r2]
pop {r4-r12, pc}
ENDP
; constants
c00010001
DCD 0x00010001
c00020002
DCD 0x00020002
c00FF00FF
DCD 0x00FF00FF
END
|
expr/src/main/antlr4/com/groupon/lex/metrics/timeseries/parser/ExpressionLexer.g4 | groupon/monsoon | 32 | 1427 | <reponame>groupon/monsoon
lexer grammar ExpressionLexer;
import MonsoonExprLexer;
|
source/oasis/program-elements-defining_operator_symbols.ads | optikos/oasis | 0 | 1948 | <filename>source/oasis/program-elements-defining_operator_symbols.ads
-- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Defining_Names;
with Program.Lexical_Elements;
package Program.Elements.Defining_Operator_Symbols is
pragma Pure (Program.Elements.Defining_Operator_Symbols);
type Defining_Operator_Symbol is
limited interface and Program.Elements.Defining_Names.Defining_Name;
type Defining_Operator_Symbol_Access is
access all Defining_Operator_Symbol'Class with Storage_Size => 0;
type Defining_Operator_Symbol_Text is limited interface;
type Defining_Operator_Symbol_Text_Access is
access all Defining_Operator_Symbol_Text'Class with Storage_Size => 0;
not overriding function To_Defining_Operator_Symbol_Text
(Self : aliased in out Defining_Operator_Symbol)
return Defining_Operator_Symbol_Text_Access is abstract;
not overriding function Operator_Symbol_Token
(Self : Defining_Operator_Symbol_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Defining_Operator_Symbols;
|
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/fzero.lzh/fzero/fzero_main.asm | prismotizm/gigaleak | 0 | 10388 | Name: fzero_main.asm
Type: file
Size: 46001
Last-Modified: '1993-07-20T07:13:24Z'
SHA-1: CC7183EED4FECD0ECF8CD8A008B5597DD169A296
Description: null
|
data/mapObjects/seafoamislands2.asm | adhi-thirumala/EvoYellow | 16 | 886 | <filename>data/mapObjects/seafoamislands2.asm
SeafoamIslands2Object:
db $7d ; border block
db $7 ; warps
db $2, $4, $0, SEAFOAM_ISLANDS_3
db $5, $7, $4, SEAFOAM_ISLANDS_1
db $7, $d, $2, SEAFOAM_ISLANDS_3
db $f, $13, $3, SEAFOAM_ISLANDS_3
db $f, $17, $6, SEAFOAM_ISLANDS_1
db $b, $19, $5, SEAFOAM_ISLANDS_3
db $3, $19, $5, SEAFOAM_ISLANDS_1
db $0 ; signs
db $2 ; objects
object SPRITE_BOULDER, $11, $6, STAY, BOULDER_MOVEMENT_BYTE_2, $1 ; person
object SPRITE_BOULDER, $16, $6, STAY, BOULDER_MOVEMENT_BYTE_2, $2 ; person
; warp-to
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $2, $4 ; SEAFOAM_ISLANDS_3
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $5, $7 ; SEAFOAM_ISLANDS_1
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $7, $d ; SEAFOAM_ISLANDS_3
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $f, $13 ; SEAFOAM_ISLANDS_3
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $f, $17 ; SEAFOAM_ISLANDS_1
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $b, $19 ; SEAFOAM_ISLANDS_3
EVENT_DISP SEAFOAM_ISLANDS_2_WIDTH, $3, $19 ; SEAFOAM_ISLANDS_1
|
Transynther/x86/_processed/AVXALIGN/_st_sm_/i7-8650U_0xd2.log_55_709.asm | ljhsiun2/medusa | 9 | 173981 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rbp
push %rdx
lea addresses_WT_ht+0x103d8, %rdx
nop
nop
nop
nop
cmp $30882, %rbp
mov (%rdx), %r11w
nop
cmp $35502, %r9
lea addresses_WC_ht+0x1c484, %rdx
clflush (%rdx)
nop
nop
nop
nop
nop
dec %r12
mov $0x6162636465666768, %r9
movq %r9, (%rdx)
nop
nop
nop
nop
nop
dec %rdx
pop %rdx
pop %rbp
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Load
lea addresses_D+0x1bb24, %r9
nop
cmp $57553, %r8
movups (%r9), %xmm4
vpextrq $1, %xmm4, %rdx
nop
nop
nop
nop
nop
cmp %rdx, %rdx
// Store
lea addresses_PSE+0x7c04, %rdx
cmp %rax, %rax
movl $0x51525354, (%rdx)
sub $31611, %r15
// REPMOV
mov $0x44, %rsi
lea addresses_normal+0x295c, %rdi
nop
and $57729, %rdx
mov $109, %rcx
rep movsb
nop
nop
nop
sub $38197, %rsi
// Store
mov $0x804, %rax
cmp $18149, %r15
movw $0x5152, (%rax)
nop
xor %rdx, %rdx
// Store
lea addresses_PSE+0x7c04, %r15
clflush (%r15)
nop
nop
xor $16861, %rdi
mov $0x5152535455565758, %r9
movq %r9, (%r15)
nop
dec %rdi
// Faulty Load
lea addresses_PSE+0x7c04, %r15
clflush (%r15)
nop
nop
nop
add %r8, %r8
mov (%r15), %eax
lea oracles, %rcx
and $0xff, %rax
shlq $12, %rax
mov (%rcx,%rax,1), %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_P', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': True, 'NT': True, 'congruent': 5, 'same': False}}
{'58': 55}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
firmware/coreboot/3rdparty/libgfxinit/common/g45/hw-gfx-gma-power_and_clocks.adb | fabiojna02/OpenCellular | 1 | 26628 | --
-- Copyright (C) 2016 secunet Security Networks AG
--
-- This program 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 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.Time;
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Registers;
package body HW.GFX.GMA.Power_And_Clocks is
FSB_FREQ_SEL_MASK : constant := 7 * 2 ** 0;
CLKCFG_FSB_400 : constant Frequency_Type := 100_000_000;
CLKCFG_FSB_533 : constant Frequency_Type := 133_333_333;
CLKCFG_FSB_667 : constant Frequency_Type := 166_666_666;
CLKCFG_FSB_800 : constant Frequency_Type := 200_000_000;
CLKCFG_FSB_1067 : constant Frequency_Type := 266_666_666;
CLKCFG_FSB_1333 : constant Frequency_Type := 333_333_333;
-- The Raw Freq is 1/4 of the FSB freq
procedure Initialize
is
CLK_CFG : Word32;
type Freq_Sel is new Natural range 0 .. 7;
begin
Registers.Read
(Register => Registers.GMCH_CLKCFG,
Value => CLK_CFG);
case Freq_Sel (CLK_CFG and FSB_FREQ_SEL_MASK) is
when 0 => Config.Raw_Clock := CLKCFG_FSB_1067;
when 1 => Config.Raw_Clock := CLKCFG_FSB_533;
when 2 => Config.Raw_Clock := CLKCFG_FSB_800;
when 3 => Config.Raw_Clock := CLKCFG_FSB_667;
when 4 => Config.Raw_Clock := CLKCFG_FSB_1333;
when 5 => Config.Raw_Clock := CLKCFG_FSB_400;
when 6 => Config.Raw_Clock := CLKCFG_FSB_1067;
when 7 => Config.Raw_Clock := CLKCFG_FSB_1333;
end case;
end Initialize;
end HW.GFX.GMA.Power_And_Clocks;
|
programs/oeis/047/A047403.asm | neoneye/loda | 22 | 105348 | <gh_stars>10-100
; A047403: Numbers that are congruent to {0, 2, 3, 6} mod 8.
; 0,2,3,6,8,10,11,14,16,18,19,22,24,26,27,30,32,34,35,38,40,42,43,46,48,50,51,54,56,58,59,62,64,66,67,70,72,74,75,78,80,82,83,86,88,90,91,94,96,98,99,102,104,106,107,110,112,114,115,118,120,122,123,126,128
mov $1,$0
mul $0,8
add $1,10
mod $1,4
add $0,$1
sub $0,1
div $0,4
|
programs/oeis/083/A083224.asm | neoneye/loda | 22 | 82256 | ; A083224: a(n) = (6*7^n + (-7)^n)/7.
; 1,5,49,245,2401,12005,117649,588245,5764801,28824005,282475249,1412376245,13841287201,69206436005,678223072849,3391115364245,33232930569601,166164652848005,1628413597910449,8142067989552245,79792266297612001,398961331488060005,3909821048582988049,19549105242914940245,191581231380566414401,957906156902832072005,9387480337647754305649,46937401688238771528245,459986536544739960976801,2299932682723699804884005,22539340290692258087863249,112696701453461290439316245,1104427674243920646305299201,5522138371219603231526496005,54116956037952111668959660849,270584780189760558344798304245,2651730845859653471779023381601,13258654229298267358895116908005,129934811447123020117172145698449,649674057235615100585860728492245,6366805760909027985741435139224001,31834028804545139928707175696120005,311973482284542371301330321821976049
add $0,1
mov $2,$0
mod $2,2
mov $1,$2
mov $4,5
add $4,$2
add $1,$4
mul $1,9
mov $3,7
pow $3,$0
mul $1,$3
div $1,1764
mul $1,4
add $1,1
mov $0,$1
|
src/test/ref/norom-charset.asm | jbrandwood/kickc | 2 | 23798 | // Generate a charset based on a 5x3 pattern stored in 2 bytes
// Commodore 64 PRG executable file
.file [name="norom-charset.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 VICII_MEMORY = $d018
.label SCREEN = $400
.label CHARSET = $3000
.segment Code
main: {
.label charset = 5
.label c = 7
lda #<CHARSET+8
sta.z charset
lda #>CHARSET+8
sta.z charset+1
lda #0
sta.z c
__b1:
// for(byte c=0;c!=4;c++)
lda #4
cmp.z c
bne __b2
// *VICII_MEMORY = (byte)(((word)SCREEN/$40)|((word)CHARSET/$400))
lda #SCREEN/$40|CHARSET/$400
sta VICII_MEMORY
// }
rts
__b2:
// gen_char3(charset, charset_spec_row[c])
lda.z c
asl
tax
lda charset_spec_row,x
sta.z gen_char3.spec
lda charset_spec_row+1,x
sta.z gen_char3.spec+1
jsr gen_char3
// charset = charset+8
lda #8
clc
adc.z charset
sta.z charset
bcc !+
inc.z charset+1
!:
// for(byte c=0;c!=4;c++)
inc.z c
jmp __b1
}
// Generate one 5x3 character from a 16-bit char spec
// The 5x3 char is stored as 5x 3-bit rows followed by a zero. %aaabbbcc cdddeee0
// void gen_char3(__zp(5) char *dst, __zp(2) unsigned int spec)
gen_char3: {
.label dst = 5
.label spec = 2
.label r = 4
lda #0
sta.z r
__b1:
ldx #0
ldy #0
__b2:
// BYTE1(spec)
lda.z spec+1
// BYTE1(spec)&$80
and #$80
// if((BYTE1(spec)&$80)!=0)
cmp #0
beq __b3
// b = b|1
tya
ora #1
tay
__b3:
// b = b*2
tya
asl
tay
// spec = spec*2
asl.z spec
rol.z spec+1
// for(byte c: 0..2 )
inx
cpx #3
bne __b2
// dst[r] = b
tya
ldy.z r
sta (dst),y
// for(byte r : 0..4 )
inc.z r
lda #5
cmp.z r
bne __b1
// }
rts
}
.segment Data
// Stores chars as 15 bits (in 2 bytes) specifying the 3x5
// The 5x3 char is stored as 5x 3-bit rows followed by a zero. %aaabbbcc cdddeee0
charset_spec_row: .word $f7da, $f7de, $f24e, $d6de
|
halt.asm | adrianna157/CS444-Lab5-Mutexes | 0 | 25897 | <filename>halt.asm
_halt: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "types.h"
#include "user.h"
int main(void)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
#ifdef HALT
halt();
6: e8 d7 02 00 00 call 2e2 <halt>
#endif // HALT
exit();
b: e8 22 02 00 00 call 232 <exit>
00000010 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
10: 55 push %ebp
11: 89 e5 mov %esp,%ebp
13: 8b 45 08 mov 0x8(%ebp),%eax
16: 8b 4d 0c mov 0xc(%ebp),%ecx
19: 53 push %ebx
char *os;
os = s;
while((*s++ = *t++) != 0)
1a: 89 c2 mov %eax,%edx
1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
20: 83 c1 01 add $0x1,%ecx
23: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
27: 83 c2 01 add $0x1,%edx
2a: 84 db test %bl,%bl
2c: 88 5a ff mov %bl,-0x1(%edx)
2f: 75 ef jne 20 <strcpy+0x10>
;
return os;
}
31: 5b pop %ebx
32: 5d pop %ebp
33: c3 ret
34: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000040 <strcmp>:
int
strcmp(const char *p, const char *q)
{
40: 55 push %ebp
41: 89 e5 mov %esp,%ebp
43: 8b 55 08 mov 0x8(%ebp),%edx
46: 53 push %ebx
47: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
4a: 0f b6 02 movzbl (%edx),%eax
4d: 84 c0 test %al,%al
4f: 74 2d je 7e <strcmp+0x3e>
51: 0f b6 19 movzbl (%ecx),%ebx
54: 38 d8 cmp %bl,%al
56: 74 0e je 66 <strcmp+0x26>
58: eb 2b jmp 85 <strcmp+0x45>
5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
60: 38 c8 cmp %cl,%al
62: 75 15 jne 79 <strcmp+0x39>
p++, q++;
64: 89 d9 mov %ebx,%ecx
66: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
69: 0f b6 02 movzbl (%edx),%eax
p++, q++;
6c: 8d 59 01 lea 0x1(%ecx),%ebx
while(*p && *p == *q)
6f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx
73: 84 c0 test %al,%al
75: 75 e9 jne 60 <strcmp+0x20>
77: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
79: 29 c8 sub %ecx,%eax
}
7b: 5b pop %ebx
7c: 5d pop %ebp
7d: c3 ret
7e: 0f b6 09 movzbl (%ecx),%ecx
while(*p && *p == *q)
81: 31 c0 xor %eax,%eax
83: eb f4 jmp 79 <strcmp+0x39>
85: 0f b6 cb movzbl %bl,%ecx
88: eb ef jmp 79 <strcmp+0x39>
8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000090 <strlen>:
uint
strlen(const char *s)
{
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
96: 80 39 00 cmpb $0x0,(%ecx)
99: 74 12 je ad <strlen+0x1d>
9b: 31 d2 xor %edx,%edx
9d: 8d 76 00 lea 0x0(%esi),%esi
a0: 83 c2 01 add $0x1,%edx
a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
a7: 89 d0 mov %edx,%eax
a9: 75 f5 jne a0 <strlen+0x10>
;
return n;
}
ab: 5d pop %ebp
ac: c3 ret
for(n = 0; s[n]; n++)
ad: 31 c0 xor %eax,%eax
}
af: 5d pop %ebp
b0: c3 ret
b1: eb 0d jmp c0 <memset>
b3: 90 nop
b4: 90 nop
b5: 90 nop
b6: 90 nop
b7: 90 nop
b8: 90 nop
b9: 90 nop
ba: 90 nop
bb: 90 nop
bc: 90 nop
bd: 90 nop
be: 90 nop
bf: 90 nop
000000c0 <memset>:
void*
memset(void *dst, int c, uint n)
{
c0: 55 push %ebp
c1: 89 e5 mov %esp,%ebp
c3: 8b 55 08 mov 0x8(%ebp),%edx
c6: 57 push %edi
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
c7: 8b 4d 10 mov 0x10(%ebp),%ecx
ca: 8b 45 0c mov 0xc(%ebp),%eax
cd: 89 d7 mov %edx,%edi
cf: fc cld
d0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
d2: 89 d0 mov %edx,%eax
d4: 5f pop %edi
d5: 5d pop %ebp
d6: c3 ret
d7: 89 f6 mov %esi,%esi
d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000e0 <strchr>:
char*
strchr(const char *s, char c)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 8b 45 08 mov 0x8(%ebp),%eax
e6: 53 push %ebx
e7: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
ea: 0f b6 18 movzbl (%eax),%ebx
ed: 84 db test %bl,%bl
ef: 74 1d je 10e <strchr+0x2e>
if(*s == c)
f1: 38 d3 cmp %dl,%bl
f3: 89 d1 mov %edx,%ecx
f5: 75 0d jne 104 <strchr+0x24>
f7: eb 17 jmp 110 <strchr+0x30>
f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
100: 38 ca cmp %cl,%dl
102: 74 0c je 110 <strchr+0x30>
for(; *s; s++)
104: 83 c0 01 add $0x1,%eax
107: 0f b6 10 movzbl (%eax),%edx
10a: 84 d2 test %dl,%dl
10c: 75 f2 jne 100 <strchr+0x20>
return (char*)s;
return 0;
10e: 31 c0 xor %eax,%eax
}
110: 5b pop %ebx
111: 5d pop %ebp
112: c3 ret
113: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000120 <gets>:
char*
gets(char *buf, int max)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 57 push %edi
124: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
125: 31 f6 xor %esi,%esi
{
127: 53 push %ebx
128: 83 ec 2c sub $0x2c,%esp
cc = read(0, &c, 1);
12b: 8d 7d e7 lea -0x19(%ebp),%edi
for(i=0; i+1 < max; ){
12e: eb 31 jmp 161 <gets+0x41>
cc = read(0, &c, 1);
130: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
137: 00
138: 89 7c 24 04 mov %edi,0x4(%esp)
13c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
143: e8 02 01 00 00 call 24a <read>
if(cc < 1)
148: 85 c0 test %eax,%eax
14a: 7e 1d jle 169 <gets+0x49>
break;
buf[i++] = c;
14c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
for(i=0; i+1 < max; ){
150: 89 de mov %ebx,%esi
buf[i++] = c;
152: 8b 55 08 mov 0x8(%ebp),%edx
if(c == '\n' || c == '\r')
155: 3c 0d cmp $0xd,%al
buf[i++] = c;
157: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
15b: 74 0c je 169 <gets+0x49>
15d: 3c 0a cmp $0xa,%al
15f: 74 08 je 169 <gets+0x49>
for(i=0; i+1 < max; ){
161: 8d 5e 01 lea 0x1(%esi),%ebx
164: 3b 5d 0c cmp 0xc(%ebp),%ebx
167: 7c c7 jl 130 <gets+0x10>
break;
}
buf[i] = '\0';
169: 8b 45 08 mov 0x8(%ebp),%eax
16c: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
170: 83 c4 2c add $0x2c,%esp
173: 5b pop %ebx
174: 5e pop %esi
175: 5f pop %edi
176: 5d pop %ebp
177: c3 ret
178: 90 nop
179: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000180 <stat>:
int
stat(const char *n, struct stat *st)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 56 push %esi
184: 53 push %ebx
185: 83 ec 10 sub $0x10,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
188: 8b 45 08 mov 0x8(%ebp),%eax
18b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
192: 00
193: 89 04 24 mov %eax,(%esp)
196: e8 d7 00 00 00 call 272 <open>
if(fd < 0)
19b: 85 c0 test %eax,%eax
fd = open(n, O_RDONLY);
19d: 89 c3 mov %eax,%ebx
if(fd < 0)
19f: 78 27 js 1c8 <stat+0x48>
return -1;
r = fstat(fd, st);
1a1: 8b 45 0c mov 0xc(%ebp),%eax
1a4: 89 1c 24 mov %ebx,(%esp)
1a7: 89 44 24 04 mov %eax,0x4(%esp)
1ab: e8 da 00 00 00 call 28a <fstat>
close(fd);
1b0: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
1b3: 89 c6 mov %eax,%esi
close(fd);
1b5: e8 a0 00 00 00 call 25a <close>
return r;
1ba: 89 f0 mov %esi,%eax
}
1bc: 83 c4 10 add $0x10,%esp
1bf: 5b pop %ebx
1c0: 5e pop %esi
1c1: 5d pop %ebp
1c2: c3 ret
1c3: 90 nop
1c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
1c8: b8 ff ff ff ff mov $0xffffffff,%eax
1cd: eb ed jmp 1bc <stat+0x3c>
1cf: 90 nop
000001d0 <atoi>:
int
atoi(const char *s)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 8b 4d 08 mov 0x8(%ebp),%ecx
1d6: 53 push %ebx
int n;
n = 0;
while('0' <= *s && *s <= '9')
1d7: 0f be 11 movsbl (%ecx),%edx
1da: 8d 42 d0 lea -0x30(%edx),%eax
1dd: 3c 09 cmp $0x9,%al
n = 0;
1df: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
1e4: 77 17 ja 1fd <atoi+0x2d>
1e6: 66 90 xchg %ax,%ax
n = n*10 + *s++ - '0';
1e8: 83 c1 01 add $0x1,%ecx
1eb: 8d 04 80 lea (%eax,%eax,4),%eax
1ee: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
1f2: 0f be 11 movsbl (%ecx),%edx
1f5: 8d 5a d0 lea -0x30(%edx),%ebx
1f8: 80 fb 09 cmp $0x9,%bl
1fb: 76 eb jbe 1e8 <atoi+0x18>
return n;
}
1fd: 5b pop %ebx
1fe: 5d pop %ebp
1ff: c3 ret
00000200 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
200: 55 push %ebp
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
201: 31 d2 xor %edx,%edx
{
203: 89 e5 mov %esp,%ebp
205: 56 push %esi
206: 8b 45 08 mov 0x8(%ebp),%eax
209: 53 push %ebx
20a: 8b 5d 10 mov 0x10(%ebp),%ebx
20d: 8b 75 0c mov 0xc(%ebp),%esi
while(n-- > 0)
210: 85 db test %ebx,%ebx
212: 7e 12 jle 226 <memmove+0x26>
214: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
218: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
21c: 88 0c 10 mov %cl,(%eax,%edx,1)
21f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
222: 39 da cmp %ebx,%edx
224: 75 f2 jne 218 <memmove+0x18>
return vdst;
}
226: 5b pop %ebx
227: 5e pop %esi
228: 5d pop %ebp
229: c3 ret
0000022a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
22a: b8 01 00 00 00 mov $0x1,%eax
22f: cd 40 int $0x40
231: c3 ret
00000232 <exit>:
SYSCALL(exit)
232: b8 02 00 00 00 mov $0x2,%eax
237: cd 40 int $0x40
239: c3 ret
0000023a <wait>:
SYSCALL(wait)
23a: b8 03 00 00 00 mov $0x3,%eax
23f: cd 40 int $0x40
241: c3 ret
00000242 <pipe>:
SYSCALL(pipe)
242: b8 04 00 00 00 mov $0x4,%eax
247: cd 40 int $0x40
249: c3 ret
0000024a <read>:
SYSCALL(read)
24a: b8 05 00 00 00 mov $0x5,%eax
24f: cd 40 int $0x40
251: c3 ret
00000252 <write>:
SYSCALL(write)
252: b8 10 00 00 00 mov $0x10,%eax
257: cd 40 int $0x40
259: c3 ret
0000025a <close>:
SYSCALL(close)
25a: b8 15 00 00 00 mov $0x15,%eax
25f: cd 40 int $0x40
261: c3 ret
00000262 <kill>:
SYSCALL(kill)
262: b8 06 00 00 00 mov $0x6,%eax
267: cd 40 int $0x40
269: c3 ret
0000026a <exec>:
SYSCALL(exec)
26a: b8 07 00 00 00 mov $0x7,%eax
26f: cd 40 int $0x40
271: c3 ret
00000272 <open>:
SYSCALL(open)
272: b8 0f 00 00 00 mov $0xf,%eax
277: cd 40 int $0x40
279: c3 ret
0000027a <mknod>:
SYSCALL(mknod)
27a: b8 11 00 00 00 mov $0x11,%eax
27f: cd 40 int $0x40
281: c3 ret
00000282 <unlink>:
SYSCALL(unlink)
282: b8 12 00 00 00 mov $0x12,%eax
287: cd 40 int $0x40
289: c3 ret
0000028a <fstat>:
SYSCALL(fstat)
28a: b8 08 00 00 00 mov $0x8,%eax
28f: cd 40 int $0x40
291: c3 ret
00000292 <link>:
SYSCALL(link)
292: b8 13 00 00 00 mov $0x13,%eax
297: cd 40 int $0x40
299: c3 ret
0000029a <mkdir>:
SYSCALL(mkdir)
29a: b8 14 00 00 00 mov $0x14,%eax
29f: cd 40 int $0x40
2a1: c3 ret
000002a2 <chdir>:
SYSCALL(chdir)
2a2: b8 09 00 00 00 mov $0x9,%eax
2a7: cd 40 int $0x40
2a9: c3 ret
000002aa <dup>:
SYSCALL(dup)
2aa: b8 0a 00 00 00 mov $0xa,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <getpid>:
SYSCALL(getpid)
2b2: b8 0b 00 00 00 mov $0xb,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <sbrk>:
SYSCALL(sbrk)
2ba: b8 0c 00 00 00 mov $0xc,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <sleep>:
SYSCALL(sleep)
2c2: b8 0d 00 00 00 mov $0xd,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <uptime>:
SYSCALL(uptime)
2ca: b8 0e 00 00 00 mov $0xe,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <getppid>:
#ifdef GETPPID
SYSCALL(getppid)
2d2: b8 16 00 00 00 mov $0x16,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <cps>:
#endif // GETPPID
#ifdef CPS
SYSCALL(cps)
2da: b8 17 00 00 00 mov $0x17,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <halt>:
#endif // CPS
#ifdef HALT
SYSCALL(halt)
2e2: b8 18 00 00 00 mov $0x18,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <kdebug>:
#endif // HALT
#ifdef KDEBUG
SYSCALL(kdebug)
2ea: b8 19 00 00 00 mov $0x19,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <va2pa>:
#endif // KDEBUG
#ifdef VA2PA
SYSCALL(va2pa)
2f2: b8 1a 00 00 00 mov $0x1a,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <kthread_create>:
#endif // VA2PA
#ifdef KTHREADS
SYSCALL(kthread_create)
2fa: b8 1b 00 00 00 mov $0x1b,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <kthread_join>:
SYSCALL(kthread_join)
302: b8 1c 00 00 00 mov $0x1c,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <kthread_exit>:
SYSCALL(kthread_exit)
30a: b8 1d 00 00 00 mov $0x1d,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <kthread_self>:
#endif // KTHREADS
#ifdef BENNY_MOOTEX
SYSCALL(kthread_self)
312: b8 1e 00 00 00 mov $0x1e,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <kthread_yield>:
SYSCALL(kthread_yield)
31a: b8 1f 00 00 00 mov $0x1f,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <kthread_cpu_count>:
SYSCALL(kthread_cpu_count)
322: b8 20 00 00 00 mov $0x20,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <kthread_thread_count>:
SYSCALL(kthread_thread_count)
32a: b8 21 00 00 00 mov $0x21,%eax
32f: cd 40 int $0x40
331: c3 ret
332: 66 90 xchg %ax,%ax
334: 66 90 xchg %ax,%ax
336: 66 90 xchg %ax,%ax
338: 66 90 xchg %ax,%ax
33a: 66 90 xchg %ax,%ax
33c: 66 90 xchg %ax,%ax
33e: 66 90 xchg %ax,%ax
00000340 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
340: 55 push %ebp
341: 89 e5 mov %esp,%ebp
343: 57 push %edi
344: 56 push %esi
345: 89 c6 mov %eax,%esi
347: 53 push %ebx
348: 83 ec 4c sub $0x4c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
34b: 8b 5d 08 mov 0x8(%ebp),%ebx
34e: 85 db test %ebx,%ebx
350: 74 09 je 35b <printint+0x1b>
352: 89 d0 mov %edx,%eax
354: c1 e8 1f shr $0x1f,%eax
357: 84 c0 test %al,%al
359: 75 75 jne 3d0 <printint+0x90>
neg = 1;
x = -xx;
} else {
x = xx;
35b: 89 d0 mov %edx,%eax
neg = 0;
35d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
364: 89 75 c0 mov %esi,-0x40(%ebp)
}
i = 0;
367: 31 ff xor %edi,%edi
369: 89 ce mov %ecx,%esi
36b: 8d 5d d7 lea -0x29(%ebp),%ebx
36e: eb 02 jmp 372 <printint+0x32>
do{
buf[i++] = digits[x % base];
370: 89 cf mov %ecx,%edi
372: 31 d2 xor %edx,%edx
374: f7 f6 div %esi
376: 8d 4f 01 lea 0x1(%edi),%ecx
379: 0f b6 92 f0 09 00 00 movzbl 0x9f0(%edx),%edx
}while((x /= base) != 0);
380: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
382: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
385: 75 e9 jne 370 <printint+0x30>
if(neg)
387: 8b 55 c4 mov -0x3c(%ebp),%edx
buf[i++] = digits[x % base];
38a: 89 c8 mov %ecx,%eax
38c: 8b 75 c0 mov -0x40(%ebp),%esi
if(neg)
38f: 85 d2 test %edx,%edx
391: 74 08 je 39b <printint+0x5b>
buf[i++] = '-';
393: 8d 4f 02 lea 0x2(%edi),%ecx
396: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
while(--i >= 0)
39b: 8d 79 ff lea -0x1(%ecx),%edi
39e: 66 90 xchg %ax,%ax
3a0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax
3a5: 83 ef 01 sub $0x1,%edi
write(fd, &c, 1);
3a8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3af: 00
3b0: 89 5c 24 04 mov %ebx,0x4(%esp)
3b4: 89 34 24 mov %esi,(%esp)
3b7: 88 45 d7 mov %al,-0x29(%ebp)
3ba: e8 93 fe ff ff call 252 <write>
while(--i >= 0)
3bf: 83 ff ff cmp $0xffffffff,%edi
3c2: 75 dc jne 3a0 <printint+0x60>
putc(fd, buf[i]);
}
3c4: 83 c4 4c add $0x4c,%esp
3c7: 5b pop %ebx
3c8: 5e pop %esi
3c9: 5f pop %edi
3ca: 5d pop %ebp
3cb: c3 ret
3cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
x = -xx;
3d0: 89 d0 mov %edx,%eax
3d2: f7 d8 neg %eax
neg = 1;
3d4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
3db: eb 87 jmp 364 <printint+0x24>
3dd: 8d 76 00 lea 0x0(%esi),%esi
000003e0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3e0: 55 push %ebp
3e1: 89 e5 mov %esp,%ebp
3e3: 57 push %edi
char *s;
int c, i, state;
uint *ap;
state = 0;
3e4: 31 ff xor %edi,%edi
{
3e6: 56 push %esi
3e7: 53 push %ebx
3e8: 83 ec 3c sub $0x3c,%esp
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3eb: 8b 5d 0c mov 0xc(%ebp),%ebx
ap = (uint*)(void*)&fmt + 1;
3ee: 8d 45 10 lea 0x10(%ebp),%eax
{
3f1: 8b 75 08 mov 0x8(%ebp),%esi
ap = (uint*)(void*)&fmt + 1;
3f4: 89 45 d4 mov %eax,-0x2c(%ebp)
for(i = 0; fmt[i]; i++){
3f7: 0f b6 13 movzbl (%ebx),%edx
3fa: 83 c3 01 add $0x1,%ebx
3fd: 84 d2 test %dl,%dl
3ff: 75 39 jne 43a <printf+0x5a>
401: e9 ca 00 00 00 jmp 4d0 <printf+0xf0>
406: 66 90 xchg %ax,%ax
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
408: 83 fa 25 cmp $0x25,%edx
40b: 0f 84 c7 00 00 00 je 4d8 <printf+0xf8>
write(fd, &c, 1);
411: 8d 45 e0 lea -0x20(%ebp),%eax
414: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
41b: 00
41c: 89 44 24 04 mov %eax,0x4(%esp)
420: 89 34 24 mov %esi,(%esp)
state = '%';
} else {
putc(fd, c);
423: 88 55 e0 mov %dl,-0x20(%ebp)
write(fd, &c, 1);
426: e8 27 fe ff ff call 252 <write>
42b: 83 c3 01 add $0x1,%ebx
for(i = 0; fmt[i]; i++){
42e: 0f b6 53 ff movzbl -0x1(%ebx),%edx
432: 84 d2 test %dl,%dl
434: 0f 84 96 00 00 00 je 4d0 <printf+0xf0>
if(state == 0){
43a: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
43c: 0f be c2 movsbl %dl,%eax
if(state == 0){
43f: 74 c7 je 408 <printf+0x28>
}
} else if(state == '%'){
441: 83 ff 25 cmp $0x25,%edi
444: 75 e5 jne 42b <printf+0x4b>
if(c == 'd' || c == 'u'){
446: 83 fa 75 cmp $0x75,%edx
449: 0f 84 99 00 00 00 je 4e8 <printf+0x108>
44f: 83 fa 64 cmp $0x64,%edx
452: 0f 84 90 00 00 00 je 4e8 <printf+0x108>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
458: 25 f7 00 00 00 and $0xf7,%eax
45d: 83 f8 70 cmp $0x70,%eax
460: 0f 84 aa 00 00 00 je 510 <printf+0x130>
putc(fd, '0');
putc(fd, 'x');
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
466: 83 fa 73 cmp $0x73,%edx
469: 0f 84 e9 00 00 00 je 558 <printf+0x178>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
46f: 83 fa 63 cmp $0x63,%edx
472: 0f 84 2b 01 00 00 je 5a3 <printf+0x1c3>
putc(fd, *ap);
ap++;
} else if(c == '%'){
478: 83 fa 25 cmp $0x25,%edx
47b: 0f 84 4f 01 00 00 je 5d0 <printf+0x1f0>
write(fd, &c, 1);
481: 8d 45 e6 lea -0x1a(%ebp),%eax
484: 83 c3 01 add $0x1,%ebx
487: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
48e: 00
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
48f: 31 ff xor %edi,%edi
write(fd, &c, 1);
491: 89 44 24 04 mov %eax,0x4(%esp)
495: 89 34 24 mov %esi,(%esp)
498: 89 55 d0 mov %edx,-0x30(%ebp)
49b: c6 45 e6 25 movb $0x25,-0x1a(%ebp)
49f: e8 ae fd ff ff call 252 <write>
putc(fd, c);
4a4: 8b 55 d0 mov -0x30(%ebp),%edx
write(fd, &c, 1);
4a7: 8d 45 e7 lea -0x19(%ebp),%eax
4aa: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4b1: 00
4b2: 89 44 24 04 mov %eax,0x4(%esp)
4b6: 89 34 24 mov %esi,(%esp)
putc(fd, c);
4b9: 88 55 e7 mov %dl,-0x19(%ebp)
write(fd, &c, 1);
4bc: e8 91 fd ff ff call 252 <write>
for(i = 0; fmt[i]; i++){
4c1: 0f b6 53 ff movzbl -0x1(%ebx),%edx
4c5: 84 d2 test %dl,%dl
4c7: 0f 85 6d ff ff ff jne 43a <printf+0x5a>
4cd: 8d 76 00 lea 0x0(%esi),%esi
}
}
}
4d0: 83 c4 3c add $0x3c,%esp
4d3: 5b pop %ebx
4d4: 5e pop %esi
4d5: 5f pop %edi
4d6: 5d pop %ebp
4d7: c3 ret
state = '%';
4d8: bf 25 00 00 00 mov $0x25,%edi
4dd: e9 49 ff ff ff jmp 42b <printf+0x4b>
4e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 10, 1);
4e8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
4ef: b9 0a 00 00 00 mov $0xa,%ecx
printint(fd, *ap, 16, 0);
4f4: 8b 45 d4 mov -0x2c(%ebp),%eax
state = 0;
4f7: 31 ff xor %edi,%edi
printint(fd, *ap, 16, 0);
4f9: 8b 10 mov (%eax),%edx
4fb: 89 f0 mov %esi,%eax
4fd: e8 3e fe ff ff call 340 <printint>
ap++;
502: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
506: e9 20 ff ff ff jmp 42b <printf+0x4b>
50b: 90 nop
50c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
write(fd, &c, 1);
510: 8d 45 e1 lea -0x1f(%ebp),%eax
513: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
51a: 00
51b: 89 44 24 04 mov %eax,0x4(%esp)
51f: 89 34 24 mov %esi,(%esp)
522: c6 45 e1 30 movb $0x30,-0x1f(%ebp)
526: e8 27 fd ff ff call 252 <write>
52b: 8d 45 e2 lea -0x1e(%ebp),%eax
52e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
535: 00
536: 89 44 24 04 mov %eax,0x4(%esp)
53a: 89 34 24 mov %esi,(%esp)
53d: c6 45 e2 78 movb $0x78,-0x1e(%ebp)
541: e8 0c fd ff ff call 252 <write>
printint(fd, *ap, 16, 0);
546: b9 10 00 00 00 mov $0x10,%ecx
54b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
552: eb a0 jmp 4f4 <printf+0x114>
554: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
558: 8b 45 d4 mov -0x2c(%ebp),%eax
ap++;
55b: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
s = (char*)*ap;
55f: 8b 38 mov (%eax),%edi
s = "(null)";
561: b8 e9 09 00 00 mov $0x9e9,%eax
566: 85 ff test %edi,%edi
568: 0f 44 f8 cmove %eax,%edi
while(*s != 0){
56b: 0f b6 07 movzbl (%edi),%eax
56e: 84 c0 test %al,%al
570: 74 2a je 59c <printf+0x1bc>
572: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
578: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
57b: 8d 45 e3 lea -0x1d(%ebp),%eax
s++;
57e: 83 c7 01 add $0x1,%edi
write(fd, &c, 1);
581: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
588: 00
589: 89 44 24 04 mov %eax,0x4(%esp)
58d: 89 34 24 mov %esi,(%esp)
590: e8 bd fc ff ff call 252 <write>
while(*s != 0){
595: 0f b6 07 movzbl (%edi),%eax
598: 84 c0 test %al,%al
59a: 75 dc jne 578 <printf+0x198>
state = 0;
59c: 31 ff xor %edi,%edi
59e: e9 88 fe ff ff jmp 42b <printf+0x4b>
putc(fd, *ap);
5a3: 8b 45 d4 mov -0x2c(%ebp),%eax
state = 0;
5a6: 31 ff xor %edi,%edi
putc(fd, *ap);
5a8: 8b 00 mov (%eax),%eax
write(fd, &c, 1);
5aa: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
5b1: 00
5b2: 89 34 24 mov %esi,(%esp)
putc(fd, *ap);
5b5: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5b8: 8d 45 e4 lea -0x1c(%ebp),%eax
5bb: 89 44 24 04 mov %eax,0x4(%esp)
5bf: e8 8e fc ff ff call 252 <write>
ap++;
5c4: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
5c8: e9 5e fe ff ff jmp 42b <printf+0x4b>
5cd: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
5d0: 8d 45 e5 lea -0x1b(%ebp),%eax
state = 0;
5d3: 31 ff xor %edi,%edi
write(fd, &c, 1);
5d5: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
5dc: 00
5dd: 89 44 24 04 mov %eax,0x4(%esp)
5e1: 89 34 24 mov %esi,(%esp)
5e4: c6 45 e5 25 movb $0x25,-0x1b(%ebp)
5e8: e8 65 fc ff ff call 252 <write>
5ed: e9 39 fe ff ff jmp 42b <printf+0x4b>
5f2: 66 90 xchg %ax,%ax
5f4: 66 90 xchg %ax,%ax
5f6: 66 90 xchg %ax,%ax
5f8: 66 90 xchg %ax,%ax
5fa: 66 90 xchg %ax,%ax
5fc: 66 90 xchg %ax,%ax
5fe: 66 90 xchg %ax,%ax
00000600 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
600: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
601: a1 78 0e 00 00 mov 0xe78,%eax
{
606: 89 e5 mov %esp,%ebp
608: 57 push %edi
609: 56 push %esi
60a: 53 push %ebx
60b: 8b 5d 08 mov 0x8(%ebp),%ebx
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
60e: 8b 08 mov (%eax),%ecx
bp = (Header*)ap - 1;
610: 8d 53 f8 lea -0x8(%ebx),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
613: 39 d0 cmp %edx,%eax
615: 72 11 jb 628 <free+0x28>
617: 90 nop
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
618: 39 c8 cmp %ecx,%eax
61a: 72 04 jb 620 <free+0x20>
61c: 39 ca cmp %ecx,%edx
61e: 72 10 jb 630 <free+0x30>
620: 89 c8 mov %ecx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
622: 39 d0 cmp %edx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
624: 8b 08 mov (%eax),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
626: 73 f0 jae 618 <free+0x18>
628: 39 ca cmp %ecx,%edx
62a: 72 04 jb 630 <free+0x30>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
62c: 39 c8 cmp %ecx,%eax
62e: 72 f0 jb 620 <free+0x20>
break;
if(bp + bp->s.size == p->s.ptr){
630: 8b 73 fc mov -0x4(%ebx),%esi
633: 8d 3c f2 lea (%edx,%esi,8),%edi
636: 39 cf cmp %ecx,%edi
638: 74 1e je 658 <free+0x58>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
63a: 89 4b f8 mov %ecx,-0x8(%ebx)
if(p + p->s.size == bp){
63d: 8b 48 04 mov 0x4(%eax),%ecx
640: 8d 34 c8 lea (%eax,%ecx,8),%esi
643: 39 f2 cmp %esi,%edx
645: 74 28 je 66f <free+0x6f>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
647: 89 10 mov %edx,(%eax)
freep = p;
649: a3 78 0e 00 00 mov %eax,0xe78
}
64e: 5b pop %ebx
64f: 5e pop %esi
650: 5f pop %edi
651: 5d pop %ebp
652: c3 ret
653: 90 nop
654: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
658: 03 71 04 add 0x4(%ecx),%esi
65b: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
65e: 8b 08 mov (%eax),%ecx
660: 8b 09 mov (%ecx),%ecx
662: 89 4b f8 mov %ecx,-0x8(%ebx)
if(p + p->s.size == bp){
665: 8b 48 04 mov 0x4(%eax),%ecx
668: 8d 34 c8 lea (%eax,%ecx,8),%esi
66b: 39 f2 cmp %esi,%edx
66d: 75 d8 jne 647 <free+0x47>
p->s.size += bp->s.size;
66f: 03 4b fc add -0x4(%ebx),%ecx
freep = p;
672: a3 78 0e 00 00 mov %eax,0xe78
p->s.size += bp->s.size;
677: 89 48 04 mov %ecx,0x4(%eax)
p->s.ptr = bp->s.ptr;
67a: 8b 53 f8 mov -0x8(%ebx),%edx
67d: 89 10 mov %edx,(%eax)
}
67f: 5b pop %ebx
680: 5e pop %esi
681: 5f pop %edi
682: 5d pop %ebp
683: c3 ret
684: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
68a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000690 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
690: 55 push %ebp
691: 89 e5 mov %esp,%ebp
693: 57 push %edi
694: 56 push %esi
695: 53 push %ebx
696: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
699: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
69c: 8b 1d 78 0e 00 00 mov 0xe78,%ebx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6a2: 8d 48 07 lea 0x7(%eax),%ecx
6a5: c1 e9 03 shr $0x3,%ecx
if((prevp = freep) == 0){
6a8: 85 db test %ebx,%ebx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6aa: 8d 71 01 lea 0x1(%ecx),%esi
if((prevp = freep) == 0){
6ad: 0f 84 9b 00 00 00 je 74e <malloc+0xbe>
6b3: 8b 13 mov (%ebx),%edx
6b5: 8b 7a 04 mov 0x4(%edx),%edi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
6b8: 39 fe cmp %edi,%esi
6ba: 76 64 jbe 720 <malloc+0x90>
6bc: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax
if(nu < 4096)
6c3: bb 00 80 00 00 mov $0x8000,%ebx
6c8: 89 45 e4 mov %eax,-0x1c(%ebp)
6cb: eb 0e jmp 6db <malloc+0x4b>
6cd: 8d 76 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6d0: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6d2: 8b 78 04 mov 0x4(%eax),%edi
6d5: 39 fe cmp %edi,%esi
6d7: 76 4f jbe 728 <malloc+0x98>
6d9: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6db: 3b 15 78 0e 00 00 cmp 0xe78,%edx
6e1: 75 ed jne 6d0 <malloc+0x40>
if(nu < 4096)
6e3: 8b 45 e4 mov -0x1c(%ebp),%eax
6e6: 81 fe 00 10 00 00 cmp $0x1000,%esi
6ec: bf 00 10 00 00 mov $0x1000,%edi
6f1: 0f 43 fe cmovae %esi,%edi
6f4: 0f 42 c3 cmovb %ebx,%eax
p = sbrk(nu * sizeof(Header));
6f7: 89 04 24 mov %eax,(%esp)
6fa: e8 bb fb ff ff call 2ba <sbrk>
if(p == (char*)-1)
6ff: 83 f8 ff cmp $0xffffffff,%eax
702: 74 18 je 71c <malloc+0x8c>
hp->s.size = nu;
704: 89 78 04 mov %edi,0x4(%eax)
free((void*)(hp + 1));
707: 83 c0 08 add $0x8,%eax
70a: 89 04 24 mov %eax,(%esp)
70d: e8 ee fe ff ff call 600 <free>
return freep;
712: 8b 15 78 0e 00 00 mov 0xe78,%edx
if((p = morecore(nunits)) == 0)
718: 85 d2 test %edx,%edx
71a: 75 b4 jne 6d0 <malloc+0x40>
return 0;
71c: 31 c0 xor %eax,%eax
71e: eb 20 jmp 740 <malloc+0xb0>
if(p->s.size >= nunits){
720: 89 d0 mov %edx,%eax
722: 89 da mov %ebx,%edx
724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
728: 39 fe cmp %edi,%esi
72a: 74 1c je 748 <malloc+0xb8>
p->s.size -= nunits;
72c: 29 f7 sub %esi,%edi
72e: 89 78 04 mov %edi,0x4(%eax)
p += p->s.size;
731: 8d 04 f8 lea (%eax,%edi,8),%eax
p->s.size = nunits;
734: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
737: 89 15 78 0e 00 00 mov %edx,0xe78
return (void*)(p + 1);
73d: 83 c0 08 add $0x8,%eax
}
}
740: 83 c4 1c add $0x1c,%esp
743: 5b pop %ebx
744: 5e pop %esi
745: 5f pop %edi
746: 5d pop %ebp
747: c3 ret
prevp->s.ptr = p->s.ptr;
748: 8b 08 mov (%eax),%ecx
74a: 89 0a mov %ecx,(%edx)
74c: eb e9 jmp 737 <malloc+0xa7>
base.s.ptr = freep = prevp = &base;
74e: c7 05 78 0e 00 00 7c movl $0xe7c,0xe78
755: 0e 00 00
base.s.size = 0;
758: ba 7c 0e 00 00 mov $0xe7c,%edx
base.s.ptr = freep = prevp = &base;
75d: c7 05 7c 0e 00 00 7c movl $0xe7c,0xe7c
764: 0e 00 00
base.s.size = 0;
767: c7 05 80 0e 00 00 00 movl $0x0,0xe80
76e: 00 00 00
771: e9 46 ff ff ff jmp 6bc <malloc+0x2c>
776: 66 90 xchg %ax,%ax
778: 66 90 xchg %ax,%ax
77a: 66 90 xchg %ax,%ax
77c: 66 90 xchg %ax,%ax
77e: 66 90 xchg %ax,%ax
00000780 <benny_thread_create>:
static struct benny_thread_s *bt_new(void);
int
benny_thread_create(benny_thread_t *abt, void (*func)(void*), void *arg_ptr)
{
780: 55 push %ebp
781: 89 e5 mov %esp,%ebp
783: 56 push %esi
784: 53 push %ebx
785: 83 ec 10 sub $0x10,%esp
}
static struct benny_thread_s *
bt_new(void)
{
struct benny_thread_s *bt = malloc(sizeof(struct benny_thread_s));
788: c7 04 24 0c 00 00 00 movl $0xc,(%esp)
78f: e8 fc fe ff ff call 690 <malloc>
if (bt == NULL) {
794: 85 c0 test %eax,%eax
struct benny_thread_s *bt = malloc(sizeof(struct benny_thread_s));
796: 89 c6 mov %eax,%esi
if (bt == NULL) {
798: 74 66 je 800 <benny_thread_create+0x80>
// allocate 2 pages worth of memory and then make sure the
// beginning address used for the stack is page alligned.
// we want it page alligned so that we don't generate a
// page fault by accessing the stack for a thread.
bt->bt_stack = bt->mem_stack = malloc(PGSIZE * 2);
79a: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
7a1: e8 ea fe ff ff call 690 <malloc>
if (bt->bt_stack == NULL) {
7a6: 85 c0 test %eax,%eax
bt->bt_stack = bt->mem_stack = malloc(PGSIZE * 2);
7a8: 89 c3 mov %eax,%ebx
7aa: 89 46 08 mov %eax,0x8(%esi)
7ad: 89 46 04 mov %eax,0x4(%esi)
if (bt->bt_stack == NULL) {
7b0: 74 5d je 80f <benny_thread_create+0x8f>
free(bt);
return NULL;
}
if (((uint) bt->bt_stack) % PGSIZE != 0) {
7b2: 25 ff 0f 00 00 and $0xfff,%eax
7b7: 75 37 jne 7f0 <benny_thread_create+0x70>
// allign the thread stack to a page boundary
bt->bt_stack += (PGSIZE - ((uint) bt->bt_stack) % PGSIZE);
}
bt->bid = -1;
7b9: c7 06 ff ff ff ff movl $0xffffffff,(%esi)
bt->bid = kthread_create(func, arg_ptr, bt->bt_stack);
7bf: 8b 45 10 mov 0x10(%ebp),%eax
7c2: 89 5c 24 08 mov %ebx,0x8(%esp)
7c6: 89 44 24 04 mov %eax,0x4(%esp)
7ca: 8b 45 0c mov 0xc(%ebp),%eax
7cd: 89 04 24 mov %eax,(%esp)
7d0: e8 25 fb ff ff call 2fa <kthread_create>
if (bt->bid != 0) {
7d5: 85 c0 test %eax,%eax
bt->bid = kthread_create(func, arg_ptr, bt->bt_stack);
7d7: 89 06 mov %eax,(%esi)
if (bt->bid != 0) {
7d9: 74 2d je 808 <benny_thread_create+0x88>
*abt = (benny_thread_t) bt;
7db: 8b 45 08 mov 0x8(%ebp),%eax
7de: 89 30 mov %esi,(%eax)
result = 0;
7e0: 31 c0 xor %eax,%eax
}
7e2: 83 c4 10 add $0x10,%esp
7e5: 5b pop %ebx
7e6: 5e pop %esi
7e7: 5d pop %ebp
7e8: c3 ret
7e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bt->bt_stack += (PGSIZE - ((uint) bt->bt_stack) % PGSIZE);
7f0: 29 c3 sub %eax,%ebx
7f2: 81 c3 00 10 00 00 add $0x1000,%ebx
7f8: 89 5e 04 mov %ebx,0x4(%esi)
7fb: eb bc jmp 7b9 <benny_thread_create+0x39>
7fd: 8d 76 00 lea 0x0(%esi),%esi
800: 8b 1d 04 00 00 00 mov 0x4,%ebx
806: eb b7 jmp 7bf <benny_thread_create+0x3f>
int result = -1;
808: b8 ff ff ff ff mov $0xffffffff,%eax
80d: eb d3 jmp 7e2 <benny_thread_create+0x62>
free(bt);
80f: 89 34 24 mov %esi,(%esp)
return NULL;
812: 31 f6 xor %esi,%esi
free(bt);
814: e8 e7 fd ff ff call 600 <free>
819: 8b 5b 04 mov 0x4(%ebx),%ebx
81c: eb a1 jmp 7bf <benny_thread_create+0x3f>
81e: 66 90 xchg %ax,%ax
00000820 <benny_thread_bid>:
{
820: 55 push %ebp
821: 89 e5 mov %esp,%ebp
return bt->bid;
823: 8b 45 08 mov 0x8(%ebp),%eax
}
826: 5d pop %ebp
return bt->bid;
827: 8b 00 mov (%eax),%eax
}
829: c3 ret
82a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000830 <benny_thread_join>:
{
830: 55 push %ebp
831: 89 e5 mov %esp,%ebp
833: 53 push %ebx
834: 83 ec 14 sub $0x14,%esp
837: 8b 5d 08 mov 0x8(%ebp),%ebx
retVal = kthread_join(bt->bid);
83a: 8b 03 mov (%ebx),%eax
83c: 89 04 24 mov %eax,(%esp)
83f: e8 be fa ff ff call 302 <kthread_join>
if (retVal == 0) {
844: 85 c0 test %eax,%eax
846: 75 27 jne 86f <benny_thread_join+0x3f>
free(bt->mem_stack);
848: 8b 53 08 mov 0x8(%ebx),%edx
84b: 89 45 f4 mov %eax,-0xc(%ebp)
84e: 89 14 24 mov %edx,(%esp)
851: e8 aa fd ff ff call 600 <free>
bt->bt_stack = bt->mem_stack = NULL;
856: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
85d: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx)
free(bt);
864: 89 1c 24 mov %ebx,(%esp)
867: e8 94 fd ff ff call 600 <free>
86c: 8b 45 f4 mov -0xc(%ebp),%eax
}
86f: 83 c4 14 add $0x14,%esp
872: 5b pop %ebx
873: 5d pop %ebp
874: c3 ret
875: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
879: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000880 <benny_thread_exit>:
{
880: 55 push %ebp
881: 89 e5 mov %esp,%ebp
}
883: 5d pop %ebp
return kthread_exit(exitValue);
884: e9 81 fa ff ff jmp 30a <kthread_exit>
889: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000890 <benny_mootex_init>:
}
# ifdef BENNY_MOOTEX
int
benny_mootex_init(benny_mootex_t *benny_mootex)
{
890: 55 push %ebp
891: 89 e5 mov %esp,%ebp
893: 8b 45 08 mov 0x8(%ebp),%eax
benny_mootex->locked = 0;
896: c7 00 00 00 00 00 movl $0x0,(%eax)
benny_mootex->bid = -1;
89c: c7 40 04 ff ff ff ff movl $0xffffffff,0x4(%eax)
return 0;
}
8a3: 31 c0 xor %eax,%eax
8a5: 5d pop %ebp
8a6: c3 ret
8a7: 89 f6 mov %esi,%esi
8a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000008b0 <benny_mootex_yieldlock>:
int
benny_mootex_yieldlock(benny_mootex_t *benny_mootex)
{
8b0: 55 push %ebp
xchg(volatile uint *addr, uint newval)
{
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
8b1: b8 01 00 00 00 mov $0x1,%eax
8b6: 89 e5 mov %esp,%ebp
8b8: 56 push %esi
8b9: 53 push %ebx
8ba: 8b 5d 08 mov 0x8(%ebp),%ebx
8bd: f0 87 03 lock xchg %eax,(%ebx)
// #error this is the call to lock the mootex that will yield in a
// #error loop until the lock is acquired.
while(xchg(&benny_mootex->locked, 1) != 0){
8c0: 85 c0 test %eax,%eax
8c2: be 01 00 00 00 mov $0x1,%esi
8c7: 74 15 je 8de <benny_mootex_yieldlock+0x2e>
8c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
benny_yield(void)
{
// # error This just gives up the rest of this scheduled time slice to
// # error another process/thread.
return kthread_yield();
8d0: e8 45 fa ff ff call 31a <kthread_yield>
8d5: 89 f0 mov %esi,%eax
8d7: f0 87 03 lock xchg %eax,(%ebx)
while(xchg(&benny_mootex->locked, 1) != 0){
8da: 85 c0 test %eax,%eax
8dc: 75 f2 jne 8d0 <benny_mootex_yieldlock+0x20>
return kthread_self();
8de: e8 2f fa ff ff call 312 <kthread_self>
benny_mootex->bid = benny_self();
8e3: 89 43 04 mov %eax,0x4(%ebx)
}
8e6: 31 c0 xor %eax,%eax
8e8: 5b pop %ebx
8e9: 5e pop %esi
8ea: 5d pop %ebp
8eb: c3 ret
8ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000008f0 <benny_mootex_spinlock>:
{
8f0: 55 push %ebp
8f1: ba 01 00 00 00 mov $0x1,%edx
8f6: 89 e5 mov %esp,%ebp
8f8: 53 push %ebx
8f9: 83 ec 04 sub $0x4,%esp
8fc: 8b 5d 08 mov 0x8(%ebp),%ebx
8ff: 90 nop
900: 89 d0 mov %edx,%eax
902: f0 87 03 lock xchg %eax,(%ebx)
while(xchg(&benny_mootex->locked, 1) != 0){
905: 85 c0 test %eax,%eax
907: 75 f7 jne 900 <benny_mootex_spinlock+0x10>
return kthread_self();
909: e8 04 fa ff ff call 312 <kthread_self>
benny_mootex->bid = benny_self();
90e: 89 43 04 mov %eax,0x4(%ebx)
}
911: 83 c4 04 add $0x4,%esp
914: 31 c0 xor %eax,%eax
916: 5b pop %ebx
917: 5d pop %ebp
918: c3 ret
919: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000920 <benny_mootex_unlock>:
{
920: 55 push %ebp
921: 89 e5 mov %esp,%ebp
923: 53 push %ebx
924: 83 ec 04 sub $0x4,%esp
927: 8b 5d 08 mov 0x8(%ebp),%ebx
return kthread_self();
92a: e8 e3 f9 ff ff call 312 <kthread_self>
if(tid == benny_mootex->bid){
92f: 39 43 04 cmp %eax,0x4(%ebx)
932: 75 1c jne 950 <benny_mootex_unlock+0x30>
__sync_synchronize();
934: 0f ae f0 mfence
return 0;
937: 31 c0 xor %eax,%eax
benny_mootex->bid = -1;
939: c7 43 04 ff ff ff ff movl $0xffffffff,0x4(%ebx)
__sync_lock_release(&benny_mootex->locked);
940: c7 03 00 00 00 00 movl $0x0,(%ebx)
}
946: 83 c4 04 add $0x4,%esp
949: 5b pop %ebx
94a: 5d pop %ebp
94b: c3 ret
94c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
950: 83 c4 04 add $0x4,%esp
return -1;
953: b8 ff ff ff ff mov $0xffffffff,%eax
}
958: 5b pop %ebx
959: 5d pop %ebp
95a: c3 ret
95b: 90 nop
95c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000960 <benny_mootex_trylock>:
{
960: 55 push %ebp
961: b8 01 00 00 00 mov $0x1,%eax
966: 89 e5 mov %esp,%ebp
968: 53 push %ebx
969: 83 ec 04 sub $0x4,%esp
96c: 8b 5d 08 mov 0x8(%ebp),%ebx
96f: f0 87 03 lock xchg %eax,(%ebx)
if(xchg(&benny_mootex->locked, 1) != 0){
972: 85 c0 test %eax,%eax
974: 75 08 jne 97e <benny_mootex_trylock+0x1e>
int tid = kthread_self();
976: e8 97 f9 ff ff call 312 <kthread_self>
benny_mootex->bid = tid;
97b: 89 43 04 mov %eax,0x4(%ebx)
}
97e: 83 c4 04 add $0x4,%esp
981: b8 ff ff ff ff mov $0xffffffff,%eax
986: 5b pop %ebx
987: 5d pop %ebp
988: c3 ret
989: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000990 <benny_mootex_wholock>:
{
990: 55 push %ebp
991: 89 e5 mov %esp,%ebp
return benny_mootex->bid;
993: 8b 45 08 mov 0x8(%ebp),%eax
}
996: 5d pop %ebp
return benny_mootex->bid;
997: 8b 40 04 mov 0x4(%eax),%eax
}
99a: c3 ret
99b: 90 nop
99c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000009a0 <benny_mootex_islocked>:
{
9a0: 55 push %ebp
9a1: 89 e5 mov %esp,%ebp
return benny_mootex->locked;
9a3: 8b 45 08 mov 0x8(%ebp),%eax
}
9a6: 5d pop %ebp
return benny_mootex->locked;
9a7: 8b 00 mov (%eax),%eax
}
9a9: c3 ret
9aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000009b0 <benny_self>:
{
9b0: 55 push %ebp
9b1: 89 e5 mov %esp,%ebp
}
9b3: 5d pop %ebp
return kthread_self();
9b4: e9 59 f9 ff ff jmp 312 <kthread_self>
9b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000009c0 <benny_yield>:
{
9c0: 55 push %ebp
9c1: 89 e5 mov %esp,%ebp
}
9c3: 5d pop %ebp
return kthread_yield();
9c4: e9 51 f9 ff ff jmp 31a <kthread_yield>
9c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000009d0 <benny_cpu_count>:
int
benny_cpu_count(void)
{
9d0: 55 push %ebp
9d1: 89 e5 mov %esp,%ebp
// # error call the kthread_cpu_count() function.
// kthread_cpu_count();
return kthread_cpu_count();
}
9d3: 5d pop %ebp
return kthread_cpu_count();
9d4: e9 49 f9 ff ff jmp 322 <kthread_cpu_count>
9d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000009e0 <benny_thread_count>:
int
benny_thread_count(void)
{
9e0: 55 push %ebp
9e1: 89 e5 mov %esp,%ebp
// # error call the kthread_thread_count() function.
// kthread_thread_count()
return kthread_thread_count();
}
9e3: 5d pop %ebp
return kthread_thread_count();
9e4: e9 41 f9 ff ff jmp 32a <kthread_thread_count>
|
programs/oeis/017/A017056.asm | neoneye/loda | 22 | 19041 | <filename>programs/oeis/017/A017056.asm<gh_stars>10-100
; A017056: a(n) = (7*n + 6)^4.
; 1296,28561,160000,531441,1336336,2825761,5308416,9150625,14776336,22667121,33362176,47458321,65610000,88529281,116985856,151807041,193877776,244140625,303595776,373301041,454371856,547981281,655360000,777796321,916636176,1073283121,1249198336,1445900625,1664966416,1908029761,2176782336,2472973441,2798410000,3154956561,3544535296,3969126001,4430766096,4931550625,5473632256,6059221281,6690585616,7370050801,8100000000,8882874001,9721171216,10617447681,11574317056,12594450625,13680577296,14835483601,16062013696,17363069361,18741610000,20200652641,21743271936,23372600161,25091827216,26904200625,28813025536,30821664721,32933538576,35152125121,37480960000,39923636481,42483805456,45165175441,47971512576,50906640625,53974440976,57178852641,60523872256,64013554081,67652010000,71443409521,75391979776,79502005521,83777829136,88223850625,92844527616,97644375361,102627966736,107799932241,113164960000,118727795761,124493242896,130466162401,136651472896,143054150625,149679229456,156531800881,163617014016,170940075601,178506250000,186320859201,194389282816,202716958081,211309379856,220172100625,229310730496,238730937201
mul $0,7
add $0,6
pow $0,4
|
alloy4fun_models/trashltl/models/1/DZMfybrwQvZDfajCW.als | Kaixi26/org.alloytools.alloy | 0 | 4508 | <reponame>Kaixi26/org.alloytools.alloy
open main
pred idDZMfybrwQvZDfajCW_prop2 {
eventually some File
}
pred __repair { idDZMfybrwQvZDfajCW_prop2 }
check __repair { idDZMfybrwQvZDfajCW_prop2 <=> prop2o } |
SacTy.agda | ashinkarov/agda-extractor | 1 | 2668 | open import Structures
open import Data.String using (String)
open import Data.Nat
open import Data.Nat.Show renaming (show to showNat)
open import Data.Vec as V using (Vec; []; _∷_)
open import Data.List as L using (List; []; _∷_)
open import Data.Sum
open import Data.Product
open import Relation.Nullary
open import Function using (_$_)
data Nesting : Set where
hom : Nesting
nes : Nesting
data SacTy : Set where
unit : SacTy
int : SacTy
float : SacTy
bool : SacTy
char : SacTy
-- Nested `n`-dimensional array is isomorphic to Listⁿ
-- Homogeneous `n`-dimensional array is isomorphic to Vecⁿ
-- The first argument does not tell whether the entire array needs
-- to be implemented as nested or not (just an annotation), e.g:
-- akd hom (akd nest nat 3)
-- akd nes nat 2
-- akd nes (akd nes nat 1)
-- and so on. In actual sac (with no support for nested arrays)
-- it all collapses to three cases, but it is convenient to keep
-- this distinction in the model.
aud : Nesting → SacTy → (sh : Prog) → SacTy
akd : Nesting → SacTy → (sh : Prog) → ℕ → SacTy
aks : Nesting → SacTy → (sh : Prog) → (n : ℕ) → Vec ℕ n → SacTy
data SacBase : SacTy → Set where
unit : SacBase unit
int : SacBase int
float : SacBase float
bool : SacBase bool
char : SacBase char
data SacArray : SacTy → Set where
aud : ∀ {n? τ es} → SacArray (aud n? τ es)
akd : ∀ {n? τ es n} → SacArray (akd n? τ es n)
aks : ∀ {n? τ es n s} → SacArray (aks n? τ es n s)
array-or-base : ∀ τ → SacBase τ ⊎ SacArray τ
array-or-base unit = inj₁ unit
array-or-base int = inj₁ int
array-or-base float = inj₁ float
array-or-base bool = inj₁ bool
array-or-base char = inj₁ char
array-or-base (aud x τ es) = inj₂ aud
array-or-base (akd x τ es x₁) = inj₂ akd
array-or-base (aks x τ es n x₁) = inj₂ aks
is-base : ∀ τ → Dec (SacBase τ)
is-base τ with array-or-base τ
... | inj₁ bt = yes bt
... | inj₂ aud = no λ ()
... | inj₂ akd = no λ ()
... | inj₂ aks = no λ ()
is-array : ∀ τ → Dec (SacArray τ)
is-array τ with array-or-base τ
... | inj₂ ar = yes ar
... | inj₁ unit = no λ ()
... | inj₁ int = no λ ()
... | inj₁ float = no λ ()
... | inj₁ bool = no λ ()
... | inj₁ char = no λ ()
-- Is it the case that the entire array can be implemented
-- as a flattened homogeneous (multi-dimensional) array.
nested? : SacTy → Nesting
nested? unit = hom
nested? int = hom
nested? float = hom
nested? bool = hom
nested? char = hom
nested? (aud hom τ _) = nested? τ
nested? (aud nes _ _) = nes
nested? (akd hom τ _ _) = nested? τ
nested? (akd nes _ _ _) = nes
nested? (aks hom τ _ _ _) = nested? τ
nested? (aks nes _ _ _ _) = nes
get-base : SacTy → Σ[ τ ∈ SacTy ] SacBase τ
get-base unit = unit , unit
get-base int = int , int
get-base float = float , float
get-base bool = bool , bool
get-base char = char , char
get-base (aud x τ es) = get-base τ
get-base (akd x τ es x₁) = get-base τ
get-base (aks x τ es n x₁) = get-base τ
bt-tostring : ∀ {τ} → SacBase τ → String
bt-tostring unit = "unit"
bt-tostring int = "int"
bt-tostring float = "float"
bt-tostring bool = "bool"
bt-tostring char = "char"
postfix-aud = "[*]"
postfix-akd : ℕ → String
postfix-akd n = "[" ++ ("," ++/ L.replicate n ".") ++ "]"
postfix-aks : (n : ℕ) → Vec ℕ n → String
postfix-aks n s = "[" ++ ("," ++/ L.map showNat (V.toList s)) ++ "]"
bt : SacTy → String
bt τ = bt-tostring (proj₂ $ get-base τ)
sacty-to-string : SacTy → String
sacty-to-string σ with array-or-base σ
sacty-to-string σ | inj₁ bt = bt-tostring bt
sacty-to-string σ | inj₂ (aud {nes} {τ}) = sacty-to-string τ ++ postfix-aud
sacty-to-string σ | inj₂ (aud {hom} {τ}) with nested? τ
... | hom = bt τ ++ postfix-aud
... | nes = sacty-to-string τ ++ postfix-aud
sacty-to-string σ | inj₂ (akd {nes} {τ} {_} {n}) = sacty-to-string τ ++ postfix-akd n
sacty-to-string σ | inj₂ (akd {hom} {τ} {_} {n}) with nested? τ
... | nes = sacty-to-string τ ++ postfix-akd n
... | hom with array-or-base τ
... | inj₁ bt =
bt-tostring bt ++ postfix-akd n
... | inj₂ aud =
--(τ[*])[.,.,.] → τ([.,.,.] ++ [*]) = τ[*]
bt τ ++ postfix-aud
... | inj₂ (akd {n = m}) =
--(τ[.,.])[.,.,.] → τ([.,.,.] ++ [.,.]) = τ[.,.,., .,.]
bt τ ++ postfix-akd (n + m)
... | inj₂ (aks {n = m}) =
--(τ[5,6])[.,.,.] → τ([.,.,.] ++ [5,6]) = τ[.,.,., .,.]
bt τ ++ postfix-akd (n + m)
sacty-to-string σ | inj₂ (aks {nes} {τ} {_} {n} {s}) = sacty-to-string τ ++ postfix-aks n s
sacty-to-string σ | inj₂ (aks {hom} {τ} {_} {n} {s}) with nested? τ
... | nes = sacty-to-string τ ++ postfix-aks n s
... | hom with array-or-base τ
... | inj₁ bt =
bt-tostring bt ++ postfix-aks n s
... | inj₂ aud =
-- (τ[*])[5,6] → τ([5,6] ++ [*]) = τ[*]
bt τ ++ postfix-aud
... | inj₂ (akd {n = m}) =
--(τ[.,.])[5,6] → τ([5,6] ++ [.,.]) = τ[.,.,.,.]
bt τ ++ postfix-akd (n + m)
... | inj₂ (aks {s = s′}) =
--(τ[7,8])[5,6] → τ([5,6] ++ [7,8]) = τ[5,6,7,8]
bt τ ++ postfix-aks _ (s V.++ s′)
-- For some rare cases we can eliminate nesting
-- Note that this function does not recurse, as:
-- a: List (hom X) ~ Vec (hom X) (length a)
-- but
-- a: List (List (hom X)) ≁ Vec (Vec X _) _
sacty-normalise : SacTy → SacTy
sacty-normalise τ with array-or-base τ
sacty-normalise τ | inj₁ bt = τ
sacty-normalise τ | inj₂ aud = τ
sacty-normalise τ | inj₂ (akd {hom}) = τ
sacty-normalise τ | inj₂ (akd {nes} {σ} {es} {0}) = -- There is no need to nest a 0-dimensional array
akd hom σ es 0
sacty-normalise τ | inj₂ (akd {nes} {σ} {es} {1}) = -- Nested array of depth 1 of homogeneous elements
-- is the same as homogeneous of dimension 1.
akd hom σ es 1
sacty-normalise τ | inj₂ (akd {nes} {_} {_}) = τ
sacty-normalise τ | inj₂ (aks {hom}) = τ
sacty-normalise τ | inj₂ (aks {nes} {σ} {es} {n} {s}) = aks hom σ es n s
sacty-shape : SacTy → Prog
sacty-shape τ with array-or-base τ
... | inj₁ bt = ok $ "[]"
... | inj₂ (aud {hom} {σ} {s}) = s ⊕ " ++ " ⊕ sacty-shape σ
... | inj₂ (aud {nes} {σ} {s}) = error $ "sacty-shape: nested-array `" ++ sacty-to-string τ ++ "`"
... | inj₂ (akd {hom} {σ} {s}) = s ⊕ " ++ " ⊕ sacty-shape σ
... | inj₂ (akd {nes} {σ} {s}) = error $ "sacty-shape: nested-array `" ++ sacty-to-string τ ++ "`"
... | inj₂ (aks {hom} {σ} {s}) = s ⊕ " ++ " ⊕ sacty-shape σ
... | inj₂ (aks {nes} {σ} {s}) = error $ "sacty-shape: nested-array `" ++ sacty-to-string τ ++ "`"
|
programs/oeis/136/A136157.asm | neoneye/loda | 22 | 96579 | <reponame>neoneye/loda
; A136157: Triangle by columns, (3, 1, 0, 0, 0,...) in every column.
; 3,1,3,0,1,3,0,0,1,3,0,0,0,1,3,0,0,0,0,1,3,0,0,0,0,0,1,3,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,1,3
seq $0,212012 ; Triangle read by rows in which row n lists the number of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order.
sub $0,1
mov $1,4
trn $1,$0
mov $0,$1
|
agda/List/Permutation/Base/Preorder.agda | bgbianchi/sorting | 6 | 43 | <reponame>bgbianchi/sorting
module List.Permutation.Base.Preorder (A : Set) where
open import List.Permutation.Base A
open import List.Permutation.Base.Equivalence A
open import Data.List
open import Relation.Binary
open import Relation.Binary.PropositionalEquality hiding ([_])
∼-preorder : Preorder _ _ _
∼-preorder = record {
Carrier = List A;
_≈_ = _≡_;
_∼_ = _∼_;
isPreorder = record {
isEquivalence = Relation.Binary.Setoid.isEquivalence (setoid (List A)) ;
reflexive = reflexive-aux;
trans = trans∼
}
}
where
reflexive-aux : {i j : List A} → i ≡ j → i ∼ j
reflexive-aux {i = i} {j = .i} refl = refl∼
|
data/mapHeaders/saffronpokecenter.asm | adhi-thirumala/EvoYellow | 16 | 98593 | SaffronPokecenter_h:
db POKECENTER ; tileset
db SAFFRON_POKECENTER_HEIGHT, SAFFRON_POKECENTER_WIDTH ; dimensions (y, x)
dw SaffronPokecenterBlocks, SaffronPokecenterTextPointers, SaffronPokecenterScript ; blocks, texts, scripts
db $00 ; connections
dw SaffronPokecenterObject ; objects
|
src/main/antlr4/imports/JadevalLexerGrammar.g4 | TristanoSuriani/jadeval | 0 | 518 | <reponame>TristanoSuriani/jadeval<gh_stars>0
lexer grammar JadevalLexerGrammar ;
ARROW : '->' ;
EQUALS : '=' ;
WHEN : 'when' ;
THEN : 'then' ;
AND : 'and' ;
ISNOTIN : 'is not in' ;
ISNOT : '!=' | 'is not' ;
ISIN : 'is in' ;
IS : '==' | 'is' ;
GTE : '>=' ;
GT : '>' ;
LTE : '<=' ;
LT : '<' ;
CONTAINS : 'contains' ;
DOES_NOT_CONTAIN : 'does not contain' ;
STARTS_WITH : 'starts with' ;
DOES_NOT_START__WITH : 'does not start with' ;
ENDS_WITH : 'ends with' ;
DOES_NOT_END_WITH : 'does not with' ;
OPEN_BRACKET : '{' ;
CLOSE_BRACKET : '}' ;
OPEN_SQUARE_BRACKET : '[' ;
CLOSE_SQUARE_BRACKET : ']' ;
SET : 'set' ;
TO : 'to' ;
NUMBER : [\-]?[0-9]+ ('.' [0-9]+)? ;
BOOLEAN : 'true' | 'false';
CONSTANT : '$' [a-zA-Z0-9_.]+ ;
ID : [a-zA-Z0-9_.]+ ;
TEXT : DOUBLE_QUOTES ~["]* DOUBLE_QUOTES ;
DOUBLE_QUOTES : '"' ;
COMMENT : '/*' .*? '*/' -> skip ;
LINE_COMMENT : '//' ~[\r\n]* -> skip ;
WS : [ \r\n\t]+ -> skip ;
COMMA : ',' -> skip ;
|
src/test/java/eqn/antlr4/Equation.g4 | lukehutch/squirrelparser | 2 | 4987 | <filename>src/test/java/eqn/antlr4/Equation.g4<gh_stars>1-10
grammar Equation;
@header { package eqn.antlr4; }
eqn : prec0;
prec4 : OPEN prec0 CLOSE;
prec3 : NUM | prec4;
prec2 : (MINUS prec3) | prec3;
prec1 : (prec2 (TIMES | DIV) prec2) | prec2;
prec0 : (prec1 (PLUS | MINUS) prec1) | prec1;
NUM : [0-9]+;
OPEN : '(';
CLOSE : ')';
PLUS : '+';
MINUS : '-';
TIMES : '*';
DIV : '/';
|
vp8/decoder/arm/armv5/dequantize_v5.asm | CM-Archive/android_external_libvpx | 3 | 6373 | <gh_stars>1-10
;
; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
EXPORT |vp8_dequantize_b_armv5|
AREA |.text|, CODE, READONLY ; name this block of code
q RN r0
dqc RN r1
cnt RN r2
;void dequantize_b_armv5(short *Q, short *DQC)
|vp8_dequantize_b_armv5| PROC
stmdb sp!, {r4, lr}
ldr r3, [q]
ldr r4, [dqc], #8
mov cnt, #4
dequant_loop
smulbb lr, r3, r4
smultt r12, r3, r4
ldr r3, [q, #4]
ldr r4, [dqc, #-4]
strh lr, [q], #2
strh r12, [q], #2
smulbb lr, r3, r4
smultt r12, r3, r4
subs cnt, cnt, #1
ldrne r3, [q, #4]
ldrne r4, [dqc], #8
strh lr, [q], #2
strh r12, [q], #2
bne dequant_loop
ldmia sp!, {r4, pc}
ENDP ;|vp8_dequantize_b_arm|
END
|
applescript/Playlist To CD Insert.applescript | egorpe/pls2cdinsert | 0 | 2200 | tell application "iTunes"
copy view of front window to selectedLibrary
copy id of selectedLibrary to playlistId
do shell script "~/bin/make_cd_insert " & playlistId
display alert "Done!"
end tell
|
src/apsepp-generic_fixture-creator.ads | thierr26/ada-apsepp | 0 | 23116 | -- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
generic
with function Allocate return Fixture_Type_Access
is Default_Allocator;
Just_Pretend : Boolean := False;
package Apsepp.Generic_Fixture.Creator is
function Has_Actually_Created return Boolean;
end Apsepp.Generic_Fixture.Creator;
|
libsrc/_DEVELOPMENT/arch/zx/display/c/sdcc/zx_saddrpdown.asm | jpoikela/z88dk | 640 | 164772 |
; void *zx_saddrpdown(void *saddr)
SECTION code_clib
SECTION code_arch
PUBLIC _zx_saddrpdown
EXTERN asm_zx_saddrpdown
_zx_saddrpdown:
pop af
pop hl
push hl
push af
jp asm_zx_saddrpdown
|
test/test.zstr.len.asm | richRemer/atlatl | 0 | 97360 | <filename>test/test.zstr.len.asm
global test_case
extern sys.error
extern zstr.len
section .text
test_case:
lea rax, [str]
call zstr.len
cmp rax, 7
jnz .error
ret
.error:
mov rax, -1
call sys.error
section .data
str: db "1234567", 0x0
|
libsrc/target/sam/graphics/pixeladdress_MODE3.asm | w5Mike/z88dk | 0 | 242802 | <reponame>w5Mike/z88dk<filename>libsrc/target/sam/graphics/pixeladdress_MODE3.asm
SECTION code_graphics
PUBLIC pixeladdress_MODE3
EXTERN SCREEN_BASE
; Entry: hl = x
; de = y
; Exit: hl = addr
; a = pixel offset
; z = pixel @1100000
pixeladdress_MODE3:
ex de,hl
add hl,hl ;*2
add hl,hl ;*4
add hl,hl ;*8
add hl,hl ;*16
add hl,hl ;*32
add hl,hl ;*64
add hl,hl ;*128
ld c,e ;save x (lowest byte)
; Divide x by 4 to get the byte
srl d
rr e
srl d
rr e
ld a,d
or +(SCREEN_BASE / 256)
ld d,a
add hl,de
ld a,c
and 3
ret
|
src/FsmParser.g4 | bvandepo/FSMProcess | 0 | 4250 | <reponame>bvandepo/FSMProcess<filename>src/FsmParser.g4<gh_stars>0
//Copyright (c) 2016, <NAME>, LAAS/CNRS
//All rights reserved.
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
//
//* Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//* Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//* Neither the name of the University of California, Berkeley 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 REGENTS 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 REGENTS AND 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.
parser grammar FsmParser;
// now I use non-combined grammar, the lexer rules are in the ModeFsmLexer.g4 file
// p277: Modes are not allowed within combined grammars, just lexer grammars.
// example: lexmagic/XMLParser.g4
options { tokenVocab=FsmLexer; } // use tokens from ModeFsmLexer.g4
fsmgeneric: stat+;
stat: assignExpr* printExpr;
printExpr: numericexpr SEMICOLON*;
assignExpr: id EQUAL numericexpr SEMICOLON;
numericbinaryoperatorB: PLUS | MINUS;
numericbinaryoperatorA: SLASH | STAR | PERCENT | POWER;
logoperator : L O G ;
numericunaryoperator: PLUS | MINUS;
numericexpr: numericexpr numericbinaryoperatorA numericexpr # MulDivModPow
| numericexpr numericbinaryoperatorB numericexpr # AddSub
| numericunaryoperator numericexpr # ChangeSign
| logoperator parenthesisopen numericexpr COMMA numericexpr parenthesisclose #Log
| parenthesisopen numericexpr parenthesisclose # parens
| positive_integer # int
| id # identifier
;
fsmfile : (line)+ ; //a state machine is many lines, the fsm name is mandatory as the first entry
//////keywords at parser level/////////////////////////////////////
letter: A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z;
action_type : R|S|M|I|F;
parenthesisopen: PARENTHESISOPEN; //keep it as parser rules to be abble to process it in the listener functions
parenthesisclose: PARENTHESISCLOSE;
/**
and : A N D;
nand : N A N D;
or : O R ;
nor : N O R ;
xor : X O R;
xnor : X N O R ;
not : N O T ;
*/
//operators : and | or | xor | xnor | not | PLUS | MINUS | STAR | SLASH | DOUBLEEQUAL | NOTEQUAL ;//to complete with all needed operators
//unary_operators : not | PLUS | MINUS ;//to complete with all needed operators
//binary_operators : and | or | xor | xnor | PLUS | MINUS | STAR | SLASH | DOUBLEEQUAL | NOTEQUAL ;//to complete with all needed operators
operators : AND | OR | XOR | XNOR | NOT | PLUS | MINUS | STAR | SLASH | DOUBLEEQUAL | NOTEQUAL ;//to complete with all needed operators
unary_operators : NOT | PLUS | MINUS ;//to complete with all needed operators
binary_operators : AND | OR | XOR | XNOR | PLUS | MINUS | STAR | SLASH | DOUBLEEQUAL | NOTEQUAL ;//to complete with all needed operators
in : I N;
out : O U T;
inout : I N O U T;
buffer : B U F F E R;
linkage : L I N K A G E;
to: TO ;
downto: DOWNTO;
std_logic : S T D UNDERSCORE L O G I C ;
std_logic_vector : S T D UNDERSCORE L O G I C UNDERSCORE V E C T O R;
integer : I N T E G E R;
natural: N A T U R A L;
positive: P O S I T I V E;
real: R E A L;
positive_integer : (PLUS)? DIGIT+ ;
negative_integer : (MINUS)? DIGIT+ ;
/** "a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )" */
number : MINUS? ( DOT DIGIT+ | DIGIT+ ( DOT DIGIT* )? ) ;
constant: positive_integer ;
/////identifiers ///////////////////////////
id : (letter ) ( letter | DIGIT | UNDERSCORE)* ;
signal_id: (letter ) ( letter | DIGIT | UNDERSCORE)* ;
input: signal_id;
state_id:( letter | DIGIT | UNDERSCORE)+ ; //at least one char
action_id: signal_id;
/////////////////////////////////////////////
//* A line in a fsm file can be one of these statements */
line : state
| transition
| reset_transition
| repeatedly_action
| reset_asynchronous
| clock_definition
| multi_transitions_directive
| multi_transitions_to_same_directive
| multi_state_action_directive
| pragma_directive;
pragma_directive:
pragma_dot_directive
| pragma_vhdl_directive;
pragma_vhdl_directive:
pragma_vhdl_pre_entity_directive
| pragma_vhdl_entity_directive
| pragma_vhdl_architecture_pre_begin_directive
| pragma_vhdl_architecture_post_begin_directive
| pragma_vhdl_promote_to_buffer_directive
| pragma_vhdl_demote_to_signal_directive
| pragma_vhdl_allow_automatic_buffering
| pragma_vhdl_set_bit_size_for_output_state_number
| pragma_vhdl_generic_directive
| pragma_vhdl_testbench
| pragma_vhdl_init_testbench
| pragma_vhdl_testbench_pre_begin_directive
;
pragma_dot_directive:
pragma_dot_global_directive;
multi_state_action_directive:
(multi_transitions_base_state_name)? PARENTHESISOPEN multi_transitions_first_state_number to multi_transitions_last_state_number PARENTHESISCLOSE (COLON multi_state_action)+ SEMICOLON;
multi_transitions_directive:
SHARP (multi_transitions_base_state_name)? PARENTHESISOPEN multi_transitions_first_state_number to multi_transitions_last_state_number PARENTHESISCLOSE ( STAR multi_transitions_priority)? (CONDITION condition_multi_transitions)? (COLON transition_action)* SEMICOLON;
multi_transitions_base_state_name:state_id;
multi_transitions_first_state_number:positive_integer;
multi_transitions_last_state_number:positive_integer;
multi_transitions_priority:positive_integer;
condition_multi_transitions: boolean_operation;
multi_transitions_to_same_directive:
SHARP (multi_transitions_base_state_name)? PARENTHESISOPEN multi_transitions_first_state_number to multi_transitions_last_state_number PARENTHESISCLOSE ARROW multi_transitions_destination_state ( STAR multi_transitions_priority)? (CONDITION condition_multi_transitions)? (COLON transition_action)* SEMICOLON;
multi_transitions_destination_state: state_id;
state : state_id ( COLON state_action)* SEMICOLON ; //state (with action(s))
clock_definition: SLASH input_clock SEMICOLON ;
input_clock: signal_id;
reset_asynchronous: DOUBLEARROW state_id (CONDITION condition_reset_asynchronous)? ( COMMA level_reset_asynchronous)? (COLON action_reset_asynchronous)* SEMICOLON ;
level_reset_asynchronous : DIGIT ;
condition_reset_asynchronous: input_async_reset;
input_async_reset: signal_id;
action_reset_asynchronous : action_id_reset_asynchronous ( EQUAL action_expression_reset_asynchronous)? ;
action_expression_reset_asynchronous : boolean_operation;
repeatedly_action : PERCENT (action_type COMMA)? action_id ( EQUAL action_expression)? SEMICOLON ;
// different rules to trigger different listener functions
state_action : (action_type COMMA)? action_id (EQUAL action_expression)? ;
multi_state_action: (action_type COMMA)? action_id (EQUAL action_expression)? ;
transition_action : (action_type COMMA)? action_id (EQUAL action_expression)? ;
transition : state_id ARROW state_id ( STAR transition_priority)? ('?' condition)? (COLON transition_action)* SEMICOLON ; //transition (with action(s))
reset_transition : '->' state_id (STAR reset_transition_priority)? ('?' condition) (COLON transition_action)* SEMICOLON ; //transition (with action(s)), the condition is mandatory for reset transition
transition_priority: positive_integer;
reset_transition_priority: positive_integer;
condition : boolean_operation;
action_id_reset_asynchronous: signal_id ;
action_expression: boolean_operation;
boolean_operation: (unary_operators)? expr (binary_operators expr)* ;
expr: (parenthesisopen expr parenthesisclose)
| expr binary_operators expr
| unary_operators expr
| input
| constant
;
pragma_vhdl_pre_entity_directive : PRAGMA_VHDL_PRE_ENTITY_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_entity_directive : PRAGMA_VHDL_ENTITY_DIRECTIVE
interface_port_declaration
(interface_port_declaration)*
PRAGMA_ENDING;
pragma_vhdl_architecture_pre_begin_directive : PRAGMA_VHDL_ARCHITECTURE_PRE_BEGIN_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_architecture_post_begin_directive : PRAGMA_VHDL_ARCHITECTURE_POST_BEGIN_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_promote_to_buffer_directive : PRAGMA_VHDL_PROMOTE_TO_BUFFER_DIRECTIVE
input_or_output_to_promote_to_buffer (COMMA input_or_output_to_promote_to_buffer)*
PRAGMA_ENDING;
pragma_vhdl_demote_to_signal_directive : PRAGMA_VHDL_DEMOTE_TO_SIGNAL_DIRECTIVE
input_or_output_to_demote_to_signal (COMMA input_or_output_to_demote_to_signal)*
PRAGMA_ENDING;
pragma_vhdl_allow_automatic_buffering : PRAGMA_VHDL_ALLOW_AUTOMATIC_BUFFERING_DIRECTIVE ;
pragma_vhdl_set_bit_size_for_output_state_number: PRAGMA_VHDL_SET_BIT_SIZE_FOR_OUTPUT_STATE_NUMBER
bit_size_for_output_state_number
PRAGMA_ENDING;
pragma_vhdl_init_testbench : PRAGMA_VHDL_INIT_TESTBENCH_BEGIN_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_testbench : PRAGMA_VHDL_TESTBENCH_BEGIN_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_testbench_pre_begin_directive : PRAGMA_VHDL_TESTBENCH_PRE_BEGIN_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
pragma_vhdl_generic_directive : PRAGMA_VHDL_GENERIC_DIRECTIVE
generic_declaration
(generic_declaration)*
PRAGMA_ENDING;
pragma_dot_global_directive : PRAGMA_DOT_GLOBAL_DIRECTIVE
PRAGMA_WITH_BEGINING_AND_ENDING;
bit_size_for_output_state_number: positive_integer;
input_or_output_to_promote_to_buffer: signal_id ;
input_or_output_to_demote_to_signal: signal_id ;
// {System.out.println("found an pragma");} -> channel(PRAGMAS_CHANNEL);
// PragmaDirective : '#pragma' ~[\r\n]* {System.out.println("found an pragma");} -> channel(PRAGMAS_CHANNEL);
// PragmaMultilineDirective : '#pragma{' .*? '#pragma}' {System.out.println("found a multiline pragma");} -> channel(PRAGMAS_CHANNEL);
//parsing of added entity pragmas
generic_declaration : generic_id COLON type_generic COLONEQUAL default_generic SEMICOLON;
generic_id: id | R | S | M | I | F; //used for definition of bus ex n in (n-1 downto 0)
type_generic: integer | positive | natural | real;
default_generic: id | number | positive_integer;
interface_port_declaration : interface_name (COMMA interface_name)* COLON interface_port_mode interface_port_type SEMICOLON;
interface_port_mode : in | out | inout | buffer | linkage ;
interface_port_type: interface_port_type_std_logic
| interface_port_type_std_logic_vector PARENTHESISOPEN bus_begin to_or_down_to bus_end PARENTHESISCLOSE;
to_or_down_to : to | downto;
number_of_bit_with_optional_generic_prefix: (unary_num_operators)? expr_num (binary_num_operators expr)* ;
expr_num: (parenthesisopen expr_num parenthesisclose)
| expr_num binary_num_operators expr_num
| unary_num_operators expr_num
| generic_id
| constant
;
unary_num_operators : PLUS | MINUS ;//to complete with all needed operators
binary_num_operators : PLUS | MINUS | STAR | SLASH ;//to complete with all needed operators
bus_begin: number_of_bit_with_optional_generic_prefix;
bus_end: number_of_bit_with_optional_generic_prefix;
interface_port_type_std_logic: std_logic;
interface_port_type_std_logic_vector: std_logic_vector ;
interface_name : signal_id ;
|
oeis/305/A305262.asm | neoneye/loda-programs | 11 | 222 | ; A305262: a(n) = 140*2^n - 127.
; 13,153,433,993,2113,4353,8833,17793,35713,71553,143233,286593,573313,1146753,2293633,4587393,9174913,18349953,36700033,73400193,146800513,293601153,587202433,1174404993,2348810113,4697620353,9395240833,18790481793,37580963713,75161927553,150323855233,300647710593,601295421313,1202590842753,2405181685633,4810363371393,9620726742913,19241453485953,38482906972033,76965813944193,153931627888513,307863255777153,615726511554433,1231453023108993,2462906046218113,4925812092436353,9851624184872833
mov $1,2
pow $1,$0
sub $1,1
mul $1,140
add $1,13
mov $0,$1
|
test/asm/fibonacci.asm | renatocf/MAC0242-PROJECT | 1 | 94184 | PUSH 1
DUP
STO 0
STO 1
PUSH 10
STO 2
LOOP: RCL 0
RCL 1
DUP
STO 0
ADD
DUP
STO 1
PRN
RCL 2
PUSH 1
SUB
DUP
STO 2
PUSH 0
EQ
JIF LOOP
END
|
lib/Haskell/Prim/Absurd.agda | dxts/agda2hs | 1 | 16153 | <filename>lib/Haskell/Prim/Absurd.agda
module Haskell.Prim.Absurd where
open import Agda.Builtin.Nat
open import Agda.Builtin.List
open import Agda.Builtin.Unit
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_; absurd to absurdP)
open import Agda.Builtin.Equality
open import Haskell.Prim
private
pattern vArg x = arg (arg-info visible relevant) x
refute : Nat → Term
refute i = def (quote _$_) (vArg (pat-lam (absurd-clause (vArg absurdP ∷ []) ∷ []) []) ∷ vArg (var i []) ∷ [])
tryRefute : Nat → Term → TC ⊤
tryRefute 0 _ = typeError (strErr "No variable of empty type found in the context" ∷ [])
tryRefute (suc n) hole = catchTC (unify hole (refute n)) (tryRefute n hole)
absurd : Term → TC ⊤
absurd hole = do
Γ ← getContext
tryRefute (lengthNat Γ) hole
|
test/Compiler/simple/Irrelevant.agda | cruhland/agda | 1,989 | 12250 | module Irrelevant where
open import Common.IO
open import Common.Nat
open import Common.Unit
A : Set
A = Nat
record R : Set where
id : A → A
id x = x
postulate r : R
id2 : .A → A → A
id2 x y = y
open R
main : IO Unit
main = printNat (id2 10 20) ,,
printNat (id r 30) ,,
return unit
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.