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 |
|---|---|---|---|---|
roms/virtual-disk/option.asm | teknoman117/ts-3100-kvm-emulator | 1 | 246588 | <gh_stars>1-10
; virtual disk option rom
bits 16
org 0x0000
section .text
; header
db 0x55
db 0xaa
db 16
jmp rom_init
%include "stringformat.asm"
rom_init:
; backup registers we clobber
push ax
push bx
push cx
push dx
push si
push bp
push ds
push es
; set DS to local data (we cheat and use our internal memory because we are a vm)
mov ax, cs
mov ds, ax
; backup existing int 13h and int 19h vectors
xor ax, ax
mov es, ax
mov ax, WORD [es:13h*4]
mov WORD [ds:bios_int13h_offset], ax
mov ax, WORD [es:13h*4+2]
mov WORD [ds:bios_int13h_segment], ax
mov ax, WORD [es:19h*4]
mov WORD [ds:bios_int19h_offset], ax
mov ax, WORD [es:19h*4+2]
mov WORD [ds:bios_int19h_segment], ax
; overwrite int 19h with our vector
mov WORD [es:13h*4], int13h_handler
mov WORD [es:13h*4+2], cs
mov WORD [es:19h*4], int19h_handler
mov WORD [es:19h*4+2], cs
; up the fixed disk count, get our drive number
mov ax, 0x0040
mov es, ax
mov al, BYTE [es:0x75]
mov bl, al
add bl, 0x80
mov BYTE [ds:vdisk_drivenum], bl
inc al
mov BYTE [es:0x75], al
; select the zero lba
mov dx, 0xD000
mov ax, 0x0000
out dx, ax
add dx, 2
out dx, ax
add dx, 2
out dx, ax
; get the current video mode
mov ah, 0x0F
int 10h
; print messages
mov ah, 0x0E
mov si, rom_message
lodsb
.rom_init_print_message:
int 10h
lodsb
test al, al
jnz .rom_init_print_message
; restore registers
pop es
pop ds
pop bp
pop si
pop dx
pop cx
pop bx
pop ax
retf
; if this chains to another handler, we need to *replace* ourself with the other call
int19h_handler:
sti
; set a stack frame
push bp
mov bp, sp
sub sp, 8
%if 1
; replace call with old bios call, todo: overwrite our stack frame
mov WORD [ss:bp-2], ax
mov WORD [ss:bp-4], bx
mov WORD [ss:bp-6], ds
mov WORD [ss:bp-8], es
xor ax, ax
mov es, ax
mov ax, cs
mov ds, ax
mov ax, WORD [es:13h*4]
mov bx, WORD [es:13h*4+2]
push WORD [ds:bios_int19h_segment]
push WORD [ds:bios_int19h_offset]
mov ax, WORD [ss:bp-2]
mov bx, WORD [ss:bp-4]
mov ds, WORD [ss:bp-6]
mov es, WORD [ss:bp-8]
retf
; this call SHOULD NOT return
%endif
%if 0
; map LBA zero into the virtual disk
mov dx, 0xd000
mov ax, 2048
out dx, ax
add dx, 2
xor ax, ax
out dx, ax
add dx, 2
out dx, ax
; set the data segment to the code segment, extra segment to 0
mov ax, cs
mov ds, ax
xor ax, ax
mov es, ax
; copy the IPL and jump to it
mov si, 0x1000
mov di, 0x7c00
mov cx, 0x100
rep movsw
jmp WORD 0x0000:0x7c00
%endif
int13h_handler:
sti
; set a stack frame
push bp
mov bp, sp
sub sp, 12
; save some registers, setup vars pointer
mov WORD [ss:bp-2], ax
mov WORD [ss:bp-4], ds
mov WORD [ss:bp-6], cx
mov WORD [ss:bp-8], di
mov WORD [ss:bp-10], dx
mov WORD [ss:bp-12], si
mov ax, cs
mov ds, ax
mov ax, WORD [ss:bp-2]
; skip disk reset for now
cmp ah, 0x00
je .BIOSInt13h
; skip if not our disk
cmp dl, BYTE [ds:vdisk_drivenum]
jne .BIOSInt13h
; we only support disk parameter check at the moment
cmp ah, 0x08
je .HandleAH08
cmp ah, 0x02
je .HandleAH02
cmp ah, 0x03
je .HandleAH03
;int 3
jmp .BIOSInt13h
.HandleAH08:
; use 255x63 virtual mappings
; bits [15:8] = head count = 1 (255 heads here)
; bits [7:0] = drive count (1 drive here)
mov dx, 0xfe01
; bits [15:6] = cylinder count - 1 (8 cylinders here)
; bits [5:0] = sectors/track count (63 sectors/track)
mov cx, 0x073f
; no error (clear CF, zero AH)
xor ah, ah
clc
mov WORD [ss:bp-2], ax
mov WORD [ss:bp-6], cx
mov WORD [ss:bp-10], dx
jmp .FinishInt13hHandler
.HandleAH02:
;int 3
cld
; put BX in DI (the destination address)
mov di, bx
; convert chs to lba (dx:ax = 512 bytes/sector lba)
mov al, 255
mul ch
mov dl, dh
xor dh, dh
add ax, dx
mov dx, 63
mul dx
xor ch, ch
sub cl, 1
add ax, cx
adc dx, 0
; check the current lba
push ax
mov bx, ax
mov cx, dx
and bx, 0xFFF8
mov dx, 0xD000
in ax, dx
cmp ax, bx
jne .HandleAH02_OutputLBALowWord
add dx, 2
in ax, dx
cmp ax, cx
jne .HandleAH02_OutputLBAHighWord
jmp .HandleAH02_SkipLBA
; write out the lba (and select it)
.HandleAH02_OutputLBALowWord:
mov ax, bx
out dx, ax
add dx, 2
.HandleAH02_OutputLBAHighWord:
mov ax, cx
out dx, ax
add dx, 2
out dx, ax
.HandleAH02_SkipLBA:
pop ax
; figure out the offset
mov bx, [ss:bp-2] ; get old ax value (bl contains sector count to move)
and ax, 0x0007
je .HandleAH02_SkipAlignment
; get blocks to move
xor cl, cl
mov ch, 8 ; "effective" multiply by 256 (512 bytes, cx is in words)
sub ch, al
cmp ch, bl ; do we terminate early?
jng .HandleAH02_StartCopy
; so we aren't moving a whole block
mov ch, bl
.HandleAH02_StartCopy:
sub bl, ch
; compute offset into memory
mov ah, al ; "effective" multiply by 512
shl ah, 1
xor al, al
mov si, 0x1000
add si, ax
rep movsw
test bl, bl
jz .HandleAH02_FinishCopy
; increment the LBA before continuing to main loop
call IncrementLBA
.HandleAH02_SkipAlignment:
test bl, 0xF8
jz .HandleAH02_LastCopy
mov cx, 2048
mov si, 0x1000
rep movsw
sub bl, 8
jz .HandleAH02_FinishCopy
; increment the LBA before the next block
; can the following be replaced by (push SkipAlignment, jmp IncrementLBA ?)
call IncrementLBA
jmp .HandleAH02_SkipAlignment
.HandleAH02_LastCopy:
xor cl, cl
mov ch, bl
mov si, 0x1000
rep movsw
.HandleAH02_FinishCopy:
; setup results
mov ax, WORD [ss:bp-2]
xor ah, ah
clc
mov WORD [ss:bp-2], ax
jmp .FinishInt13hHandler
.HandleAH03:
;int 3
cld
; put BX in SI (the source address)
mov si, bx
; convert chs to lba (dx:ax = 512 bytes/sector lba)
mov al, 255
mul ch
mov dl, dh
xor dh, dh
add ax, dx
mov dx, 63
mul dx
xor ch, ch
sub cl, 1
add ax, cx
adc dx, 0
; check the current lba
push ax
mov bx, ax
mov cx, dx
and bx, 0xFFF8
mov dx, 0xD000
in ax, dx
cmp ax, bx
jne .HandleAH03_OutputLBALowWord
add dx, 2
in ax, dx
cmp ax, cx
jne .HandleAH03_OutputLBAHighWord
jmp .HandleAH03_SkipLBA
; write out the lba (and select it)
.HandleAH03_OutputLBALowWord:
mov ax, bx
out dx, ax
add dx, 2
.HandleAH03_OutputLBAHighWord:
mov ax, cx
out dx, ax
add dx, 2
out dx, ax
.HandleAH03_SkipLBA:
pop ax
; swap ds, es
mov bx, es
mov dx, ds
mov es, dx
mov ds, bx
; figure out the offset
mov bx, [ss:bp-2] ; get old ax value (bl contains sector count to move)
and ax, 0x0007
je .HandleAH03_SkipAlignment
; get blocks to move
xor cl, cl
mov ch, 8 ; "effective" multiply by 256 (512 bytes, cx is in words)
sub ch, al
cmp ch, bl ; do we terminate early?
jng .HandleAH03_StartCopy
; so we aren't moving a whole block
mov ch, bl
.HandleAH03_StartCopy:
sub bl, ch
; compute offset into memory
mov ah, al ; "effective" multiply by 512
shl ah, 1
xor al, al
mov di, 0x1000
add di, ax
rep movsw
test bl, bl
jz .HandleAH03_FinishCopy
; increment the LBA before continuing to main loop
call IncrementLBA
.HandleAH03_SkipAlignment:
test bl, 0xF8
jz .HandleAH03_LastCopy
mov cx, 2048
mov di, 0x1000
rep movsw
sub bl, 8
jz .HandleAH03_FinishCopy
; increment the LBA before the next block
; can the following be replaced by (push SkipAlignment, jmp IncrementLBA ?)
call IncrementLBA
jmp .HandleAH03_SkipAlignment
.HandleAH03_LastCopy:
xor cl, cl
mov ch, bl
mov di, 0x1000
rep movsw
.HandleAH03_FinishCopy:
; swap ds, es
mov bx, es
mov dx, ds
mov es, dx
mov ds, bx
; setup results
mov ax, WORD [ss:bp-2]
xor ah, ah
clc
mov WORD [ss:bp-2], ax
jmp .FinishInt13hHandler
.BIOSInt13h:
; stack frame looks like
; flags
; segment
; offset
; bp --> bp (caller's)
; call original int 13h call
push bp
; simulate int instruction's return data
push WORD [ss:bp+6] ; flags
push cs ; segment
push .ReturnFromInt13h ; offset
; push old handler and restore variables
push WORD [ds:bios_int13h_segment]
push WORD [ds:bios_int13h_offset]
mov ax, WORD [ss:bp-2]
mov ds, WORD [ss:bp-4]
mov cx, WORD [ss:bp-6]
mov di, WORD [ss:bp-8]
mov dx, WORD [ss:bp-10]
mov bp, WORD [ss:bp]
retf
.ReturnFromInt13h:
;int 3
pop bp
; overwrite registers which store return data from the old int 13h function
mov WORD [ss:bp-2], ax
mov WORD [ss:bp-6], cx
mov WORD [ss:bp-8], di
mov WORD [ss:bp-10], dx
mov WORD [ss:bp-12], si
; setup vars pointer
mov ax, cs
mov ds, ax
.FinishInt13hHandler:
; restore registers
mov ax, WORD [ss:bp-2]
mov ds, WORD [ss:bp-4]
mov cx, WORD [ss:bp-6]
mov di, WORD [ss:bp-8]
mov dx, WORD [ss:bp-10]
mov si, WORD [ss:bp-12]
; restore stack frame
mov sp, bp
pop bp
; we want the current flags to be returned to the caller, but iret
; preserves the caller's flags. we can get around this by using
; a far return with a '2' passed so it skips over the flags entry
; on the stack
retf 2
; clobbers ax, dx
IncrementLBA:
push dx
push ax
mov dx, 0xD000
in ax, dx
add ax, 8
out dx, ax
add dx, 2
in ax, dx
adc ax, 0
out dx, ax
add dx, 2
out dx, ax
pop ax
pop dx
ret
section .data align=4
indicator: dq 0xefcdab8967452301
bios_int13h_segment: dw 0x0000
bios_int13h_offset: dw 0x0000
bios_int19h_segment: dw 0x0000
bios_int19h_offset: dw 0x0000
vdisk_drivenum: db 0x00
rom_message: db 13, 10, "-= Virtual Disk Driver =-", 13, 10
db "v0.0.1 (2020-05-06)", 13, 10
db "Released under GNU GPL v2", 13, 10, 0
;times 8191-($-$$) db 0x00
; db 0x00 ; checksum
|
sys/dev/adb/files.adb | ArrogantWombatics/openbsd-src | 1 | 19494 | <gh_stars>1-10
# $OpenBSD: files.adb,v 1.2 2014/10/18 12:21:57 miod Exp $
file dev/adb/adb_subr.c adb
device akbd: wskbddev
attach akbd at adb
file dev/adb/akbd.c akbd needs-flag
device ams: wsmousedev
attach ams at adb
file dev/adb/ams.c ams
|
oeis/159/A159850.asm | neoneye/loda-programs | 11 | 14888 | <reponame>neoneye/loda-programs
; A159850: Numerator of Hermite(n, 17/22).
; Submitted by <NAME>
; 1,17,47,-7429,-160415,4464217,269993839,-1892147821,-489536076223,-4658915114335,987008017069999,28053710866880683,-2150502256703365727,-118026514721378720791,4759029349325350323695,480777330814562061542723,-9102061914203466628786559,-2016304877455443234982794959,3168699798290526716120389423,8836891942766849685759101461595,135657481354496602817183174280161,-40464379819965110231181937111357063,-1377305777182958609447017822584848273,192018159949383950510213330196922582771
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $2,17
mul $3,-1
mul $3,$0
mul $3,242
lpe
mov $0,$1
|
src/basics/helloworld-len.asm | Pentium1080Ti/x86-assembly | 0 | 166030 | <reponame>Pentium1080Ti/x86-assembly
SECTION .data
msg db 'Hello world! :)',0Ah
SECTION .text
global _start
_start:
mov ebx,msg ; move msg into ebx
mov eax,ebx ; move address in ebx to eax
nextchar:
cmp byte [eax],0 ; compare byte against 0
jz finished ; if 0 jmp to finished
inc eax
jmp nextchar
finished:
sub eax,ebx ; subtract addr in ebx from eax - eax++ 1 byte for each char in str
; sub gives the number of segments between then when subtracting addresses - no. of bytes
mov edx,eax
mov ecx,msg
mov ebx,1
mov eax,4
int 80h
mov ebx,0
mov eax,1
int 80h |
bios/hyper_mbr.asm | UltraOS/Hyper | 3 | 102127 | <reponame>UltraOS/Hyper
BITS 16
BYTES_PER_SECTOR: equ 512
MBR_LOAD_BASE: equ 0x7C00
MBR_SIZE_IN_BYTES: equ BYTES_PER_SECTOR
STAGE2_LOAD_BASE: equ MBR_LOAD_BASE + MBR_SIZE_IN_BYTES
STAGE2_BASE_SECTOR: equ 1
SECTORS_PER_BATCH: equ 64
BYTES_PER_BATCH: equ SECTORS_PER_BATCH * BYTES_PER_SECTOR
STAGE2_SECTORS_TO_LOAD: equ 256 ; must be a multiple of SECTORS_PER_BATCH
ORG MBR_LOAD_BASE
start:
cli
; in case BIOS sets 0x07C0:0000
jmp 0:segment_0
segment_0:
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov fs, ax
mov gs, ax
mov sp, MBR_LOAD_BASE
sti
clc ; carry gets set in case of an error, clear just in case
mov cx, STAGE2_SECTORS_TO_LOAD
mov ebx, STAGE2_LOAD_BASE
load_stage2:
mov al, bl
and al, ~0xF0
mov [DAP.read_into_offset], al
mov eax, ebx
shr eax, 4
mov [DAP.read_into_segment], ax
; NOTE: dl contains the drive number here, don't overwrite it
; Actual function: https://en.wikipedia.org/wiki/INT_13H#INT_13h_AH=42h:_Extended_Read_Sectors_From_Drive
mov ax, DAP
mov si, ax
mov ah, 0x42
int 0x13
mov si, disk_error
jc panic
add [DAP.sector_begin_low], dword SECTORS_PER_BATCH
add ebx, BYTES_PER_BATCH
sub cx, SECTORS_PER_BATCH
jnz load_stage2
STAGE2_MAGIC_LOWER: equ 'Hype'
STAGE2_MAGIC_UPPER: equ 'rST2'
verify_stage2_magic:
mov eax, [STAGE2_LOAD_BASE]
cmp eax, STAGE2_MAGIC_LOWER
jne on_invalid_magic
mov eax, [STAGE2_LOAD_BASE + 4]
cmp eax, STAGE2_MAGIC_UPPER
je off_to_stage2
on_invalid_magic:
mov si, invalid_magic_error
jmp panic
off_to_stage2:
mov sp, STAGE2_LOAD_BASE
; jump to base + 16 to skip stage 2 signature
jmp STAGE2_LOAD_BASE + 16
BITS 16
; void write_string(ds:si string)
; clobbers ax, bx, si
write_string:
; Uses this function: https://stanislavs.org/helppc/int_10-e.html
cld
lodsb
or al, al
jz .done
xor bx, bx
mov ah, 0x0E
int 0x10
jmp write_string
.done:
ret
; [[noreturn]] void panic(ds:si message)
panic:
call write_string
mov si, reboot_msg
call write_string
; https://stanislavs.org/helppc/int_16-0.html
xor ax, ax
int 0x16
; actually reboot
jmp word 0xFFFF:0x0000
DAP_SIZE: equ 16
DAP:
.size: db DAP_SIZE
.unused: db 0x00
.sector_count: dw SECTORS_PER_BATCH
.read_into_offset: dw 0x0000
.read_into_segment: dw 0x0000
.sector_begin_low: dd STAGE2_BASE_SECTOR
.sector_begin_high: dd 0x00000000
CR: equ 0x0D
LF: equ 0x0A
no_lba_support_error: db "This BIOS doesn't support LBA disk access!", CR, LF, 0
disk_error: db "Error reading the disk!", CR, LF, 0
invalid_magic_error: db "Invalid stage 2 loader magic!", CR, LF, 0
reboot_msg: db "Press any key to reboot...", CR, LF, 0
; padding before partition list
times 446 - ($ - $$) db 0
; 4 empty partitions by default
times 16 * 4 db 0
boot_signature: dw 0xAA55
|
experiments/litmus/amd/9/thread.1.asm | phlo/concubine | 0 | 173241 | ADDI 1
STORE 1
FENCE
MEM 1
LOAD 0
|
processor/arch/c64/pre.asm | HakierGrzonzo/bfc64 | 1 | 19983 | <filename>processor/arch/c64/pre.asm
BasicUpstart2(start)
*=$4000 "Program"
// $00FB - pointer to tape page
start:
jsr $ff81
lda #$02
sta $d020
sta $d021
lda #$01
sta $0286
lda #$73
sta $00FB + 1
lda #$00
sta $00FB // memory at is like $00FB to …00 73… so we have a pointer to $7300
ldy #$ff // initialize tape index to 255
|
pwnlib/shellcraft/templates/aarch64/linux/cat2.asm | tkmikan/pwntools | 9 | 13607 | <filename>pwnlib/shellcraft/templates/aarch64/linux/cat2.asm
<%
from pwnlib import shellcraft
%>
<%page args="filename, fd=1, length=0x4000"/>
<%docstring>
Opens a file and writes its contents to the specified file descriptor.
Uses an extra stack buffer and must know the length.
Example:
>>> f = tempfile.mktemp()
>>> write(f, 'This is the flag\n')
>>> shellcode = shellcraft.cat2(f) + shellcraft.exit(0)
>>> run_assembly(shellcode).recvline()
b'This is the flag\n'
</%docstring>
<%
if fd == 'x0':
raise Exception("File descriptor cannot be x0, it will be overwritten")
%>
${shellcraft.open(filename)}
${shellcraft.mov('x2', length)}
sub sp, sp, x2
${shellcraft.read('x0', 'sp', 'x2')}
${shellcraft.write(fd, 'sp', 'x0')}
|
programs/oeis/052/A052954.asm | jmorken/loda | 1 | 243936 | <reponame>jmorken/loda
; A052954: Expansion of (2-x-x^2-x^3)/((1-x)*(1-x^2-x^3)).
; 2,1,2,2,2,3,3,4,5,6,8,10,13,17,22,29,38,50,66,87,115,152,201,266,352,466,617,817,1082,1433,1898,2514,3330,4411,5843,7740,10253,13582,17992,23834,31573,41825,55406,73397,97230,128802,170626,226031,299427,396656,525457,696082,922112,1221538,1618193,2143649,2839730,3761841,4983378,6601570,8745218,11584947,15346787,20330164,26931733,35676950,47261896,62608682,82938845,109870577,145547526,192809421,255418102,338356946,448227522,593775047,786584467,1042002568,1380359513,1828587034,2422362080,3208946546,4250949113,5631308625,7459895658,9882257737,13091204282,17342153394,22973462018,30433357675,40315615411,53406819692,70748973085,93722435102,124155792776,164471408186,217878227877,288627200961,382349636062,506505428837,670976837022,888855064898,1177482265858,1559831901919,2066337330755,2737314167776,3626169232673,4803651498530,6363483400448,8429820731202,11167134898977,14793304131649,19596955630178,25960439030625,34390259761826,45557394660802,60350698792450,79947654422627,105908093453251,140298353215076,185855747875877,246206446668326,326154101090952,432062194544202,572360547759277,758216295635153,1004422742303478,1330576843394429,1762639037938630,2334999585697906,3093215881333058,4097638623636535,5428215467030963,7190854504969592
mov $3,2
mov $5,$0
lpb $3
sub $3,1
add $0,$3
sub $0,1
mov $4,$0
add $4,1
cal $4,23434 ; Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-4).
mov $2,$3
lpb $2
mov $1,$4
sub $2,1
lpe
lpe
lpb $5
sub $1,$4
mov $5,0
lpe
add $1,1
|
src/bintoasc-base32.ads | jhumphry/Ada_BinToAsc | 0 | 18264 | <gh_stars>0
-- BinToAsc.Base32
-- Binary data to ASCII codecs - Base64 codec as in RFC4648
-- Copyright (c) 2015, <NAME> - see LICENSE file for details
generic
Alphabet : Alphabet_32;
Padding : Character;
Case_Sensitive : Boolean;
Allow_Homoglyphs : Boolean;
package BinToAsc.Base32 is
type Base32_To_String is new Codec_To_String with private;
overriding
procedure Reset (C : out Base32_To_String);
overriding
function Input_Group_Size (C : in Base32_To_String) return Positive is (5);
overriding
function Output_Group_Size (C : in Base32_To_String) return Positive is (8);
overriding
procedure Process (C : in out Base32_To_String;
Input : in Bin;
Output : out String;
Output_Length : out Natural)
with Post => (Output_Length = 0 or Output_Length = 8);
overriding
procedure Process (C : in out Base32_To_String;
Input : in Bin_Array;
Output : out String;
Output_Length : out Natural)
with Post => (Output_Length / 8 = Input'Length / 5 or
Output_Length / 8 = Input'Length / 5 + 1);
overriding
procedure Complete (C : in out Base32_To_String;
Output : out String;
Output_Length : out Natural)
with Post => (Output_Length = 0 or Output_Length = 8);
function To_String (Input : in Bin_Array) return String;
type Base32_To_Bin is new Codec_To_Bin with private;
overriding
procedure Reset (C : out Base32_To_Bin);
overriding
function Input_Group_Size (C : in Base32_To_Bin) return Positive is (8);
overriding
function Output_Group_Size (C : in Base32_To_Bin) return Positive is (5);
overriding
procedure Process (C : in out Base32_To_Bin;
Input : in Character;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
with Post => (Output_Length >= 0 and Output_Length <= 5);
overriding
procedure Process (C : in out Base32_To_Bin;
Input : in String;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
with Post => ((Output_Length / 5 >= Input'Length / 8 - 1 and
Output_Length / 5 <= Input'Length / 8 + 1) or
C.State = Failed);
-- Re: the postcondition. If the input is a given number of eight character
-- groups but with the last containing padding, the output may be less than
-- that number of five character groups. As usual, if the codec contained
-- some partially decoded data, the number of output groups can be one more
-- than otherwise expected.
overriding
procedure Complete (C : in out Base32_To_Bin;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
with Post => (Output_Length = 0);
function To_Bin (Input : in String) return Bin_Array;
private
type Base32_Bin_Index is range 0..4;
type Base32_Bin_Buffer is array (Base32_Bin_Index) of Bin;
type Base32_To_String is new Codec_To_String with
record
Next_Index : Base32_Bin_Index := 0;
Buffer : Base32_Bin_Buffer := (others => 0);
end record;
type Base32_Reverse_Index is range 0..7;
type Base32_Reverse_Buffer is array (Base32_Reverse_Index) of Bin;
type Base32_To_Bin is new Codec_To_Bin with
record
Next_Index : Base32_Reverse_Index := 0;
Buffer : Base32_Reverse_Buffer := (others => 0);
Padding_Length : Bin_Array_Index := 0;
end record;
end BinToAsc.Base32;
|
agda-stdlib/src/Relation/Binary/Indexed/Heterogeneous/Structures.agda | DreamLinuxer/popl21-artifact | 5 | 2936 | ------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed binary relations
------------------------------------------------------------------------
-- The contents of this module should be accessed via
-- `Relation.Binary.Indexed.Heterogeneous`.
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Indexed.Heterogeneous.Core
module Relation.Binary.Indexed.Heterogeneous.Structures
{i a ℓ} {I : Set i} (A : I → Set a) (_≈_ : IRel A ℓ)
where
open import Function.Base
open import Level using (suc; _⊔_)
open import Relation.Binary using (_⇒_)
open import Relation.Binary.PropositionalEquality.Core as P using (_≡_)
open import Relation.Binary.Indexed.Heterogeneous.Definitions
------------------------------------------------------------------------
-- Equivalences
record IsIndexedEquivalence : Set (i ⊔ a ⊔ ℓ) where
field
refl : Reflexive A _≈_
sym : Symmetric A _≈_
trans : Transitive A _≈_
reflexive : ∀ {i} → _≡_ ⟨ _⇒_ ⟩ _≈_ {i}
reflexive P.refl = refl
record IsIndexedPreorder {ℓ₂} (_∼_ : IRel A ℓ₂) : Set (i ⊔ a ⊔ ℓ ⊔ ℓ₂) where
field
isEquivalence : IsIndexedEquivalence
reflexive : ∀ {i j} → (_≈_ {i} {j}) ⟨ _⇒_ ⟩ _∼_
trans : Transitive A _∼_
module Eq = IsIndexedEquivalence isEquivalence
refl : Reflexive A _∼_
refl = reflexive Eq.refl
|
src/test/ref/loopnest3.asm | jbrandwood/kickc | 2 | 20156 | <reponame>jbrandwood/kickc<gh_stars>1-10
// Commodore 64 PRG executable file
.file [name="loopnest3.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.label SCREEN = $400
.segment Code
main: {
lda #0
__b1:
// b(i)
jsr b
// for(byte i:0..100)
clc
adc #1
cmp #$65
bne __b1
// }
rts
}
// void b(__register(A) char i)
b: {
// c(i)
jsr c
// }
rts
}
// void c(__register(A) char i)
c: {
ldx #0
__b1:
// SCREEN[j] = i
sta SCREEN,x
// for( byte j: 0..100)
inx
cpx #$65
bne __b1
// }
rts
}
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/derived_type3.adb | best08618/asylo | 7 | 22448 | -- { dg-do run }
with Derived_Type3_Pkg; use Derived_Type3_Pkg;
procedure Derived_Type3 is
begin
Proc1;
Proc2;
end;
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/case_function.ads | ouankou/rose | 488 | 28232 | <reponame>ouankou/rose<gh_stars>100-1000
function Case_Function(X : in Integer) return Integer;
|
programs/oeis/235/A235963.asm | neoneye/loda | 22 | 165191 | <reponame>neoneye/loda
; A235963: n appears (n+1)/(1 + (n mod 2)) times.
; 0,1,2,2,2,3,3,4,4,4,4,4,5,5,5,6,6,6,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15
mul $0,2
mov $1,1
lpb $0
sub $0,$1
sub $1,$2
sub $2,$1
mod $2,2
lpe
sub $1,1
mov $0,$1
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr11_pkg.ads | best08618/asylo | 7 | 29622 | <reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr11_pkg.ads
package Aggr11_Pkg is
type Error_Type is (No_Error, Error);
type Rec (Kind : Error_Type := No_Error) is record
case Kind is
when Error => null;
when others => B : Boolean;
end case;
end record;
type Arr is array (1..6) of Rec;
end Aggr11_Pkg;
|
src/regular-star.agda | shinji-kono/automaton-in-agda | 0 | 4213 | module regular-star where
open import Level renaming ( suc to Suc ; zero to Zero )
open import Data.List
open import Data.Nat hiding ( _≟_ )
open import Data.Fin hiding ( _+_ )
open import Data.Empty
open import Data.Unit
open import Data.Product
-- open import Data.Maybe
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import logic
open import nat
open import automaton
open import regular-language
open import nfa
open import sbconst2
open import finiteSet
open import finiteSetUtil
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import regular-concat
open Automaton
open FiniteSet
open RegularLanguage
Star-NFA : {Σ : Set} → (A : RegularLanguage Σ ) → NAutomaton (states A ) Σ
Star-NFA {Σ} A = record { Nδ = δnfa ; Nend = nend }
module Star-NFA where
δnfa : states A → Σ → states A → Bool
δnfa q i q₁ with aend (automaton A) q
... | true = equal? (afin A) ( astart A) q₁
... | false = equal? (afin A) (δ (automaton A) q i) q₁
nend : states A → Bool
nend q = aend (automaton A) q
Star-NFA-start : {Σ : Set} → (A : RegularLanguage Σ ) → states A → Bool
Star-NFA-start A q = equal? (afin A) (astart A) q \/ aend (automaton A) q
SNFA-exist : {Σ : Set} → (A : RegularLanguage Σ ) → (states A → Bool) → Bool
SNFA-exist A qs = exists (afin A) qs
M-Star : {Σ : Set} → (A : RegularLanguage Σ ) → RegularLanguage Σ
M-Star {Σ} A = record {
states = states A → Bool
; astart = Star-NFA-start A
; afin = fin→ (afin A)
; automaton = subset-construction (SNFA-exist A ) (Star-NFA A )
}
open Split
open _∧_
open NAutomaton
open import Data.List.Properties
closed-in-star : {Σ : Set} → (A B : RegularLanguage Σ ) → ( x : List Σ ) → isRegular (Star (contain A) ) x ( M-Star A )
closed-in-star {Σ} A B x = ≡-Bool-func closed-in-star→ closed-in-star← where
NFA = (Star-NFA A )
closed-in-star→ : Star (contain A) x ≡ true → contain (M-Star A ) x ≡ true
closed-in-star→ star = {!!}
open Found
closed-in-star← : contain (M-Star A ) x ≡ true → Star (contain A) x ≡ true
closed-in-star← C with subset-construction-lemma← (SNFA-exist A ) NFA {!!} x C
... | CC = {!!}
|
source/web/tools/a2js/properties-definitions-record_type.adb | svn2github/matreshka | 24 | 24249 | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-2018, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Asis.Elements;
with Asis.Declarations;
with Asis.Definitions;
with Properties.Tools;
package body Properties.Definitions.Record_Type is
---------------
-- Alignment --
---------------
function Alignment
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Integer_Property) return Integer
is
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Element);
Result : Integer := 1;
Down : Integer;
begin
for J in List'Range loop
Down := Engine.Integer.Get_Property (List (J), Name);
Result := Integer'Max (Result, Down);
end loop;
return Result;
end Alignment;
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
Decl : constant Asis.Declaration :=
Asis.Elements.Enclosing_Element (Element);
Is_Array_Buffer : constant Boolean :=
Properties.Tools.Is_Array_Buffer (Decl);
Result : League.Strings.Universal_String;
Size : League.Strings.Universal_String;
begin
Result.Append ("(function (){"); -- Wrapper
Result.Append ("var _result = function ("); -- Type constructor
-- Declare type's discriminant
declare
List : constant Asis.Discriminant_Association_List :=
Properties.Tools.Corresponding_Type_Discriminants (Element);
begin
for J in List'Range loop
declare
Id : League.Strings.Universal_String;
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
begin
for N in Names'Range loop
Id := Engine.Text.Get_Property (Names (N), Name);
Result.Append (Id);
if J /= List'Last or N /= Names'Last then
Result.Append (",");
end if;
end loop;
end;
end loop;
Result.Append ("){");
if Is_Array_Buffer then
Size := Engine.Text.Get_Property (Element, Engines.Size);
Result.Append ("this.A = new ArrayBuffer(");
Result.Append (Size);
Result.Append ("/8);");
Result.Append ("this._u8 = new Uint8Array(this.A);");
Result.Append ("this._f32 = new Float32Array(this.A);");
end if;
-- Copy type's discriminant
for J in List'Range loop
declare
Id : League.Strings.Universal_String;
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
Init : constant Asis.Expression :=
Asis.Declarations.Initialization_Expression (List (J));
begin
for N in Names'Range loop
Id := Engine.Text.Get_Property (Names (N), Name);
if not Asis.Elements.Is_Nil (Init) then
Result.Append ("if (typeof ");
Result.Append (Id);
Result.Append ("=== 'undefined')");
Result.Append (Id);
Result.Append ("=");
Result.Append (Engine.Text.Get_Property (Init, Name));
Result.Append (";");
end if;
Result.Append ("this.");
Result.Append (Id);
Result.Append (" = ");
Result.Append (Id);
Result.Append (";");
end loop;
end;
end loop;
end;
-- Initialize type's components
declare
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Element);
begin
for J in List'Range loop
declare
Id : League.Strings.Universal_String;
Init : constant Asis.Expression :=
Asis.Declarations.Initialization_Expression (List (J));
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
Value : League.Strings.Universal_String;
begin
if not Asis.Elements.Is_Nil (Init) then
Value := Engine.Text.Get_Property (Init, Name);
end if;
for N in Names'Range loop
Id := Engine.Text.Get_Property (Names (N), Name);
Result.Append ("this.");
Result.Append (Id);
Result.Append (" = ");
if Asis.Elements.Is_Nil (Init) then
Result.Append
(Engine.Text.Get_Property
(List (J), Engines.Initialize));
else
Result.Append (Value);
end if;
Result.Append (";");
end loop;
end;
end loop;
end;
Result.Append ("};"); -- End of constructor
-- Limited types should also have _cast, so we need _assign
-- Update prototype with _assign
Result.Append ("_result.prototype._assign = function(src){");
declare
Down : League.Strings.Universal_String;
Def : constant Asis.Definition :=
Asis.Definitions.Record_Definition (Element);
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Def);
begin
Down := Engine.Text.Get_Property
(List => List,
Name => Engines.Assign,
Empty => League.Strings.Empty_Universal_String,
Sum => Properties.Tools.Join'Access);
Result.Append (Down);
Result.Append ("};"); -- End of _assign
end;
Result.Append ("_result._cast = function _cast (value){");
Result.Append ("var result = new _result(");
declare
Down : League.Strings.Universal_String;
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Discriminants (Element);
begin
for J in List'Range loop
declare
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
begin
for K in Names'Range loop
Down := Engine.Text.Get_Property (Names (K), Name);
Result.Append ("value.");
Result.Append (Down);
if K /= Names'Last or J /= List'Last then
Result.Append (",");
end if;
end loop;
end;
end loop;
end;
Result.Append (");");
Result.Append ("result._assign (value);");
Result.Append ("return result;");
Result.Append ("};");
Result.Append ("var props = {};");
declare
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Element);
Prev : League.Strings.Universal_String;
begin
Prev.Append ("0");
for J in List'Range loop
declare
Id : League.Strings.Universal_String;
Comp : constant Asis.Definition :=
Asis.Declarations.Object_Declaration_View (List (J));
Def : constant Asis.Definition :=
Asis.Definitions.Component_Definition_View (Comp);
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
Down : League.Strings.Universal_String;
Comp_Size : League.Strings.Universal_String;
Is_Simple_Type : Boolean;
begin
if Is_Array_Buffer then
Comp_Size := Engine.Text.Get_Property
(List (J), Engines.Size);
Is_Simple_Type := Engine.Boolean.Get_Property
(Def, Engines.Is_Simple_Type);
if Is_Simple_Type then
Down := Engine.Text.Get_Property
(Def, Engines.Typed_Array_Item_Type);
else
Down := Engine.Text.Get_Property (Def, Name);
end if;
end if;
for N in Names'Range loop
Id := Engine.Text.Get_Property (Names (N), Name);
Result.Append ("props._pos_");
Result.Append (Id);
Result.Append ("={value: ");
if Is_Array_Buffer then
Result.Append (Prev);
Result.Append ("};");
Result.Append ("props._size_");
Result.Append (Id);
Result.Append ("={value: ");
Result.Append (Comp_Size);
Result.Append ("}; props.");
Result.Append (Id);
Result.Append ("= {get: function(){ return ");
if Is_Simple_Type then
Result.Append ("this.");
Result.Append (Down);
Result.Append ("[");
Result.Append ("this._pos_");
Result.Append (Id);
Result.Append ("*8/this._size_");
Result.Append (Id);
Result.Append ("]");
else
Result.Append (Down);
Result.Append (".prototype._from_dataview (");
Result.Append ("new DataView (this.A,");
Result.Append ("this._u8.byteOffset+this._pos_");
Result.Append (Id);
Result.Append (",this._size_");
Result.Append (Id);
Result.Append ("/8))");
end if;
Result.Append (";},");
Result.Append ("set: function(_v){ ");
if Is_Simple_Type then
Result.Append ("this.");
Result.Append (Down);
Result.Append ("[");
Result.Append ("this._pos_");
Result.Append (Id);
Result.Append ("*8/this._size_");
Result.Append (Id);
Result.Append ("]=_v");
else
Result.Append (Down);
Result.Append (".prototype._from_dataview (");
Result.Append ("new DataView (this.A,");
Result.Append ("this._u8.byteOffset+this._pos_");
Result.Append (Id);
Result.Append (",this._size_");
Result.Append (Id);
Result.Append ("/8))._assign(_v)");
end if;
Result.Append (";}};");
Prev.Clear;
Prev.Append ("props._pos_");
Prev.Append (Id);
Prev.Append (".value+props._size_");
Prev.Append (Id);
Prev.Append (".value/8");
else
Result.Append ("'");
Result.Append (Id);
Result.Append ("'};");
end if;
end loop;
end;
end loop;
end;
Result.Append ("Object.defineProperties(_result.prototype, props);");
if Is_Array_Buffer then
-- Set _from_dataview
Result.Append
("_result._from_dataview = function _from_dataview(_u8){");
Result.Append ("var result = Object.create (_result.prototype);");
Result.Append ("result.A = _u8.buffer;");
Result.Append
("result._f32 = new Float32Array(_u8.buffer,_u8.byteOffset,");
Result.Append (Size);
Result.Append ("/8/4);");
Result.Append ("result._u8 = _u8;");
Result.Append ("return result;");
Result.Append ("};"); -- End of _from_dataview
end if;
Result.Append ("return _result;");
Result.Append ("})();"); -- End of Wrapper and call it
return Result;
end Code;
----------------
-- Initialize --
----------------
function Initialize
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property)
return League.Strings.Universal_String
is
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Element);
Text : League.Strings.Universal_String;
Down : League.Strings.Universal_String;
begin
Text.Append ("{");
for J in List'Range loop
declare
Id : League.Strings.Universal_String;
Names : constant Asis.Defining_Name_List :=
Asis.Declarations.Names (List (J));
begin
Down := Engine.Text.Get_Property (List (J), Name);
for N in Names'Range loop
Id := Engine.Text.Get_Property (Names (N), Engines.Code);
Text.Append (Id);
Text.Append (":");
Text.Append (Down);
if N /= Names'Last then
Text.Append (",");
end if;
end loop;
if J /= List'Last then
Text.Append (",");
end if;
end;
end loop;
Text.Append ("}");
return Text;
end Initialize;
----------
-- Size --
----------
function Size
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
List : constant Asis.Declaration_List :=
Properties.Tools.Corresponding_Type_Components (Element);
Result : League.Strings.Universal_String;
Down : League.Strings.Universal_String;
begin
Result.Append ("(0");
for J in List'Range loop
Down := Engine.Text.Get_Property (List (J), Name);
Result.Append ("+");
Result.Append (Down);
end loop;
Result.Append (")");
return Result;
end Size;
end Properties.Definitions.Record_Type;
|
demo/tutorial/engines.adb | csb6/libtcod-ada | 0 | 11520 | <reponame>csb6/libtcod-ada<filename>demo/tutorial/engines.adb
with Ada.Numerics.Discrete_Random, Ada.Assertions;
with Libtcod.Maps.BSP, Libtcod.Color;
package body Engines is
use Ada.Assertions;
use type Maps.X_Pos, Maps.Y_Pos;
Max_Monsters_Per_Room : constant := 3;
Max_Room_Size : constant := 12;
Min_Room_Size : constant := 6;
function get_actor(self : in out Engine; id : Actor_Id) return Actor_Ref is
(self.actor_list.Reference(id));
function player(self : in out Engine) return Actor_Ref is (self.get_actor(self.player_id));
type Random_Int is new Natural;
package Natural_Random is new Ada.Numerics.Discrete_Random(Random_Int);
use Natural_Random;
rand_nat_gen : Natural_Random.Generator;
function one_of_n_chance(n : Random_Int) return Boolean is
(Random(rand_nat_gen) mod n = 0);
function k_of_n_chance(k, n : Random_Int) return Boolean is
(Random(rand_nat_gen) mod n < k);
generic
type A is range <>;
type B is range <>;
function generic_rand_range(start_n : A; end_n : B) return Random_Int;
function generic_rand_range(start_n : A; end_n : B) return Random_Int is
(Random(rand_nat_gen) mod (Random_Int(end_n) - Random_Int(start_n)) + Random_Int(start_n));
function rand_range is new generic_rand_range(Random_Int, Random_Int);
function rand_range is new generic_rand_range(Maps.X_Pos, Maps.X_Pos);
function rand_range is new generic_rand_range(Maps.X_Pos, Width);
function rand_range is new generic_rand_range(Maps.Y_Pos, Maps.Y_Pos);
function rand_range is new generic_rand_range(Maps.Y_Pos, Height);
--------------
-- can_walk --
--------------
function can_walk(self : Engine; x : Maps.X_Pos; y : Maps.Y_Pos) return Boolean is
begin
if self.map.is_wall(x, y) then
return False;
end if;
for a of self.actor_list loop
if a.x = x and then a.y = y and then a.blocks then
-- Actor is present, cannot walk here
return False;
end if;
end loop;
return True;
end can_walk;
-----------------
-- add_monster --
-----------------
procedure add_monster(self : in out Engine; x : Maps.X_Pos; y : Maps.Y_Pos) is
begin
if k_of_n_chance(k => 80, n => 100) then
self.actor_list.Append(Actors.make_orc(x, y));
else
self.actor_list.Append(Actors.make_troll(x, y));
end if;
end add_monster;
-----------------
-- create_room --
-----------------
procedure create_room(self : in out Engine; first : Boolean;
x1 : Maps.X_Pos; y1 : Maps.Y_Pos;
x2 : Maps.X_Pos; y2 : Maps.Y_Pos) is
monster_count : Random_Int := rand_range(Random_Int'(0), Max_Monsters_Per_Room);
monster_x : Maps.X_Pos;
monster_y : Maps.Y_Pos;
begin
self.map.dig(x1, y1, x2, y2);
if first then
self.player.x := (x1+x2) / 2;
self.player.y := (y1+y2) / 2;
elsif one_of_n_chance(n => 4) then
for i in 1 .. monster_count loop
monster_x := Maps.X_Pos(rand_range(x1, x2));
monster_y := Maps.Y_Pos(rand_range(y1, y2));
if self.can_walk(monster_x, monster_y) then
self.add_monster(monster_x, monster_y);
end if;
end loop;
end if;
end create_room;
---------------
-- setup_map --
---------------
procedure setup_map(self : in out Engine) is
use Maps, Maps.BSP;
bsp_builder : BSP_Tree := make_BSP(0, 0, Width(self.map.width), Height(self.map.height));
room_num : Natural := 0;
last_x : Maps.X_Pos;
last_y : Maps.Y_Pos;
function visit(node : in out BSP_Node) return Boolean is
x : Maps.X_Pos;
y : Maps.Y_Pos;
w : Width;
h : Height;
begin
if node.is_leaf then
w := Width(rand_range(Min_Room_Size, node.w-2));
h := Height(rand_range(Min_Room_Size, node.h-2));
x := X_Pos(rand_range(node.x+X_Pos'(1), Width(node.x)+node.w-w-1));
y := Y_Pos(rand_range(node.y+Y_Pos'(1), Height(node.y)+node.h-h-1));
self.create_room(room_num = 0, x, y, x+X_Pos(w)-1, y+Y_Pos(h)-1);
if room_num /= 0 then
self.map.dig(last_x, last_y, x+X_Pos(w)/2, last_y);
self.map.dig(x+X_Pos(w)/2, last_y, x+X_Pos(w)/2, y+Y_Pos(h)/2);
end if;
last_x := x+X_Pos(w)/2;
last_y := y+Y_Pos(h)/2;
room_num := room_num + 1;
end if;
return True;
end visit;
not_exited_early : Boolean;
begin
bsp_builder.split_recursive(recursion_level => 8,
min_w => Max_Room_Size, min_h => Max_Room_Size,
min_wh_ratio => 1.5, min_hw_ratio => 1.5);
not_exited_early := bsp_builder.traverse_inverted_level_order(visit'Access);
Assert(not_exited_early);
-- Calcluate player's initial FOV
self.map.compute_fov(self.player.x, self.player.y, self.fov_radius);
end setup_map;
-----------------
-- make_engine --
-----------------
function make_engine(w : Libtcod.Width; h : Libtcod.Height) return Engine is
begin
return self : Engine := (width => Maps.X_Pos(w), height => Maps.Y_Pos(h),
map => make_game_map(w, h-GUIs.Panel_Height),
player_id => Actor_Id'First,
status => Status_Idle,
fov_radius => 10,
gui => GUIs.make_GUI(w),
others => <>) do
self.actor_list.Append(make_player(60, 13, "Player",
defense_stat => 2, power => 5,
hp => 30, max_hp => 30));
self.gui.log("Welcome stranger!" & ASCII.LF
& "Prepare to perish in the Tombs of the" & ASCII.LF
& "Ancient Kings", Libtcod.Color.red);
setup_map(self);
end return;
end make_engine;
------------
-- update --
------------
procedure update(self : in out Engine) is
use Input;
use type Input.Event_Type;
k : aliased Key;
event_kind : Event_Type := Input.check_for_event(Event_Key_Press, k);
last_key_type : Key_Type;
begin
if event_kind /= Event_Key_Press then
return;
end if;
last_key_type := get_key_type(k);
if last_key_type not in Valid_Key_Type then
return;
end if;
self.last_key_type := last_key_type;
self.status := Status_Idle;
for each of self.actor_list loop
each.update(self);
end loop;
end update;
------------
-- render --
------------
procedure render(self : in out Engine; screen : in out Console.Screen) is
begin
screen.clear;
self.map.render(screen);
for each of reverse self.actor_list loop
if self.map.in_fov(each.x, each.y) then
each.render(screen);
end if;
end loop;
self.gui.render(screen, self);
end render;
end Engines;
|
msp430x2/msp430g2452/svd/msp430_svd-interrupts.ads | ekoeppen/MSP430_Generic_Ada_Drivers | 0 | 18793 | -- This spec has been automatically generated from out.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package MSP430_SVD.INTERRUPTS is
pragma Preelaborate;
-----------------
-- Peripherals --
-----------------
type INTERRUPTS_Peripheral is record
end record
with Volatile;
for INTERRUPTS_Peripheral use record
end record;
INTERRUPTS_Periph : aliased _INTERRUPTS_Peripheral
with Import, Address => _INTERRUPTS_Base;
end MSP430_SVD.INTERRUPTS;
|
src/drivers/ado-drivers.ads | My-Colaborations/ada-ado | 0 | 4637 | -----------------------------------------------------------------------
-- ADO Drivers -- Database Drivers
-- Copyright (C) 2010, 2011, 2012, 2013, 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Properties;
-- == Database Drivers ==
-- Database drivers provide operations to access the database. These operations are
-- specific to the database type and the `ADO.Drivers` package among others provide
-- an abstraction that allows to make the different databases look like they have almost
-- the same interface.
--
-- A database driver exists for SQLite, MySQL and PostgreSQL. The driver
-- is either statically linked to the application or it can be loaded dynamically if it was
-- built as a shared library. For a dynamic load, the driver shared library name must be
-- prefixed by `libada_ado_`. For example, for a `mysql` driver, the shared
-- library name is `libada_ado_mysql.so`.
--
-- | Driver name | Database |
-- | ----------- | --------- |
-- | mysql | MySQL, MariaDB |
-- | sqlite | SQLite |
-- | postgresql | PostgreSQL |
--
-- The database drivers are initialized automatically but in some cases, you may want
-- to control some database driver configuration parameter. In that case,
-- the initialization must be done only once before creating a session
-- factory and getting a database connection. The initialization can be made using
-- a property file which contains the configuration for the database drivers and
-- the database connection properties. For such initialization, you will have to
-- call one of the `Initialize` operation from the `ADO.Drivers` package.
--
-- ADO.Drivers.Initialize ("db.properties");
--
-- The set of configuration properties can be set programatically and passed to the
-- `Initialize` operation.
--
-- Config : Util.Properties.Manager;
-- ...
-- Config.Set ("ado.database", "sqlite:///mydatabase.db");
-- Config.Set ("ado.queries.path", ".;db");
-- ADO.Drivers.Initialize (Config);
--
-- Once initialized, a configuration property can be retrieved by using the `Get_Config`
-- operation.
--
-- URI : constant String := ADO.Drivers.Get_Config ("ado.database");
--
-- Dynamic loading of database drivers is disabled by default for security reasons and
-- it can be enabled by setting the following property in the configuration file:
--
-- ado.drivers.load=true
--
-- Dynamic loading is triggered when a database connection string refers to a database
-- driver which is not known.
--
-- @include ado-mysql.ads
-- @include ado-sqlite.ads
-- @include ado-postgresql.ads
package ADO.Drivers is
-- Initialize the drivers and the library by reading the property file
-- and configure the runtime with it.
procedure Initialize (Config : in String);
-- Initialize the drivers and the library and configure the runtime with the given properties.
procedure Initialize (Config : in Util.Properties.Manager'Class);
-- Initialize the drivers which are available.
procedure Initialize;
end ADO.Drivers;
|
src/sys/os-win64/util-systems-types.ads | RREE/ada-util | 60 | 17221 | <filename>src/sys/os-win64/util-systems-types.ads
-- Generated by utildgen.c from system includes
with Interfaces.C;
package Util.Systems.Types is
subtype dev_t is Interfaces.C.unsigned;
subtype ino_t is Interfaces.C.unsigned_short;
subtype off_t is Long_Long_Integer;
subtype uid_t is Interfaces.C.unsigned_short;
subtype gid_t is Interfaces.C.unsigned_short;
subtype nlink_t is Interfaces.C.unsigned_short;
subtype mode_t is Interfaces.C.unsigned_short;
S_IFMT : constant mode_t := 8#00170000#;
S_IFDIR : constant mode_t := 8#00040000#;
S_IFCHR : constant mode_t := 8#00020000#;
S_IFBLK : constant mode_t := 8#00030000#;
S_IFREG : constant mode_t := 8#00100000#;
S_IFIFO : constant mode_t := 8#00010000#;
S_IFLNK : constant mode_t := 8#00000000#;
S_IFSOCK : constant mode_t := 8#00000000#;
S_ISUID : constant mode_t := 8#00000000#;
S_ISGID : constant mode_t := 8#00000000#;
S_IREAD : constant mode_t := 8#00000400#;
S_IWRITE : constant mode_t := 8#00000200#;
S_IEXEC : constant mode_t := 8#00000100#;
-- The windows HANDLE is defined as a void* in the C API.
subtype HANDLE is Interfaces.C.ptrdiff_t;
subtype File_Type is HANDLE;
subtype Time_Type is Long_Long_Integer;
type Timespec is record
tv_sec : Time_Type;
end record;
pragma Convention (C_Pass_By_Copy, Timespec);
type Seek_Mode is (SEEK_SET, SEEK_CUR, SEEK_END);
for Seek_Mode use (SEEK_SET => 0, SEEK_CUR => 1, SEEK_END => 2);
type Stat_Type is record
st_dev : dev_t;
st_ino : ino_t;
st_mode : mode_t;
st_nlink : nlink_t;
st_uid : uid_t;
st_gid : gid_t;
st_rdev : dev_t;
st_size : off_t;
st_atime : Time_Type;
st_mtime : Time_Type;
st_ctime : Time_Type;
end record;
pragma Convention (C_Pass_By_Copy, Stat_Type);
end Util.Systems.Types;
|
src/implementation/yaml-events-queue.adb | persan/AdaYaml | 32 | 22605 | -- part of AdaYaml, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "copying.txt"
package body Yaml.Events.Queue is
procedure Adjust (Object : in out Reference) is
begin
Increase_Refcount (Object.Data);
end Adjust;
procedure Finalize (Object : in out Reference) is
begin
Decrease_Refcount (Object.Data);
end Finalize;
procedure Copy_Data (Source : Instance;
Target : not null Event_Array_Access) is
begin
Target (1 .. Source.Data.all'Last - Source.First_Pos + 1) :=
Source.Data (Source.First_Pos .. Source.Data.all'Last);
Target (Source.Data.all'Last - Source.First_Pos + 2 ..
Source.Data.all'Last) :=
Source.Data (1 .. Source.First_Pos - 1);
end Copy_Data;
procedure Append (Object : in out Instance; E : Event) is
Position : Mark;
begin
Append (Object, E, Position);
end Append;
function Next_Index (Object : Instance) return Positive is
(((Object.First_Pos + Object.Length - 1) mod
Object.Data.all'Length) + 1);
procedure Append (Object : in out Instance; E : Event; Position : out Mark)
is begin
if Object.Stream_Count > 0 then
raise State_Error with
"cannot manipulate event queue while a Stream_Instance exists";
end if;
if Object.Length = Object.Data.all'Length then
Object.Grow;
Object.First_Pos := 1;
end if;
Position := Mark (Next_Index (Object));
Object.Data (Positive (Position)) := E;
Object.Length := Object.Length + 1;
end Append;
function Length (Object : in Instance) return Natural is
(Object.Length);
function Length (Object : Reference) return Natural is
(Object.Data.Length);
function First (Object : in Instance) return Event is
begin
if Object.Length = 0 then
raise Constraint_Error with "no items in event queue";
end if;
return Object.Data (Object.First_Pos);
end First;
procedure Dequeue (Object : in out Instance) is
begin
if Object.Stream_Count > 0 then
raise State_Error with
"cannot manipulate event queue while a Stream_Instance exists";
elsif Object.Length = 0 then
raise Constraint_Error with "no items in event queue";
end if;
Object.Length := Object.Length - 1;
Object.First_Pos := Object.First_Pos + 1;
if Object.First_Pos > Object.Data.all'Last then
Object.First_Pos := 1;
end if;
end Dequeue;
function Value (Object : Reference) return Accessor is
((Data => Object.Data));
function New_Queue return Reference is
Ptr : constant not null Instance_Access := new Instance;
begin
return Reference'(Ada.Finalization.Controlled with Data => Ptr);
end New_Queue;
function Element (Object : Instance; Position : Mark)
return Element_Accessor is
Index : constant Positive := Positive (Position);
begin
if Index < Object.First_Pos and then Index >= Next_Index (Object) then
raise State_Error with "no element at this index";
end if;
return (Data => Object.Data (Index)'Unrestricted_Access);
end Element;
function As_Stream (Object : Reference'Class) return Stream_Reference is
Ptr : constant not null Stream_Instance_Access :=
new Stream_Instance'(Refcount_Base with Buffer => Reference (Object),
Offset => 0);
begin
Ptr.Buffer.Data.Stream_Count := Ptr.Buffer.Data.Stream_Count + 1;
return Stream_Reference'(Ada.Finalization.Controlled with
Data => Ptr);
end As_Stream;
function Value (Object : Stream_Reference) return Stream_Accessor is
((Data => Object.Data));
function Value (Object : Optional_Stream_Reference) return Stream_Accessor is
((Data => Object.Data));
function Next (Object : in out Stream_Instance) return Event is
Index : constant Positive :=
(Object.Buffer.Data.First_Pos + Object.Offset) mod
Object.Buffer.Data.Data.all'Last;
begin
if Object.Offset = Object.Buffer.Data.Length then
raise Constraint_Error with
"Tried to query more events than in queue";
else
return E : constant Event := Object.Buffer.Data.Data (Index) do
Object.Offset := Object.Offset + 1;
end return;
end if;
end Next;
function Required (Object : Optional_Stream_Reference'Class)
return Stream_Reference is
begin
Object.Data.Increase_Refcount;
return (Ada.Finalization.Controlled with Data => Object.Data);
end Required;
function Optional (Object : Stream_Reference'Class)
return Optional_Stream_Reference is
begin
Object.Data.Increase_Refcount;
return (Ada.Finalization.Controlled with Data => Object.Data);
end Optional;
procedure Finalize (Object : in out Stream_Instance) is
begin
Object.Buffer.Data.Stream_Count := Object.Buffer.Data.Stream_Count - 1;
end Finalize;
overriding procedure Adjust (Object : in out Stream_Reference) is
begin
Increase_Refcount (Object.Data);
end Adjust;
procedure Finalize (Object : in out Stream_Reference) is
begin
Decrease_Refcount (Object.Data);
end Finalize;
overriding procedure Adjust (Object : in out Optional_Stream_Reference) is
begin
if Object.Data /= null then
Increase_Refcount (Object.Data);
end if;
end Adjust;
procedure Finalize (Object : in out Optional_Stream_Reference) is
begin
if Object.Data /= null then
Decrease_Refcount (Object.Data);
end if;
end Finalize;
end Yaml.Events.Queue;
|
org.alloytools.alloy.diff/misc/multiplicities/oneBank.als | jringert/alloy-diff | 1 | 965 | <gh_stars>1-10
module oneBank
sig addr{}
one sig Bank{
s: one addr
}
|
memsim-master/src/distribution.ads | strenkml/EE368 | 0 | 25833 |
with Ada.Numerics.Discrete_Random;
with Ada.Containers.Vectors;
use Ada.Containers;
with Applicative; use Applicative;
with Util; use Util;
-- Package containing functions for generating random numbers.
package Distribution is
-- Type to represent a random distribution.
type Distribution_Type is limited private;
type Distribution_Pointer is access all Distribution_Type;
-- Set the seed used for selecting random addresses.
procedure Set_Seed(dist : in out Distribution_Type;
seed : in Integer);
-- Insert an address to the pool.
-- This should be called the first time a trace is executed.
procedure Insert(dist : in out Distribution_Type;
address : in Address_Type;
size : in Positive);
-- Push an address limit on to the stack.
-- This is done when evaluating a part of a split or scratchpad.
-- Only addresses within this limit will be selected at random.
procedure Push_Limit(dist : in out Distribution_Type;
lower : in Address_Type;
upper : in Address_Type);
-- Pop an address limit off of the stack.
procedure Pop_Limit(dist : in out Distribution_Type);
-- Push an address transform on to the stack.
-- This is done when evaluating an address transform or split.
procedure Push_Transform(dist : in out Distribution_Type;
trans : in Applicative_Pointer);
-- Pop an address transform off of the stack.
procedure Pop_Transform(dist : in out Distribution_Type);
-- Select a random address from the distribution.
function Random_Address(dist : Distribution_Type;
alignment : Positive) return Address_Type;
-- Select a uniform random number.
function Random(dist : Distribution_Type) return Natural;
-- Display address ranges (for debugging).
procedure Print(dist : in Distribution_Type);
private
type Range_Type is record
start : Address_Type;
size : Positive;
end record;
type Limit_Type is record
trans : Applicative_Pointer := null;
lower : Address_Type := 0;
upper : Address_Type := 0;
end record;
package RNG is new Ada.Numerics.Discrete_Random(Natural);
package Range_Vectors is new Vectors(Positive, Range_Type);
package Limit_Vectors is new Vectors(Positive, Limit_Type);
type Distribution_Type is limited record
generator : RNG.Generator;
ranges : Range_Vectors.Vector;
limits : Limit_Vectors.Vector;
end record;
end Distribution;
|
MOS3/TestProgram/test.asm | Mishin870/MOS | 1 | 166350 | <reponame>Mishin870/MOS
use32
;mov dx, 0x3F8
;mov al, 'c'
;out dx, al
;int 30h
qwe:
jmp qwe |
src/Data/List/Relation/Binary/Subset/Propositional/Instances.agda | johnyob/agda-union | 0 | 8401 | <reponame>johnyob/agda-union
module Data.List.Relation.Binary.Subset.Propositional.Instances where
open import Data.List using (List; _∷_; [])
open import Data.List.Relation.Unary.Any using (here; there)
open import Data.List.Membership.Propositional using (_∈_; _∉_)
open import Data.List.Membership.Setoid.Properties using (∈-resp-≈)
open import Data.List.Relation.Binary.Subset.Propositional using (_⊆_)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary.PropositionalEquality using (sym; setoid)
open import Level using (Level)
private
variable
a : Level
A : Set a
x y : A
xs ys : List A
-- ----------------------------------------------------------------------
-- Wrapped subset. Could use Data.Wrap but required curried arguments
-- Easier to define specific data type.
infix 4 ⦅_⊆_⦆
data ⦅_⊆_⦆ {a} {A : Set a} : List A → List A → Set a where
[_] : xs ⊆ ys → ⦅ xs ⊆ ys ⦆
proj : ⦅ xs ⊆ ys ⦆ → xs ⊆ ys
proj [ xs⊆ys ] = xs⊆ys
-- ----------------------------------------------------------------------
-- Lemmas used for instance searching
x∉[] : x ∉ []
x∉[] = λ ()
[]⊆xs : [] ⊆ xs
[]⊆xs = λ x∈[] → contradiction x∈[] x∉[]
xs⊆x∷xs : xs ⊆ x ∷ xs
xs⊆x∷xs = there
xs⊆ys⇒x∷xs⊆x∷ys : xs ⊆ ys → x ∷ xs ⊆ x ∷ ys
xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (here y≡x) = here y≡x
xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys (there y∈x∷xs) = there (xs⊆ys y∈x∷xs)
x∈ys-xs⊆ys⇒x∷xs⊆ys : x ∈ ys → xs ⊆ ys → x ∷ xs ⊆ ys
x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (here y≡x) = ∈-resp-≈ (setoid _) (sym y≡x) x∈ys
x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys (there y∈x∷xs) = xs⊆ys y∈x∷xs
-- ----------------------------------------------------------------------
-- Instances
instance
⦃[]⊆xs⦄ : ⦅ [] ⊆ xs ⦆
⦃[]⊆xs⦄ = [ []⊆xs ]
-- Removed to improve instance search, syntax directed.
-- ⦃xs⊆x∷xs⦄ : ⦅ xs ⊆ x ∷ xs ⦆
-- ⦃xs⊆x∷xs⦄ = [ xs⊆x∷xs ]
-- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ : ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ x ∷ ys ⦆
-- ⦃xs⊆ys⇒x∷xs⊆x∷ys⦄ ⦃ [ xs⊆ys ] ⦄ = [ xs⊆ys⇒x∷xs⊆x∷ys xs⊆ys ]
⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ : ⦃ x ∈ ys ⦄ → ⦃ ⦅ xs ⊆ ys ⦆ ⦄ → ⦅ x ∷ xs ⊆ ys ⦆
⦃x∈ys-xs⊆ys⇒x∷xs⊆ys⦄ ⦃ x∈ys ⦄ ⦃ [ xs⊆ys ] ⦄ = [ x∈ys-xs⊆ys⇒x∷xs⊆ys x∈ys xs⊆ys ]
|
Appl/Games/Amateur/amateurContent.asm | steakknife/pcgeos | 504 | 9253 | <gh_stars>100-1000
COMMENT @----------------------------------------------------------------------
PROJECT: Amateur Night
MODULE: amateurContent
FILE: amateurContent.asm
AUTHOR: <NAME>
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91
DESCRIPTION:
This file contains code to implement the "Content" object of
peanut command. This object receives input from the UI
and performs the appropriate action / routing to the visible
objects
$Id: amateurContent.asm,v 1.1 97/04/04 15:12:27 newdeal Exp $
-----------------------------------------------------------------------------@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentRelocate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Relocate the clown moniker list
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentRelocate method dynamic AmateurContentClass,
reloc
uses ax,cx,dx,bp
.enter
call HackApp_RelocOrUnReloc
.leave
mov di, offset AmateurContentClass
call ObjRelocOrUnRelocSuper
ret
ContentRelocate endm
COMMENT @---------------------------------------------------------------------
ContentInitialize
------------------------------------------------------------------------------
SYNOPSIS: Setup the Content object and the gameObjects block
with proper data -- set the mouse pointer
CALLED BY: ProcessClass on UI_OPEN_APPLICATION
PASS:
RETURN: nothing
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentInitialize method dynamic AmateurContentClass,
MSG_CONTENT_INITIALIZE
call CalcClownSize
; Set monikers for clowns
call ContentSetClownMonikers
; Read the joke file
call ContentReadJokeFile
; create movable objects
call CreateObjects
; Set the mouse pointer image
push si
mov cx, handle mousePtr
mov dx, offset mousePtr
mov ax, MSG_GEN_VIEW_SET_PTR_IMAGE
clr di
mov bx, handle AmateurView
mov si, offset AmateurView
call ObjMessage
pop si
; Init the starting level
mov di, ds:[si]
add di, ds:[di].Vis_offset
mov ds:[di].ACI_startAct, 1
call DisplayAct
; Reset the score and pellets left displays (to deal with
; restarting from state).
call ContentDisplayScore
call ContentDisplayPelletsLeft
clr cl
call EnableTriggers
; Figure out the deal...
mov ax,MSG_GEN_APPLICATION_GET_DISPLAY_SCHEME
call GenCallApplication
mov es:[displayType], ah
mov ax, MSG_CLOWN_SET_STATUS
mov cl, CS_ALIVE
call CallAllClowns
call SetColorInfo
call FindMonikers
ret
ContentInitialize endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSetStartAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Set the starting act for future games
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSetStartAct method dynamic AmateurContentClass,
MSG_CONTENT_SET_START_ACT
mov ds:[di].ACI_startAct, dx
ret
ContentSetStartAct endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentCancelSetStartAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Cancel setting the starting act for future games
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentCancelSetStartAct method dynamic AmateurContentClass,
MSG_CONTENT_CANCEL_SET_START_ACT
clr bp ;not indeterminate
mov cx,ds:[di].ACI_startAct
mov bx,handle SetLevelRange
mov si,offset SetLevelRange
mov di,mask MF_FIXUP_DS
mov ax,MSG_GEN_VALUE_SET_INTEGER_VALUE
call ObjMessage
clr cx ;not modified
mov di,mask MF_FIXUP_DS
mov ax,MSG_GEN_VALUE_SET_MODIFIED_STATE
call ObjMessage
mov bx,handle SetLevelInteraction
mov si,offset SetLevelInteraction
mov di,mask MF_FIXUP_DS
mov ax,MSG_GEN_MAKE_NOT_APPLYABLE
call ObjMessage
ret
ContentCancelSetStartAct endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentPauseGame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Pause the game
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN: nothing
DESTROYED: cx
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentPauseGame method AmateurContentClass,
MSG_CONTENT_PAUSE_GAME
mov ds:[di].ACI_status, AGS_PAUSED
mov cl, mask TF_CONTINUE or mask TF_ABORT
call EnableTriggers
call DisplayPauseText
ret
ContentPauseGame endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentAbortGame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN: nothing
DESTROYED: ax,cx,dx,bp
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentAbortGame method dynamic AmateurContentClass,
MSG_CONTENT_ABORT_GAME
call ContentStopTimer
; Set all pellets/peanuts/clouds to "unused" status
clr al
lea bx, ds:[di].ACI_pellets
mov cx, MAX_MOVABLE_OBJECTS
resetLoop:
mov ds:[bx].HS_status, al
add bx, size HandleStruct
loop resetLoop
mov ax,MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
mov ds:[di].ACI_status, AGS_OVER
;
; Nuke the Abort and Pause triggers
;
clr cl
call EnableTriggers
ret
ContentAbortGame endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentContinueGame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: continue a paused game. If none paused, start a new one.
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentContinueGame method dynamic AmateurContentClass,
MSG_CONTENT_CONTINUE_GAME
uses ax,cx,dx,bp
.enter
cmp ds:[di].ACI_status, AGS_RUNNING
je done
cmp ds:[di].ACI_status, AGS_OVER
je startNew
cmp ds:[di].ACI_status, AGS_STOPPED
je startNew
mov cl, mask TF_PAUSE or mask TF_ABORT
call EnableTriggers
mov ds:[di].ACI_status, AGS_RUNNING
mov ax, MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
call ContentStartTimer
done:
.leave
ret
startNew:
call ContentStartGame
jmp done
ContentContinueGame endm
if 0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentGetStartAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the starting act from the UI and stick it in my
ear.
CALLED BY: ContentInitialize, ContentStartGame
PASS: ds:di - content
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentGetStartAct proc near
uses ax,bx,si
class AmateurContentClass
.enter
push di
mov bx, handle Interface
mov si, offset SetLevelRange
mov ax, MSG_GEN_VALUE_GET_VALUE
mov di, mask MF_CALL
call ObjMessage
pop di
EC < call ECCheckContentDSDI >
mov ds:[di].ACI_startAct, dx
; display it to the world
call DisplayAct
.leave
ret
ContentGetStartAct endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentStartGame
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si = AmateurContent`Class object
ds:di = AmateurContent`Class instance data
es = Segment of AmateurContent`Class.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentStartGame method AmateurContentClass,
MSG_CONTENT_START_GAME
uses ax,cx,dx,bp
.enter
mov cl, mask TF_ABORT or mask TF_PAUSE
call EnableTriggers
call ContentStopTimer ; kill the old timer (if any)
; Set instance variables
mov ds:[di].ACI_clownsLeft, NUM_CLOWNS
mov ds:[di].ACI_sound, ST_EXTRA_CLOWN
mov ax, ds:[di].ACI_startAct
mov ds:[di].ACI_act, ax
cmp ax,1
jne startingAtBonusLevel
clrdw dxax
setInitScore:
movdw ds:[di].ACI_score,dxax
movdw ds:[di].ACI_scoreLastAct,dxax
; Set all clowns to "alive" status
mov ax, MSG_CLOWN_SET_STATUS
mov cl, CS_ALIVE
call CallAllClowns
call ContentPrepareNextAct
.leave
ret
startingAtBonusLevel:
mov cx,ax ;starting act
dec cx ;don't include level starting at
clrdw dxax ;initial score
nextLevel:
call ContentCalcMaxScoreForAct
add ax,bx
adc dx,0
loop nextLevel
jmp setInitScore
ContentStartGame endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentCalcMaxScoreForAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Calculate the maximum score a player can get from a level
if he destroyed all peanuts and tomatoes, saved all the
clowns and used 1/2 of the pellets. This only works for
levels in the ActTable.
CALLED BY: INTERNAL
ContentStartGame
PASS: ds:si - AmateurContent
cx - level
RETURN:
bx - max score for level
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 6/ 2/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentCalcMaxScoreForAct proc far
uses es,ax,dx,cx,si
.enter
mov ax,cx ;act
dec ax ;1st act at 0 offset
mov cx,segment idata
mov es,cx
clr cx ;score
mov bx,size ActInfo
mul bx
mov si,ax
add si,offset ActTable
mov bx,es:[si].AI_peanuts
mov ax,SCORE_PEANUT_HIT
mul bx
add cx,ax
mov bx,es:[si].AI_tomatoes
mov ax,SCORE_TOMATO
mul bx
add cx,ax
mov bx,es:[si].AI_pellets
shr bx,1
mov ax,SCORE_PELLET_LEFT
mul bx
add cx,ax
add cx,(SCORE_CLOWN * 6) + (SCORE_CLOWN_ADDER * 15)
mov bx,cx
.leave
ret
ContentCalcMaxScoreForAct endp
COMMENT @---------------------------------------------------------------------
ContentStartTimer
------------------------------------------------------------------------------
SYNOPSIS: Start the timer
CALLED BY: ContentStartGame
PASS: ds:di - content object
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentStartTimer proc near
uses di
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
cmp ds:[di].ACI_status, AGS_RUNNING
jne 20$
call ContentStopTimer ; kill old timer, if any
20$:
mov ds:[di].ACI_status, AGS_RUNNING
mov cx, INTERVAL_START_ACT
mov dx, MSG_TIMER_TICK
call ContentSetupTimer
.leave
ret
ContentStartTimer endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSetupTimer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up a one-shot timer
CALLED BY:
PASS: ds:di - content
cx - timer interval
dx - message to send to this content when timer expires
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/10/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSetupTimer proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov al, TIMER_EVENT_ONE_SHOT ; Prepare timer
mov bx, handle GameObjects
call TimerStart
mov ds:[di].ACI_timerID, ax
mov ds:[di].ACI_timerHandle, bx
.leave
ret
ContentSetupTimer endp
COMMENT @---------------------------------------------------------------------
ContentStopTimer
------------------------------------------------------------------------------
SYNOPSIS: Stop the timer
CALLED BY: Global
PASS: -
RETURN: -
DESTROYED: -
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentStopTimer proc near
uses bx
.enter
class AmateurContentClass
EC < call ECCheckContentDSDI >
clr bx
xchg bx, ds:[di].ACI_timerHandle ; stop the timer
tst bx
jz markStopped
mov ax, ds:[di].ACI_timerID
call TimerStop
markStopped:
mov ds:[di].ACI_status, AGS_STOPPED
.leave
ret
ContentStopTimer endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentViewSizeChanged
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: We need to reposition all the clowns and veggie blasters
when the size changes
PASS:
*(ds:si) - instance data of object
ds:[bx] - instance data of object
ds:[di] - master part of object (if any)
es - segment of AmateurContentClass
bp - handle of pane window
cx - new window width
dx - new window height
RETURN:
nothing
DESTROYED:
ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
none
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This method should be optimized for SMALL SIZE over SPEED
Common cases:
unknown
REVISION HISTORY:
Name Date Description
---- ---- -----------
srs 6/ 2/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentViewSizeChanged method dynamic AmateurContentClass,
MSG_META_CONTENT_VIEW_SIZE_CHANGED
mov di,offset AmateurContentClass
call ObjCallSuperNoLock
clr cx,dx
mov ax,MSG_VIS_SET_POSITION
GOTO ObjCallInstanceNoLock
ContentViewSizeChanged endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSetPosition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Position the clowns
CALLED BY: ContentSubviewSizeChanged, ContentVisOpen
PASS: ds:di - content
RETURN: nothing
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/10/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSetPosition method dynamic AmateurContentClass,
MSG_VIS_SET_POSITION
.enter
mov di, offset AmateurContentClass
call ObjCallSuperNoLock
mov di, ds:[si]
add di, ds:[di].Vis_offset
clr bp
mov ax, MSG_VIS_RECALC_SIZE
call CallAllBitmaps ; bp <- total widths of all
mov ax, ds:[di].VCNI_viewWidth
sub ax, bp
mov bx, NUM_CLOWNS+1
clr dx
div bx
sub sp, size BitmapPositionParams
mov bp, sp
mov [bp].BPP_distBetween, ax
mov ax, ds:[di].VCNI_viewWidth
mov [bp].BPP_viewWidth, ax
mov ax, ds:[di].VCNI_viewHeight
mov [bp].BPP_viewHeight, ax
clr [bp].BPP_curPos
mov ax, MSG_VIS_SET_POSITION
call CallAllBitmaps
add sp, size BitmapPositionParams
; Make sure we get another draw
mov ax, MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
mov ax, MSG_VIS_GET_SIZE
mov si, offset LeftBlaster
call ObjCallInstanceNoLock
mov ds:[di].ACI_blasterHeight, dx
.leave
ret
ContentSetPosition endm
COMMENT @---------------------------------------------------------------------
ContentVisOpen
------------------------------------------------------------------------------
SYNOPSIS: This procedure is the Content Class' method for opening
the view, setting the gstate, and clearing some state
variables.
CALLED BY: GLOBAL
PASS: *ds:si - content
RETURN: nothing
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentVisOpen method AmateurContentClass, MSG_VIS_OPEN
push di
mov di, offset AmateurContentClass
call ObjCallSuperNoLock
pop di
mov ax, MSG_VIS_VUP_CREATE_GSTATE ; Create Graphics State
call ObjCallInstanceNoLock
mov es:[gstate], bp ;Save GState
clr cx, dx
mov ax, MSG_VIS_SET_POSITION
GOTO ObjCallInstanceNoLock
ContentVisOpen endm
COMMENT @---------------------------------------------------------------------
ContentDraw
------------------------------------------------------------------------------
SYNOPSIS: draw blasters, clowns
CALLED BY: MSG_DRAW
PASS: bp - gstate handle
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentDraw method AmateurContentClass, MSG_VIS_DRAW
; save the old gstate, and use the new one temporarily
xchg es:[gstate], bp
; draw a rectangle in the bg color
mov cx, ds:[di].VCNI_viewWidth
mov dx, ds:[di].VCNI_viewHeight
mov ax, ds:[di].ACI_colorInfo.CI_background
push di
mov di, es:[gstate]
call GrSetAreaColor
clr ax
clr bx
call GrFillRect
pop di
mov ax, MSG_VIS_DRAW
call CallAllBitmaps
; If game is over, draw game over text
cmp ds:[di].ACI_status, AGS_OVER
jne notOver
call DisplayGameOverText
notOver:
cmp ds:[di].ACI_status, AGS_PAUSED
jne done
call DisplayPauseText
done:
xchg es:[gstate], bp
ret
ContentDraw endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DrawClowns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: redraw all the clowns
CALLED BY: ContentDraw, ContentTimerTick
PASS: ds:di - content
RETURN: nothing
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DrawClowns proc near
class AmateurContentClass
uses bp
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
mov ax, MSG_VIS_DRAW
call CallAllClowns
.leave
ret
DrawClowns endp
COMMENT @---------------------------------------------------------------------
ContentVisClose
------------------------------------------------------------------------------
SYNOPSIS: Destroy the Gstate and stop the timer
CALLED BY: MSG_VIS_CLOSE
PASS: -
RETURN: -
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentVisClose method AmateurContentClass, MSG_VIS_CLOSE
; call superclass
push di
mov di, offset AmateurContentClass
call ObjCallSuperNoLock
pop di
; If the game is running, pause it
cmp ds:[di].ACI_status, AGS_RUNNING
jne afterPause
call ContentPauseGame
afterPause:
; nuke the gstate
clr cx
xchg cx, es:[gstate]
jcxz done
mov di, cx
call GrDestroyState
done:
ret
ContentVisClose endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentKBDChar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Handle keyboard events
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/ 4/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentKBDChar method dynamic AmateurContentClass,
MSG_META_KBD_CHAR
uses ax,cx,dx,bp
.enter
mov bp, di ; instance ptr
; Only pay attention to first presses
test dl, mask CF_FIRST_PRESS
jz done
; ignore releases and repeat presses
test dl, mask CF_RELEASE or mask CF_REPEAT_PRESS
jnz done
; See if it's off the left edge of the screen
mov al, cl
mov dl, cl
mov di, offset LeftPelletList
mov cx, length LeftPelletList
repne scasb
je leftBlaster
mov al, dl
mov di, offset RightPelletList
mov cx, length RightPelletList
repne scasb
jne done
mov di, bp
mov cx, ds:[di].ACI_mouse.P_x
mov dx, ds:[di].ACI_mouse.P_y
call ShootRightPellet
jmp done
leftBlaster:
mov di, bp
mov cx, ds:[di].ACI_mouse.P_x
mov dx, ds:[di].ACI_mouse.P_y
call ShootLeftPellet
done:
.leave
ret
ContentKBDChar endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ShootRightPellet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS: ds:di - content
cx, dx - end position
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ShootRightPellet proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ax, ds:[di].VCNI_viewWidth
sub ax, BLASTER_WIDTH
call ContentButtonCommon
jnc done
mov ax, MSG_BLASTER_DRAW_ALT_NEXT_TIME
mov si, offset RightBlaster
call ObjCallInstanceNoLock
done:
.leave
ret
ShootRightPellet endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ShootLeftPellet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Shoot a pellet from the left of the screen
CALLED BY:
PASS: ds:di - content
cx, dx - position
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ShootLeftPellet proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
clr ax
call ContentButtonCommon
jnc done
mov ax, MSG_BLASTER_DRAW_ALT_NEXT_TIME
mov si, offset LeftBlaster
call ObjCallInstanceNoLock
done:
.leave
ret
ShootLeftPellet endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentPtr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Store the mouse position in case user presses a key
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/ 4/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentPtr method dynamic AmateurContentClass,
MSG_META_PTR
mov ds:[di].ACI_mouse.P_x, cx
mov ds:[di].ACI_mouse.P_y, dx
mov ax, mask MRF_PROCESSED
ret
ContentPtr endm
COMMENT @-------------------------------------------------------------------
ContentStartSelect
----------------------------------------------------------------------------
SYNOPSIS: When a button is pressed, this message is sent to the
content object from the UI. The content tries to get
a new pellet object going and sends it on its way.
CALLED BY:
PASS: cx, dx - x and y posn of button press
*ds:si - AmateurContent instance data
RETURN: ax - mask MRF_PROCESSED
DESTROYED: cx, dx, bp
PSEUDO CODE/STRATEGY:
Go through the pellet array, find the first free pellet
Get its handle, and send that pellet a message to
shoot itself
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentStartSelect method AmateurContentClass, MSG_META_START_SELECT
call ShootLeftPellet
mov ax, mask MRF_PROCESSED
ret
ContentStartSelect endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentButtonCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Common code to handle a button or key press
CALLED BY:
PASS: ax - left edge of blaster to shoot from
ds:di - content
cx, dx, - ending position
RETURN: carry - SET if bullet fired
DESTROYED: ax,bx,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentButtonCommon proc near
class AmateurContentClass
uses si, di
.enter
CheckHack <size PelletParams eq 5 * size word>
push ds:[di].ACI_colorInfo.CI_pellets
push dx
push cx
mov cx, ds:[di].VCNI_viewHeight
sub cx, ds:[di].ACI_blasterHeight
add cx, BLASTER_HOT_Y
push cx
add ax, BLASTER_HOT_X
push ax
mov bp, sp
; Is the game running? Then shame on the user!
cmp ds:[di].ACI_status, AGS_RUNNING
jne noFire
tst es:[gstate]
jz noFire
tst ds:[di].ACI_actInfo.AI_pellets
jz noneLeft ; don't fire if no pellets left!
mov ax, MAX_PELLETS
mov bx, offset ACI_pellets
call FindFreeObject
jnc maxPellets
; draw some lines at the current position
call DrawPelletMark
ornf ds:[di].ACI_display, mask DF_PELLETS_LEFT
dec ds:[di].ACI_actInfo.AI_pellets
cmp ds:[di].ACI_actInfo.AI_pellets, 5
jge afterFew
mov ds:[di].ACI_sound, ST_FEW_PELLETS
afterFew:
mov ds:[si].HS_status, 1 ; we've found a pellet to shoot!
mov si, ds:[si].HS_handle
mov ax, MSG_MOVE_START
call ObjCallInstanceNoLock
stc
done:
lahf
add sp, size PelletParams
sahf
.leave
ret
noneLeft:
mov ds:[di].ACI_sound, ST_NO_PELLETS
jmp noFire
maxPellets:
mov ds:[di].ACI_sound, ST_MAX_PELLETS_ON_SCREEN
noFire:
clc
jmp done
ContentButtonCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DrawPelletMark
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draw a cross where the user pressed the button
CALLED BY: ContentButtonCommon
PASS: ss:bp - PelletParams
ds:di - content
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/14/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DrawPelletMark proc near
uses di
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ax, ds:[di].ACI_colorInfo.CI_pellets
mov di, es:[gstate]
call GrSetLineColor
clrdw dxax
call GrSetLineWidth
mov ax, ss:[bp].BP_end.P_x
mov bx, ss:[bp].BP_end.P_y
mov cx, ax
mov dx, bx
sub ax, PELLET_MARK_SIZE/2
add cx, PELLET_MARK_SIZE/2
sub bx, PELLET_MARK_SIZE/2
add dx, PELLET_MARK_SIZE/2
call GrDrawEllipse
.leave
ret
DrawPelletMark endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentStartMoveCopy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: handle right-mouse button press
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentStartMoveCopy method dynamic AmateurContentClass,
MSG_META_START_MOVE_COPY
call ShootRightPellet
mov ax, mask MRF_PROCESSED
ret
ContentStartMoveCopy endm
COMMENT @-------------------------------------------------------------------
FindFreeObject
----------------------------------------------------------------------------
SYNOPSIS: Starting at the array (address passed in), find a free
object.
CALLED BY: GameButtonPressed, EndPellet, etc.
PASS: ax - max size of array
bx - offset from start of GCI to array
*ds:si - AmateurContent instance data
RETURN: carry set if found
ds:si - address of array element
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
FindFreeObject proc near
.enter
EC < call ECCheckContentDSSI >
mov si, ds:[si]
add si, ds:[si].AmateurContent_offset
add si, bx
FFO_loop:
tst ds:[si].HS_status
jz found
add si, size HandleStruct
dec ax
jnz FFO_loop
clc
done:
.leave
ret
found:
stc
jmp done
FindFreeObject endp
COMMENT @-------------------------------------------------------------------
ContentTimerTick
----------------------------------------------------------------------------
SYNOPSIS: Each time the timer ticks, Tell everything to move itself
CALLED BY: MSG_TIMER_TICK
PASS: cx:dx = tick count
ds:di - AmateurContent instance data
*ds:si - AmateurContent object
RETURN: nothing
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentTimerTick method AmateurContentClass, MSG_TIMER_TICK
locals local TimerTickVars
.enter
cmp ds:[di].ACI_status, AGS_RUNNING
LONG jne done
tst es:[gstate]
jz done
mov cx, INTERVAL_STD_TIMER
mov dx, MSG_TIMER_TICK
call ContentSetupTimer ; set up the timer for another
; go...
call ContentDisplay
mov locals.TTV_callOnNotEnd, offset Stub
mov locals.TTV_callback, offset PelletMove
mov locals.TTV_callOnEnd, offset ContentStartCloud
mov locals.TTV_array, offset ACI_pellets
mov ax, MAX_PELLETS
call TimerTickLoop
; Update peanuts
mov ax, MAX_PEANUTS
mov locals.TTV_callback, offset PeanutMove
mov locals.TTV_callOnEnd, offset ContentEndPeanut
mov locals.TTV_array, offset ACI_peanuts
call TimerTickLoop
; Update smart peanuts
mov ax, MAX_TOMATOES
mov locals.TTV_callback, offset TomatoMove
mov locals.TTV_callOnEnd, offset ContentEndTomato
mov locals.TTV_array, offset ACI_Tomatoes
call TimerTickLoop
; Update clouds
mov ax, MAX_CLOUDS
mov locals.TTV_callOnEnd, offset ContentEndCloud
mov locals.TTV_callOnNotEnd, offset ContentSendCloudToPeanuts
mov locals.TTV_array, offset ACI_clouds
mov locals.TTV_callback, offset Cloud
call TimerTickLoop
push bp
call ContentSendPeanut ; send any new peanuts
call ContentSendTomato
call ContentCheckActEnd
pop bp
done:
.leave
ret
ContentTimerTick endm
COMMENT @-------------------------------------------------------------------
TimerTickLoop
----------------------------------------------------------------------------
SYNOPSIS: Called by ContentTimerTick, sends events to movable objects
in the current array
CALLED BY:
PASS: ax - number of items
ds:di - content instance data
*ds:si - Content object
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
TimerTickLoop proc near
uses si,di
class AmateurContentClass
locals local TimerTickVars
.enter inherit
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
mov bx, locals.TTV_array ; current element
add bx, di
startLoop:
push ax, bx
tst ds:[bx].HS_status
jz next
push bx, di, si, bp
mov si, ds:[bx].HS_handle
mov bx, locals.TTV_callback
call bx
pop bx, di, si, bp
jc callOnEnd
call locals.TTV_callOnNotEnd
jmp next
callOnEnd:
clr ds:[bx].HS_status ; status is DONE
call locals.TTV_callOnEnd
next:
pop ax, bx
add bx, size HandleStruct
dec ax
jnz startLoop
.leave
ret
TimerTickLoop endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentEndTomato
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Nuke a smart peanut
CALLED BY:
PASS: ds:di - content
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentEndTomato proc near
class AmateurContentClass
EC < call ECCheckContentDSDI >
dec ds:[di].ACI_screenTomatoes
GOTO ContentEndPeanutCommon
ContentEndTomato endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentEndPeanut
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: End the trajectory of a normal peanut
CALLED BY: ContentTimerTick
PASS: ds:di - content
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentEndPeanut proc near
class AmateurContentClass
dec ds:[di].ACI_screenPeanuts
FALL_THRU ContentEndPeanutCommon
ContentEndPeanut endp
COMMENT @---------------------------------------------------------------------
ContentEndPeanutCommon
------------------------------------------------------------------------------
SYNOPSIS: set things up on the content side to end a peanut
see if any clowns were hit, or if blasters need to
be redrawn.
CALLED BY: TimerTickLoop (ContentTimerTick)
PASS: cx, dx = peanut position (x,y)
bp - score to add if peanut died as result of an
cloud.
ds:di - content
RETURN:
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If peanut cloudd up in the air, start an cloud.
Otherwise, check if peanut cloudd on the ground. If so,
start an cloud.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentEndPeanutCommon proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
; See if peanut cloudd high or low
mov ax, ds:[di].VCNI_viewHeight
mov bx, es:[clownHeight]
shr bx
sub ax, bx
cmp ax, dx
jg higherUp
mov ax, MSG_BITMAP_CHECK_PEANUT
call CallAllBitmaps
jnc done
call ContentStartCloud
mov ds:[di].ACI_sound, ST_CLOWN_HIT
dec ds:[di].ACI_clownsLeft
done:
.leave
ret
higherUp:
call ContentStartCloud
jmp done
ContentEndPeanutCommon endp
COMMENT @-------------------------------------------------------------------
ContentStartCloud
----------------------------------------------------------------------------
SYNOPSIS: Set things up on the Content Side to initiate an
cloud instance
CALLED BY: AmateurTimerTick
PASS: cx, dx - position of cloud
ds:di - content
RETURN:
DESTROYED: ax,bx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentStartCloud proc near
uses di, si, bp
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ax, MAX_CLOUDS
mov bx, offset ACI_clouds
call FindFreeObject ; returns array location in si
jnc done ; if not found, forget it
inc ds:[si].HS_status
mov ax, MSG_MOVE_START
mov si, ds:[si].HS_handle
call ObjCallInstanceNoLock
done:
.leave
ret
ContentStartCloud endp
COMMENT @-------------------------------------------------------------------
ContentSendCloudToPeanuts
----------------------------------------------------------------------------
SYNOPSIS: Send data about the current cloud to all peanuts
CALLED BY:
PASS: cx, dx - position of cloud
ax - size of cloud
*ds:si - content
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY: send a message to each active peanut to see
if it should end itself and initiate an cloud
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentSendCloudToPeanuts proc near
uses si,di,bp
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov bp, ax ; cloud size
mov ax, MAX_PEANUTS
lea bx, ds:[di].ACI_peanuts
mov si, SCORE_PEANUT_HIT
call SendCloudLoop
mov ax, MAX_TOMATOES
lea bx, ds:[di].ACI_Tomatoes
mov si, SCORE_TOMATO
call SendCloudLoop
.leave
ret
ContentSendCloudToPeanuts endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SendCloudLoop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Loop thru the peanuts or smart peanuts, sending
cloud info to each. If there's a hit, update
the score
CALLED BY:
PASS: ss:bp - SendCloudVars
ax - number of elements in array
ds:bx - array of peanuts/smart peanuts
RETURN: nothing
DESTROYED: ax,bx,si,di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/27/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SendCloudLoop proc near
class AmateurContentClass
.enter inherit
startLoop:
tst ds:[bx].HS_status
jz next
push si
mov si, ds:[bx].HS_handle
call PeanutNotifyCloud
pop si
jnc next
add ds:[di].ACI_score.low, si
adc ds:[di].ACI_score.high, 0
ornf ds:[di].ACI_display, mask DF_SCORE
next:
add bx, size HandleStruct
dec ax
jnz startLoop
.leave
ret
SendCloudLoop endp
COMMENT @-------------------------------------------------------------------
CreateObjects
----------------------------------------------------------------------------
SYNOPSIS: Create all the pellet, peanut, cloud objects
needed by the program.
CALLED BY: ContentVisOpen
PASS: *ds:si - Content
RETURN:
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
Allocate all the objects, storing their handles in the
GCI arrays
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
CreateObjects proc near
uses ax,bx,cx,dx,di,bp
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
mov di, offset AmateurPelletClass
mov bx, offset ACI_pellets
mov cx, MAX_PELLETS
call CreateObjectsOfClass
mov di, offset AmateurPeanutClass
mov bx, offset ACI_peanuts
mov cx, MAX_PEANUTS
call CreateObjectsOfClass
mov di, offset TomatoClass
mov bx, offset ACI_Tomatoes
mov cx, MAX_TOMATOES
call CreateObjectsOfClass
mov di, offset AmateurCloudClass
mov bx, offset ACI_clouds
mov cx, MAX_CLOUDS
call CreateObjectsOfClass
.leave
ret
CreateObjects endp
COMMENT @-------------------------------------------------------------------
CreateObjectsOfClass
----------------------------------------------------------------------------
SYNOPSIS: create a single object
CALLED BY: CreateObjects
PASS: *ds:si - ContentObject
es:di - class definition
bx - offset to array (in GCI) in which to store handle
bx - object block handle
cx - number of objects to create
RETURN:
DESTROYED: ax,bx,cx,dx,bp
REGISTER USAGE:
cx - counter
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
CreateObjectsOfClass proc near
class AmateurContentClass
.enter
startLoop:
push bx, cx, si
mov bx, ds:[LMBH_handle]
call ObjInstantiate
mov ax, si ; chunk handle of new object
pop bx, cx, si
push di
mov di, ds:[si]
add di, ds:[di].Vis_offset
clr ds:[bx][di].HS_status
mov ds:[bx][di].HS_handle, ax ; new chunk handle
add bx, size HandleStruct
pop di
EC < call ECCheckContentDSSI >
loop startLoop
.leave
ret
CreateObjectsOfClass endp
COMMENT @---------------------------------------------------------------------
ContentSendPeanut
------------------------------------------------------------------------------
SYNOPSIS: Send a new peanut
CALLED BY: ContentTimerTick
PASS: ds:di - AmateurContent instance data
*ds:si - AmateurContent object
RETURN: nothing
DESTROYED: ax, bx, cx, dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentSendPeanut proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
; set up stack frame to send to peanuts
CheckHack <size PeanutParams eq 8 * size word>
push ax ; view Height (will be set
; later)
push ds:[di].VCNI_viewWidth
push ds:[di].ACI_colorInfo.CI_trail
push ds:[di].ACI_colorInfo.CI_peanut
push ds:[di].ACI_actInfo.AI_speed
push ds:[di].ACI_actInfo.AI_maxScreenPeanuts
push ds:[di].ACI_screenPeanuts
push ds:[di].ACI_actInfo.AI_peanuts
mov bp, sp
mov ax, MAX_PEANUTS
mov bx, offset ACI_peanuts
call SendPeanutCommon
; store updated values
mov ax, ss:[bp].MP_actPeanuts
mov ds:[di].ACI_actInfo.AI_peanuts, ax
mov ax, ss:[bp].MP_screenPeanuts
mov ds:[di].ACI_screenPeanuts, ax
add sp, size PeanutParams
.leave
ret
ContentSendPeanut endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSendTomato
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send off a smart peanut
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSendTomato proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
; set up stack frame to send to peanuts
CheckHack <size PeanutParams eq 8 * size word>
push ax ; true value will be filled in later
push ds:[di].VCNI_viewWidth
push ds:[di].ACI_colorInfo.CI_trail
push ds:[di].ACI_colorInfo.CI_Tomato
push ds:[di].ACI_actInfo.AI_speed
push ds:[di].ACI_actInfo.AI_maxScreenTomatoes
push ds:[di].ACI_screenTomatoes
push ds:[di].ACI_actInfo.AI_tomatoes
mov bp, sp
mov ax, MAX_TOMATOES
mov bx, offset ACI_Tomatoes
call SendPeanutCommon
; store updated values
mov ax, ss:[bp].MP_actPeanuts
mov ds:[di].ACI_actInfo.AI_tomatoes, ax
mov ax, ss:[bp].MP_screenPeanuts
mov ds:[di].ACI_screenTomatoes, ax
add sp, size PeanutParams
.leave
ret
ContentSendTomato endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SendPeanutCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send either a peanut or a smart peanut
CALLED BY:
PASS: ss:bp - PeanutParams
*ds:si - content
ds:di - content
ax - size of array
bx - offset in AmateurContent instance data to array
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SendPeanutCommon proc near
uses di,si
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ax, ds:[di].VCNI_viewHeight
mov dx, es:[clownHeight]
shr dx, 1
sub ax, dx
mov [bp].MP_viewHeight, ax
call FindFreeObject
jnc done
tst ss:[bp].MP_actPeanuts ; see if any more peanuts
jz done
; See if the screen is currently full
mov ax, ss:[bp].MP_screenPeanuts
cmp ax, ss:[bp].MP_maxScreenPeanuts
je done
; Increment the number of peanuts on-screen, decrement total
; number for this act
inc ss:[bp].MP_screenPeanuts
dec ss:[bp].MP_actPeanuts
; Send it the message
inc ds:[si].HS_status
mov si, ds:[si].HS_handle
mov ax, MSG_MOVE_START
call ObjCallInstanceNoLock
done:
.leave
ret
SendPeanutCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentCheckActEnd
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Run through all data structures, see if everything is done
CALLED BY:
PASS: *ds:si - Content object
ds:di - content instance data
RETURN: nothing
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 1/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentCheckActEnd proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
; Make sure there aren't any objects moving
mov cx, MAX_MOVABLE_OBJECTS
lea bx, ds:[di].ACI_pellets
startLoop:
tst ds:[bx].HS_status
jnz done
add bx, size HandleStruct
loop startLoop
call ContentEndAct
done:
.leave
ret
ContentCheckActEnd endp
COMMENT @---------------------------------------------------------------------
ContentEndAct
------------------------------------------------------------------------------
SYNOPSIS: Give player bonus points for each unused pellet
check for no clowns left -- if so, end game
increment the "level" counter
check for score going over multiples of 20,000. If so,
give player a random clown
CALLED BY:
PASS:
RETURN:
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cdb 1/91 initial revision
---------------------------------------------------------------------------@
ContentEndAct proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSSI >
EC < call ECCheckContentDSDI >
mov ds:[di].ACI_status, AGS_BETWEEN_ACTS
call ContentStopTimer
mov ax, MSG_BITMAP_DRAW_IF_NEEDED
call CallAllBitmaps
; Update score for remaining clowns
call ContentTallyClowns
; Update score for extra pellets
mov cx, ds:[di].ACI_actInfo.AI_pellets
jcxz afterPellets
startLoop:
adddw ds:[di].ACI_score, SCORE_PELLET_LEFT
dec ds:[di].ACI_actInfo.AI_pellets
call ContentDisplayScore
call ContentDisplayPelletsLeft
loop startLoop
afterPellets:
; Figure out if user gets a new clown
movdw dxax, ds:[di].ACI_scoreLastAct
mov cx, SCORE_EXTRA_CLOWN
div cx
mov bx, ax
movdw dxax, ds:[di].ACI_score
div cx
sub ax, bx ; number of extra clowns
call MakeClownsAlive
; Figure out if game over
tst ds:[di].ACI_clownsLeft
jnz gameNotOver
call ContentGameOver
jmp done
gameNotOver:
inc ds:[di].ACI_act
call ContentPrepareNextAct
done:
.leave
ret
ContentEndAct endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentPrepareNextAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: start an act
CALLED BY:
PASS: ds:di - content
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentPrepareNextAct proc near
uses di,si
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
mov ds:[di].ACI_status, AGS_BETWEEN_ACTS
mov di, ds:[si]
add di, ds:[di].Vis_offset
clr ds:[di].ACI_screenPeanuts
clr ds:[di].ACI_screenTomatoes
movdw ds:[di].ACI_scoreLastAct, ds:[di].ACI_score, ax
call DisplayAct
call ContentSetActInfo
; Set all pellets/peanuts/clouds to "unused" status
clr al
lea bx, ds:[di].ACI_pellets
mov cx, MAX_MOVABLE_OBJECTS
resetLoop:
mov ds:[bx].HS_status, al
add bx, size HandleStruct
loop resetLoop
mov bp, es:[gstate]
mov ax, MSG_VIS_DRAW
call ContentDraw
call ContentChooseJoke
mov cx, START_ACT_INTERVAL
mov dx, MSG_CONTENT_START_ACT
call ContentSetupTimer
.leave
ret
ContentPrepareNextAct endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentGameOver
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: End the game
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/10/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentGameOver proc near
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ds:[di].ACI_sound, ST_GAME_OVER
call ContentPlaySound
mov ds:[di].ACI_status, AGS_OVER
call DisplayGameOverText
mov ax, INTERVAL_GAME_OVER
call TimerSleep
movdw dxcx, ds:[di].ACI_score
mov ax, MSG_HIGH_SCORE_ADD_SCORE
mov bx, handle AmateurHighScore
mov si, offset AmateurHighScore
clr bp
clr di
call ObjMessage
;
; Nuke the Abort and Pause triggers
;
clr cl
call EnableTriggers
.leave
ret
ContentGameOver endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSetActInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the act data for the content for the current
act.
CALLED BY:
PASS: ds:di - content
es - idata
RETURN: nothing
DESTROYED: ax,bx,cx,dx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 8/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSetActInfo proc near
uses di,si
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
mov ax, ds:[di].ACI_act
dec ax
Min ax, <MAX_ACT-1>
mov bx, size ActInfo
mul bx
mov si, ax
add si, offset ActTable
lea di, ds:[di].ACI_actInfo
mov cx, size ActInfo/2
segxchg ds, es, ax
rep movsw
segxchg ds, es, ax
.leave
ret
ContentSetActInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetColorInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the color information based on the display type.
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/23/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetColorInfo proc near
uses ax,cx,di,si,es,ds
class AmateurContentClass
.enter
mov al, es:[displayType]
andnf al, mask DT_DISP_CLASS
cmp al, DC_GRAY_1 shl offset DT_DISP_CLASS
jne color
mov si, offset BWColorTable
jmp copy
color:
mov si, offset ColorColorTable
copy:
lea di, ds:[di].ACI_colorInfo
segxchg ds, es, cx
mov cx, size ColorInfo/2
rep movsw
.leave
ret
SetColorInfo endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckContentDSSI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS: *ds:si - content
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 1/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
if ERROR_CHECK
ECCheckContentDSSI proc near
.enter
pushf
cmp si, offset ContentObject
ERROR_NE SI_NOT_POINTING_AT_CONTENT_OBJECT
popf
call ECCheckObject
.leave
ret
ECCheckContentDSSI endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ECCheckContentDSDI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 7/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ECCheckContentDSDI proc near
uses si
.enter
pushf
assume ds:GameObjects
mov si, ds:[ContentObject]
add si, ds:[si].Vis_offset
cmp si, di
ERROR_NE DS_DI_NOT_POINTING_AT_CONTENT_OBJECT
popf
assume ds:dgroup
.leave
ret
ECCheckContentDSDI endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MakeClownsAlive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Bring a number of clowns back to life
CALLED BY:
PASS: ax - number of clowns to restore (usually 1)
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 8/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MakeClownsAlive proc near
uses ax,bx,cx,dx,di,si,bp
class AmateurContentClass
.enter
EC < call ECCheckContentDSDI >
EC < call ECCheckContentDSSI >
outerLoop:
tst ax
jz done
cmp ds:[di].ACI_clownsLeft, NUM_CLOWNS
je done
mov ds:[di].ACI_sound, ST_EXTRA_CLOWN
inc ds:[di].ACI_clownsLeft
dec ax
push ax
findDeadClown:
mov dx, NUM_CLOWNS
call GameRandom
mov ax, MSG_CLOWN_GET_STATUS
mov bx, dx
call CallClown
cmp cl, CS_ALIVE
je findDeadClown
; bx is number of clown to make alive
mov ax, MSG_CLOWN_SET_STATUS
mov cl, CS_ALIVE
call CallClown
pop ax
jmp outerLoop
done:
call DrawClowns
.leave
ret
MakeClownsAlive endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CallClown
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: send a message to a clown
CALLED BY: MakeClownsAlive
PASS: ax - message
bx - clown #
cx, dx, bp - message data
RETURN: ax,cx,dx,bp - returned by clown
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 8/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CallClown proc near
uses bx, si
.enter
shl bx, 1
mov si, cs:clownTable[bx]
call ObjCallInstanceNoLock
.leave
ret
CallClown endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CallAllClowns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call all clowns
CALLED BY:
PASS: ax, cx, dx, bp - message data
RETURN: ax, cx, dx, bp - returned from clowns
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
CALLED ROUTINE:
can destroy/modify cx,dx,bp
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/ 8/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CallAllClowns proc near
uses bx, si
.enter
mov bx, (offset clownTable) + (size clownTable)
mov si, offset clownTable
call CallObjects
.leave
ret
CallAllClowns endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CallAllBitmaps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: call all blasters & clowns
CALLED BY:
PASS: ax,cx,dx,bp - message data
RETURN: ax,cx,dx,bp - returned from called object
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CallAllBitmaps proc near
uses bx,si
.enter
mov bx, (offset bitmapTable) + (size bitmapTable)
mov si, offset bitmapTable
call CallObjects
.leave
ret
CallAllBitmaps endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CallObjects
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CallObjects proc near
.enter
startLoop:
push ax, si
mov si, cs:[si]
call ObjCallInstanceNoLock
pop ax, si
jc done
add si, 2
cmp si, bx
jl startLoop
done:
.leave
ret
CallObjects endp
bitmapTable word \
offset LeftBlaster,
offset Clown0,
offset Clown1,
offset Clown2,
offset Clown3,
offset Clown4,
offset Clown5,
offset RightBlaster
clownTable word \
offset Clown0,
offset Clown1,
offset Clown2,
offset Clown3,
offset Clown4,
offset Clown5
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EnableTriggers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS: cl - TriggerFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
EnableTriggers proc near
uses ax,bx,cx,dx,di,si,bp
.enter
clr bp
mov bx, handle Interface
mov dl, VUM_DELAYED_VIA_UI_QUEUE
mov di, mask MF_FORCE_QUEUE
startLoop:
mov si, cs:TriggerTable[bp]
shl cl
jnc disable
mov ax, MSG_GEN_SET_ENABLED
jmp sendIt
disable:
mov ax, MSG_GEN_SET_NOT_ENABLED
sendIt:
push ax, cx, dx, bp
call ObjMessage
pop ax, cx, dx, bp
add bp, 2
cmp bp, size TriggerTable
jl startLoop
.leave
ret
EnableTriggers endp
TriggerTable word \
offset AbortTrigger,
offset PauseTrigger,
offset ContinueTrigger
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentTallyClowns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: add up scores for each remaining clown
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: ax,cx,dx,bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/14/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentTallyClowns proc near
class AmateurContentClass
.enter
clr ax
push ax ; CSP_scoreTally
mov ax, STD_TEXT_HEIGHT
push ax ; CSP_textHeight
mov ax, SCORE_CLOWN_ADDER
push ax ; CSP_scoreAdder
mov ax, SCORE_CLOWN
push ax ; CSP_score
push ds:[di].ACI_colorInfo.CI_Tomato
mov bp, sp
mov ax, MSG_CLOWN_TALLY_SCORE
call CallAllClowns
mov ax, ss:[bp].CSP_scoreTally
clr bx
adddw ds:[di].ACI_score, bxax
add sp, size ClownScoreParams
.leave
ret
ContentTallyClowns endp
Stub proc near
ret
Stub endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentDisplay
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update the display
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 2/14/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentDisplay proc near
uses bp
class AmateurContentClass
.enter
call ContentPlaySound
mov ax, MSG_BITMAP_DRAW_IF_NEEDED
call CallAllBitmaps
test ds:[di].ACI_display, mask DF_SCORE
jz afterDisplayScore
call ContentDisplayScore
andnf ds:[di].ACI_display, not mask DF_SCORE
afterDisplayScore:
test ds:[di].ACI_display, mask DF_PELLETS_LEFT
jz done
call ContentDisplayPelletsLeft
andnf ds:[di].ACI_display, not mask DF_PELLETS_LEFT
done:
.leave
ret
ContentDisplay endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentStartAct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: Start the next act
PASS: *ds:si = GameContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN: nothing
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentStartAct method dynamic AmateurContentClass,
MSG_CONTENT_START_ACT
uses ax,cx,dx,bp
.enter
cmp ds:[di].ACI_status, AGS_BETWEEN_ACTS
jne done
mov ds:[di].ACI_status, AGS_RUNNING
push si
mov cx, IC_DISMISS
mov ax, MSG_GEN_GUP_INTERACTION_COMMAND
mov bx, handle JokeSummons
mov si, offset JokeSummons
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
pop si
mov di, ds:[si]
add di, ds:[di].Vis_offset
call ContentStartTimer
ornf ds:[di].ACI_display, mask DF_PELLETS_LEFT or\
mask DF_SCORE
done:
.leave
ret
ContentStartAct endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentLostKbd
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Stops the game timers and temporarily pauses.
CALLED BY: GLOBAL
PASS: nada
RETURN: nada
DESTROYED: various important but undocumented things
PSEUDO CODE/STRATEGY:
This page intentionally left blank
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cbh 11/28/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentLostKbd method dynamic AmateurContentClass, MSG_META_LOST_KBD_EXCL,
MSG_META_LOST_SYS_TARGET_EXCL,
MSG_META_LOST_SYS_FOCUS_EXCL
mov ax, MSG_CONTENT_TEMP_PAUSE
call ObjCallInstanceNoLock
ret
ContentLostKbd endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentGainedKbd
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Restarts the game timers.
CALLED BY: GLOBAL
PASS: nada
RETURN: nada
DESTROYED: various important but undocumented things
PSEUDO CODE/STRATEGY:
This page intentionally left blank
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cbh 1/14/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentGainedKbd method dynamic AmateurContentClass,
MSG_META_GAINED_KBD_EXCL,
MSG_META_GAINED_SYS_TARGET_EXCL,
MSG_META_GAINED_SYS_FOCUS_EXCL
mov ax, MSG_CONTENT_END_TEMP_PAUSE
call ObjCallInstanceNoLock
ret
ContentGainedKbd endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentTempPause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentTempPause method dynamic AmateurContentClass,
MSG_CONTENT_TEMP_PAUSE
cmp ds:[di].ACI_status, AGS_RUNNING
jne done
mov ds:[di].ACI_status, AGS_TEMP_PAUSED
done:
ret
ContentTempPause endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentEndTempPause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION:
PASS: *ds:si = AmateurContentClass object
ds:di = AmateurContentClass instance data
es = Segment of AmateurContentClass.
RETURN:
DESTROYED: nothing
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentEndTempPause method dynamic AmateurContentClass,
MSG_CONTENT_END_TEMP_PAUSE
cmp ds:[di].ACI_status, AGS_TEMP_PAUSED
jne done
call ContentStartTimer ; will set status to RUNNING
done:
ret
ContentEndTempPause endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentEndCloud
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call all blasters, clowns to see if they should redraw
selves.
CALLED BY:
PASS: cx, dx - position of cloud
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/25/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentEndCloud proc near
.enter
mov ax, MSG_BITMAP_CHECK_CLOUD
call CallAllBitmaps
.leave
ret
ContentEndCloud endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ContentSetClownMonikers
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Assign one moniker to each clown, making sure that all
six are assigned
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/26/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ContentSetClownMonikers proc near
uses ax,bx,cx,dx,di,si,bp
.enter
mov cx, NUM_CLOWNS
mov ax, MSG_CLOWN_SET_MONIKER
startLoop:
; pick a clown to have this moniker
mov dx, NUM_CLOWNS
call GameRandom
mov bx, dx
call CallClown
jc startLoop ; carry. Choose another clown
; instead.
; Now, on to the next
loop startLoop
.leave
ret
ContentSetClownMonikers endp
|
asmTests/mov.asm | SimpleTease/asm2c | 154 | 179940 | .386p
_DATA segment use32 dword public 'DATA' ;IGNORE
a db 1
b dw 2
c dd 3
d db 4
e db 5
f db 6
g dd 12345
h db -1
h2 db 1
_DATA ends ;IGNORE
_TEXT segment use32 dword public 'CODE' ;IGNORE
assume cs:_TEXT,ds:_DATA
start: ;IGNORE
mov ebx,0aabbccddh
cmp bl,0ddh
jne failure
cmp bh,0cch
jne failure
mov eax,256+3+65536
mov a,al
cmp a,3
jne failure
mov a,ah
cmp a,1
jne failure
mov b,ax
cmp b,256+3
jne failure
mov c,eax
cmp c,256+3+65536
jne failure
mov byte ptr [a],5
cmp byte ptr [a],5
jne failure
mov a,5
cmp a,5
jne failure
mov [a],5
cmp [a],5
jne failure
xor ebx,ebx
mov bx,word ptr [d]
cmp bx,4+5*256
jne failure
xor ebx,ebx
mov bx,word ptr [e]
cmp bx,6*256+5
jne failure
mov ecx,-1
mov bx,5
movzx ecx,bx
cmp ecx,5
jne failure
xor ecx,ecx
mov cx,-5
movsx ecx,cx
cmp ecx,-5
jne failure
xor ebx,ebx
mov bl,-1
movsx bx,bl
cmp bx,-1
jne failure
mov ebx,0FFFFFFFFh
mov bl,1
movsx bx,bl
cmp bx,1
jne failure
xor ebx,ebx
movsx bx,byte ptr [h]
cmp bx,-1
jne failure
xor ebx,ebx
movsx bx,byte ptr [h2]
cmp bx,1
jne failure
;TOFIX: test in dosbox if this works
xor ebx,ebx
movsx bx,[h2]
cmp bx,1
jne failure
mov ebx,[g]
cmp ebx,12345
jne failure
mov ebx,g
cmp ebx,12345
jne failure
MOV al,0
JMP exitLabel
failure:
mov al,1
exitLabel:
mov ah,4ch ; AH=4Ch - Exit To DOS
int 21h ; DOS INT 21h
_TEXT ends ;IGNORE
stackseg segment para stack 'STACK' ;IGNORE
db 1000h dup(?)
stackseg ends ;IGNORE
end start ;IGNORE
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca.log_21829_654.asm | ljhsiun2/medusa | 9 | 174576 | .global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1b2b1, %r14
nop
nop
cmp %r12, %r12
mov $0x6162636465666768, %rbp
movq %rbp, %xmm6
vmovups %ymm6, (%r14)
nop
nop
nop
nop
sub %r8, %r8
lea addresses_normal_ht+0x1a1cd, %rsi
lea addresses_WC_ht+0x1b8ad, %rdi
dec %r9
mov $14, %rcx
rep movsl
nop
nop
add %r9, %r9
lea addresses_D_ht+0x198ad, %r12
nop
xor %rdi, %rdi
movb $0x61, (%r12)
nop
nop
nop
add $35679, %rbp
lea addresses_WC_ht+0x4c2d, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
cmp $42283, %r8
movups (%rsi), %xmm7
vpextrq $1, %xmm7, %r9
nop
sub $38357, %r9
lea addresses_WT_ht+0x4e2b, %rdi
nop
nop
nop
nop
nop
xor %rcx, %rcx
vmovups (%rdi), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %r9
nop
nop
nop
sub %rcx, %rcx
lea addresses_D_ht+0x15dad, %rsi
lea addresses_UC_ht+0x44ad, %rdi
nop
nop
nop
and $38024, %r12
mov $47, %rcx
rep movsb
add %rbp, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r15
push %r9
push %rbx
push %rdi
// Store
lea addresses_PSE+0x2855, %r14
add $65341, %r10
movl $0x51525354, (%r14)
xor %r10, %r10
// Store
lea addresses_normal+0xd6a5, %r13
clflush (%r13)
sub %rbx, %rbx
movw $0x5152, (%r13)
nop
dec %r15
// Store
lea addresses_UC+0xb29d, %r9
clflush (%r9)
nop
nop
nop
nop
nop
inc %r10
movl $0x51525354, (%r9)
nop
nop
nop
nop
sub $15551, %r14
// Store
lea addresses_normal+0x1b4ed, %r15
clflush (%r15)
nop
nop
nop
nop
cmp $64291, %rbx
movl $0x51525354, (%r15)
nop
nop
nop
and %rbx, %rbx
// Faulty Load
lea addresses_normal+0x130ad, %r15
nop
nop
and $21117, %r13
movb (%r15), %bl
lea oracles, %r9
and $0xff, %rbx
shlq $12, %rbx
mov (%r9,%rbx,1), %rbx
pop %rdi
pop %rbx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_PSE'}}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_UC'}}
{'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_normal'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 7, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_UC_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
*/
|
driver_scripts/chrome_scroll.scpt | eti-p-doray/chrome_safari_power | 0 | 3340 | set myURL to "https://reddit.com"
set scrollAmount to "100" --- % down the page
tell application "Google Chrome"
activate
tell front window to set curTab to make new tab at after (get active tab) with properties {URL:myURL}
tell curTab
repeat while (loading)
delay 1
end repeat
repeat with i from 1 to 30
-- set the vertical scroll
repeat with y from 90 to 100
execute javascript "h=document.documentElement.scrollHeight-document.documentElement.clientHeight; window.scrollTo(0,h*" & y & "/100)"
delay 0.25
end repeat
delay 3
end repeat
end tell
end tell |
Transynther/x86/_processed/AVXALIGN/_st_/i3-7100_9_0xca_notsx.log_511_836.asm | ljhsiun2/medusa | 9 | 97909 | <reponame>ljhsiun2/medusa<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x12802, %rsi
lea addresses_normal_ht+0x11cb4, %rdi
add %r13, %r13
mov $70, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $5154, %r15
lea addresses_WT_ht+0x1705c, %r11
nop
nop
cmp %r10, %r10
movb $0x61, (%r11)
nop
nop
xor $1415, %r11
lea addresses_WC_ht+0x80c4, %r11
nop
nop
nop
sub %rdi, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, (%r11)
nop
nop
nop
add $31446, %r13
lea addresses_D_ht+0x1271c, %r15
nop
nop
nop
and %r11, %r11
vmovups (%r15), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %rdi
nop
nop
add $17331, %r10
lea addresses_D_ht+0xa0fc, %rsi
lea addresses_A_ht+0x9324, %rdi
nop
nop
nop
nop
nop
cmp $56034, %r9
mov $24, %rcx
rep movsl
nop
nop
nop
nop
nop
inc %r15
lea addresses_A_ht+0x18db8, %r11
nop
nop
xor %rsi, %rsi
mov (%r11), %r10w
nop
cmp %rcx, %rcx
lea addresses_normal_ht+0x182f6, %r10
clflush (%r10)
sub %r15, %r15
mov (%r10), %r13d
nop
nop
nop
nop
nop
add $32184, %rsi
lea addresses_UC_ht+0x1a2ac, %r11
nop
nop
nop
and %rsi, %rsi
movups (%r11), %xmm7
vpextrq $0, %xmm7, %rcx
nop
nop
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x154fc, %rdi
and $42908, %r10
mov (%rdi), %r9d
nop
nop
nop
nop
sub $10488, %r13
lea addresses_WC_ht+0x2a60, %rsi
lea addresses_normal_ht+0x29b4, %rdi
nop
nop
nop
and $25216, %r9
mov $28, %rcx
rep movsb
nop
nop
nop
nop
nop
add %r15, %r15
lea addresses_D_ht+0xbde, %rsi
nop
dec %r9
movups (%rsi), %xmm2
vpextrq $0, %xmm2, %r13
nop
nop
sub $12641, %r11
lea addresses_normal_ht+0x8f44, %r11
nop
and $35685, %rsi
movb (%r11), %r15b
nop
nop
nop
nop
add %r9, %r9
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r15
push %r8
push %r9
push %rbx
push %rdi
// Store
lea addresses_UC+0x114fc, %r8
nop
nop
nop
sub %r9, %r9
mov $0x5152535455565758, %rdi
movq %rdi, (%r8)
nop
sub $61691, %rbx
// Store
mov $0x74d0f70000000414, %r13
xor %r11, %r11
movl $0x51525354, (%r13)
nop
nop
nop
nop
nop
cmp $55155, %r9
// Store
lea addresses_A+0x11991, %r11
xor $40123, %r13
mov $0x5152535455565758, %r8
movq %r8, %xmm1
movups %xmm1, (%r11)
nop
nop
nop
nop
sub %r13, %r13
// Store
lea addresses_A+0x55fc, %r13
nop
nop
nop
nop
nop
sub %r15, %r15
mov $0x5152535455565758, %r9
movq %r9, %xmm3
vmovups %ymm3, (%r13)
nop
and $16164, %rbx
// Faulty Load
lea addresses_D+0x70fc, %r13
nop
nop
nop
xor $48347, %r15
mov (%r13), %rbx
lea oracles, %r11
and $0xff, %rbx
shlq $12, %rbx
mov (%r11,%rbx,1), %rbx
pop %rdi
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_NC', 'size': 4, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A', 'size': 32, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_D', 'size': 8, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': True, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': True, 'congruent': 2, 'NT': True, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'36': 511}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48.log_21829_1598.asm | ljhsiun2/medusa | 9 | 101424 | .global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r15
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xfc42, %r13
xor %r14, %r14
mov (%r13), %r15
nop
nop
nop
nop
xor $1349, %rbp
lea addresses_normal_ht+0x1c682, %r9
clflush (%r9)
dec %rax
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
vmovups %ymm4, (%r9)
nop
nop
nop
nop
cmp %r14, %r14
lea addresses_UC_ht+0x13fdb, %rsi
lea addresses_A_ht+0x996, %rdi
clflush (%rsi)
nop
nop
nop
nop
cmp %rbp, %rbp
mov $87, %rcx
rep movsq
nop
dec %rsi
lea addresses_WC_ht+0xd82, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
xor $42548, %rax
mov $0x6162636465666768, %rcx
movq %rcx, %xmm7
vmovups %ymm7, (%rsi)
nop
sub $17758, %r14
lea addresses_A_ht+0x9b82, %rsi
lea addresses_WT_ht+0x10982, %rdi
nop
nop
nop
nop
inc %r14
mov $39, %rcx
rep movsw
nop
nop
xor %r14, %r14
lea addresses_WT_ht+0x17482, %rsi
lea addresses_normal_ht+0x2ac2, %rdi
nop
nop
inc %r9
mov $41, %rcx
rep movsb
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_WT_ht+0x15b02, %rbp
nop
nop
inc %rsi
movb (%rbp), %r9b
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_D_ht+0xd3ac, %rsi
lea addresses_D_ht+0x1a582, %rdi
nop
nop
nop
xor $49664, %r15
mov $10, %rcx
rep movsq
mfence
lea addresses_WC_ht+0x1e082, %rsi
lea addresses_WC_ht+0x19fc2, %rdi
nop
nop
nop
and $28793, %rbp
mov $116, %rcx
rep movsq
dec %rdi
lea addresses_WC_ht+0xb782, %rsi
lea addresses_normal_ht+0x4782, %rdi
nop
nop
nop
nop
nop
xor %rax, %rax
mov $116, %rcx
rep movsl
nop
nop
add %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r15
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %rbp
push %rcx
push %rdi
push %rdx
// Faulty Load
lea addresses_US+0x1ab82, %rdx
nop
nop
nop
nop
nop
add %rcx, %rcx
movups (%rdx), %xmm4
vpextrq $0, %xmm4, %rbp
lea oracles, %r12
and $0xff, %rbp
shlq $12, %rbp
mov (%r12,%rbp,1), %rbp
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': True}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
source/slim-message_visiters.ads | reznikmm/slimp | 0 | 4809 | -- Copyright (c) 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Messages.ANIC;
with Slim.Messages.BUTN;
with Slim.Messages.DSCO;
with Slim.Messages.HELO;
with Slim.Messages.IR;
with Slim.Messages.META;
with Slim.Messages.RESP;
with Slim.Messages.SETD;
with Slim.Messages.STAT;
with Slim.Messages.aude;
with Slim.Messages.audg;
with Slim.Messages.audp;
with Slim.Messages.bdac;
with Slim.Messages.bled;
with Slim.Messages.cont;
with Slim.Messages.grfb;
with Slim.Messages.grfe;
with Slim.Messages.grfg;
with Slim.Messages.grfs;
with Slim.Messages.rtcs;
with Slim.Messages.Server_setd;
with Slim.Messages.strm;
with Slim.Messages.vers;
with Slim.Messages.visu;
package Slim.Message_Visiters is
type Visiter is limited interface;
not overriding procedure ANIC
(Self : in out Visiter;
Message : not null access Slim.Messages.ANIC.ANIC_Message) is null;
not overriding procedure BUTN
(Self : in out Visiter;
Message : not null access Slim.Messages.BUTN.BUTN_Message) is null;
not overriding procedure DSCO
(Self : in out Visiter;
Message : not null access Slim.Messages.DSCO.DSCO_Message) is null;
not overriding procedure HELO
(Self : in out Visiter;
Message : not null access Slim.Messages.HELO.HELO_Message) is null;
not overriding procedure IR
(Self : in out Visiter;
Message : not null access Slim.Messages.IR.IR_Message) is null;
not overriding procedure META
(Self : in out Visiter;
Message : not null access Slim.Messages.META.META_Message) is null;
not overriding procedure RESP
(Self : in out Visiter;
Message : not null access Slim.Messages.RESP.RESP_Message) is null;
not overriding procedure SETD
(Self : in out Visiter;
Message : not null access Slim.Messages.SETD.SETD_Message) is null;
not overriding procedure STAT
(Self : in out Visiter;
Message : not null access Slim.Messages.STAT.STAT_Message) is null;
not overriding procedure aude
(Self : in out Visiter;
Message : not null access Slim.Messages.aude.Aude_Message) is null;
not overriding procedure audg
(Self : in out Visiter;
Message : not null access Slim.Messages.audg.Audg_Message) is null;
not overriding procedure audp
(Self : in out Visiter;
Message : not null access Slim.Messages.audp.Audp_Message) is null;
not overriding procedure bdac
(Self : in out Visiter;
Message : not null access Slim.Messages.bdac.Bdac_Message) is null;
not overriding procedure bled
(Self : in out Visiter;
Message : not null access Slim.Messages.bled.Bled_Message) is null;
not overriding procedure cont
(Self : in out Visiter;
Message : not null access Slim.Messages.cont.Cont_Message) is null;
not overriding procedure grfb
(Self : in out Visiter;
Message : not null access Slim.Messages.grfb.Grfb_Message) is null;
not overriding procedure grfe
(Self : in out Visiter;
Message : not null access Slim.Messages.grfe.Grfe_Message) is null;
not overriding procedure grfg
(Self : in out Visiter;
Message : not null access Slim.Messages.grfg.Grfg_Message) is null;
not overriding procedure grfs
(Self : in out Visiter;
Message : not null access Slim.Messages.grfs.Grfs_Message) is null;
not overriding procedure rtcs
(Self : in out Visiter;
Message : not null access Slim.Messages.rtcs.Rtcs_Message) is null;
not overriding procedure setd
(Self : in out Visiter;
Message : not null access Slim.Messages.Server_setd.Setd_Message)
is null;
not overriding procedure strm
(Self : in out Visiter;
Message : not null access Slim.Messages.strm.Strm_Message) is null;
not overriding procedure vers
(Self : in out Visiter;
Message : not null access Slim.Messages.vers.Vers_Message) is null;
not overriding procedure visu
(Self : in out Visiter;
Message : not null access Slim.Messages.visu.Visu_Message) is null;
end Slim.Message_Visiters;
|
oeis/050/A050141.asm | neoneye/loda-programs | 11 | 98255 | <reponame>neoneye/loda-programs
; A050141: a(n) = 2*floor((n+1)*phi) - 2*floor(n*phi) - 1 where phi = (1 + sqrt(5))/2 is the golden ratio.
; Submitted by <NAME>(s4)
; 3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3,3,1,3,1,3,3,1,3,3,1,3,1,3
seq $0,35612 ; Horizontal para-Fibonacci sequence: says which column of Wythoff array (starting column count at 1) contains n.
mod $0,2
mul $0,2
add $0,1
|
session_06/02-mmiokeyboard/mmiokeyboard.asm | DigiOhhh/LabArchitettura2-2017-2018 | 1 | 101763 | <reponame>DigiOhhh/LabArchitettura2-2017-2018
.data
outstr : .asciiz "Caratteri scritti: "
.text
.globl main
main:
la $t8, 0xFFFF0000 # Keyboard address control
la $t9, 0xFFFF0004 # Keyboard address data
li $t7, 0x0A # newline ASCII keycode
move $t6, $zero # init counter
loop: lw $t0, 0($t8) # Controlla se è stato premuto un tasto
bne $t0, 1, endloop # Se non è stato letto itera
lw $t1, 0($t9) # Leggi il carattere
sw $zero, 0($t8) # Consuma il carattere
beq $t1, $t7, exit # Se il carattere è newline termina
addi $t6, $t6, 1 # Incrementa il contatore
endloop: j loop
exit: la $a0, outstr # Stringa da stampare
move $a1, $t6 # Valore da stampare
li $v0, 56 # Numero syscall
syscall
li $v0, 10 # Esci
syscall
|
uprogs/cat.asm | zhiyihuang/xv6_rpi_port | 36 | 19661 |
_cat: file format elf32-littlearm
Disassembly of section .text:
00000000 <main>:
int
main(int argc, char *argv[])
{
int fd, i;
if(argc <= 1){
0: e3500001 cmp r0, #1
}
}
int
main(int argc, char *argv[])
{
4: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
8: e1a07000 mov r7, r0
c: e28db01c add fp, sp, #28
exit();
}
}
int
main(int argc, char *argv[])
10: c2814004 addgt r4, r1, #4
14: c3a05001 movgt r5, #1
{
int fd, i;
if(argc <= 1){
18: da000012 ble 68 <main+0x68>
cat(0);
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
1c: e5940000 ldr r0, [r4]
20: e3a01000 mov r1, #0
24: eb000137 bl 508 <open>
28: e1a06004 mov r6, r4
2c: e2844004 add r4, r4, #4
30: e2508000 subs r8, r0, #0
34: ba000006 blt 54 <main+0x54>
printf(1, "cat: cannot open %s\n", argv[i]);
exit();
}
cat(fd);
38: eb00000e bl 78 <cat>
if(argc <= 1){
cat(0);
exit();
}
for(i = 1; i < argc; i++){
3c: e2855001 add r5, r5, #1
if((fd = open(argv[i], 0)) < 0){
printf(1, "cat: cannot open %s\n", argv[i]);
exit();
}
cat(fd);
close(fd);
40: e1a00008 mov r0, r8
44: eb000108 bl 46c <close>
if(argc <= 1){
cat(0);
exit();
}
for(i = 1; i < argc; i++){
48: e1550007 cmp r5, r7
4c: 1afffff2 bne 1c <main+0x1c>
exit();
}
cat(fd);
close(fd);
}
exit();
50: eb0000c4 bl 368 <exit>
exit();
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
printf(1, "cat: cannot open %s\n", argv[i]);
54: e3a00001 mov r0, #1
58: e59f1014 ldr r1, [pc, #20] ; 74 <main+0x74>
5c: e5962000 ldr r2, [r6]
60: eb000213 bl 8b4 <printf>
exit();
64: eb0000bf bl 368 <exit>
main(int argc, char *argv[])
{
int fd, i;
if(argc <= 1){
cat(0);
68: e3a00000 mov r0, #0
6c: eb000001 bl 78 <cat>
exit();
70: eb0000bc bl 368 <exit>
74: 00000bb0 .word 0x00000bb0
00000078 <cat>:
char buf[512];
void
cat(int fd)
{
78: e92d4818 push {r3, r4, fp, lr}
7c: e1a04000 mov r4, r0
80: e28db00c add fp, sp, #12
int n;
while((n = read(fd, buf, sizeof(buf))) > 0)
84: ea000002 b 94 <cat+0x1c>
write(1, buf, n);
88: e3a00001 mov r0, #1
8c: e59f102c ldr r1, [pc, #44] ; c0 <cat+0x48>
90: eb0000e8 bl 438 <write>
void
cat(int fd)
{
int n;
while((n = read(fd, buf, sizeof(buf))) > 0)
94: e3a02c02 mov r2, #512 ; 0x200
98: e1a00004 mov r0, r4
9c: e59f101c ldr r1, [pc, #28] ; c0 <cat+0x48>
a0: eb0000d7 bl 404 <read>
a4: e2502000 subs r2, r0, #0
a8: cafffff6 bgt 88 <cat+0x10>
write(1, buf, n);
if(n < 0){
ac: 08bd8818 popeq {r3, r4, fp, pc}
printf(1, "cat: read error\n");
b0: e3a00001 mov r0, #1
b4: e59f1008 ldr r1, [pc, #8] ; c4 <cat+0x4c>
b8: eb0001fd bl 8b4 <printf>
exit();
bc: eb0000a9 bl 368 <exit>
c0: 00000bf0 .word 0x00000bf0
c4: 00000b9c .word 0x00000b9c
000000c8 <strcpy>:
#include "user.h"
#include "arm.h"
char*
strcpy(char *s, char *t)
{
c8: e52db004 push {fp} ; (str fp, [sp, #-4]!)
char *os;
os = s;
while((*s++ = *t++) != 0)
cc: e1a02000 mov r2, r0
#include "user.h"
#include "arm.h"
char*
strcpy(char *s, char *t)
{
d0: e28db000 add fp, sp, #0
char *os;
os = s;
while((*s++ = *t++) != 0)
d4: e4d13001 ldrb r3, [r1], #1
d8: e3530000 cmp r3, #0
dc: e4c23001 strb r3, [r2], #1
e0: 1afffffb bne d4 <strcpy+0xc>
;
return os;
}
e4: e28bd000 add sp, fp, #0
e8: e8bd0800 pop {fp}
ec: e12fff1e bx lr
000000f0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
f0: e52db004 push {fp} ; (str fp, [sp, #-4]!)
f4: e28db000 add fp, sp, #0
while(*p && *p == *q)
f8: e5d03000 ldrb r3, [r0]
fc: e5d12000 ldrb r2, [r1]
100: e3530000 cmp r3, #0
104: 1a000004 bne 11c <strcmp+0x2c>
108: ea000005 b 124 <strcmp+0x34>
10c: e5f03001 ldrb r3, [r0, #1]!
110: e3530000 cmp r3, #0
114: 0a000006 beq 134 <strcmp+0x44>
118: e5f12001 ldrb r2, [r1, #1]!
11c: e1530002 cmp r3, r2
120: 0afffff9 beq 10c <strcmp+0x1c>
p++, q++;
return (uchar)*p - (uchar)*q;
}
124: e0620003 rsb r0, r2, r3
128: e28bd000 add sp, fp, #0
12c: e8bd0800 pop {fp}
130: e12fff1e bx lr
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
134: e5d12001 ldrb r2, [r1, #1]
138: eafffff9 b 124 <strcmp+0x34>
0000013c <strlen>:
return (uchar)*p - (uchar)*q;
}
uint
strlen(char *s)
{
13c: e52db004 push {fp} ; (str fp, [sp, #-4]!)
140: e28db000 add fp, sp, #0
int n;
for(n = 0; s[n]; n++)
144: e5d03000 ldrb r3, [r0]
148: e3530000 cmp r3, #0
14c: 01a00003 moveq r0, r3
150: 0a000006 beq 170 <strlen+0x34>
154: e1a02000 mov r2, r0
158: e3a03000 mov r3, #0
15c: e5f21001 ldrb r1, [r2, #1]!
160: e2833001 add r3, r3, #1
164: e1a00003 mov r0, r3
168: e3510000 cmp r1, #0
16c: 1afffffa bne 15c <strlen+0x20>
;
return n;
}
170: e28bd000 add sp, fp, #0
174: e8bd0800 pop {fp}
178: e12fff1e bx lr
0000017c <memset>:
memset(void *dst, int c, uint n)
{
char *p=dst;
u32 rc=n;
while (rc-- > 0) *p++ = c;
17c: e3520000 cmp r2, #0
return n;
}
void*
memset(void *dst, int c, uint n)
{
180: e52db004 push {fp} ; (str fp, [sp, #-4]!)
184: e28db000 add fp, sp, #0
char *p=dst;
u32 rc=n;
while (rc-- > 0) *p++ = c;
188: 0a000006 beq 1a8 <memset+0x2c>
18c: e6ef1071 uxtb r1, r1
190: e1a03002 mov r3, r2
}
void*
memset(void *dst, int c, uint n)
{
char *p=dst;
194: e1a0c000 mov ip, r0
u32 rc=n;
while (rc-- > 0) *p++ = c;
198: e2533001 subs r3, r3, #1
19c: e4cc1001 strb r1, [ip], #1
1a0: 1afffffc bne 198 <memset+0x1c>
1a4: e0800002 add r0, r0, r2
return (void *)p;
}
1a8: e28bd000 add sp, fp, #0
1ac: e8bd0800 pop {fp}
1b0: e12fff1e bx lr
000001b4 <strchr>:
char*
strchr(const char *s, char c)
{
1b4: e52db004 push {fp} ; (str fp, [sp, #-4]!)
1b8: e28db000 add fp, sp, #0
for(; *s; s++)
1bc: e5d03000 ldrb r3, [r0]
1c0: e3530000 cmp r3, #0
1c4: 1a000004 bne 1dc <strchr+0x28>
1c8: ea000008 b 1f0 <strchr+0x3c>
1cc: e5d03001 ldrb r3, [r0, #1]
1d0: e2800001 add r0, r0, #1
1d4: e3530000 cmp r3, #0
1d8: 0a000004 beq 1f0 <strchr+0x3c>
if(*s == c)
1dc: e1530001 cmp r3, r1
1e0: 1afffff9 bne 1cc <strchr+0x18>
return (char*)s;
return 0;
}
1e4: e28bd000 add sp, fp, #0
1e8: e8bd0800 pop {fp}
1ec: e12fff1e bx lr
strchr(const char *s, char c)
{
for(; *s; s++)
if(*s == c)
return (char*)s;
return 0;
1f0: e1a00003 mov r0, r3
1f4: eafffffa b 1e4 <strchr+0x30>
000001f8 <gets>:
}
char*
gets(char *buf, int max)
{
1f8: e92d49f0 push {r4, r5, r6, r7, r8, fp, lr}
1fc: e28db018 add fp, sp, #24
200: e24dd00c sub sp, sp, #12
204: e1a08000 mov r8, r0
208: e1a07001 mov r7, r1
int i, cc;
char c;
for(i=0; i+1 < max; ){
20c: e1a06000 mov r6, r0
210: e3a05000 mov r5, #0
214: ea000008 b 23c <gets+0x44>
cc = read(0, &c, 1);
218: eb000079 bl 404 <read>
if(cc < 1)
21c: e3500000 cmp r0, #0
220: da00000b ble 254 <gets+0x5c>
break;
buf[i++] = c;
224: e55b301d ldrb r3, [fp, #-29]
if(c == '\n' || c == '\r')
228: e1a05004 mov r5, r4
22c: e353000a cmp r3, #10
230: 1353000d cmpne r3, #13
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
234: e4c63001 strb r3, [r6], #1
if(c == '\n' || c == '\r')
238: 0a00000a beq 268 <gets+0x70>
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
23c: e3a02001 mov r2, #1
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
240: e0854002 add r4, r5, r2
244: e1540007 cmp r4, r7
cc = read(0, &c, 1);
248: e3a00000 mov r0, #0
24c: e24b101d sub r1, fp, #29
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
250: bafffff0 blt 218 <gets+0x20>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
254: e3a03000 mov r3, #0
258: e7c83005 strb r3, [r8, r5]
return buf;
}
25c: e1a00008 mov r0, r8
260: e24bd018 sub sp, fp, #24
264: e8bd89f0 pop {r4, r5, r6, r7, r8, fp, pc}
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
268: e1a05004 mov r5, r4
26c: eafffff8 b 254 <gets+0x5c>
00000270 <stat>:
return buf;
}
int
stat(char *n, struct stat *st)
{
270: e92d4830 push {r4, r5, fp, lr}
274: e1a05001 mov r5, r1
278: e28db00c add fp, sp, #12
int fd;
int r;
fd = open(n, O_RDONLY);
27c: e3a01000 mov r1, #0
280: eb0000a0 bl 508 <open>
if(fd < 0)
284: e2504000 subs r4, r0, #0
return -1;
288: b3e05000 mvnlt r5, #0
{
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
28c: ba000004 blt 2a4 <stat+0x34>
return -1;
r = fstat(fd, st);
290: e1a01005 mov r1, r5
294: eb0000c2 bl 5a4 <fstat>
298: e1a05000 mov r5, r0
close(fd);
29c: e1a00004 mov r0, r4
2a0: eb000071 bl 46c <close>
return r;
}
2a4: e1a00005 mov r0, r5
2a8: e8bd8830 pop {r4, r5, fp, pc}
000002ac <atoi>:
int
atoi(const char *s)
{
2ac: e52db004 push {fp} ; (str fp, [sp, #-4]!)
2b0: e28db000 add fp, sp, #0
int n;
n = 0;
while('0' <= *s && *s <= '9')
2b4: e5d03000 ldrb r3, [r0]
2b8: e2432030 sub r2, r3, #48 ; 0x30
2bc: e6ef2072 uxtb r2, r2
2c0: e3520009 cmp r2, #9
int
atoi(const char *s)
{
int n;
n = 0;
2c4: 83a00000 movhi r0, #0
while('0' <= *s && *s <= '9')
2c8: 8a000009 bhi 2f4 <atoi+0x48>
2cc: e1a02000 mov r2, r0
int
atoi(const char *s)
{
int n;
n = 0;
2d0: e3a00000 mov r0, #0
while('0' <= *s && *s <= '9')
n = n*10 + *s++ - '0';
2d4: e0800100 add r0, r0, r0, lsl #2
2d8: e0830080 add r0, r3, r0, lsl #1
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
2dc: e5f23001 ldrb r3, [r2, #1]!
n = n*10 + *s++ - '0';
2e0: e2400030 sub r0, r0, #48 ; 0x30
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
2e4: e2431030 sub r1, r3, #48 ; 0x30
2e8: e6ef1071 uxtb r1, r1
2ec: e3510009 cmp r1, #9
2f0: 9afffff7 bls 2d4 <atoi+0x28>
n = n*10 + *s++ - '0';
return n;
}
2f4: e28bd000 add sp, fp, #0
2f8: e8bd0800 pop {fp}
2fc: e12fff1e bx lr
00000300 <memmove>:
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
300: e3520000 cmp r2, #0
return n;
}
void*
memmove(void *vdst, void *vsrc, int n)
{
304: e52db004 push {fp} ; (str fp, [sp, #-4]!)
308: e28db000 add fp, sp, #0
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
30c: da000005 ble 328 <memmove+0x28>
n = n*10 + *s++ - '0';
return n;
}
void*
memmove(void *vdst, void *vsrc, int n)
310: e0802002 add r2, r0, r2
{
char *dst, *src;
dst = vdst;
314: e1a03000 mov r3, r0
src = vsrc;
while(n-- > 0)
*dst++ = *src++;
318: e4d1c001 ldrb ip, [r1], #1
31c: e4c3c001 strb ip, [r3], #1
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
320: e1530002 cmp r3, r2
324: 1afffffb bne 318 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
328: e28bd000 add sp, fp, #0
32c: e8bd0800 pop {fp}
330: e12fff1e bx lr
00000334 <fork>:
334: e92d4000 push {lr}
338: e92d0008 push {r3}
33c: e92d0004 push {r2}
340: e92d0002 push {r1}
344: e92d0001 push {r0}
348: e3a00001 mov r0, #1
34c: ef000040 svc 0x00000040
350: e8bd0002 pop {r1}
354: e8bd0002 pop {r1}
358: e8bd0004 pop {r2}
35c: e8bd0008 pop {r3}
360: e8bd4000 pop {lr}
364: e12fff1e bx lr
00000368 <exit>:
368: e92d4000 push {lr}
36c: e92d0008 push {r3}
370: e92d0004 push {r2}
374: e92d0002 push {r1}
378: e92d0001 push {r0}
37c: e3a00002 mov r0, #2
380: ef000040 svc 0x00000040
384: e8bd0002 pop {r1}
388: e8bd0002 pop {r1}
38c: e8bd0004 pop {r2}
390: e8bd0008 pop {r3}
394: e8bd4000 pop {lr}
398: e12fff1e bx lr
0000039c <wait>:
39c: e92d4000 push {lr}
3a0: e92d0008 push {r3}
3a4: e92d0004 push {r2}
3a8: e92d0002 push {r1}
3ac: e92d0001 push {r0}
3b0: e3a00003 mov r0, #3
3b4: ef000040 svc 0x00000040
3b8: e8bd0002 pop {r1}
3bc: e8bd0002 pop {r1}
3c0: e8bd0004 pop {r2}
3c4: e8bd0008 pop {r3}
3c8: e8bd4000 pop {lr}
3cc: e12fff1e bx lr
000003d0 <pipe>:
3d0: e92d4000 push {lr}
3d4: e92d0008 push {r3}
3d8: e92d0004 push {r2}
3dc: e92d0002 push {r1}
3e0: e92d0001 push {r0}
3e4: e3a00004 mov r0, #4
3e8: ef000040 svc 0x00000040
3ec: e8bd0002 pop {r1}
3f0: e8bd0002 pop {r1}
3f4: e8bd0004 pop {r2}
3f8: e8bd0008 pop {r3}
3fc: e8bd4000 pop {lr}
400: e12fff1e bx lr
00000404 <read>:
404: e92d4000 push {lr}
408: e92d0008 push {r3}
40c: e92d0004 push {r2}
410: e92d0002 push {r1}
414: e92d0001 push {r0}
418: e3a00005 mov r0, #5
41c: ef000040 svc 0x00000040
420: e8bd0002 pop {r1}
424: e8bd0002 pop {r1}
428: e8bd0004 pop {r2}
42c: e8bd0008 pop {r3}
430: e8bd4000 pop {lr}
434: e12fff1e bx lr
00000438 <write>:
438: e92d4000 push {lr}
43c: e92d0008 push {r3}
440: e92d0004 push {r2}
444: e92d0002 push {r1}
448: e92d0001 push {r0}
44c: e3a00010 mov r0, #16
450: ef000040 svc 0x00000040
454: e8bd0002 pop {r1}
458: e8bd0002 pop {r1}
45c: e8bd0004 pop {r2}
460: e8bd0008 pop {r3}
464: e8bd4000 pop {lr}
468: e12fff1e bx lr
0000046c <close>:
46c: e92d4000 push {lr}
470: e92d0008 push {r3}
474: e92d0004 push {r2}
478: e92d0002 push {r1}
47c: e92d0001 push {r0}
480: e3a00015 mov r0, #21
484: ef000040 svc 0x00000040
488: e8bd0002 pop {r1}
48c: e8bd0002 pop {r1}
490: e8bd0004 pop {r2}
494: e8bd0008 pop {r3}
498: e8bd4000 pop {lr}
49c: e12fff1e bx lr
000004a0 <kill>:
4a0: e92d4000 push {lr}
4a4: e92d0008 push {r3}
4a8: e92d0004 push {r2}
4ac: e92d0002 push {r1}
4b0: e92d0001 push {r0}
4b4: e3a00006 mov r0, #6
4b8: ef000040 svc 0x00000040
4bc: e8bd0002 pop {r1}
4c0: e8bd0002 pop {r1}
4c4: e8bd0004 pop {r2}
4c8: e8bd0008 pop {r3}
4cc: e8bd4000 pop {lr}
4d0: e12fff1e bx lr
000004d4 <exec>:
4d4: e92d4000 push {lr}
4d8: e92d0008 push {r3}
4dc: e92d0004 push {r2}
4e0: e92d0002 push {r1}
4e4: e92d0001 push {r0}
4e8: e3a00007 mov r0, #7
4ec: ef000040 svc 0x00000040
4f0: e8bd0002 pop {r1}
4f4: e8bd0002 pop {r1}
4f8: e8bd0004 pop {r2}
4fc: e8bd0008 pop {r3}
500: e8bd4000 pop {lr}
504: e12fff1e bx lr
00000508 <open>:
508: e92d4000 push {lr}
50c: e92d0008 push {r3}
510: e92d0004 push {r2}
514: e92d0002 push {r1}
518: e92d0001 push {r0}
51c: e3a0000f mov r0, #15
520: ef000040 svc 0x00000040
524: e8bd0002 pop {r1}
528: e8bd0002 pop {r1}
52c: e8bd0004 pop {r2}
530: e8bd0008 pop {r3}
534: e8bd4000 pop {lr}
538: e12fff1e bx lr
0000053c <mknod>:
53c: e92d4000 push {lr}
540: e92d0008 push {r3}
544: e92d0004 push {r2}
548: e92d0002 push {r1}
54c: e92d0001 push {r0}
550: e3a00011 mov r0, #17
554: ef000040 svc 0x00000040
558: e8bd0002 pop {r1}
55c: e8bd0002 pop {r1}
560: e8bd0004 pop {r2}
564: e8bd0008 pop {r3}
568: e8bd4000 pop {lr}
56c: e12fff1e bx lr
00000570 <unlink>:
570: e92d4000 push {lr}
574: e92d0008 push {r3}
578: e92d0004 push {r2}
57c: e92d0002 push {r1}
580: e92d0001 push {r0}
584: e3a00012 mov r0, #18
588: ef000040 svc 0x00000040
58c: e8bd0002 pop {r1}
590: e8bd0002 pop {r1}
594: e8bd0004 pop {r2}
598: e8bd0008 pop {r3}
59c: e8bd4000 pop {lr}
5a0: e12fff1e bx lr
000005a4 <fstat>:
5a4: e92d4000 push {lr}
5a8: e92d0008 push {r3}
5ac: e92d0004 push {r2}
5b0: e92d0002 push {r1}
5b4: e92d0001 push {r0}
5b8: e3a00008 mov r0, #8
5bc: ef000040 svc 0x00000040
5c0: e8bd0002 pop {r1}
5c4: e8bd0002 pop {r1}
5c8: e8bd0004 pop {r2}
5cc: e8bd0008 pop {r3}
5d0: e8bd4000 pop {lr}
5d4: e12fff1e bx lr
000005d8 <link>:
5d8: e92d4000 push {lr}
5dc: e92d0008 push {r3}
5e0: e92d0004 push {r2}
5e4: e92d0002 push {r1}
5e8: e92d0001 push {r0}
5ec: e3a00013 mov r0, #19
5f0: ef000040 svc 0x00000040
5f4: e8bd0002 pop {r1}
5f8: e8bd0002 pop {r1}
5fc: e8bd0004 pop {r2}
600: e8bd0008 pop {r3}
604: e8bd4000 pop {lr}
608: e12fff1e bx lr
0000060c <mkdir>:
60c: e92d4000 push {lr}
610: e92d0008 push {r3}
614: e92d0004 push {r2}
618: e92d0002 push {r1}
61c: e92d0001 push {r0}
620: e3a00014 mov r0, #20
624: ef000040 svc 0x00000040
628: e8bd0002 pop {r1}
62c: e8bd0002 pop {r1}
630: e8bd0004 pop {r2}
634: e8bd0008 pop {r3}
638: e8bd4000 pop {lr}
63c: e12fff1e bx lr
00000640 <chdir>:
640: e92d4000 push {lr}
644: e92d0008 push {r3}
648: e92d0004 push {r2}
64c: e92d0002 push {r1}
650: e92d0001 push {r0}
654: e3a00009 mov r0, #9
658: ef000040 svc 0x00000040
65c: e8bd0002 pop {r1}
660: e8bd0002 pop {r1}
664: e8bd0004 pop {r2}
668: e8bd0008 pop {r3}
66c: e8bd4000 pop {lr}
670: e12fff1e bx lr
00000674 <dup>:
674: e92d4000 push {lr}
678: e92d0008 push {r3}
67c: e92d0004 push {r2}
680: e92d0002 push {r1}
684: e92d0001 push {r0}
688: e3a0000a mov r0, #10
68c: ef000040 svc 0x00000040
690: e8bd0002 pop {r1}
694: e8bd0002 pop {r1}
698: e8bd0004 pop {r2}
69c: e8bd0008 pop {r3}
6a0: e8bd4000 pop {lr}
6a4: e12fff1e bx lr
000006a8 <getpid>:
6a8: e92d4000 push {lr}
6ac: e92d0008 push {r3}
6b0: e92d0004 push {r2}
6b4: e92d0002 push {r1}
6b8: e92d0001 push {r0}
6bc: e3a0000b mov r0, #11
6c0: ef000040 svc 0x00000040
6c4: e8bd0002 pop {r1}
6c8: e8bd0002 pop {r1}
6cc: e8bd0004 pop {r2}
6d0: e8bd0008 pop {r3}
6d4: e8bd4000 pop {lr}
6d8: e12fff1e bx lr
000006dc <sbrk>:
6dc: e92d4000 push {lr}
6e0: e92d0008 push {r3}
6e4: e92d0004 push {r2}
6e8: e92d0002 push {r1}
6ec: e92d0001 push {r0}
6f0: e3a0000c mov r0, #12
6f4: ef000040 svc 0x00000040
6f8: e8bd0002 pop {r1}
6fc: e8bd0002 pop {r1}
700: e8bd0004 pop {r2}
704: e8bd0008 pop {r3}
708: e8bd4000 pop {lr}
70c: e12fff1e bx lr
00000710 <sleep>:
710: e92d4000 push {lr}
714: e92d0008 push {r3}
718: e92d0004 push {r2}
71c: e92d0002 push {r1}
720: e92d0001 push {r0}
724: e3a0000d mov r0, #13
728: ef000040 svc 0x00000040
72c: e8bd0002 pop {r1}
730: e8bd0002 pop {r1}
734: e8bd0004 pop {r2}
738: e8bd0008 pop {r3}
73c: e8bd4000 pop {lr}
740: e12fff1e bx lr
00000744 <uptime>:
744: e92d4000 push {lr}
748: e92d0008 push {r3}
74c: e92d0004 push {r2}
750: e92d0002 push {r1}
754: e92d0001 push {r0}
758: e3a0000e mov r0, #14
75c: ef000040 svc 0x00000040
760: e8bd0002 pop {r1}
764: e8bd0002 pop {r1}
768: e8bd0004 pop {r2}
76c: e8bd0008 pop {r3}
770: e8bd4000 pop {lr}
774: e12fff1e bx lr
00000778 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
778: e92d4800 push {fp, lr}
77c: e28db004 add fp, sp, #4
780: e24b3004 sub r3, fp, #4
784: e24dd008 sub sp, sp, #8
write(fd, &c, 1);
788: e3a02001 mov r2, #1
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
78c: e5631001 strb r1, [r3, #-1]!
write(fd, &c, 1);
790: e1a01003 mov r1, r3
794: ebffff27 bl 438 <write>
}
798: e24bd004 sub sp, fp, #4
79c: e8bd8800 pop {fp, pc}
000007a0 <printint>:
return q;
}
static void
printint(int fd, int xx, int base, int sgn)
{
7a0: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
7a4: e1a04000 mov r4, r0
char buf[16];
int i, neg;
uint x, y, b;
neg = 0;
if(sgn && xx < 0){
7a8: e1a00fa1 lsr r0, r1, #31
7ac: e3530000 cmp r3, #0
7b0: 03a03000 moveq r3, #0
7b4: 12003001 andne r3, r0, #1
return q;
}
static void
printint(int fd, int xx, int base, int sgn)
{
7b8: e28db020 add fp, sp, #32
char buf[16];
int i, neg;
uint x, y, b;
neg = 0;
if(sgn && xx < 0){
7bc: e3530000 cmp r3, #0
return q;
}
static void
printint(int fd, int xx, int base, int sgn)
{
7c0: e24dd014 sub sp, sp, #20
7c4: e59f909c ldr r9, [pc, #156] ; 868 <printint+0xc8>
uint x, y, b;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
7c8: 12611000 rsbne r1, r1, #0
int i, neg;
uint x, y, b;
neg = 0;
if(sgn && xx < 0){
neg = 1;
7cc: 13a03001 movne r3, #1
} else {
x = xx;
}
b = base;
i = 0;
7d0: e3a0a000 mov sl, #0
7d4: e24b6034 sub r6, fp, #52 ; 0x34
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
if(r >= d) {
r = r - d;
q = q | (1 << i);
7d8: e3a08001 mov r8, #1
write(fd, &c, 1);
}
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
7dc: e3a07000 mov r7, #0
int i;
for(i=31;i>=0;i--){
7e0: e3a0001f mov r0, #31
write(fd, &c, 1);
}
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
7e4: e1a0c007 mov ip, r7
int i;
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
7e8: e1a0e031 lsr lr, r1, r0
7ec: e20ee001 and lr, lr, #1
7f0: e18ec08c orr ip, lr, ip, lsl #1
if(r >= d) {
7f4: e152000c cmp r2, ip
r = r - d;
q = q | (1 << i);
7f8: 91877018 orrls r7, r7, r8, lsl r0
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
if(r >= d) {
r = r - d;
7fc: 9062c00c rsbls ip, r2, ip
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
int i;
for(i=31;i>=0;i--){
800: e2500001 subs r0, r0, #1
804: 2afffff7 bcs 7e8 <printint+0x48>
b = base;
i = 0;
do{
y = div(x, b);
buf[i++] = digits[x - y * b];
808: e0000792 mul r0, r2, r7
}while((x = y) != 0);
80c: e3570000 cmp r7, #0
b = base;
i = 0;
do{
y = div(x, b);
buf[i++] = digits[x - y * b];
810: e0601001 rsb r1, r0, r1
814: e28a5001 add r5, sl, #1
818: e7d91001 ldrb r1, [r9, r1]
81c: e7c6100a strb r1, [r6, sl]
}while((x = y) != 0);
820: 11a01007 movne r1, r7
b = base;
i = 0;
do{
y = div(x, b);
buf[i++] = digits[x - y * b];
824: 11a0a005 movne sl, r5
828: 1affffeb bne 7dc <printint+0x3c>
}while((x = y) != 0);
if(neg)
82c: e3530000 cmp r3, #0
buf[i++] = '-';
830: 124b2024 subne r2, fp, #36 ; 0x24
834: 10823005 addne r3, r2, r5
838: 128a5002 addne r5, sl, #2
while(--i >= 0)
83c: e2455001 sub r5, r5, #1
do{
y = div(x, b);
buf[i++] = digits[x - y * b];
}while((x = y) != 0);
if(neg)
buf[i++] = '-';
840: 13a0202d movne r2, #45 ; 0x2d
844: 15432010 strbne r2, [r3, #-16]
while(--i >= 0)
putc(fd, buf[i]);
848: e7d61005 ldrb r1, [r6, r5]
84c: e1a00004 mov r0, r4
buf[i++] = digits[x - y * b];
}while((x = y) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
850: e2455001 sub r5, r5, #1
putc(fd, buf[i]);
854: ebffffc7 bl 778 <putc>
buf[i++] = digits[x - y * b];
}while((x = y) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
858: e3750001 cmn r5, #1
85c: 1afffff9 bne 848 <printint+0xa8>
putc(fd, buf[i]);
}
860: e24bd020 sub sp, fp, #32
864: e8bd8ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, pc}
868: 00000bc8 .word 0x00000bc8
0000086c <div>:
write(fd, &c, 1);
}
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
86c: e3a03000 mov r3, #0
{
write(fd, &c, 1);
}
u32 div(u32 n, u32 d) // long division
{
870: e92d0830 push {r4, r5, fp}
874: e1a02000 mov r2, r0
878: e28db008 add fp, sp, #8
u32 q=0, r=0;
int i;
for(i=31;i>=0;i--){
87c: e3a0c01f mov ip, #31
write(fd, &c, 1);
}
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
880: e1a00003 mov r0, r3
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
if(r >= d) {
r = r - d;
q = q | (1 << i);
884: e3a05001 mov r5, #1
u32 q=0, r=0;
int i;
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
888: e1a04c32 lsr r4, r2, ip
88c: e2044001 and r4, r4, #1
890: e1843083 orr r3, r4, r3, lsl #1
if(r >= d) {
894: e1530001 cmp r3, r1
r = r - d;
q = q | (1 << i);
898: 21800c15 orrcs r0, r0, r5, lsl ip
for(i=31;i>=0;i--){
r = r << 1;
r = r | ((n >> i) & 1);
if(r >= d) {
r = r - d;
89c: 20613003 rsbcs r3, r1, r3
u32 div(u32 n, u32 d) // long division
{
u32 q=0, r=0;
int i;
for(i=31;i>=0;i--){
8a0: e25cc001 subs ip, ip, #1
8a4: 2afffff7 bcs 888 <div+0x1c>
r = r - d;
q = q | (1 << i);
}
}
return q;
}
8a8: e24bd008 sub sp, fp, #8
8ac: e8bd0830 pop {r4, r5, fp}
8b0: e12fff1e bx lr
000008b4 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
8b4: e92d000e push {r1, r2, r3}
8b8: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
8bc: e28db020 add fp, sp, #32
8c0: e1a05000 mov r5, r0
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
8c4: e59b4004 ldr r4, [fp, #4]
8c8: e5d48000 ldrb r8, [r4]
8cc: e3580000 cmp r8, #0
8d0: 0a000027 beq 974 <printf+0xc0>
ap++;
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
8d4: e59f712c ldr r7, [pc, #300] ; a08 <printf+0x154>
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
8d8: e28b6008 add r6, fp, #8
{
char *s;
int c, i, state;
uint *ap;
state = 0;
8dc: e3a0a000 mov sl, #0
8e0: ea000008 b 908 <printf+0x54>
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
8e4: e3580025 cmp r8, #37 ; 0x25
state = '%';
8e8: 01a0a008 moveq sl, r8
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
8ec: 0a000002 beq 8fc <printf+0x48>
state = '%';
} else {
putc(fd, c);
8f0: e1a00005 mov r0, r5
8f4: e1a01008 mov r1, r8
8f8: ebffff9e bl 778 <putc>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
8fc: e5f48001 ldrb r8, [r4, #1]!
900: e3580000 cmp r8, #0
904: 0a00001a beq 974 <printf+0xc0>
c = fmt[i] & 0xff;
if(state == 0){
908: e35a0000 cmp sl, #0
90c: 0afffff4 beq 8e4 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
910: e35a0025 cmp sl, #37 ; 0x25
914: 1afffff8 bne 8fc <printf+0x48>
if(c == 'd'){
918: e3580064 cmp r8, #100 ; 0x64
91c: 0a00002c beq 9d4 <printf+0x120>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
920: e3580078 cmp r8, #120 ; 0x78
924: 13580070 cmpne r8, #112 ; 0x70
928: 13a09000 movne r9, #0
92c: 03a09001 moveq r9, #1
930: 0a000013 beq 984 <printf+0xd0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
934: e3580073 cmp r8, #115 ; 0x73
938: 0a000018 beq 9a0 <printf+0xec>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
93c: e3580063 cmp r8, #99 ; 0x63
940: 0a00002a beq 9f0 <printf+0x13c>
putc(fd, *ap);
ap++;
} else if(c == '%'){
944: e3580025 cmp r8, #37 ; 0x25
putc(fd, c);
948: e1a0100a mov r1, sl
94c: e1a00005 mov r0, r5
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
ap++;
} else if(c == '%'){
950: 0a000002 beq 960 <printf+0xac>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
954: ebffff87 bl 778 <putc>
putc(fd, c);
958: e1a00005 mov r0, r5
95c: e1a01008 mov r1, r8
960: ebffff84 bl 778 <putc>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
964: e5f48001 ldrb r8, [r4, #1]!
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
968: e1a0a009 mov sl, r9
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
96c: e3580000 cmp r8, #0
970: 1affffe4 bne 908 <printf+0x54>
putc(fd, c);
}
state = 0;
}
}
}
974: e24bd020 sub sp, fp, #32
978: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr}
97c: e28dd00c add sp, sp, #12
980: e12fff1e bx lr
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
984: e1a00005 mov r0, r5
988: e4961004 ldr r1, [r6], #4
98c: e3a02010 mov r2, #16
990: e3a03000 mov r3, #0
994: ebffff81 bl 7a0 <printint>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
998: e3a0a000 mov sl, #0
99c: eaffffd6 b 8fc <printf+0x48>
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
s = (char*)*ap;
9a0: e4968004 ldr r8, [r6], #4
ap++;
if(s == 0)
s = "(null)";
9a4: e3580000 cmp r8, #0
9a8: 01a08007 moveq r8, r7
while(*s != 0){
9ac: e5d81000 ldrb r1, [r8]
9b0: e3510000 cmp r1, #0
9b4: 0a000004 beq 9cc <printf+0x118>
putc(fd, *s);
9b8: e1a00005 mov r0, r5
9bc: ebffff6d bl 778 <putc>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
9c0: e5f81001 ldrb r1, [r8, #1]!
9c4: e3510000 cmp r1, #0
9c8: 1afffffa bne 9b8 <printf+0x104>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
9cc: e1a0a001 mov sl, r1
9d0: eaffffc9 b 8fc <printf+0x48>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
9d4: e1a00005 mov r0, r5
9d8: e4961004 ldr r1, [r6], #4
9dc: e3a0200a mov r2, #10
9e0: e3a03001 mov r3, #1
9e4: ebffff6d bl 7a0 <printint>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
9e8: e3a0a000 mov sl, #0
9ec: eaffffc2 b 8fc <printf+0x48>
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
9f0: e4961004 ldr r1, [r6], #4
9f4: e1a00005 mov r0, r5
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
9f8: e1a0a009 mov sl, r9
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
9fc: e6ef1071 uxtb r1, r1
a00: ebffff5c bl 778 <putc>
a04: eaffffbc b 8fc <printf+0x48>
a08: 00000bdc .word 0x00000bdc
00000a0c <free>:
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
a0c: e59f3098 ldr r3, [pc, #152] ; aac <free+0xa0>
static Header base;
static Header *freep;
void
free(void *ap)
{
a10: e92d0830 push {r4, r5, fp}
Header *bp, *p;
bp = (Header*)ap - 1;
a14: e240c008 sub ip, r0, #8
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
a18: e5932000 ldr r2, [r3]
static Header base;
static Header *freep;
void
free(void *ap)
{
a1c: e28db008 add fp, sp, #8
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
a20: e152000c cmp r2, ip
a24: e5921000 ldr r1, [r2]
a28: 2a000001 bcs a34 <free+0x28>
a2c: e15c0001 cmp ip, r1
a30: 3a000007 bcc a54 <free+0x48>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
a34: e1520001 cmp r2, r1
a38: 3a000003 bcc a4c <free+0x40>
a3c: e152000c cmp r2, ip
a40: 3a000003 bcc a54 <free+0x48>
a44: e15c0001 cmp ip, r1
a48: 3a000001 bcc a54 <free+0x48>
static Header base;
static Header *freep;
void
free(void *ap)
{
a4c: e1a02001 mov r2, r1
a50: eafffff2 b a20 <free+0x14>
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){
a54: e5104004 ldr r4, [r0, #-4]
if(p + p->s.size == bp){
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
a58: e5832000 str r2, [r3]
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){
a5c: e08c5184 add r5, ip, r4, lsl #3
a60: e1550001 cmp r5, r1
bp->s.size += p->s.ptr->s.size;
a64: 05911004 ldreq r1, [r1, #4]
a68: 00814004 addeq r4, r1, r4
a6c: 05004004 streq r4, [r0, #-4]
bp->s.ptr = p->s.ptr->s.ptr;
a70: 05921000 ldreq r1, [r2]
a74: 05911000 ldreq r1, [r1]
} else
bp->s.ptr = p->s.ptr;
a78: e5001008 str r1, [r0, #-8]
if(p + p->s.size == bp){
a7c: e5921004 ldr r1, [r2, #4]
a80: e0824181 add r4, r2, r1, lsl #3
a84: e15c0004 cmp ip, r4
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
a88: 1582c000 strne ip, [r2]
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;
a8c: 0510c004 ldreq ip, [r0, #-4]
a90: 008c1001 addeq r1, ip, r1
a94: 05821004 streq r1, [r2, #4]
p->s.ptr = bp->s.ptr;
a98: 05101008 ldreq r1, [r0, #-8]
a9c: 05821000 streq r1, [r2]
} else
p->s.ptr = bp;
freep = p;
}
aa0: e24bd008 sub sp, fp, #8
aa4: e8bd0830 pop {r4, r5, fp}
aa8: e12fff1e bx lr
aac: 00000be4 .word 0x00000be4
00000ab0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
ab0: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
ab4: e2804007 add r4, r0, #7
if((prevp = freep) == 0){
ab8: e59f50d4 ldr r5, [pc, #212] ; b94 <malloc+0xe4>
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
abc: e1a041a4 lsr r4, r4, #3
return freep;
}
void*
malloc(uint nbytes)
{
ac0: e28db01c add fp, sp, #28
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
ac4: e5953000 ldr r3, [r5]
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
ac8: e2844001 add r4, r4, #1
if((prevp = freep) == 0){
acc: e3530000 cmp r3, #0
ad0: 0a00002b beq b84 <malloc+0xd4>
ad4: e5930000 ldr r0, [r3]
ad8: e5902004 ldr r2, [r0, #4]
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){
adc: e1520004 cmp r2, r4
ae0: 2a00001b bcs b54 <malloc+0xa4>
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
ae4: e59f80ac ldr r8, [pc, #172] ; b98 <malloc+0xe8>
p->s.size -= nunits;
p += p->s.size;
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
ae8: e1a07184 lsl r7, r4, #3
aec: ea000003 b b00 <malloc+0x50>
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){
af0: e5930000 ldr r0, [r3]
if(p->s.size >= nunits){
af4: e5902004 ldr r2, [r0, #4]
af8: e1540002 cmp r4, r2
afc: 9a000014 bls b54 <malloc+0xa4>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
b00: e5952000 ldr r2, [r5]
b04: e1a03000 mov r3, r0
b08: e1500002 cmp r0, r2
b0c: 1afffff7 bne af0 <malloc+0x40>
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
b10: e1540008 cmp r4, r8
nu = 4096;
p = sbrk(nu * sizeof(Header));
b14: 81a00007 movhi r0, r7
b18: 93a00902 movls r0, #32768 ; 0x8000
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
b1c: 81a06004 movhi r6, r4
b20: 93a06a01 movls r6, #4096 ; 0x1000
nu = 4096;
p = sbrk(nu * sizeof(Header));
b24: ebfffeec bl 6dc <sbrk>
b28: e1a03000 mov r3, r0
if(p == (char*)-1)
b2c: e3730001 cmn r3, #1
return 0;
hp = (Header*)p;
hp->s.size = nu;
free((void*)(hp + 1));
b30: e2800008 add r0, r0, #8
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
if(p == (char*)-1)
b34: 0a000010 beq b7c <malloc+0xcc>
return 0;
hp = (Header*)p;
hp->s.size = nu;
b38: e5836004 str r6, [r3, #4]
free((void*)(hp + 1));
b3c: ebffffb2 bl a0c <free>
return freep;
b40: e5953000 ldr r3, [r5]
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
b44: e3530000 cmp r3, #0
b48: 1affffe8 bne af0 <malloc+0x40>
return 0;
b4c: e1a00003 mov r0, r3
}
}
b50: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
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)
b54: e1540002 cmp r4, r2
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
b58: 10642002 rsbne r2, r4, r2
b5c: 15802004 strne r2, [r0, #4]
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;
b60: 05902000 ldreq r2, [r0]
else {
p->s.size -= nunits;
p += p->s.size;
b64: 10800182 addne r0, r0, r2, lsl #3
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;
b68: 05832000 streq r2, [r3]
else {
p->s.size -= nunits;
p += p->s.size;
p->s.size = nunits;
b6c: 15804004 strne r4, [r0, #4]
}
freep = prevp;
b70: e5853000 str r3, [r5]
return (void*)(p + 1);
b74: e2800008 add r0, r0, #8
b78: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
b7c: e3a00000 mov r0, #0
b80: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
b84: e2850004 add r0, r5, #4
b88: e5850000 str r0, [r5]
base.s.size = 0;
b8c: e9850009 stmib r5, {r0, r3}
b90: eaffffd3 b ae4 <malloc+0x34>
b94: 00000be4 .word 0x00000be4
b98: 00000fff .word 0x00000fff
|
parser/src/main/resources/mysql expression.g4 | buzhidaolvtu/mysql-parser | 1 | 3339 | <filename>parser/src/main/resources/mysql expression.g4
expr:
expr OR expr
| expr || expr
| expr XOR expr
| expr AND expr
| expr '&' '&' expr
| NOT expr
| '!' expr
| boolean_primary IS NOT? (TRUE | FALSE | UNKNOWN)
| boolean_primary
boolean_primary:
boolean_primary IS NOT? NULL
| boolean_primary '<' '=' '>' predicate
| boolean_primary comparison_operator predicate
| boolean_primary comparison_operator (ALL | ANY) '(' subquery ')'
| predicate
comparison_operator: '=' | '>' '=' | '>' | '<' '=' | '<' | '<' '>' | '!' '='
predicate:
bit_expr NOT? IN '(' subquery ')'
| bit_expr NOT? IN '(' expr (',' expr)* ')'
| bit_expr NOT? BETWEEN bit_expr AND predicate
| bit_expr SOUNDS LIKE bit_expr
| bit_expr NOT? LIKE simple_expr (ESCAPE simple_expr)?
| bit_expr NOT? REGEXP bit_expr
| bit_expr
bit_expr:
bit_expr '|' bit_expr
| bit_expr '&' bit_expr
| bit_expr '<' '<' bit_expr
| bit_expr '>' '>' bit_expr
| bit_expr '+' bit_expr
| bit_expr '-' bit_expr
| bit_expr '*' bit_expr
| bit_expr '/' bit_expr
| bit_expr DIV bit_expr
| bit_expr MOD bit_expr
| bit_expr '%' bit_expr
| bit_expr '^' bit_expr
| bit_expr '+' interval_expr
| bit_expr '-' interval_expr
| simple_expr
simple_expr:
literal
| identifier
| function_call
| simple_expr COLLATE collation_name
| param_marker
| variable
| simple_expr '|' '|' simple_expr
| '+' simple_expr
| '-' simple_expr
| '~' simple_expr
| '!' simple_expr
| BINARY simple_expr
| '(' expr (',' expr)* ')'
| ROW '(' expr, expr (',' expr)* ')'
| '(' subquery ')'
| EXISTS '(' subquery ')'
| '{' identifier expr '}'
| match_expr
| case_expr
| interval_expr |
ffmpeg-2.3.6/ffmpeg-2.3.6/libavcodec/x86/hevc_idct.asm | d2262272d/ffmpeg | 16 | 246742 | <gh_stars>10-100
; /*
; * Provide SSE & MMX idct functions for HEVC decoding
; * Copyright (c) 2014 <NAME>
; *
; * This file is part of FFmpeg.
; *
; * FFmpeg is free software; you can redistribute it and/or
; * modify it under the terms of the GNU Lesser General Public
; * License as published by the Free Software Foundation; either
; * version 2.1 of the License, or (at your option) any later version.
; *
; * FFmpeg 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
; * Lesser General Public License for more details.
; *
; * You should have received a copy of the GNU Lesser General Public
; * License along with FFmpeg; if not, write to the Free Software
; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
; */
%include "libavutil/x86/x86util.asm"
SECTION_RODATA 32
max_pixels_10: times 16 dw ((1 << 10)-1)
dc_add_10: times 4 dd ((1 << 14-10) + 1)
SECTION_TEXT 32
;the idct_dc_add macros and functions were largely inspired by x264 project's code in the h264_idct.asm file
%macro DC_ADD_INIT 2
add %1w, ((1 << 14-8) + 1)
sar %1w, (15-8)
movd m0, %1d
lea %1, [%2*3]
SPLATW m0, m0, 0
pxor m1, m1
psubw m1, m0
packuswb m0, m0
packuswb m1, m1
%endmacro
%macro DC_ADD_INIT_AVX2 2
add %1w, ((1 << 14-8) + 1)
sar %1w, (15-8)
movd xm0, %1d
vpbroadcastw m0, xm0 ;SPLATW
lea %1, [%2*3]
pxor m1, m1
psubw m1, m0
packuswb m0, m0
packuswb m1, m1
%endmacro
%macro DC_ADD_OP 4
%1 m2, [%2 ]
%1 m3, [%2+%3 ]
%1 m4, [%2+%3*2]
%1 m5, [%2+%4 ]
paddusb m2, m0
paddusb m3, m0
paddusb m4, m0
paddusb m5, m0
psubusb m2, m1
psubusb m3, m1
psubusb m4, m1
psubusb m5, m1
%1 [%2 ], m2
%1 [%2+%3 ], m3
%1 [%2+%3*2], m4
%1 [%2+%4 ], m5
%endmacro
INIT_MMX mmxext
; void ff_hevc_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
%if ARCH_X86_64
cglobal hevc_idct4_dc_add_8, 3, 4, 0
movsx r3, word [r1]
DC_ADD_INIT r3, r2
DC_ADD_OP movh, r0, r2, r3
RET
; void ff_hevc_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
cglobal hevc_idct8_dc_add_8, 3, 4, 0
movsx r3, word [r1]
DC_ADD_INIT r3, r2
DC_ADD_OP mova, r0, r2, r3
lea r0, [r0+r2*4]
DC_ADD_OP mova, r0, r2, r3
RET
%else
; void ff_hevc_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
cglobal hevc_idct4_dc_add_8, 2, 3, 0
movsx r2, word [r1]
mov r1, r2m
DC_ADD_INIT r2, r1
DC_ADD_OP movh, r0, r1, r2
RET
; void ff_hevc_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
cglobal hevc_idct8_dc_add_8, 2, 3, 0
movsx r2, word [r1]
mov r1, r2m
DC_ADD_INIT r2, r1
DC_ADD_OP mova, r0, r1, r2
lea r0, [r0+r1*4]
DC_ADD_OP mova, r0, r1, r2
RET
%endif
INIT_XMM sse2
; void ff_hevc_idct16_dc_add_8_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
cglobal hevc_idct16_dc_add_8, 3, 4, 6
movsx r3, word [r1]
DC_ADD_INIT r3, r2
DC_ADD_OP mova, r0, r2, r3
lea r0, [r0+r2*4]
DC_ADD_OP mova, r0, r2, r3
lea r0, [r0+r2*4]
DC_ADD_OP mova, r0, r2, r3
lea r0, [r0+r2*4]
DC_ADD_OP mova, r0, r2, r3
RET
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
; void ff_hevc_idct32_dc_add_8_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
cglobal hevc_idct32_dc_add_8, 3, 4, 6
movsx r3, word [r1]
DC_ADD_INIT_AVX2 r3, r2
DC_ADD_OP mova, r0, r2, r3,
%rep 7
lea r0, [r0+r2*4]
DC_ADD_OP mova, r0, r2, r3
%endrep
RET
%endif ;HAVE_AVX2_EXTERNAL
;-----------------------------------------------------------------------------
; void ff_hevc_idct_dc_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT_DC_ADD_OP_10 3
pxor m5, m5
%if avx_enabled
paddw m1, m0, [%1+0 ]
paddw m2, m0, [%1+%2 ]
paddw m3, m0, [%1+%2*2]
paddw m4, m0, [%1+%3 ]
%else
mova m1, [%1+0 ]
mova m2, [%1+%2 ]
mova m3, [%1+%2*2]
mova m4, [%1+%3 ]
paddw m1, m0
paddw m2, m0
paddw m3, m0
paddw m4, m0
%endif
CLIPW m1, m5, m6
CLIPW m2, m5, m6
CLIPW m3, m5, m6
CLIPW m4, m5, m6
mova [%1+0 ], m1
mova [%1+%2 ], m2
mova [%1+%2*2], m3
mova [%1+%3 ], m4
%endmacro
INIT_MMX mmxext
cglobal hevc_idct4_dc_add_10,3,3
mov r1w, [r1]
add r1w, ((1 << 4) + 1)
sar r1w, 5
movd m0, r1d
lea r1, [r2*3]
SPLATW m0, m0, 0
mova m6, [max_pixels_10]
IDCT_DC_ADD_OP_10 r0, r2, r1
RET
;-----------------------------------------------------------------------------
; void ff_hevc_idct8_dc_add_10(pixel *dst, int16_t *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT8_DC_ADD 0
cglobal hevc_idct8_dc_add_10,3,4,7
mov r1w, [r1]
add r1w, ((1 << 4) + 1)
sar r1w, 5
movd m0, r1d
lea r1, [r2*3]
SPLATW m0, m0, 0
mova m6, [max_pixels_10]
IDCT_DC_ADD_OP_10 r0, r2, r1
lea r0, [r0+r2*4]
IDCT_DC_ADD_OP_10 r0, r2, r1
RET
%endmacro
INIT_XMM sse2
IDCT8_DC_ADD
%if HAVE_AVX_EXTERNAL
INIT_XMM avx
IDCT8_DC_ADD
%endif
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
cglobal hevc_idct16_dc_add_10,3,4,7
mov r1w, [r1]
add r1w, ((1 << 4) + 1)
sar r1w, 5
movd xm0, r1d
lea r1, [r2*3]
vpbroadcastw m0, xm0 ;SPLATW
mova m6, [max_pixels_10]
IDCT_DC_ADD_OP_10 r0, r2, r1
lea r0, [r0+r2*4]
IDCT_DC_ADD_OP_10 r0, r2, r1
lea r0, [r0+r2*4]
IDCT_DC_ADD_OP_10 r0, r2, r1
lea r0, [r0+r2*4]
IDCT_DC_ADD_OP_10 r0, r2, r1
RET
%endif ;HAVE_AVX_EXTERNAL
|
cc4x86/tests/regressive/asm_listings/shl_shr__optimize.asm | artyompal/C-compiler | 4 | 16891 |
.686
.model flat
.xmm
.code
_test proc
push ebp
mov ebp,esp
sub esp,8
mov eax,-16
sar eax,4
cmp eax,-1
je label0000
mov eax,1
add esp,8
pop ebp
ret
label0000:
mov eax,-16
shr eax,4
cmp eax,268435455
je label0001
mov eax,2
add esp,8
pop ebp
ret
label0001:
mov eax,1073741824
sal eax,1
cmp eax,0
jl label0002
mov eax,3
add esp,8
pop ebp
ret
label0002:
mov eax,1073741824
shl eax,1
cmp eax,-2147483648
je label0003
mov eax,4
add esp,8
pop ebp
ret
label0003:
mov ecx,3
inc ecx
mov eax,1
shl eax,cl
cmp eax,16
je label0004
mov eax,5
add esp,8
pop ebp
ret
label0004:
mov ecx,5
inc ecx
mov eax,1
sal eax,cl
cmp eax,64
je label0005
mov eax,6
add esp,8
pop ebp
ret
label0005:
mov eax,0
add esp,8
pop ebp
ret
_test endp
end
|
alloy4fun_models/trashltl/models/10/mtJfGYicfca7koBEr.als | Kaixi26/org.alloytools.alloy | 0 | 3071 | open main
pred idmtJfGYicfca7koBEr_prop11 {
all f : File | f not in Protected implies after f in Protected
}
pred __repair { idmtJfGYicfca7koBEr_prop11 }
check __repair { idmtJfGYicfca7koBEr_prop11 <=> prop11o } |
pyson/pyson/pyson.g4 | ZizhouJia/pyson | 2 | 5284 | grammar pyson;
INT:[+-]?[0-9]+;
FLOAT:[-+]?([0-9]+('.'[0-9]*)?|'.'[0-9]+)([eE][-+]?[0-9]+)?;
TRUE: 'True'|'true';
FALSE: 'False'|'false';
NONE: 'None'|'none';
SELF:'self';
KEY: [A-Za-z_]+[A-Za-z0-9_]*;
fragment ESC_DOUBLE : '\\"' ;
fragment ESC_SINGLE : '\\\'';
STRING: '"' (ESC_DOUBLE|.|'\\' [btnr"\\])*?'"'|'\'' (ESC_SINGLE|.|'\\' [btnr"\\])*? '\'' ;
OBJECT: '@'?([A-Za-z_]+[A-Za-z0-9_]*)('.'([A-Za-z_]+[A-Za-z0-9_]*|'0'|[1-9][0-9]*))*;
COLON: ',';
COMMA: ':';
LEFT_DICT:'{';
RIGHT_DICT:'}';
LEFT_LIST:'[';
RIGHT_LIST:']';
LEFT_BUKKET:'(';
RIGHT_BUKKEFT:')';
LINE_COMMENT : '//' .*? '\r'? '\n' -> skip ;
COMMENT : '/*' .*? '*/' ->skip ;
WS : [ \t\r\n]+ -> skip ;
entry_point: item_dict|item_list;
item_dict: LEFT_DICT items RIGHT_DICT;
items: item other_items|;
other_items: COLON item other_items|;
item: KEY COMMA value;
value: INT|FLOAT|TRUE|FALSE|NONE|STRING|SELF|item_dict|item_list|item_object;
values: value other_values|;
other_values: COLON value other_values|;
item_list: LEFT_LIST values RIGHT_LIST;
item_tuple:LEFT_BUKKET values RIGHT_BUKKEFT;
object_name: OBJECT|KEY;
item_object: object_name (item_dict|item_tuple|);
|
oldstuff/tigcc/PolySnd/sources/statique/GetMode.asm | bcherry/bcherry | 3 | 168051 | <gh_stars>1-10
section ".data"
xdef pSnd_GetMode
pSnd_GetMode:
move.w state_and_mode,d0
move.w d0,d1
;Extrait modes voice1
andi.w #%0000000001111000,d0
lsr.w #3,d0
;Extrait modes voice2
andi.w #%0011110000000000,d1
lsr.w #6,d1
or.w d1,d0
rts |
pixy/src/host/pantilt_in_ada/pan_tilt.adb | GambuzX/Pixy-SIW | 0 | 11197 | --
-- Copyright (c) 2015, <NAME> <<EMAIL>>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above copyright
-- notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
-- TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
-- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
-- Pixy Tracking Demo - Ada Version --
--
-- To Build:
--
-- gnatmake pan_tilt.adb -aO/usr/local/lib -aO/usr/lib/gcc/x86_64-linux-gnu/4.8/ -aO/usr/lib/x86_64-linux-gnu/ -largs -lpthread -lpixyusb -lboost_system -lboost_chrono -lboost_thread -lstdc++ -lusb-1.0
WITH ADA.TEXT_IO; USE ADA.TEXT_IO;
WITH INTERFACES; USE INTERFACES;
WITH INTERFACES.C; USE INTERFACES.C;
WITH PIXY; USE PIXY;
WITH SIGINT_HANDLER; USE SIGINT_HANDLER;
FUNCTION PAN_TILT RETURN INT IS
SUCCESS : CONSTANT := 0;
PIXY_X_CENTER : CONSTANT SENSOR_WIDTH := (SENSOR_WIDTH'LAST - SENSOR_WIDTH'FIRST) / 2;
PIXY_Y_CENTER : CONSTANT SENSOR_HEIGHT := (SENSOR_HEIGHT'LAST - SENSOR_HEIGHT'FIRST) / 2;
PIXY_RCS_CENTER : CONSTANT RCS_POSITION := (RCS_POSITION'LAST - RCS_POSITION'FIRST) / 2;
-- PROPORTION-INTEGRAL-DERIVATIVE (PID) CONTROL PARAMETERS --
AZIMUTH_PROPORTIONAL_GAIN : CONSTANT INTEGER := 400;
AZIMUTH_DERIVATIVE_GAIN : CONSTANT INTEGER := 300;
ALTITUDE_PROPORTIONAL_GAIN : CONSTANT INTEGER := 500;
ALTITUDE_DERIVATIVE_GAIN : CONSTANT INTEGER := 400;
TYPE GIMBAL IS RECORD
POSITION : RCS_POSITION;
ERROR : RCS_ERROR;
PREVIOUS_ERROR : RCS_ERROR;
PREVIOUS_ERROR_VALID : BOOLEAN;
END RECORD;
TYPE AZIMUTH_TYPE IS NEW GIMBAL;
TYPE ALTITUDE_TYPE IS NEW GIMBAL;
BLOCK : ALIASED PIXY.BLOCK;
AZIMUTH : AZIMUTH_TYPE;
ALTITUDE : ALTITUDE_TYPE;
PIXY_INIT_STATUS : INT;
BLOCKS_COPIED : INT;
RESULT : INT;
FRAME_INDEX : INTEGER;
------------------------
-- INITIALIZE_GIMBALS --
------------------------
PROCEDURE INITIALIZE_GIMBALS IS
BEGIN
AZIMUTH.POSITION := PIXY_RCS_CENTER;
AZIMUTH.PREVIOUS_ERROR_VALID := FALSE;
ALTITUDE.POSITION := PIXY_RCS_CENTER;
ALTITUDE.PREVIOUS_ERROR_VALID := FALSE;
END INITIALIZE_GIMBALS;
--------------------
-- UPDATE_AZIMUTH --
--------------------
PROCEDURE UPDATE_AZIMUTH IS
P_GAIN : INTEGER RENAMES AZIMUTH_PROPORTIONAL_GAIN;
D_GAIN : INTEGER RENAMES AZIMUTH_DERIVATIVE_GAIN;
VELOCITY : INTEGER;
ERROR_DELTA : RCS_ERROR;
BEGIN
IF AZIMUTH.PREVIOUS_ERROR_VALID THEN
ERROR_DELTA := AZIMUTH.ERROR - AZIMUTH.PREVIOUS_ERROR;
VELOCITY := (INTEGER(AZIMUTH.ERROR) * P_GAIN + INTEGER(ERROR_DELTA) * D_GAIN) / 1024;
-- UPDATE AZIMUTH POSITION --
IF INTEGER(AZIMUTH.POSITION) + VELOCITY > INTEGER(RCS_POSITION'LAST) THEN
AZIMUTH.POSITION := RCS_POSITION'LAST;
ELSIF INTEGER(AZIMUTH.POSITION) + VELOCITY < INTEGER(RCS_POSITION'FIRST) THEN
AZIMUTH.POSITION := RCS_POSITION'FIRST;
ELSE
AZIMUTH.POSITION := RCS_POSITION(INTEGER(AZIMUTH.POSITION) + VELOCITY);
END IF;
ELSE
AZIMUTH.PREVIOUS_ERROR_VALID := TRUE;
END IF;
AZIMUTH.PREVIOUS_ERROR := AZIMUTH.ERROR;
END UPDATE_AZIMUTH;
---------------------
-- UPDATE_ALTITUDE --
---------------------
PROCEDURE UPDATE_ALTITUDE IS
P_GAIN : INTEGER RENAMES ALTITUDE_PROPORTIONAL_GAIN;
D_GAIN : INTEGER RENAMES ALTITUDE_DERIVATIVE_GAIN;
VELOCITY : INTEGER;
ERROR_DELTA : RCS_ERROR;
BEGIN
IF ALTITUDE.PREVIOUS_ERROR_VALID THEN
ERROR_DELTA := ALTITUDE.ERROR - ALTITUDE.PREVIOUS_ERROR;
VELOCITY := (INTEGER(ALTITUDE.ERROR) * P_GAIN + INTEGER(ERROR_DELTA) * D_GAIN) / 1024;
-- UPDATE ALTITUDE POSITION --
IF INTEGER(ALTITUDE.POSITION) + VELOCITY > INTEGER(RCS_POSITION'LAST) THEN
ALTITUDE.POSITION := RCS_POSITION'LAST;
ELSIF INTEGER(ALTITUDE.POSITION) + VELOCITY < INTEGER(RCS_POSITION'FIRST) THEN
ALTITUDE.POSITION := RCS_POSITION'FIRST;
ELSE
ALTITUDE.POSITION := RCS_POSITION(INTEGER(ALTITUDE.POSITION) + VELOCITY);
END IF;
ELSE
ALTITUDE.PREVIOUS_ERROR_VALID := TRUE;
END IF;
ALTITUDE.PREVIOUS_ERROR := ALTITUDE.ERROR;
END UPDATE_ALTITUDE;
BEGIN
PUT_LINE("+ PIXY TRACKING DEMO STARTED +");
INITIALIZE_GIMBALS;
PIXY_INIT_STATUS := PIXY.INIT;
FRAME_INDEX := 0;
-- WAS THERE AN ERROR INITIALIZING PIXY? --
IF PIXY_INIT_STATUS /= 0 THEN
PUT("ERROR: PIXY_INIT() [" & INT'IMAGE(PIXY_INIT_STATUS) & "] ");
PIXY.ERROR(PIXY_INIT_STATUS);
RETURN PIXY_INIT_STATUS;
END IF;
TRACKING_LOOP:
WHILE NOT SIGINT LOOP
-- WAIT FOR NEW BLOCKS TO BE AVAILABLE --
WAITING_LOOP:
WHILE PIXY.BLOCKS_ARE_NEW = 0 AND NOT SIGINT LOOP
NULL;
END LOOP WAITING_LOOP;
-- GET BLOCKS FROM PIXY --
BLOCKS_COPIED := GET_BLOCKS(1, BLOCK'ACCESS);
IF BLOCKS_COPIED < 0 THEN
-- ERROR: PIXY.GET_BLOCKS --
PUT("ERROR: PIXY_GET_BLOCKS() [" & INT'IMAGE(BLOCKS_COPIED) & "]");
PIXY.ERROR(BLOCKS_COPIED);
END IF;
IF BLOCKS_COPIED > 0 THEN
-- CALCULATE THE DIFFERENCE BETWEEN THE CENTER OF PIXY'S --
-- FOCUS AND THE TARGET. --
AZIMUTH.ERROR := RCS_ERROR(PIXY_X_CENTER) - RCS_ERROR(BLOCK.X);
ALTITUDE.ERROR := RCS_ERROR(BLOCK.Y) - RCS_ERROR(PIXY_Y_CENTER);
-- APPLY CORRECTIONS TO THE AZIMUTH/ELEVATION WITH THE GOAL --
-- OF PUTTING THE TARGET IN THE CENTER OF PIXY'S FOCUS. --
UPDATE_AZIMUTH;
UPDATE_ALTITUDE;
RESULT := RCS_SET_POSITION(RCS_AZIMUTH_CHANNEL, UINT16(AZIMUTH.POSITION));
IF RESULT < 0 THEN
PUT("ERROR: PIXY_RCS_SET_POSITION() [" & INT'IMAGE(RESULT) & "]");
PIXY.ERROR(RESULT);
END IF;
RESULT := RCS_SET_POSITION(RCS_ALTITUDE_CHANNEL, UINT16(ALTITUDE.POSITION));
IF RESULT < 0 THEN
PUT("ERROR: PIXY_RCS_SET_POSITION() [" & INT'IMAGE(RESULT) & "]");
PIXY.ERROR(RESULT);
END IF;
IF FRAME_INDEX MOD 50 = 0 THEN
PUT_LINE("FRAME " & INTEGER'IMAGE(FRAME_INDEX) & ":");
PUT_LINE(" SIG: " & UINT16'IMAGE(BLOCK.SIGNATURE) &
" X:" & UINT16'IMAGE(BLOCK.X) &
" Y:" & UINT16'IMAGE(BLOCK.Y) &
" WIDTH:" & UINT16'IMAGE(BLOCK.WIDTH) &
" HEIGHT:" & UINT16'IMAGE(BLOCK.HEIGHT));
END IF;
FRAME_INDEX := FRAME_INDEX + 1;
END IF;
END LOOP TRACKING_LOOP;
PUT_LINE ("+ PIXY TERMINATING +");
PIXY.CLOSE;
RETURN SUCCESS;
END PAN_TILT;
|
MIPS/DelSubString.asm | saurabhcommand/Hello-world | 1,428 | 164848 | .data
str1: .space 1001
str2: .space 1001
str3: .space 1001
prompt: .asciiz "Enter String.\n"
prompt1: .asciiz "Enter Substring.\n"
prompt2: .asciiz "The Required String is \n"
line: .asciiz "\n"
.text
main:
#Prompt user to enter String
la $a0, prompt
li $v0, 4
syscall
#Read String and add Terminator
la $a0, str1
li $a1, 1001
li $v0, 8
syscall
#Print NewLine
la $a0, line
li $v0, 4
syscall
#Prompt user to enter SubString
la $a0, prompt1
li $v0, 4
syscall
#Read SubString and add Terminator
la $a0, str2
li $a1, 1001
li $v0, 8
syscall
#Print NewLine
la $a0, line
li $v0, 4
syscall
String1Len:
add $t1,$zero,$zero
la $a0, str1
lenloop1:
lb $t2, ($a0)
beqz $t2, String2Len
addi $t1,$t1,1 #$t1 contains length of string
addi $a0,$a0,1
j lenloop1
String2Len:
add $t3,$zero,$zero
la $a0, str2
lenloop2:
lb $t2, ($a0)
beqz $t2, go
addi $t3,$t3,1 #$t3 contains length of substring
addi $a0,$a0,1
j lenloop2
go:
la $a0, str1
la $a1, str2
la $a2, str3
subi $t1,$t1,1
#$t1 = strlen(str1)
add $t2,$t3,$zero
subi $t2,$t2,1
#$t2 = strlen(str2)
sub $s3,$s3,$s3 #i=0
sub $t4,$t4,$t4 #j=0
loop:
bge $s3,$t1,loopend
add $t5,$a0,$s3
#add $t6,$a1,$zero
lb $t7, ($t5) #str1[i]
lb $t8, ($a1) #str2[0]
beq $t7,$t8 check
addd: sb $t7, str3($t4) #Add to Str3[j]
addi $t4,$t4,1 #j++
addi $s3,$s3,1 #i++
j loop
check:
add $t0,$s3,$a0 #str1[i]
addi $t6,$a1,0 #str2[0]
addi $t9,$zero,0
loop2:
beq $t9, $t2 del
lb $s0, ($t0)
lb $s1, ($t6)
bne $s0,$s1 addd
addi, $t0,$t0,1
addi, $t6,$t6,1
addi, $t9,$t9,1
j loop2
del:
add $s3,$s3,$t2
j loop
loopend:
#$t7 = strlen(Str3)
#
#Prompt to print String
li $v0,4
la $a0,prompt2
syscall
#Printing String
li $v0,4
la $a0,str3
syscall
#Exiting Program
li $v0, 10
syscall
|
programs/oeis/267/A267871.asm | neoneye/loda | 22 | 10042 | ; A267871: Triangle read by rows giving successive states of cellular automaton generated by "Rule 239" initiated with a single ON (black) cell.
; 1,1,1,0,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,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
cmp $0,3
cmp $1,$0
mov $0,$1
|
Logic/DiagonalMethod.agda | Lolirofle/stuff-in-agda | 6 | 2259 | <filename>Logic/DiagonalMethod.agda
module Logic.DiagonalMethod where
open import Functional
open import Logic.Predicate
open import Logic.Propositional
import Lvl
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Function.Domain
open import Structure.Operator
open import Structure.Relator.Properties
open import Syntax.Function
open import Type.Size
open import Type
private variable ℓ : Lvl.Level
private variable T A B : Type{ℓ}
-- Also called: Diagonal method, Cantor's diagonal argument.
function-type-surjectivity-fixpoint : (A ≽ (A → B)) → ∀{f : B → B} → ∃(Fixpoint f)
function-type-surjectivity-fixpoint ([∃]-intro s) {f}
with [∃]-intro i ⦃ p ⦄ ← surjective(s) {f ∘ (s $₂_)}
= [∃]-intro(s i i) ⦃ intro(symmetry(_≡_) (congruence₂ₗ(_$_)(i) p)) ⦄
module _ where
open import Data.Boolean
open import Data.Boolean.Proofs
decidable-power-set-no-surjection : ¬(T ≽ (T → Bool))
decidable-power-set-no-surjection = (p ↦ [!]-no-fixpoints(Fixpoint.proof([∃]-proof(p{not})))) ∘ function-type-surjectivity-fixpoint
module _ where
open import Data.Boolean
open import Data.Boolean.Proofs
open import Function.Inverseᵣ
open import Structure.Function.Domain.Proofs
open import Structure.Function
open import Syntax.Transitivity
function-type-no-surjection : (B ≽ Bool) → ¬(A ≽ (A → B))
function-type-no-surjection ([∃]-intro r-bool) surj
with [∃]-intro i ⦃ fix ⦄ ← function-type-surjectivity-fixpoint surj {invᵣ r-bool ⦃ surjective-to-invertibleᵣ ⦄ ∘ not ∘ r-bool}
= [!]-no-fixpoints(symmetry(_≡_) (Inverseᵣ.proof surjective-to-inverseᵣ) 🝖 congruence₁(r-bool) (Fixpoint.proof fix))
module _ where
open import Numeral.Natural
open import Numeral.Natural.Oper.Proofs
ℕ-function-non-surjectivity : ¬(ℕ ≽ (ℕ → ℕ))
ℕ-function-non-surjectivity = (p ↦ 𝐒-not-self(Fixpoint.proof([∃]-proof(p{𝐒})))) ∘ function-type-surjectivity-fixpoint
|
Transynther/x86/_processed/US/_st_sm_/i7-7700_9_0x48.log_21829_2303.asm | ljhsiun2/medusa | 9 | 100584 | <filename>Transynther/x86/_processed/US/_st_sm_/i7-7700_9_0x48.log_21829_2303.asm<gh_stars>1-10
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xca05, %rsi
lea addresses_normal_ht+0x17dad, %rdi
clflush (%rsi)
nop
nop
dec %rbx
mov $42, %rcx
rep movsq
nop
nop
nop
nop
nop
xor %r12, %r12
lea addresses_UC_ht+0x15c05, %r13
cmp %r15, %r15
vmovups (%r13), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %rsi
nop
nop
xor %r12, %r12
lea addresses_normal_ht+0x18448, %rcx
nop
nop
nop
nop
dec %rsi
mov $0x6162636465666768, %rdi
movq %rdi, %xmm3
and $0xffffffffffffffc0, %rcx
vmovaps %ymm3, (%rcx)
nop
nop
nop
nop
sub %r12, %r12
lea addresses_D_ht+0x744e, %rbx
xor %rdi, %rdi
mov $0x6162636465666768, %r15
movq %r15, %xmm7
vmovups %ymm7, (%rbx)
nop
nop
nop
nop
add $17346, %r12
lea addresses_UC_ht+0x19a05, %rsi
lea addresses_UC_ht+0x7b25, %rdi
nop
nop
nop
nop
nop
xor $16995, %r13
mov $62, %rcx
rep movsq
nop
nop
nop
add $4457, %r12
lea addresses_D_ht+0x155e5, %r12
cmp $45784, %rcx
movw $0x6162, (%r12)
nop
nop
nop
nop
nop
inc %rbx
lea addresses_WT_ht+0x1305, %rsi
lea addresses_D_ht+0xca51, %rdi
nop
nop
nop
nop
add %r10, %r10
mov $66, %rcx
rep movsl
nop
nop
nop
nop
sub $17899, %rcx
lea addresses_A_ht+0x64b5, %r10
nop
nop
nop
xor %r15, %r15
and $0xffffffffffffffc0, %r10
movntdqa (%r10), %xmm6
vpextrq $1, %xmm6, %rcx
and $64146, %r15
lea addresses_WT_ht+0x8923, %rsi
clflush (%rsi)
nop
nop
nop
nop
sub $26057, %rdi
mov $0x6162636465666768, %r13
movq %r13, %xmm7
vmovups %ymm7, (%rsi)
nop
nop
nop
sub %r15, %r15
lea addresses_normal_ht+0x18205, %rsi
lea addresses_UC_ht+0x2005, %rdi
nop
nop
nop
and $40103, %r10
mov $24, %rcx
rep movsl
and $55813, %r15
lea addresses_UC_ht+0xfbc5, %rsi
sub $754, %r13
vmovups (%rsi), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %rdi
nop
nop
nop
nop
and $6697, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %rax
push %rbp
push %rdx
push %rsi
// Store
lea addresses_D+0x10dd5, %rsi
nop
nop
and %rdx, %rdx
mov $0x5152535455565758, %rax
movq %rax, (%rsi)
nop
nop
nop
nop
and %rsi, %rsi
// Store
lea addresses_PSE+0x8d35, %r12
nop
sub $64406, %rbp
movw $0x5152, (%r12)
// Exception!!!
nop
nop
nop
nop
mov (0), %rax
nop
nop
nop
nop
nop
sub $10620, %rdx
// Store
lea addresses_US+0x1a05, %r13
clflush (%r13)
nop
nop
nop
add %rdx, %rdx
mov $0x5152535455565758, %r14
movq %r14, %xmm0
vmovups %ymm0, (%r13)
nop
nop
nop
nop
inc %rbp
// Load
lea addresses_US+0x4005, %rbp
nop
nop
nop
cmp %r14, %r14
mov (%rbp), %r13d
nop
nop
nop
nop
xor %r14, %r14
// Faulty Load
lea addresses_US+0x1a05, %rax
nop
nop
nop
nop
nop
xor $2486, %rdx
movb (%rax), %r13b
lea oracles, %rax
and $0xff, %r13
shlq $12, %r13
mov (%rax,%r13,1), %r13
pop %rsi
pop %rdx
pop %rbp
pop %rax
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 3, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
src/generated/sys_utypes_uint8_t_h.ads | csb6/libtcod-ada | 0 | 7393 | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package sys_utypes_uint8_t_h is
-- * Copyright (c) 2012 Apple Inc. All rights reserved.
-- *
-- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
-- *
-- * This file contains Original Code and/or Modifications of Original Code
-- * as defined in and that are subject to the Apple Public Source License
-- * Version 2.0 (the 'License'). You may not use this file except in
-- * compliance with the License. The rights granted to you under the License
-- * may not be used to create, or enable the creation or redistribution of,
-- * unlawful or unlicensed copies of an Apple operating system, or to
-- * circumvent, violate, or enable the circumvention or violation of, any
-- * terms of an Apple operating system software license agreement.
-- *
-- * Please obtain a copy of the License at
-- * http://www.opensource.apple.com/apsl/ and read it before using this file.
-- *
-- * The Original Code and all software distributed under the License are
-- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
-- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
-- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
-- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
-- * Please see the License for the specific language governing rights and
-- * limitations under the License.
-- *
-- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
--
subtype int8_t is signed_char; -- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int8_t.h:30
end sys_utypes_uint8_t_h;
|
loader/decrunch.asm | sikorama/still_scrolling | 0 | 5301 |
DATA_START: EQU #8000
ENTRY_POINT: EQU #9000
; 0: mode normal
; 1: utilise le code dans le header
PRODMODE: EQU 0
ORG #4000
if PRODMODE==0
include "header.asm"
else
GET_FONT EQU 0
ld hl,(#be7d)
ld bc,#12A
add hl,bc
ld (getfont+1), hl
ld bc, 20
add hl,bc
ld (literal+1),hl
endif
START:
; Desactive ITs et Sauvegarde des registres Mirroir
if PRODMODE == 0
ld a,(#a000)
;ld (dupa00+1),a
cp #55
push af
call nz,CHECK_CRTC ; Si crtc 1 ou 2 on quitte
;call GET_FONT
; recup fonte systeme (avec des appels systeme, donc fait avant la decompressoin
GET_CARACT_TAB #A06B,63
; desactivation ITs
DI
DISABLE_INT38
ld bc,#7f00
out (c),c
ld a,GA_BLACK
out (c),a
else
getfont: call GET_FONT
endif
LD IX,CRUNCH_DATA
LD DE,DATA_START
; décompression
call shrinkler_decrunch
; On verifie si c'est un CPC +
; sauf si on a a pas testé les CRTC 1 et 2
;dupa00: ld a,0
;cp #55
pop af
jr z,go
; On lit #Be00, si 'est différent de 255 on
LD b,#BE
IN A,(C)
inc A
jr Z, go
; on a un CPC+
ld bc,#BC8d
ld a,3
out (c),a
inc b
out (c),c
inc a
ld (#9504),a ; adresse du label AJUSTE_PLUS, on met 4
; GO!
go:
JP ENTRY_POINT
CRUNCH_DATA:
INCBIN "crunched.bin"
READ "Shrinkler_Z80_v8__(Madram)__recall_209.asm"
|
gillesdubois/used_apple_scripts/weatherStatus.applescript | gillesdubois/btt-touchbar-presets | 1,879 | 196 | -- Create an api key here : https://darksky.net
-- Then add change the URL BELOW
-- You need to install JSON Helper from Apple Store
-- You need to install locateme from brew (https://brew.sh/)
-- More information in readme on github
tell application "JSON Helper"
set latLon to do shell script "/usr/local/bin/locateme -f '{LAT},{LON}'"
set weather to fetch JSON from ("https://api.darksky.net/forecast/YOUR_API_KEY_HERE/" & latLon & "?exclude=minutely,hourly,daily,alerts,flags&units=si")
set temperature to temperature of currently of weather
set weatherStatus to icon of currently of weather
end tell
if weatherStatus is equal to "clear-day" then
set myIcon to "☀️"
else if weatherStatus is equal to "clear-night" then
set myIcon to "🌙"
else if weatherStatus is equal to "partly-cloudy-day" or weatherStatus is equal to "partly-cloudy-night" then
set myIcon to "⛅️"
else if weatherStatus is equal to "partly-cloudy-night" then
set myIcon to "☁️🌙"
else if weatherStatus is equal to "cloudy" then
set myIcon to "☁️"
else if weatherStatus is equal to "rain" then
set myIcon to "🌧"
else if weatherStatus is equal to "sleet" then
set myIcon to "⛈"
else if weatherStatus is equal to "fog" then
set myIcon to "🌫️"
else if weatherStatus is equal to "wind" then
set myIcon to "🌀"
else if weatherStatus is equal to "snow" then
set myIcon to "❄️"
else
set myIcon to weatherStatus
end if
return myIcon & " " & (round (temperature)) & "°C" |
libsrc/_DEVELOPMENT/math/float/math48/lm/c/sdcc_iy/erf_fastcall.asm | jpoikela/z88dk | 640 | 84505 | <reponame>jpoikela/z88dk
SECTION code_clib
SECTION code_fp_math48
PUBLIC _erf_fastcall
EXTERN cm48_sdcciy_erf_fastcall
defc _erf_fastcall = cm48_sdcciy_erf_fastcall
|
Structure/Category/NaturalTransformation/NaturalTransformations.agda | Lolirofle/stuff-in-agda | 6 | 6730 | <reponame>Lolirofle/stuff-in-agda
module Structure.Category.NaturalTransformation.NaturalTransformations where
open import Functional using () renaming (id to idᶠⁿ)
open import Functional.Dependent using () renaming (_∘_ to _∘ᶠⁿ_)
open import Logic
open import Logic.Predicate
import Lvl
open import Structure.Category
open import Structure.Category.Functor
open import Structure.Category.NaturalTransformation
open import Structure.Categorical.Properties
open import Structure.Operator
open import Structure.Relator.Equivalence
open import Structure.Setoid
open import Syntax.Transitivity
open import Type
open CategoryObject
private variable ℓₒₗ ℓₒᵣ ℓₘₗ ℓₘᵣ ℓₑₗ ℓₑᵣ : Lvl.Level
module Raw
(catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ})
(catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ})
where
private variable F F₁ F₂ F₃ : Object(catₗ) → Object(catᵣ)
private instance _ = category catₗ
private instance _ = category catᵣ
open Category.ArrowNotation ⦃ … ⦄
open Category ⦃ … ⦄ hiding (identity)
idᴺᵀ : (x : Object(catₗ)) → (F(x) ⟶ F(x))
idᴺᵀ _ = id
_∘ᴺᵀ_ : ((x : Object(catₗ)) → (F₂(x) ⟶ F₃(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₂(x))) → ((x : Object(catₗ)) → (F₁(x) ⟶ F₃(x)))
(comp₁ ∘ᴺᵀ comp₂)(x) = comp₁(x) ∘ comp₂(x)
module _
{catₗ : CategoryObject{ℓₒₗ}{ℓₘₗ}{ℓₑₗ}}
{catᵣ : CategoryObject{ℓₒᵣ}{ℓₘᵣ}{ℓₑᵣ}}
where
private instance _ = category catₗ
private instance _ = category catᵣ
open Category ⦃ … ⦄ hiding (identity)
open Functor ⦃ … ⦄
private open module Equivᵣ {x}{y} = Equivalence (Equiv-equivalence ⦃ morphism-equiv(catᵣ){x}{y} ⦄) using ()
module _ where
open Raw(catₗ)(catᵣ)
module _ {functor@([∃]-intro F) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where
identity : NaturalTransformation(functor)(functor)(idᴺᵀ)
NaturalTransformation.natural identity {x} {y} {f} =
id ∘ map f 🝖-[ Morphism.identityₗ(_)(id) ⦃ identityₗ ⦄ ]
map f 🝖-[ Morphism.identityᵣ(_)(id) ⦃ identityᵣ ⦄ ]-sym
map f ∘ id 🝖-end
module _ {functor₁@([∃]-intro F₁) functor₂@([∃]-intro F₂) functor₃@([∃]-intro F₃) : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ} where
composition : ∀{comp₁ comp₂} → NaturalTransformation(functor₂)(functor₃)(comp₁) → NaturalTransformation(functor₁)(functor₂)(comp₂) → NaturalTransformation(functor₁)(functor₃)(comp₁ ∘ᴺᵀ comp₂)
NaturalTransformation.natural (composition {comp₁} {comp₂} nat₁ nat₂) {x} {y} {f} =
(comp₁(y) ∘ comp₂(y)) ∘ map f 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]
comp₁(y) ∘ (comp₂(y) ∘ map f) 🝖-[ congruence₂ᵣ(_∘_)(comp₁(y)) (NaturalTransformation.natural nat₂) ]
comp₁(y) ∘ (map f ∘ comp₂(x)) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]-sym
(comp₁(y) ∘ map f) ∘ comp₂(x) 🝖-[ congruence₂ₗ(_∘_)(comp₂(x)) (NaturalTransformation.natural nat₁) ]
(map f ∘ comp₁(x)) ∘ comp₂(x) 🝖-[ Morphism.associativity(_) ⦃ associativity ⦄ ]
map f ∘ (comp₁(x) ∘ comp₂(x)) 🝖-end
module Wrapped where
private variable F F₁ F₂ F₃ : catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ
idᴺᵀ : (F →ᴺᵀ F)
idᴺᵀ = [∃]-intro (Raw.idᴺᵀ(catₗ)(catᵣ)) ⦃ identity ⦄
_∘ᴺᵀ_ : (F₂ →ᴺᵀ F₃) → (F₁ →ᴺᵀ F₂) → (F₁ →ᴺᵀ F₃)
_∘ᴺᵀ_ ([∃]-intro F ⦃ F-proof ⦄) ([∃]-intro G ⦃ G-proof ⦄) = [∃]-intro (Raw._∘ᴺᵀ_ (catₗ)(catᵣ) F G) ⦃ composition F-proof G-proof ⦄
|
src/babel-strategies-default.adb | stcarrez/babel | 1 | 21532 | -----------------------------------------------------------------------
-- babel-strategies -- Strategies to backup files
-- Copyright (C) 2014, 2015, 2016 Stephane.Carrez
-- Written by Stephane.Carrez (<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.
-----------------------------------------------------------------------
pragma Ada_2012;
with Babel.Files.Signatures;
with Util.Encoders.SHA1;
with Util.Log.Loggers;
with Babel.Streams.Refs;
package body Babel.Strategies.Default is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Babel.Strategies.Default");
-- Returns true if there is a directory that must be processed by the current strategy.
overriding
function Has_Directory (Strategy : in Default_Strategy_Type) return Boolean is
begin
return false; -- not Strategy.Queue.Directories.Is_Empty;
end Has_Directory;
-- Get the next directory that must be processed by the strategy.
overriding
procedure Peek_Directory (Strategy : in out Default_Strategy_Type;
Directory : out Babel.Files.Directory_Type) is
Last : constant String := ""; -- Strategy.Queue.Directories.Last_Element;
begin
-- Strategy.Queue.Directories.Delete_Last;
null;
end Peek_Directory;
-- Set the file queue that the strategy must use.
procedure Set_Queue (Strategy : in out Default_Strategy_Type;
Queue : in Babel.Files.Queues.File_Queue_Access) is
begin
Strategy.Queue := Queue;
end Set_Queue;
overriding
procedure Execute (Strategy : in out Default_Strategy_Type) is
use type Babel.Files.File_Type;
File : Babel.Files.File_Type;
SHA1 : Util.Encoders.SHA1.Hash_Array;
Stream : Babel.Streams.Refs.Stream_Ref;
begin
Strategy.Queue.Queue.Dequeue (File, 0.1);
if File = Babel.Files.NO_FILE then
Log.Debug ("Dequeue NO_FILE");
else
Log.Debug ("Dequeue {0}", Babel.Files.Get_Path (File));
Strategy.Read_File (File, Stream);
Babel.Files.Signatures.Sha1 (Stream, SHA1);
Babel.Files.Set_Signature (File, SHA1);
if Babel.Files.Is_Modified (File) then
Strategy.Backup_File (File, Stream);
end if;
end if;
end Execute;
-- Scan the directory
overriding
procedure Scan (Strategy : in out Default_Strategy_Type;
Directory : in Babel.Files.Directory_Type;
Container : in out Babel.Files.File_Container'Class) is
procedure Add_Queue (File : in Babel.Files.File_Type) is
begin
Log.Debug ("Queueing {0}", Babel.Files.Get_Path (File));
Strategy.Queue.Add_File (File);
end Add_Queue;
begin
Strategy_Type (Strategy).Scan (Directory, Container);
Container.Each_File (Add_Queue'Access);
end Scan;
-- overriding
-- procedure Add_File (Into : in out Default_Strategy_Type;
-- Path : in String;
-- Element : in Babel.Files.File) is
-- begin
-- Into.Queue.Add_File (Path, Element);
-- end Add_File;
--
-- overriding
-- procedure Add_Directory (Into : in out Default_Strategy_Type;
-- Path : in String;
-- Name : in String) is
-- begin
-- Into.Queue.Add_Directory (Path, Name);
-- end Add_Directory;
end Babel.Strategies.Default;
|
Examples/interprocess-communication/exeapp2.asm | agguro/linux-nasm | 6 | 10434 | <reponame>agguro/linux-nasm
;name: exeapp2.asm
;
;build: nasm -felf64 exeapp2.asm -o exeapp2.o
; ld -melf_x86_64 -o exeapp2 exeapp2.o
;
;description: Demonstration on how to execute a program with commandline arguments
; from within a program.
; This example, as extension of exeapp2, shows how to pass arguments.
; Assumed is the presence of the program arguments.
bits 64
[list -]
%include "unistd.inc"
[list +]
section .rodata
filename: db "arguments",0 ; full path!
.length: equ $-filename
argv1: db "hello", 0 ; a first argument to pass
argv2: db "world", 0 ; a second argument to pass
;... put more arguments here
argvPtr: dq filename
dq argv1
dq argv2
; more pointers to arguments here
envPtr: dq 0 ; terminate the list of pointers with 0
; envPtr is put at the end of the argv pointer list to safe some bytes
forkerror: db "fork error",10
.len: equ $-forkerror
execveerror: db "execve error(not expected)",10
.len: equ $-execveerror
wait4error: db "wait4 error",10
.len: equ $-wait4error
section .text
global _start
_start:
syscall fork
and rax,rax
jns .continue
syscall write,stderr,forkerror,forkerror.len
jmp .exit
.continue:
jz .runchild
; wait for child to terminate
syscall wait4, 0, 0, 0, 0
jns .exit
syscall write,stderr,wait4error,wait4error.len
jmp .exit
.runchild:
syscall execve,filename,argvPtr,envPtr
jns .exit
syscall write,stderr,execveerror,execveerror.len
.exit:
syscall exit,0
|
oeis/295/A295933.asm | neoneye/loda-programs | 11 | 3576 | ; A295933: Number of (not necessarily maximum) cliques in the n-Sierpinski sieve graph.
; Submitted by <NAME>(s4)
; 8,20,55,160,475,1420,4255,12760,38275,114820,344455,1033360,3100075,9300220,27900655,83701960,251105875,753317620,2259952855,6779858560,20339575675,61018727020,183056181055,549168543160,1647505629475,4942516888420,14827550665255,44482651995760,133447955987275,400343867961820,1201031603885455,3603094811656360,10809284434969075,32427853304907220,97283559914721655,291850679744164960,875552039232494875,2626656117697484620,7879968353092453855,23639905059277361560,70919715177832084675
mov $1,5
mov $2,2
lpb $0
sub $0,1
add $2,$1
mul $1,2
add $1,$2
mov $2,1
lpe
mov $0,$1
add $0,3
|
src/natools-s_expressions.adb | faelys/natools | 0 | 16834 | ------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, <NAME> --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.S_Expressions is
function To_String (Data : in Atom) return String is
begin
return Result : String (1 .. Data'Length) do
for I in Result'Range loop
Result (I) := Character'Val (Data (Data'First + Offset (I - 1)));
end loop;
end return;
end To_String;
function To_Atom (Data : in String) return Atom is
begin
return Result : Atom (0 .. Data'Length - 1) do
for I in Result'Range loop
Result (I) := Character'Pos (Data (Data'First + Integer (I)));
end loop;
end return;
end To_Atom;
function Less_Than (Left, Right : Atom) return Boolean is
begin
return Left'Length < Right'Length
or else (Left'Length = Right'Length and then Left < Right);
end Less_Than;
procedure Next (Object : in out Descriptor'Class) is
Discarded : Events.Event;
pragma Unreferenced (Discarded);
begin
Next (Object, Discarded);
end Next;
procedure Close_Current_List (Object : in out Descriptor'Class) is
Level : Natural := 0;
Event : Events.Event := Object.Current_Event;
begin
if Object.Current_Event in Events.Error | Events.End_Of_Input then
return;
end if;
loop
Object.Next (Event);
case Event is
when Events.Error | Events.End_Of_Input =>
exit;
when Events.Open_List =>
Level := Level + 1;
when Events.Close_List =>
exit when Level = 0;
Level := Level - 1;
when Events.Add_Atom =>
null;
end case;
end loop;
end Close_Current_List;
end Natools.S_Expressions;
|
regtests/action_bean.ads | jquorning/ada-el | 6 | 18283 | -----------------------------------------------------------------------
-- Action_Bean - Simple bean with methods that can be called from EL
-- Copyright (C) 2010 <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.Objects;
with Util.Beans.Basic;
with Util.Beans.Methods;
with EL.Methods.Proc_1;
with EL.Methods.Proc_2;
with Test_Bean;
with Ada.Unchecked_Deallocation;
package Action_Bean is
type Action is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record
Person : Test_Bean.Person;
Count : Natural;
end record;
type Action_Access is access all Action'Class;
-- Get the value identified by the name.
function Get_Value (From : Action; Name : String) return EL.Objects.Object;
-- Set the value identified by the name.
procedure Set_Value (From : in out Action;
Name : in String;
Value : in EL.Objects.Object);
-- Get the EL method bindings exposed by the Action type.
function Get_Method_Bindings (From : in Action)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Action with one parameter.
-- Sets the person.
procedure Notify (Target : in out Action;
Param : in out Test_Bean.Person);
-- Action with two parameters.
-- Sets the person object and the counter.
procedure Notify (Target : in out Action;
Param : in Test_Bean.Person;
Count : in Natural);
-- Action with one parameter
procedure Print (Target : in out Action;
Param : in out Test_Bean.Person);
-- Package to invoke an EL method with one <b>Person</b> as parameter.
package Proc_Action is new EL.Methods.Proc_1 (Param1_Type => Test_Bean.Person);
-- Package to invoke an EL method with <b>Person</b> as parameter and a <b>Natural</b>.
package Proc2_Action is
new EL.Methods.Proc_2 (Param1_Type => Test_Bean.Person,
Param2_Type => Natural);
procedure Free is new Ada.Unchecked_Deallocation (Object => Action'Class,
Name => Action_Access);
end Action_Bean;
|
oeis/340/A340536.asm | neoneye/loda-programs | 11 | 7998 | <reponame>neoneye/loda-programs<gh_stars>10-100
; A340536: Digital root of 2*n^2.
; Submitted by <NAME>
; 2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9,2,8,9,5,5,9,8,2,9
add $0,1
pow $0,2
mul $0,40
sub $0,1
mul $0,19
div $0,18
add $0,1
mod $0,10
|
vmx_check/boot.asm | ilya101010/asm_studies | 1 | 162868 | format ELF
include 'macro.inc'
include 'elf.inc'
; include 'proc32.inc' - these macros are SICK and TIRED of your damn EMAILS!
; >>>> 16bit code
section '.text16' executable
Use16
public start
start:
org 0x7C00
mbp
cli ; disabling interrupts
mov ax, cs ; segment registers' init
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7C00 ; stack backwards => ok
shl eax,4 ;умножаем на 16
mov ebx,eax ;копируем в регистр EBX
; why?!
push dx, bx, ax, cx
mov dx, 0 ; set cursor to top left-most corner of screen
mov bh, 0 ; page
mov ah, 0x2 ; ah = 2 => set cursor
int 0x10 ; moving cursor
mov cx, 2000 ; print 2000 = 80*45 chars
mov bh, 0
mov ah, 0x9
int 0x10
pop cx, ax, bx, dx
mbp
; loading entry_pm to RAM
mov ah, 0x02 ; Read Disk Sectors
mov al, 0x10 ; Read one sector only (512 bytes per sector)
mov ch, 0x00 ; Track 0
mov cl, 0x02 ; Sector 2
mov dh, 0x00 ; Head 0
mov dl, 0x00 ; Drive 0 (Floppy 1)
mov bx, cs
mov es, bx ; Segment 0x2000
mov bx, 0x7e00 ; again remember segments bust be loaded from non immediate data
int 13h
mbp
; loading GDT
lgdt fword [GDTR]
; disable NMI
in al,70h
or al,80h
out 70h,al
; enable a20
in al,92h
or al,2
out 92h,al
; get into PM
mov eax,cr0
or al,1
mov cr0,eax
; O32 jmp far
db 66h ; O32
db 0eah ; JMP FAR
dd 0x7E00 ; offset
dw sel_code32 ; selector
GDTTable: ;таблица GDT
; zero seg
d_zero: db 0,0,0,0,0,0,0,0
; 32 bit code seg
d_code32: db 0ffh,0ffh,0,0,0,10011010b,11001111b,0
; data
d_data: db 0ffh, 0ffh, 0x00, 0, 0, 10010010b, 11001111b, 0x00
GDTSize = $-GDTTable
GDTR: ;загружаемое значение регистра GDTR
g_size: dw GDTSize-1 ;размер таблицы GDT
g_base: dd GDTTable ;адрес таблицы GDT
; >>>> 32bit code
section '.text32' executable align 10h
; org 0x7E00
use32 ;32-битный код!!!
public entry_pm
align 10h ;код должен выравниваться по границе 16 байт0
entry_pm:
; >>> setting up all the basic stuff
cli ; disabling interrupts
; cs already defined
mov ax, sel_data
mov ss, ax
mov esp, 0x7C00
mov ax, sel_data
mov ds, ax
mov es, ax
mbp
; >>> checking elf file
; >> magic number check
E ehdr elf_load
mov esi, E.e_ident.ei_mag
mov edi, elf_mag
add edi, 0x7C00
cmpsd
jnz not_elf
mbp
; > magic - OK !
ccall print, elf_mag_ok+0x7c00, 0, green
; >> checking e_type
mov ax, [E.e_type]
mov bx, 0x0001
cmp ax, bx
mbp
jnz not_elf
ccall print, elf_e_type_ok+0x7c00, 1, green
; looking for symtab (sh_type = 2)
mbp
s shdr eax
xor ecx, ecx
mov cx, [E.e_shnum]
xor eax, eax
mov eax, elf_load
add eax, [E.e_shoff]
.lp:
mov ebx, [s.sh_type]
cmp ebx, 2
jz symtab_found
xor edx, edx
mov dx, [E.e_shentsize]
add eax, edx
loop .lp
jmp not_elf
symtab_found:
ccall print, elf_symtab_ok+0x7c00, 2, green
; s contains info about .symtab
mbp
mov ecx, [s.sh_size]
shr ecx, 4 ; sym_size=16; ebx = number of symbols
mov esi, [s.sh_offset]
add esi, 0x7c00
sm sym esi
not_elf:
ccall print, error_str+0x7c00, 24, red
mbp
jmp $
; >>>> Procedures (optional cdecl or nodecl)
; # output
; print(src,y,color) // null-terminated string
print:
push ebp
mov ebp, esp
push esi, edi, eax
mov esi, [ebp+8]
mov edi, [ebp+12]
mov ah, [ebp+16]
imul edi, 160
add edi, 0xB8000
.loop: ;цикл вывода сообщения
lodsb ;считываем очередной символ строки
test al, al ;если встретили 0
jz .exit ;прекращаем вывод
stosw
jmp .loop
.exit:
pop eax, edi, esi
pop ebp
ret
; write(src) - TODO
; # ELF
; symbol table ops
; get_section
; >>>> Data
elf_mag_ok: db "ELF magic number - OK", 0
elf_e_type_ok: db "ELF e_type - relocatable - OK",0
elf_symtab_ok: db "ELF symtable - OK", 0
error_str: db "ERROR! entering infinite loop",0
elf_mag: db 0x7f, 'E', 'L', 'F' ; ELF magic number
; >>>> Const
; >>> addresses (x86 elf)
elf_load = 0x8000
; >> elf_header
elf_type_off = 0x10
elf_shoff_off = 0x20
elf_shentsize_off = 0x2E
elf_shnum_off = 0x30
elf_shstrndx_off = 0x32
; >>> селекторы дескрипторов (RPL=0, TI=0)
sel_zero = 0000000b
sel_code32 = 0001000b
sel_data = 0010000b
; >>> colors
green = 0x0A
red = 0x04
; Here goes C flat binary?
; >>> boot sector signature
;finish:
;times 0x1FE-finish+start db 0
;db 0x55, 0xAA ; ñèãíàòóðà çàãðóçî÷íîãî ñåêòîðà |
tests/jump/jump_address.asm | UPB-FILS-ALF/devoir-1-tests | 0 | 120 | <reponame>UPB-FILS-ALF/devoir-1-tests<filename>tests/jump/jump_address.asm
push 1
push 2
jump 5
push 3
stack
|
hdes-dialect/hdes-ast/src/main/antlr4/imports/ServiceTaskParser.g4 | the-wrench-io/hdes-parent | 1 | 7536 | parser grammar ServiceTaskParser;
options { tokenVocab = HdesLexer; }
import TypeDefParser, ExpressionParser;
serviceTaskUnit: simpleTypeName headers '{' externalService '}';
promise: PROMISE '{' promiseTimeout? '}';
promiseTimeout: TIMEOUT ':' expressionUnit;
externalService: promise? typeName mapping; |
Recutter.agda | pigworker/InteriorDesign | 6 | 13086 | <filename>Recutter.agda
module Recutter where
open import Basics
open import All
open import Cutting
open import Perm
module RECUTTER {I}(C : I |> I) where
open _|>_
CutKit : (I -> Set) -> Set
CutKit P = (i : I)(c : Cuts C i) -> P i -> All P (inners C c)
Subs : List I -> Set
Subs = All (\ i -> One + Cuts C i)
subCollect : (is : List I) -> Subs is -> List I
subCollect is cs = collect is (all (\ i -> (\ _ -> i ,- []) <+> inners C) is cs)
Sub : I |> Sg I (Cuts C)
Cuts Sub (i , c) = Subs (inners C c)
inners Sub {i , c} cs = subCollect (inners C c) cs
Recutter : Set
Recutter = (i : I)(c c' : Cuts C i) ->
Sg (Cuts Sub (i , c)) \ d -> Sg (Cuts Sub (i , c')) \ d' ->
inners Sub d ~ inners Sub d'
module NATRECUT where
open RECUTTER NatCut
data CutCompare (x x' y y' n : Nat) : Set where
cutLt : (d : Nat) -> (x +N suc d) == y -> (suc d +N y') == x' ->
CutCompare x x' y y' n
cutEq : x == y -> x' == y' ->
CutCompare x x' y y' n
cutGt : (d : Nat) -> (y +N suc d) == x -> (suc d +N x') == y' ->
CutCompare x x' y y' n
sucInj : {x y : Nat} -> suc x == suc y -> x == y
sucInj (refl (suc _)) = refl _
cutCompare : (x x' y y' n : Nat) -> (x +N x') == n -> (y +N y') == n ->
CutCompare x x' y y' n
cutCompare zero .n zero .n n (refl _) (refl _)
= cutEq (refl _) (refl _)
cutCompare zero .(suc (y +N y')) (suc y) y' .(suc (y +N y')) (refl _) (refl _)
= cutLt y (refl _) (refl _)
cutCompare (suc x) x' zero .(suc (x +N x')) .(suc (x +N x')) (refl _) (refl _)
= cutGt x (refl _) (refl _)
cutCompare (suc x) x' (suc y) y' zero () ()
cutCompare (suc x) x' (suc y) y' (suc n) xq yq
with cutCompare x x' y y' n (sucInj xq) (sucInj yq)
cutCompare (suc x) x' (suc .(x +N suc d)) y' (suc n) xq yq
| cutLt d (refl _) bq = cutLt d (refl _) bq
cutCompare (suc x) x' (suc .x) y' (suc n) xq yq
| cutEq (refl _) bq = cutEq (refl _) bq
cutCompare (suc .(y +N suc d)) x' (suc y) y' (suc n) xq yq
| cutGt d (refl _) bq = cutGt d (refl _) bq
NatRecut : Recutter
NatRecut n (a , b , qab) (c , d , qcd) with cutCompare a b c d n qab qcd
NatRecut n (a , b , qab) (c , d , qcd) | cutLt e q0 q1
= (inl <> , inr (suc e , d , q1) , <>)
, (inr (a , suc e , q0) , inl <> , <>)
, reflP _
NatRecut n (a , b , qab) (.a , .b , qcd) | cutEq (refl .a) (refl .b)
= (inl <> , inl <> , <>)
, (inl <> , inl <> , <>)
, reflP _
NatRecut n (a , b , qab) (c , d , qcd) | cutGt e q0 q1
= (inr (c , suc e , q0) , inl <> , <>)
, (inl <> , inr (suc e , b , q1) , <>)
, reflP _
module SUBCOLLECTLEMMA where
open _|>_
open RECUTTER
subCollectLemma : forall {I J}(C : I |> I)(D : J |> J)
(f : I -> J)(g : (i : I) -> Cuts C i -> Cuts D (f i)) ->
(q : (i : I)(c : Cuts C i) -> inners D (g i c) == list f (inners C c)) ->
(is : List I)(ps : All (\ i -> One + Cuts C i) is) ->
subCollect D (list f is) (allRe f is (all (\ i -> id +map g i) is ps)) ==
list f (subCollect C is ps)
subCollectLemma C D f g q [] <> = refl []
subCollectLemma C D f g q (i ,- is) (inl <> , ps) =
refl (f i ,-_) =$= subCollectLemma C D f g q is ps
subCollectLemma C D f g q (i ,- is) (inr c , ps) =
(inners D (g i c) +L
subCollect D (list f is) (allRe f is (allAp is (allPu (\ i -> id +map g i) is) ps)))
=[ refl _+L_ =$= q i c =$= subCollectLemma C D f g q is ps >=
(list f (inners C c) +L list f (subCollect C is ps))
=[ catNatural f (inners C c) (subCollect C is ps) >=
list f (inners C c +L subCollect C is ps)
[QED]
|
resources/scripts/api/c99.ads | Elon143/Amass | 7,053 | 881 | <reponame>Elon143/Amass
-- Copyright 2020-2021 <NAME>. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "C99"
type = "api"
function start()
set_rate_limit(10)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local resp, err = request(ctx, {['url']=build_url(domain, c.key)})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local d = json.decode(resp)
if (d == nil or d.success ~= true or #(d.subdomains) == 0) then
return
end
for i, s in pairs(d.subdomains) do
new_name(ctx, s.subdomain)
end
end
function build_url(domain, key)
return "https://api.c99.nl/subdomainfinder?key=" .. key .. "&domain=" .. domain .. "&json"
end
|
exe4-lista.asm | joaoghost19/mips-exercises | 0 | 177028 | #################################################
# exe4 MIPS assembly #
# author: <NAME> #
#################################################
.data
.text
main:
#int a = 10;
li $t1, 10
# if (a>0) { b = a + 10} else { b = a - 10 }
beq $t1, $zero, else
addi $t0, $t1, 10
j end
else:
sub $t0, $t1, 10
end:
li $v0, 1
add $a0, $t0, $zero
syscall
li $v0, 10
syscall |
oeis/121/A121454.asm | neoneye/loda-programs | 11 | 102700 | <gh_stars>10-100
; A121454: Expansion of q * psi(-q) * psi(-q^7) in powers of q where psi(q) is a Ramanujan theta function.
; Submitted by <NAME>
; 1,-1,0,-1,0,0,1,-1,1,0,2,0,0,-1,0,-1,0,-1,0,0,0,-2,2,0,1,0,0,-1,2,0,0,-1,0,0,0,-1,2,0,0,0,0,0,2,-2,0,-2,0,0,1,-1,0,0,2,0,0,-1,0,-2,0,0,0,0,1,-1,0,0,2,0,0,0,2,-1,0,-2,0,0,2,0,2,0,1,0,0,0,0,-2,0,-2,0,0,0,-2,0,0,0,0,0,-1,2,-1
mov $2,-1
pow $2,$0
seq $0,35162 ; Number of positive odd solutions to equation x^2 + 7y^2 = 8n.
mul $0,$2
|
AirDefense_MoveSprites.asm | absayuti/AirDefenseC64 | 0 | 16931 | <reponame>absayuti/AirDefenseC64<filename>AirDefense_MoveSprites.asm
*=$C000 ; ORG at 49152
; Registers where sprite (screen) position is specified
vic = 53248
sp0x = vic
sp0y = vic+1
sp1x = vic+2
sp1y = vic+3
sp2x = vic+4
sp2y = vic+5
; We use an unused block at 820-827 to store sprite location on screen
; so that we can poke and peek from BASIC
param = 820
x_xhair = param
y_xhair = param+1
x_bomb = param+2
y_bomb = param+3
x_missl = param+4
y_missl = param+5
flags = param+6 ; Bomb(1).Explode(2).MisslV(4).MisslH(8).
; Hit(16).Missed(32)
; Min & max allowable values for the bomb and crosshair positions
xmin_xhair = 16
xmax_xhair = 252
ymin_xhair = 40
ymax_xhair = 220
xmin_bomb = 0
xmax_bomb = 252
ymin_bomb = 24
ymax_bomb = 235
x0_missl = 24 ; Origin of missile position (x>255)
y0_missl = 220
; Location where key code is stored when key is pressed
inkey = 197
; Key codes when specific key is pressed
keyA = 10
keyZ = 12
keyLT = 47
keyGT = 44
keySP = 60
; Start of program ------------------------------------------------------------
LDA flags ; Check flags
AND #1 ; If no bomb dropped,
BEQ readinkey ; skip to read inkey
movebomb ; Move bomb down
LDA y_bomb
ADC #1
CMP #ymax_bomb
BCC @placeit
LDA #2 ; flag = explode
STA flags
@placeit
STA y_bomb
STA sp1y
LDA flags ; Check if missile is launched
AND #12
BEQ readinkey ; If NOT, skip to read inkey
; Missile motion routine ------------------------------------------------------
movemissile
LDA flags ; Check if vertical / horizontal motion
AND #4 ; If not vertical,
BEQ misslhoriz ; move horizontally
misslvert
LDA x_missl
STA sp2x
LDA y_missl
SBC #4
CMP y_xhair
BCS changemotion
STA sp2y
RTS
changemotion
LDA flags
AND #251 ; off bit 2 (misslV)
ORA #8 ; ON bit 4 (misslH)
STA flags
misslhoriz
LDA y_missl
STA sp2y
LDA x_missl
SBC #4
CMP #4
BCS missloff
STA sp2x
; check collision with the bomb
;
RTS
missloff
LDA flags
AND #247 ; off bit 4 (misslH)
ORA #32 ; ON bit 5 (Missed)
STA flags
RTS
; Read inkey and move crosshair -----------------------------------------------
readinkey
LDA inkey ; Check key @ 197
moveup ; if 'A' move crosshair up
CMP #keyA
BNE movedown
LDA y_xhair
SBC #2
CMP #ymin_xhair ; Greater than Y.min?
BCS @placeit
LDA #ymin_xhair
@placeit
STA y_xhair
STA sp0y
RTS
movedown ; if 'Z' move crosshair down
CMP #keyZ
BNE moveleft
LDA y_xhair
ADC #2
CMP #ymax_xhair ; Less than Y.max?
BCC @placeit
LDA #ymax_xhair
@placeit
STA y_xhair
STA sp0y
RTS
moveleft ; if '<' move crosshair left
CMP #keyLT
BNE moveright
LDA x_xhair
SBC #2
CMP #xmin_xhair ; Less than Y.max?
BCS @placeit
LDA #xmin_xhair
@placeit
STA x_xhair
STA sp0x
RTS
moveright ; if '>' move crosshair right
CMP #keyGT
BNE fire
LDA x_xhair
ADC #2
CMP #xmax_xhair ; Less than Y.max?
BCC @placeit
LDA #xmax_xhair
@placeit
STA x_xhair
STA sp0x
RTS
fire ; if {space} fire missile
CMP #keySP
BNE done
LDA #4 ; flag = launch missile, vertical motion
STA flags
done
RTS
; ------------------------------ end ------------------------------------------ |
Prelude/Monad.agda | bbarenblat/B | 1 | 16599 | <gh_stars>1-10
{- Copyright © 1992–2002 The University of Glasgow
Copyright © 2015 <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. -}
module B.Prelude.Monad where
import Category.Monad
import Data.List
import Data.Maybe
open import Function using (const)
open Category.Monad
using (RawMonad)
public
open Category.Monad.RawMonad ⦃...⦄
using (_>>=_; _>>_; return)
public
instance
Monad-List : ∀ {ℓ} → RawMonad (Data.List.List {ℓ})
Monad-List = Data.List.monad
Monad-Maybe : ∀ {ℓ} → RawMonad (Data.Maybe.Maybe {ℓ})
Monad-Maybe = Data.Maybe.monad
Monad-Function : ∀ {ℓ} {r : Set ℓ} → RawMonad (λ s → (r → s))
Monad-Function {r} = record { return = const {r}
; _>>=_ = λ f k → λ r → k (f r) r }
|
mat/src/memory/mat-memory-tools.adb | stcarrez/mat | 7 | 9299 | <gh_stars>1-10
-----------------------------------------------------------------------
-- mat-memory-tools - Tools for memory maps
-- Copyright (C) 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.
-----------------------------------------------------------------------
package body MAT.Memory.Tools is
-- ------------------------------
-- Collect the information about memory slot sizes for the memory slots in the map.
-- ------------------------------
procedure Size_Information (Memory : in MAT.Memory.Allocation_Map;
Sizes : in out Size_Info_Map) is
procedure Update_Count (Size : in MAT.Types.Target_Size;
Info : in out Size_Info_Type);
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
procedure Update_Count (Size : in MAT.Types.Target_Size;
Info : in out Size_Info_Type) is
pragma Unreferenced (Size);
begin
Info.Count := Info.Count + 1;
end Update_Count;
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation) is
pragma Unreferenced (Addr);
Pos : constant Size_Info_Cursor := Sizes.Find (Slot.Size);
begin
if Size_Info_Maps.Has_Element (Pos) then
Sizes.Update_Element (Pos, Update_Count'Access);
else
declare
Info : Size_Info_Type;
begin
Info.Count := 1;
Sizes.Insert (Slot.Size, Info);
end;
end if;
end Collect;
Iter : Allocation_Cursor := Memory.First;
begin
while Allocation_Maps.Has_Element (Iter) loop
Allocation_Maps.Query_Element (Iter, Collect'Access);
Allocation_Maps.Next (Iter);
end loop;
end Size_Information;
-- ------------------------------
-- Collect the information about threads and the memory allocations they've made.
-- ------------------------------
procedure Thread_Information (Memory : in MAT.Memory.Allocation_Map;
Threads : in out Memory_Info_Map) is
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation) is
procedure Update_Count (Thread : in MAT.Types.Target_Thread_Ref;
Info : in out Memory_Info);
procedure Update_Count (Thread : in MAT.Types.Target_Thread_Ref;
Info : in out Memory_Info) is
pragma Unreferenced (Thread);
Size : constant MAT.Types.Target_Size := Slot.Size;
begin
Info.Alloc_Count := Info.Alloc_Count + 1;
if Size < Info.Min_Slot_Size then
Info.Min_Slot_Size := Size;
end if;
if Size > Info.Max_Slot_Size then
Info.Max_Slot_Size := Size;
end if;
if Addr < Info.Min_Addr then
Info.Min_Addr := Addr;
end if;
if Addr + Size > Info.Max_Addr then
Info.Max_Addr := Addr + Size;
end if;
Info.Total_Size := Info.Total_Size + Size;
end Update_Count;
Pos : constant Memory_Info_Cursor := Threads.Find (Slot.Thread);
begin
if Memory_Info_Maps.Has_Element (Pos) then
Threads.Update_Element (Pos, Update_Count'Access);
else
declare
Info : Memory_Info;
begin
Info.Total_Size := Slot.Size;
Info.Alloc_Count := 1;
Info.Min_Slot_Size := Slot.Size;
Info.Max_Slot_Size := Slot.Size;
Info.Min_Addr := Addr;
Info.Max_Addr := Addr + Slot.Size;
Threads.Insert (Slot.Thread, Info);
end;
end if;
end Collect;
Iter : Allocation_Cursor := Memory.First;
begin
while Allocation_Maps.Has_Element (Iter) loop
Allocation_Maps.Query_Element (Iter, Collect'Access);
Allocation_Maps.Next (Iter);
end loop;
end Thread_Information;
-- ------------------------------
-- Collect the information about frames and the memory allocations they've made.
-- ------------------------------
procedure Frame_Information (Memory : in MAT.Memory.Allocation_Map;
Level : in Natural;
Frames : in out Frame_Info_Map) is
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation) is
procedure Update_Count (Frame_Addr : in MAT.Types.Target_Addr;
Info : in out Frame_Info);
procedure Update_Count (Frame_Addr : in MAT.Types.Target_Addr;
Info : in out Frame_Info) is
pragma Unreferenced (Frame_Addr);
Size : constant MAT.Types.Target_Size := Slot.Size;
begin
Info.Memory.Alloc_Count := Info.Memory.Alloc_Count + 1;
if Size < Info.Memory.Min_Slot_Size then
Info.Memory.Min_Slot_Size := Size;
end if;
if Size > Info.Memory.Max_Slot_Size then
Info.Memory.Max_Slot_Size := Size;
end if;
if Addr < Info.Memory.Min_Addr then
Info.Memory.Min_Addr := Addr;
end if;
if Addr + Size > Info.Memory.Max_Addr then
Info.Memory.Max_Addr := Addr + Size;
end if;
Info.Memory.Total_Size := Info.Memory.Total_Size + Size;
end Update_Count;
Frame : constant MAT.Frames.Frame_Table := MAT.Frames.Backtrace (Slot.Frame, Level);
Pos : Frame_Info_Cursor;
begin
for I in Frame'Range loop
Pos := Frames.Find (Frame (I));
if Frame_Info_Maps.Has_Element (Pos) then
Frames.Update_Element (Pos, Update_Count'Access);
else
declare
Info : Frame_Info;
begin
Info.Thread := Slot.Thread;
Info.Memory.Total_Size := Slot.Size;
Info.Memory.Alloc_Count := 1;
Info.Memory.Min_Slot_Size := Slot.Size;
Info.Memory.Max_Slot_Size := Slot.Size;
Info.Memory.Min_Addr := Addr;
Info.Memory.Max_Addr := Addr + Slot.Size;
Frames.Insert (Frame (I), Info);
end;
end if;
end loop;
end Collect;
Iter : Allocation_Cursor := Memory.First;
begin
while Allocation_Maps.Has_Element (Iter) loop
Allocation_Maps.Query_Element (Iter, Collect'Access);
Allocation_Maps.Next (Iter);
end loop;
end Frame_Information;
-- ------------------------------
-- Find from the <tt>Memory</tt> map the memory slots whose address intersects
-- the region [From .. To] and which is selected by the given filter expression.
-- Add the memory slot in the <tt>Into</tt> list if it does not already contains
-- the memory slot.
-- ------------------------------
procedure Find (Memory : in MAT.Memory.Allocation_Map;
From : in MAT.Types.Target_Addr;
To : in MAT.Types.Target_Addr;
Filter : in MAT.Expressions.Expression_Type;
Into : in out MAT.Memory.Allocation_Map) is
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation);
procedure Collect (Addr : in MAT.Types.Target_Addr;
Slot : in Allocation) is
begin
if MAT.Expressions.Is_Selected (Filter, Addr, Slot) then
Into.Insert (Addr, Slot);
end if;
end Collect;
Iter : MAT.Memory.Allocation_Cursor := Memory.Ceiling (From);
Pos : MAT.Memory.Allocation_Cursor;
Addr : MAT.Types.Target_Addr;
Size : MAT.Types.Target_Size;
begin
-- If there was no slot with the ceiling From address, we have to start from the last
-- node because the memory slot may intersect our region.
if not Allocation_Maps.Has_Element (Iter) then
Iter := Memory.Last;
if not Allocation_Maps.Has_Element (Iter) then
return;
end if;
Addr := Allocation_Maps.Key (Iter);
Size := Allocation_Maps.Element (Iter).Size;
if Addr + Size < From then
return;
end if;
end if;
-- Move backward until the previous memory slot does not overlap anymore our region.
-- In theory, going backward once is enough but if there was a target malloc issue,
-- several malloc may overlap the same region (which is bad for the target).
loop
Pos := Allocation_Maps.Previous (Iter);
exit when not Allocation_Maps.Has_Element (Pos);
Addr := Allocation_Maps.Key (Pos);
Size := Allocation_Maps.Element (Pos).Size;
exit when Addr + Size < From;
Iter := Pos;
end loop;
-- Add the memory slots until we moved to the end of the region.
while Allocation_Maps.Has_Element (Iter) loop
Addr := Allocation_Maps.Key (Iter);
exit when Addr > To;
Pos := Into.Find (Addr);
if not Allocation_Maps.Has_Element (Pos) then
Allocation_Maps.Query_Element (Iter, Collect'Access);
end if;
Allocation_Maps.Next (Iter);
end loop;
end Find;
end MAT.Memory.Tools;
|
examples/version.adb | ytomino/zlib-ada | 0 | 8227 | <filename>examples/version.adb<gh_stars>0
with Ada.Text_IO;
with zlib;
procedure version is
begin
Ada.Text_IO.Put_Line (zlib.Version);
end version;
|
programs/oeis/008/A008756.asm | neoneye/loda | 22 | 160423 | ; A008756: Expansion of (1+x^13)/((1-x)*(1-x^2)*(1-x^3)).
; 1,1,2,3,4,5,7,8,10,12,14,16,19,22,25,29,33,37,42,47,52,58,64,70,77,84,91,99,107,115,124,133,142,152,162,172,183,194,205,217,229,241,254,267,280,294,308,322,337,352,367,383,399,415,432,449,466,484,502,520,539,558,577,597,617,637,658,679,700,722,744,766,789,812,835,859,883,907,932,957,982,1008,1034,1060,1087,1114,1141,1169,1197,1225,1254,1283,1312,1342,1372,1402,1433,1464,1495,1527
mov $4,$0
add $4,1
mov $5,$0
lpb $4
mov $0,$5
sub $4,1
sub $0,$4
add $0,4
mov $2,2
lpb $0
mov $6,$0
sub $0,1
sub $6,2
mov $3,$6
mov $6,$0
add $0,$3
div $0,6
sub $3,$0
sub $0,1
trn $0,3
add $2,$3
mul $2,2
add $0,$2
add $6,1
sub $0,$6
lpe
div $0,2
mul $0,2
mov $6,$0
sub $6,2
div $6,2
add $1,$6
lpe
mov $0,$1
|
Cubical/Algebra/CommAlgebra/FGIdeal.agda | marcinjangrzybowski/cubical | 301 | 5314 | {-# OPTIONS --safe #-}
module Cubical.Algebra.CommAlgebra.FGIdeal where
open import Cubical.Foundations.Prelude
open import Cubical.Data.FinData
open import Cubical.Data.Nat
open import Cubical.Data.Vec
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.FGIdeal renaming (generatedIdeal to generatedIdealCommRing)
open import Cubical.Algebra.CommAlgebra
open import Cubical.Algebra.CommAlgebra.Ideal
private
variable
ℓ : Level
module _ {R : CommRing ℓ} (A : CommAlgebra R ℓ) where
open CommAlgebraStr (snd A)
generatedIdeal : {n : ℕ} → FinVec (fst A) n → IdealsIn A
generatedIdeal = generatedIdealCommRing (CommAlgebra→CommRing A)
|
oeis/066/A066003.asm | neoneye/loda-programs | 11 | 168381 | <gh_stars>10-100
; A066003: Sum of digits of 7^n.
; 1,7,13,10,7,22,28,25,31,28,43,49,37,52,58,64,52,58,73,79,76,82,97,85,73,97,112,91,133,121,118,115,103,127,142,157,136,115,130,136,142,148,136,169,175,163,187,175,136,178,184,217,196,220,217,214,211,181,241,211,199,205,256,208,232,247,262,268,202,244,259,265,271,277,292,262,277,319,298,322,265,271,313,292,307,295,364,325,277,364,298,322,310,361,376,364,370,376,355,370
mov $4,$0
mov $0,7
pow $0,$4
lpb $0
mov $2,$0
div $0,10
mod $2,10
add $3,$2
lpe
mov $0,$3
|
oeis/060/A060532.asm | neoneye/loda-programs | 11 | 161973 | <filename>oeis/060/A060532.asm
; A060532: Number of ways to color vertices of a heptagon using <= n colors, allowing rotations and reflections.
; 0,1,18,198,1300,5895,20646,60028,151848,344925,719290,1399266,2569788,4496323,7548750,12229560,19206736,29351673,43782498,63913150,91508580,128746431,178285558,243341748,327771000,436160725,573929226,747433818,964087948,1232487675,1562547870,1965648496,2454791328,3044767473,3752336050,4596414390,5598280116,6781785463,8173584198,9803371500,11704137160,13912432461,16468651098,19417324498,22807431900,26692725555,31132071406,36189805608,41936107248,48447387625,55806696450,64104145326,73437348868
mov $1,$0
pow $1,3
add $1,1
mul $0,$1
add $1,5
mul $0,$1
div $0,14
|
ADD.asm | ELASRIYASSINE/DSP-DIGITAL-SIGNAL-PROCESSING-CODES- | 0 | 15286 | <reponame>ELASRIYASSINE/DSP-DIGITAL-SIGNAL-PROCESSING-CODES-
; ADRESSAGE DIRECT
; ADDITION ET STOCKAGE DE DONNE
.text
ldi 55,R2 ;CHARGER 55 DANS R2
sti R2,@180h ;STOCKER R2 DANS L'ADRESSE @180h
ldi 45,R2 ;CHARGER 45 DANS R2
addi @180h, R2 ;MULTIPLIER @ PAR R2 RESULTAT SUR R2
sti R2,@181h ;STOCKER R2 DANS L'ADRESSE @181h
.end |
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/フランス_PAL/Fra_asm1/zel_gsub1_fra.asm | prismotizm/gigaleak | 0 | 178754 | Name: zel_gsub1_fra.asm
Type: file
Size: 3376
Last-Modified: '2016-05-13T04:20:48Z'
SHA-1: DA0413A8DF0D642D4A281E896EAEA8B8205DD6CE
Description: null
|
Applications/iTerm/tab/iterate.applescript | looking-for-a-job/applescript-examples | 1 | 1516 | <filename>Applications/iTerm/tab/iterate.applescript
tell application "iTerm"
repeat with w in every window
tell w
repeat with t in every tab of w
t
tell repeat
end tell
end repeat
end tell
|
boot/stage1/boot.asm | wodOS/wodOS | 4 | 89694 | <gh_stars>1-10
;;
; wodOS Operating System
; Copyright © 2021-2022 wodOS Operating System Developers. All rights reserved.
;
; Use of this source code is governed by a BSD-style license that can be
; found in the LICENSE file.
;
; Contributor(s):
; - <NAME> <<EMAIL>>
;;
[org 0x7c00]
[bits 16]
%include "fat_header.inc"
%define ENDL 0x0d, 0x0a
main:
; Setup the data segments
mov ax, 0
mov ds, ax
mov es, ax
; Setup the stack segments
mov ss, ax
mov sp, 0x7c00
; Some BIOS may load us at a different address
push es
push word .main2
retf
.main2:
; Move the drive number to the DL Register for later use
mov [ebr_drive_number], dl
; Print the loading message
mov si, load_msg
call print
; Read the disk using BIOS int 0x13
push es
mov ah, 08h
int 0x13
jc boot_error
pop es
and cl, 0x3F
xor ch, ch
mov [bpb_sectors_per_track], cx
inc dh
mov [bpb_heads], dh
mov ax, [bpb_sectors_per_fat]
mov bl, [bpb_fat_count]
xor bh, bh
mul bx
add ax, [bpb_reserved_sectors]
push ax
mov ax, [bpb_dir_entries_count]
shl ax, 5
xor dx, dx
div word [bpb_bytes_per_sector]
test dx, dx
jz .root_directory_after
inc ax
.root_directory_after:
mov cl, al
pop ax
mov dl, [ebr_drive_number]
mov bx, stage2_buffer
call disk_read
; Search for the stage2.bin file
xor bx, bx
mov di, stage2_buffer
.find_stage2:
mov si, stage2_bin_file
mov cx, 11
push di
repe cmpsb
pop di
je .found_stage2
add di, 32
inc bx
cmp bx, [bpb_dir_entries_count]
jl .find_stage2
jmp stage2_not_found
.found_stage2:
mov ax, [di + 26]
mov [stage2_cluster], ax
; Load the FAT from disk onto the memory
mov ax, [bpb_reserved_sectors]
mov bx, stage2_buffer
mov cl, [bpb_sectors_per_fat]
mov dl, [ebr_drive_number]
call disk_read
; Read the stage2.bin file and process the FAT chain
mov bx, STAGE2_LOAD_SEGMENT
mov es, bx
mov bx, STAGE2_LOAD_OFFSET
.load_stage2_loop:
mov ax, [stage2_cluster]
add ax, 31
mov cl, 1
mov dl, [ebr_drive_number]
call disk_read
add bx, [bpb_bytes_per_sector]
mov ax, [stage2_cluster]
mov cx, 3
mul cx
mov cx, 2
div cx
mov si, stage2_buffer
add si, ax
mov ax, [ds:si]
or dx, dx
jz .even
.odd:
shr ax, 4
jmp .next_cluster_after
.even:
and ax, 0x0FFF
.next_cluster_after:
cmp ax, 0x0FF8
jae .read_finish
mov [stage2_cluster], ax
jmp .load_stage2_loop
.read_finish:
; Change the drive numeber
mov dl, [ebr_drive_number]
; Set the segment registers
mov ax, STAGE2_LOAD_SEGMENT
mov ds, ax
mov es, ax
; Jump the stage2
jmp STAGE2_LOAD_SEGMENT:STAGE2_LOAD_OFFSET
; If there is an error
jmp wait_for_keypress_to_reboot
; Halt if stage2 returns
cli
hlt
boot_error:
mov si, err_msg
call print
jmp wait_for_keypress_to_reboot
stage2_not_found:
mov si, stage2_err_msg
call print
jmp wait_for_keypress_to_reboot
; Wait for the user to press the key
wait_for_keypress_to_reboot:
mov ah, 0
int 0x16
jmp 0FFFFh:0
; If it turns on again, do an infinite loop
.halt:
hlt
cli
jmp .halt
%include "print.asm"
%include "disk.asm"
load_msg: db 'Loading...', ENDL, 0
err_msg: db 'BOOT ERROR', ENDL, 0
stage2_err_msg: db 'STAGE2 NOT FOUND', ENDL, 0
stage2_bin_file: db 'STAGE2 BIN'
stage2_cluster: dw 0
STAGE2_LOAD_SEGMENT equ 0
STAGE2_LOAD_OFFSET equ 0x1000
times 510 - ($-$$) db 0
dw 0xaa55
stage2_buffer: |
src/Generics/Helpers.agda | flupe/generics | 11 | 16167 | {-# OPTIONS --safe --without-K #-}
open import Generics.Prelude
open import Generics.Telescope
open import Generics.Desc
open import Agda.Builtin.Reflection
module Generics.Helpers
P I
{levelArgRel : Level → Level}
(ArgRel : ∀ {a} → Set a → Set (levelArgRel a))
{levelArgIrr : Level → Level}
(ArgIrr : ∀ {a} → Set a → Set (levelArgIrr a))
(Ind : ∀ {V} (C : ConDesc P V I) → Setω)
where
data ConHelper p {V} : ConDesc P V I → Setω where
instance var : ∀ {f} → ConHelper p (var f)
pi-irr : ∀ {ℓ n v q}
{S : ⟦ P , V ⟧xtel → Set ℓ}
(let ai = n , arg-info v (modality irrelevant q))
{C : ConDesc P (V ⊢< ai > S) I}
→ ⦃ ∀ {v} → ArgIrr (S (p , v)) ⦄
→ ⦃ ConHelper p C ⦄
→ ConHelper p (π ai S C)
pi-rel : ∀ {ℓ n v q}
{S : ⟦ P , V ⟧xtel → Set ℓ}
(let ai = n , arg-info v (modality relevant q))
{C : ConDesc P (V ⊢< ai > S) I}
→ ⦃ ∀ {v} → ArgRel (S (p , v)) ⦄
→ ⦃ ConHelper p C ⦄
→ ConHelper p (π ai S C)
prod : {A B : ConDesc P V I}
→ ⦃ Ind A ⦄
→ ⦃ ConHelper p B ⦄
→ ConHelper p (A ⊗ B)
data Helpers p : {n : ℕ} → DataDesc P I n → Setω where
instance nil : Helpers p []
cons : ∀ {n} {C : ConDesc P ε I}
{D : DataDesc P I n}
→ ⦃ ConHelper p C ⦄
→ ⦃ Helpers p D ⦄
→ Helpers p (C ∷ D)
lookupHelper : ∀ {n} {D : DataDesc P I n} {p}
(HD : Helpers p D) (k : Fin n)
→ ConHelper p (lookupCon D k)
lookupHelper (cons ⦃ HC ⦄ ⦃ HD ⦄) zero = HC
lookupHelper (cons ⦃ HC ⦄ ⦃ HD ⦄) (suc k) = lookupHelper HD k
|
applescripts/spotify.scpt | bryantebeek/dotfiles | 0 | 4095 | if application "Spotify" is running then
tell application "Spotify"
set theName to name of the current track
set theArtist to artist of the current track
set theState to player state
try
if theState equals playing then
return "♫ " & theName & " - " & theArtist & " "
end if
on error err
end try
end tell
end if
|
oeis/279/A279742.asm | neoneye/loda-programs | 11 | 164005 | ; A279742: Number of 2 X n 0..1 arrays with no element equal to a strict majority of its horizontal and antidiagonal neighbors, with the exception of exactly one element, and with new values introduced in order 0 sequentially upwards.
; Submitted by <NAME>
; 0,2,6,14,26,48,84,146,250,426,722,1220,2056,3458,5806,9734,16298,27256,45532,75986,126690,211042,351266,584204,970896,1612418,2676054,4438526,7357370,12188736,20181732,33398930,55244746,91336218,150937586,249322964,411666328,679444226,1120971262,1848731126,3047878730,5023101832,8275648876,13629910994,22441388466,36938288338,60782494274,99990588956,164445707040,270378726146,444439487142,730375697390,1199987722586,1971093442128,3236983724916,5314709749394,8724228616858,14318106091146
mov $5,1
lpb $0
sub $0,1
mov $2,$1
add $1,$3
add $1,1
sub $3,$4
mov $4,$2
mov $2,$3
add $5,$4
mov $3,$5
add $4,$1
add $5,$2
lpe
add $5,$3
mov $0,$5
sub $0,1
mul $0,2
|
WEEK-12/1.asm | ShruKin/Microprocessor-and-Microcontroller-Lab | 0 | 5779 | MOV R0, #20H;set source address 20H to R0
MOV R1, #30H;set destination address 30H to R1
MOV A, @R0;take the first operand from source to register A
INC R0; Point to the next location
MOV B, @R0; take the second operand from source to register B
DIV AB ; Divide A by B
MOV @R1, A; Store Quotient to 30H
INC R1; Increase R1 to point to the next location
MOV @R1, B; Store Remainder to 31H
HALT: SJMP HALT ;Stop the program |
oeis/160/A160413.asm | neoneye/loda-programs | 11 | 177607 | <gh_stars>10-100
; A160413: a(n) = A160411(n+1)/4.
; Submitted by <NAME>(s3)
; 2,1,7,2,13,3,19,4,25,5,31,6,37,7,43,8,49,9,55,10,61,11,67,12,73,13,79,14,85,15,91,16,97,17,103,18,109,19,115,20,121,21,127,22,133,23,139,24,145
mov $4,3
mul $4,$0
gcd $4,2
mov $2,$4
mul $4,2
mov $5,$2
mul $5,2
mul $0,$5
mov $1,$4
sub $1,1
mov $3,$0
mul $3,$1
lpb $0
mov $0,1
trn $0,$2
add $1,$3
div $1,2
lpe
mov $0,$1
div $0,2
add $0,1
|
tools-src/gnu/gcc/gcc/ada/make.adb | enfoTek/tomato.linksys.e2000.nvram-mod | 80 | 1845 | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M A K E --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Command_Line; use Ada.Command_Line;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with ALI; use ALI;
with ALI.Util; use ALI.Util;
with Csets;
with Debug;
with Fname; use Fname;
with Fname.SF; use Fname.SF;
with Fname.UF; use Fname.UF;
with Gnatvsn; use Gnatvsn;
with Hostparm; use Hostparm;
with Makeusg;
with MLib.Prj;
with MLib.Tgt;
with MLib.Utl;
with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Gnatvsn;
with Output; use Output;
with Prj; use Prj;
with Prj.Com;
with Prj.Env;
with Prj.Ext;
with Prj.Pars;
with Prj.Util;
with SFN_Scan;
with Sinput.L;
with Snames; use Snames;
with Stringt; use Stringt;
with Table;
with Types; use Types;
with Switch; use Switch;
with System.WCh_Con; use System.WCh_Con;
package body Make is
use ASCII;
-- Make control characters visible
Standard_Library_Package_Body_Name : constant String := "s-stalib.adb";
-- Every program depends on this package, that must then be checked,
-- especially when -f and -a are used.
-------------------------
-- Note on terminology --
-------------------------
-- In this program, we use the phrase "termination" of a file name to
-- refer to the suffix that appears after the unit name portion. Very
-- often this is simply the extension, but in some cases, the sequence
-- may be more complex, for example in main.1.ada, the termination in
-- this name is ".1.ada" and in main_.ada the termination is "_.ada".
-------------------------------------
-- Queue (Q) Manipulation Routines --
-------------------------------------
-- The Q is used in Compile_Sources below. Its implementation uses the
-- GNAT generic package Table (basically an extensible array). Q_Front
-- points to the first valid element in the Q, whereas Q.First is the first
-- element ever enqueued, while Q.Last - 1 is the last element in the Q.
--
-- +---+--------------+---+---+---+-----------+---+--------
-- Q | | ........ | | | | ....... | |
-- +---+--------------+---+---+---+-----------+---+--------
-- ^ ^ ^
-- Q.First Q_Front Q.Last - 1
--
-- The elements comprised between Q.First and Q_Front - 1 are the
-- elements that have been enqueued and then dequeued, while the
-- elements between Q_Front and Q.Last - 1 are the elements currently
-- in the Q. When the Q is initialized Q_Front = Q.First = Q.Last.
-- After Compile_Sources has terminated its execution, Q_Front = Q.Last
-- and the elements contained between Q.Front and Q.Last-1 are those that
-- were explored and thus marked by Compile_Sources. Whenever the Q is
-- reinitialized, the elements between Q.First and Q.Last - 1 are unmarked.
procedure Init_Q;
-- Must be called to (re)initialize the Q.
procedure Insert_Q
(Source_File : File_Name_Type;
Source_Unit : Unit_Name_Type := No_Name);
-- Inserts Source_File at the end of Q. Provide Source_Unit when
-- possible for external use (gnatdist).
function Empty_Q return Boolean;
-- Returns True if Q is empty.
procedure Extract_From_Q
(Source_File : out File_Name_Type;
Source_Unit : out Unit_Name_Type);
-- Extracts the first element from the Q.
procedure Insert_Project_Sources
(The_Project : Project_Id;
Into_Q : Boolean);
-- If Into_Q is True, insert all sources of the project file that are not
-- already marked into the Q. If Into_Q is False, call Osint.Add_File for
-- all sources of the project file.
First_Q_Initialization : Boolean := True;
-- Will be set to false after Init_Q has been called once.
Q_Front : Natural;
-- Points to the first valid element in the Q.
Unique_Compile : Boolean := False;
type Q_Record is record
File : File_Name_Type;
Unit : Unit_Name_Type;
end record;
-- File is the name of the file to compile. Unit is for gnatdist
-- use in order to easily get the unit name of a file to compile
-- when its name is krunched or declared in gnat.adc.
package Q is new Table.Table (
Table_Component_Type => Q_Record,
Table_Index_Type => Natural,
Table_Low_Bound => 0,
Table_Initial => 4000,
Table_Increment => 100,
Table_Name => "Make.Q");
-- This is the actual Q.
-- The following instantiations and variables are necessary to save what
-- is found on the command line, in case there is a project file specified.
package Saved_Gcc_Switches is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Saved_Gcc_Switches");
package Saved_Binder_Switches is new Table.Table (
Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Saved_Binder_Switches");
package Saved_Linker_Switches is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Saved_Linker_Switches");
package Saved_Make_Switches is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Integer,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Saved_Make_Switches");
Saved_Maximum_Processes : Natural := 0;
Saved_WC_Encoding_Method : WC_Encoding_Method := WC_Encoding_Method'First;
Saved_WC_Encoding_Method_Set : Boolean := False;
type Arg_List_Ref is access Argument_List;
The_Saved_Gcc_Switches : Arg_List_Ref;
Project_File_Name : String_Access := null;
Current_Verbosity : Prj.Verbosity := Prj.Default;
Main_Project : Prj.Project_Id := No_Project;
procedure Add_Source_Dir (N : String);
-- Call Add_Src_Search_Dir.
-- Output one line when in verbose mode.
procedure Add_Source_Directories is
new Prj.Env.For_All_Source_Dirs (Action => Add_Source_Dir);
procedure Add_Object_Dir (N : String);
-- Call Add_Lib_Search_Dir.
-- Output one line when in verbose mode.
procedure Add_Object_Directories is
new Prj.Env.For_All_Object_Dirs (Action => Add_Object_Dir);
type Bad_Compilation_Info is record
File : File_Name_Type;
Unit : Unit_Name_Type;
Found : Boolean;
end record;
-- File is the name of the file for which a compilation failed.
-- Unit is for gnatdist use in order to easily get the unit name
-- of a file when its name is krunched or declared in gnat.adc.
-- Found is False if the compilation failed because the file could
-- not be found.
package Bad_Compilation is new Table.Table (
Table_Component_Type => Bad_Compilation_Info,
Table_Index_Type => Natural,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Bad_Compilation");
-- Full name of all the source files for which compilation fails.
type Special_Argument is record
File : String_Access;
Args : Argument_List_Access;
end record;
-- File is the name of the file for which a special set of compilation
-- arguments (Args) is required.
package Special_Args is new Table.Table (
Table_Component_Type => Special_Argument,
Table_Index_Type => Natural,
Table_Low_Bound => 1,
Table_Initial => 20,
Table_Increment => 100,
Table_Name => "Make.Special_Args");
-- Compilation arguments of all the source files for which an entry has
-- been found in the project file.
Original_Ada_Include_Path : constant String_Access :=
Getenv ("ADA_INCLUDE_PATH");
Original_Ada_Objects_Path : constant String_Access :=
Getenv ("ADA_OBJECTS_PATH");
Current_Ada_Include_Path : String_Access := null;
Current_Ada_Objects_Path : String_Access := null;
Max_Line_Length : constant := 127;
-- Maximum number of characters per line, when displaying a path
Do_Compile_Step : Boolean := True;
Do_Bind_Step : Boolean := True;
Do_Link_Step : Boolean := True;
-- Flags to indicate what step should be executed.
-- Can be set to False with the switches -c, -b and -l.
-- These flags are reset to True for each invokation of procedure Gnatmake.
----------------------
-- Marking Routines --
----------------------
procedure Mark (Source_File : File_Name_Type);
-- Mark Source_File. Marking is used to signal that Source_File has
-- already been inserted in the Q.
function Is_Marked (Source_File : File_Name_Type) return Boolean;
-- Returns True if Source_File was previously marked.
procedure Unmark (Source_File : File_Name_Type);
-- Unmarks Source_File.
-------------------
-- Misc Routines --
-------------------
procedure List_Depend;
-- Prints to standard output the list of object dependencies. This list
-- can be used directly in a Makefile. A call to Compile_Sources must
-- precede the call to List_Depend. Also because this routine uses the
-- ALI files that were originally loaded and scanned by Compile_Sources,
-- no additional ALI files should be scanned between the two calls (i.e.
-- between the call to Compile_Sources and List_Depend.)
procedure Inform (N : Name_Id := No_Name; Msg : String);
-- Prints out the program name followed by a colon, N and S.
procedure List_Bad_Compilations;
-- Prints out the list of all files for which the compilation failed.
procedure Verbose_Msg
(N1 : Name_Id;
S1 : String;
N2 : Name_Id := No_Name;
S2 : String := "";
Prefix : String := " -> ");
-- If the verbose flag (Verbose_Mode) is set then print Prefix to standard
-- output followed by N1 and S1. If N2 /= No_Name then N2 is then printed
-- after S1. S2 is printed last. Both N1 and N2 are printed in quotation
-- marks.
-----------------------
-- Gnatmake Routines --
-----------------------
subtype Lib_Mark_Type is Byte;
Ada_Lib_Dir : constant Lib_Mark_Type := 1;
GNAT_Lib_Dir : constant Lib_Mark_Type := 2;
-- Note that the notion of GNAT lib dir is no longer used. The code
-- related to it has not been removed to give an idea on how to use
-- the directory prefix marking mechanism.
-- An Ada library directory is a directory containing ali and object
-- files but no source files for the bodies (the specs can be in the
-- same or some other directory). These directories are specified
-- in the Gnatmake command line with the switch "-Adir" (to specify the
-- spec location -Idir cab be used). Gnatmake skips the missing sources
-- whose ali are in Ada library directories. For an explanation of why
-- Gnatmake behaves that way, see the spec of Make.Compile_Sources.
-- The directory lookup penalty is incurred every single time this
-- routine is called.
function Is_External_Assignment (Argv : String) return Boolean;
-- Verify that an external assignment switch is syntactically correct.
-- Correct forms are
-- -Xname=value
-- -X"name=other value"
-- Assumptions: 'First = 1, Argv (1 .. 2) = "-X"
-- When this function returns True, the external assignment has
-- been entered by a call to Prj.Ext.Add, so that in a project
-- file, External ("name") will return "value".
function In_Ada_Lib_Dir (File : File_Name_Type) return Boolean;
-- Get directory prefix of this file and get lib mark stored in name
-- table for this directory. Then check if an Ada lib mark has been set.
procedure Mark_Dir_Path
(Path : String_Access;
Mark : Lib_Mark_Type);
-- Invoke Mark_Directory on each directory of the path.
procedure Mark_Directory
(Dir : String;
Mark : Lib_Mark_Type);
-- Store Dir in name table and set lib mark as name info to identify
-- Ada libraries.
function Object_File_Name (Source : String) return String;
-- Returns the object file name suitable for switch -o.
procedure Set_Ada_Paths
(For_Project : Prj.Project_Id;
Including_Libraries : Boolean);
-- Set, if necessary, env. variables ADA_INCLUDE_PATH and
-- ADA_OBJECTS_PATH.
--
-- Note: this will modify these environment variables only
-- for the current gnatmake process and all of its children
-- (invocations of the compiler, the binder and the linker).
-- The caller process ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are
-- not affected.
function Switches_Of
(Source_File : Name_Id;
Source_File_Name : String;
Naming : Naming_Data;
In_Package : Package_Id;
Allow_ALI : Boolean)
return Variable_Value;
-- Return the switches for the source file in the specified package
-- of a project file. If the Source_File ends with a standard GNAT
-- extension (".ads" or ".adb"), try first the full name, then the
-- name without the extension. If there is no switches for either
-- names, try the default switches for Ada. If all failed, return
-- No_Variable_Value.
procedure Test_If_Relative_Path (Switch : String_Access);
-- Test if Switch is a relative search path switch.
-- Fail if it is. This subprogram is only called
-- when using project files.
procedure Set_Library_For
(Project : Project_Id;
There_Are_Libraries : in out Boolean);
-- If Project is a library project, add the correct
-- -L and -l switches to the linker invocation.
procedure Set_Libraries is
new For_Every_Project_Imported (Boolean, Set_Library_For);
-- Add the -L and -l switches to the linker for all
-- of the library projects.
----------------------------------------------------
-- Compiler, Binder & Linker Data and Subprograms --
----------------------------------------------------
Gcc : String_Access := Program_Name ("gcc");
Gnatbind : String_Access := Program_Name ("gnatbind");
Gnatlink : String_Access := Program_Name ("gnatlink");
-- Default compiler, binder, linker programs
Saved_Gcc : String_Access := null;
Saved_Gnatbind : String_Access := null;
Saved_Gnatlink : String_Access := null;
-- Given by the command line. Will be used, if non null.
Gcc_Path : String_Access :=
GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all);
Gnatbind_Path : String_Access :=
GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all);
Gnatlink_Path : String_Access :=
GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all);
-- Path for compiler, binder, linker programs, defaulted now for gnatdist.
-- Changed later if overridden on command line.
Comp_Flag : constant String_Access := new String'("-c");
Output_Flag : constant String_Access := new String'("-o");
Ada_Flag_1 : constant String_Access := new String'("-x");
Ada_Flag_2 : constant String_Access := new String'("ada");
No_gnat_adc : constant String_Access := new String'("-gnatA");
GNAT_Flag : constant String_Access := new String'("-gnatpg");
Do_Not_Check_Flag : constant String_Access := new String'("-x");
Object_Suffix : constant String := Get_Object_Suffix.all;
Executable_Suffix : constant String := Get_Executable_Suffix.all;
Display_Executed_Programs : Boolean := True;
-- Set to True if name of commands should be output on stderr.
Output_File_Name_Seen : Boolean := False;
-- Set to True after having scanned the file_name for
-- switch "-o file_name"
type Make_Program_Type is (None, Compiler, Binder, Linker);
Program_Args : Make_Program_Type := None;
-- Used to indicate if we are scanning gnatmake, gcc, gnatbind, or gnatbind
-- options within the gnatmake command line.
-- Used in Scan_Make_Arg only, but must be a global variable.
procedure Add_Switches
(The_Package : Package_Id;
File_Name : String;
Program : Make_Program_Type);
procedure Add_Switch
(S : String_Access;
Program : Make_Program_Type;
Append_Switch : Boolean := True;
And_Save : Boolean := True);
procedure Add_Switch
(S : String;
Program : Make_Program_Type;
Append_Switch : Boolean := True;
And_Save : Boolean := True);
-- Make invokes one of three programs (the compiler, the binder or the
-- linker). For the sake of convenience, some program specific switches
-- can be passed directly on the gnatmake commande line. This procedure
-- records these switches so that gnamake can pass them to the right
-- program. S is the switch to be added at the end of the command line
-- for Program if Append_Switch is True. If Append_Switch is False S is
-- added at the beginning of the command line.
procedure Check
(Lib_File : File_Name_Type;
ALI : out ALI_Id;
O_File : out File_Name_Type;
O_Stamp : out Time_Stamp_Type);
-- Determines whether the library file Lib_File is up-to-date or not. The
-- full name (with path information) of the object file corresponding to
-- Lib_File is returned in O_File. Its time stamp is saved in O_Stamp.
-- ALI is the ALI_Id corresponding to Lib_File. If Lib_File in not
-- up-to-date, then the corresponding source file needs to be recompiled.
-- In this case ALI = No_ALI_Id.
procedure Check_Linker_Options
(E_Stamp : Time_Stamp_Type;
O_File : out File_Name_Type;
O_Stamp : out Time_Stamp_Type);
-- Checks all linker options for linker files that are newer
-- than E_Stamp. If such objects are found, the youngest object
-- is returned in O_File and its stamp in O_Stamp.
--
-- If no obsolete linker files were found, the first missing
-- linker file is returned in O_File and O_Stamp is empty.
-- Otherwise O_File is No_File.
procedure Display (Program : String; Args : Argument_List);
-- Displays Program followed by the arguments in Args if variable
-- Display_Executed_Programs is set. The lower bound of Args must be 1.
--------------------
-- Add_Object_Dir --
--------------------
procedure Add_Object_Dir (N : String) is
begin
Add_Lib_Search_Dir (N);
if Opt.Verbose_Mode then
Write_Str ("Adding object directory """);
Write_Str (N);
Write_Str (""".");
Write_Eol;
end if;
end Add_Object_Dir;
--------------------
-- Add_Source_Dir --
--------------------
procedure Add_Source_Dir (N : String) is
begin
Add_Src_Search_Dir (N);
if Opt.Verbose_Mode then
Write_Str ("Adding source directory """);
Write_Str (N);
Write_Str (""".");
Write_Eol;
end if;
end Add_Source_Dir;
----------------
-- Add_Switch --
----------------
procedure Add_Switch
(S : String_Access;
Program : Make_Program_Type;
Append_Switch : Boolean := True;
And_Save : Boolean := True)
is
generic
with package T is new Table.Table (<>);
procedure Generic_Position (New_Position : out Integer);
-- Generic procedure that allocates a position for S in T at the
-- beginning or the end, depending on the boolean Append_Switch.
----------------------
-- Generic_Position --
----------------------
procedure Generic_Position (New_Position : out Integer) is
begin
T.Increment_Last;
if Append_Switch then
New_Position := Integer (T.Last);
else
for J in reverse T.Table_Index_Type'Succ (T.First) .. T.Last loop
T.Table (J) := T.Table (T.Table_Index_Type'Pred (J));
end loop;
New_Position := Integer (T.First);
end if;
end Generic_Position;
procedure Gcc_Switches_Pos is new Generic_Position (Gcc_Switches);
procedure Binder_Switches_Pos is new Generic_Position (Binder_Switches);
procedure Linker_Switches_Pos is new Generic_Position (Linker_Switches);
procedure Saved_Gcc_Switches_Pos is new
Generic_Position (Saved_Gcc_Switches);
procedure Saved_Binder_Switches_Pos is new
Generic_Position (Saved_Binder_Switches);
procedure Saved_Linker_Switches_Pos is new
Generic_Position (Saved_Linker_Switches);
New_Position : Integer;
-- Start of processing for Add_Switch
begin
if And_Save then
case Program is
when Compiler =>
Saved_Gcc_Switches_Pos (New_Position);
Saved_Gcc_Switches.Table (New_Position) := S;
when Binder =>
Saved_Binder_Switches_Pos (New_Position);
Saved_Binder_Switches.Table (New_Position) := S;
when Linker =>
Saved_Linker_Switches_Pos (New_Position);
Saved_Linker_Switches.Table (New_Position) := S;
when None =>
raise Program_Error;
end case;
else
case Program is
when Compiler =>
Gcc_Switches_Pos (New_Position);
Gcc_Switches.Table (New_Position) := S;
when Binder =>
Binder_Switches_Pos (New_Position);
Binder_Switches.Table (New_Position) := S;
when Linker =>
Linker_Switches_Pos (New_Position);
Linker_Switches.Table (New_Position) := S;
when None =>
raise Program_Error;
end case;
end if;
end Add_Switch;
procedure Add_Switch
(S : String;
Program : Make_Program_Type;
Append_Switch : Boolean := True;
And_Save : Boolean := True)
is
begin
Add_Switch (S => new String'(S),
Program => Program,
Append_Switch => Append_Switch,
And_Save => And_Save);
end Add_Switch;
------------------
-- Add_Switches --
------------------
procedure Add_Switches
(The_Package : Package_Id;
File_Name : String;
Program : Make_Program_Type)
is
Switches : Variable_Value;
Switch_List : String_List_Id;
Element : String_Element;
begin
if File_Name'Length > 0 then
Name_Len := File_Name'Length;
Name_Buffer (1 .. Name_Len) := File_Name;
Switches :=
Switches_Of
(Source_File => Name_Find,
Source_File_Name => File_Name,
Naming => Projects.Table (Main_Project).Naming,
In_Package => The_Package,
Allow_ALI =>
Program = Binder or else Program = Linker);
case Switches.Kind is
when Undefined =>
null;
when List =>
Program_Args := Program;
Switch_List := Switches.Values;
while Switch_List /= Nil_String loop
Element := String_Elements.Table (Switch_List);
String_To_Name_Buffer (Element.Value);
if Name_Len > 0 then
if Opt.Verbose_Mode then
Write_Str (" Adding ");
Write_Line (Name_Buffer (1 .. Name_Len));
end if;
Scan_Make_Arg
(Name_Buffer (1 .. Name_Len),
And_Save => False);
end if;
Switch_List := Element.Next;
end loop;
when Single =>
Program_Args := Program;
String_To_Name_Buffer (Switches.Value);
if Name_Len > 0 then
if Opt.Verbose_Mode then
Write_Str (" Adding ");
Write_Line (Name_Buffer (1 .. Name_Len));
end if;
Scan_Make_Arg
(Name_Buffer (1 .. Name_Len), And_Save => False);
end if;
end case;
end if;
end Add_Switches;
----------
-- Bind --
----------
procedure Bind (ALI_File : File_Name_Type; Args : Argument_List) is
Bind_Args : Argument_List (1 .. Args'Last + 2);
Bind_Last : Integer;
Success : Boolean;
begin
pragma Assert (Args'First = 1);
-- Optimize the simple case where the gnatbind command line looks like
-- gnatbind -aO. -I- file.ali --into-> gnatbind file.adb
if Args'Length = 2
and then Args (Args'First).all = "-aO" & Normalized_CWD
and then Args (Args'Last).all = "-I-"
and then ALI_File = Strip_Directory (ALI_File)
then
Bind_Last := Args'First - 1;
else
Bind_Last := Args'Last;
Bind_Args (Args'Range) := Args;
end if;
-- It is completely pointless to re-check source file time stamps.
-- This has been done already by gnatmake
Bind_Last := Bind_Last + 1;
Bind_Args (Bind_Last) := Do_Not_Check_Flag;
Get_Name_String (ALI_File);
Bind_Last := Bind_Last + 1;
Bind_Args (Bind_Last) := new String'(Name_Buffer (1 .. Name_Len));
Display (Gnatbind.all, Bind_Args (Args'First .. Bind_Last));
if Gnatbind_Path = null then
Osint.Fail ("error, unable to locate " & Gnatbind.all);
end if;
GNAT.OS_Lib.Spawn
(Gnatbind_Path.all, Bind_Args (Args'First .. Bind_Last), Success);
if not Success then
raise Bind_Failed;
end if;
end Bind;
-----------
-- Check --
-----------
procedure Check
(Lib_File : File_Name_Type;
ALI : out ALI_Id;
O_File : out File_Name_Type;
O_Stamp : out Time_Stamp_Type)
is
function First_New_Spec (A : ALI_Id) return File_Name_Type;
-- Looks in the with table entries of A and returns the spec file name
-- of the first withed unit (subprogram) for which no spec existed when
-- A was generated but for which there exists one now, implying that A
-- is now obsolete. If no such unit is found No_File is returned.
-- Otherwise the spec file name of the unit is returned.
--
-- **WARNING** in the event of Uname format modifications, one *MUST*
-- make sure this function is also updated.
--
-- Note: This function should really be in ali.adb and use Uname
-- services, but this causes the whole compiler to be dragged along
-- for gnatbind and gnatmake.
--------------------
-- First_New_Spec --
--------------------
function First_New_Spec (A : ALI_Id) return File_Name_Type is
Spec_File_Name : File_Name_Type := No_File;
function New_Spec (Uname : Unit_Name_Type) return Boolean;
-- Uname is the name of the spec or body of some ada unit.
-- This function returns True if the Uname is the name of a body
-- which has a spec not mentioned inali file A. If True is returned
-- Spec_File_Name above is set to the name of this spec file.
--------------
-- New_Spec --
--------------
function New_Spec (Uname : Unit_Name_Type) return Boolean is
Spec_Name : Unit_Name_Type;
File_Name : File_Name_Type;
begin
-- Test whether Uname is the name of a body unit (ie ends with %b)
Get_Name_String (Uname);
pragma
Assert (Name_Len > 2 and then Name_Buffer (Name_Len - 1) = '%');
if Name_Buffer (Name_Len) /= 'b' then
return False;
end if;
-- Convert unit name into spec name
-- ??? this code seems dubious in presence of pragma
-- Source_File_Name since there is no more direct relationship
-- between unit name and file name.
-- ??? Further, what about alternative subunit naming
Name_Buffer (Name_Len) := 's';
Spec_Name := Name_Find;
File_Name := Get_File_Name (Spec_Name, Subunit => False);
-- Look if File_Name is mentioned in A's sdep list.
-- If not look if the file exists. If it does return True.
for D in
ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
loop
if Sdep.Table (D).Sfile = File_Name then
return False;
end if;
end loop;
if Full_Source_Name (File_Name) /= No_File then
Spec_File_Name := File_Name;
return True;
end if;
return False;
end New_Spec;
-- Start of processing for First_New_Spec
begin
U_Chk : for U in
ALIs.Table (A).First_Unit .. ALIs.Table (A).Last_Unit
loop
exit U_Chk when Units.Table (U).Utype = Is_Body_Only
and then New_Spec (Units.Table (U).Uname);
for W in Units.Table (U).First_With
..
Units.Table (U).Last_With
loop
exit U_Chk when
Withs.Table (W).Afile /= No_File
and then New_Spec (Withs.Table (W).Uname);
end loop;
end loop U_Chk;
return Spec_File_Name;
end First_New_Spec;
---------------------------------
-- Data declarations for Check --
---------------------------------
Full_Lib_File : File_Name_Type;
-- Full name of current library file
Full_Obj_File : File_Name_Type;
-- Full name of the object file corresponding to Lib_File.
Lib_Stamp : Time_Stamp_Type;
-- Time stamp of the current ada library file.
Obj_Stamp : Time_Stamp_Type;
-- Time stamp of the current object file.
Modified_Source : File_Name_Type;
-- The first source in Lib_File whose current time stamp differs
-- from that stored in Lib_File.
New_Spec : File_Name_Type;
-- If Lib_File contains in its W (with) section a body (for a
-- subprogram) for which there exists a spec and the spec did not
-- appear in the Sdep section of Lib_File, New_Spec contains the file
-- name of this new spec.
Source_Name : Name_Id;
Text : Text_Buffer_Ptr;
Prev_Switch : Character;
-- First character of previous switch processed
Arg : Arg_Id := Arg_Id'First;
-- Current index in Args.Table for a given unit (init to stop warning)
Switch_Found : Boolean;
-- True if a given switch has been found
Num_Args : Integer;
-- Number of compiler arguments processed
Special_Arg : Argument_List_Access;
-- Special arguments if any of a given compilation file
-- Start of processing for Check
begin
pragma Assert (Lib_File /= No_File);
Text := Read_Library_Info (Lib_File);
Full_Lib_File := Full_Library_Info_Name;
Full_Obj_File := Full_Object_File_Name;
Lib_Stamp := Current_Library_File_Stamp;
Obj_Stamp := Current_Object_File_Stamp;
if Full_Lib_File = No_File then
Verbose_Msg (Lib_File, "being checked ...", Prefix => " ");
else
Verbose_Msg (Full_Lib_File, "being checked ...", Prefix => " ");
end if;
ALI := No_ALI_Id;
O_File := Full_Obj_File;
O_Stamp := Obj_Stamp;
if Text = null then
if Full_Lib_File = No_File then
Verbose_Msg (Lib_File, "missing.");
elsif Obj_Stamp (Obj_Stamp'First) = ' ' then
Verbose_Msg (Full_Obj_File, "missing.");
else
Verbose_Msg
(Full_Lib_File, "(" & String (Lib_Stamp) & ") newer than",
Full_Obj_File, "(" & String (Obj_Stamp) & ")");
end if;
else
ALI := Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True);
Free (Text);
if ALI = No_ALI_Id then
Verbose_Msg (Full_Lib_File, "incorrectly formatted ALI file");
return;
elsif ALIs.Table (ALI).Ver (1 .. ALIs.Table (ALI).Ver_Len) /=
Library_Version
then
Verbose_Msg (Full_Lib_File, "compiled with old GNAT version");
ALI := No_ALI_Id;
return;
end if;
-- Don't take Ali file into account if it was generated without
-- object.
if Opt.Operating_Mode /= Opt.Check_Semantics
and then ALIs.Table (ALI).No_Object
then
Verbose_Msg (Full_Lib_File, "has no corresponding object");
ALI := No_ALI_Id;
return;
end if;
-- Check for matching compiler switches if needed
if Opt.Check_Switches then
Prev_Switch := ASCII.Nul;
Num_Args := 0;
Get_Name_String (ALIs.Table (ALI).Sfile);
for J in 1 .. Special_Args.Last loop
if Special_Args.Table (J).File.all =
Name_Buffer (1 .. Name_Len)
then
Special_Arg := Special_Args.Table (J).Args;
exit;
end if;
end loop;
if Main_Project /= No_Project then
null;
end if;
if Special_Arg = null then
for J in Gcc_Switches.First .. Gcc_Switches.Last loop
-- Skip non switches, -I and -o switches
if (Gcc_Switches.Table (J) (1) = '-'
or else
Gcc_Switches.Table (J) (1) = Switch_Character)
and then Gcc_Switches.Table (J) (2) /= 'o'
and then Gcc_Switches.Table (J) (2) /= 'I'
then
Num_Args := Num_Args + 1;
-- Comparing switches is delicate because gcc reorders
-- a number of switches, according to lang-specs.h, but
-- gnatmake doesn't have the sufficient knowledge to
-- perform the same reordering. Instead, we ignore orders
-- between different "first letter" switches, but keep
-- orders between same switches, e.g -O -O2 is different
-- than -O2 -O, but -g -O is equivalent to -O -g.
if Gcc_Switches.Table (J) (2) /= Prev_Switch then
Prev_Switch := Gcc_Switches.Table (J) (2);
Arg :=
Units.Table (ALIs.Table (ALI).First_Unit).First_Arg;
end if;
Switch_Found := False;
for K in Arg ..
Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg
loop
if Gcc_Switches.Table (J).all = Args.Table (K).all then
Arg := K + 1;
Switch_Found := True;
exit;
end if;
end loop;
if not Switch_Found then
if Opt.Verbose_Mode then
Verbose_Msg (ALIs.Table (ALI).Sfile,
"switch mismatch");
end if;
ALI := No_ALI_Id;
return;
end if;
end if;
end loop;
-- Special_Arg is non-null
else
for J in Special_Arg'Range loop
-- Skip non switches, -I and -o switches
if (Special_Arg (J) (1) = '-'
or else Special_Arg (J) (1) = Switch_Character)
and then Special_Arg (J) (2) /= 'o'
and then Special_Arg (J) (2) /= 'I'
then
Num_Args := Num_Args + 1;
if Special_Arg (J) (2) /= Prev_Switch then
Prev_Switch := Special_Arg (J) (2);
Arg :=
Units.Table (ALIs.Table (ALI).First_Unit).First_Arg;
end if;
Switch_Found := False;
for K in Arg ..
Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg
loop
if Special_Arg (J).all = Args.Table (K).all then
Arg := K + 1;
Switch_Found := True;
exit;
end if;
end loop;
if not Switch_Found then
if Opt.Verbose_Mode then
Verbose_Msg (ALIs.Table (ALI).Sfile,
"switch mismatch");
end if;
ALI := No_ALI_Id;
return;
end if;
end if;
end loop;
end if;
if Num_Args /=
Integer (Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg -
Units.Table (ALIs.Table (ALI).First_Unit).First_Arg + 1)
then
if Opt.Verbose_Mode then
Verbose_Msg (ALIs.Table (ALI).Sfile,
"different number of switches");
end if;
ALI := No_ALI_Id;
return;
end if;
end if;
-- Get the source files and their time stamps. Note that some
-- sources may be missing if ALI is out-of-date.
Set_Source_Table (ALI);
Modified_Source := Time_Stamp_Mismatch (ALI);
if Modified_Source /= No_File then
ALI := No_ALI_Id;
if Opt.Verbose_Mode then
Source_Name := Full_Source_Name (Modified_Source);
if Source_Name /= No_File then
Verbose_Msg (Source_Name, "time stamp mismatch");
else
Verbose_Msg (Modified_Source, "missing");
end if;
end if;
else
New_Spec := First_New_Spec (ALI);
if New_Spec /= No_File then
ALI := No_ALI_Id;
if Opt.Verbose_Mode then
Source_Name := Full_Source_Name (New_Spec);
if Source_Name /= No_File then
Verbose_Msg (Source_Name, "new spec");
else
Verbose_Msg (New_Spec, "old spec missing");
end if;
end if;
end if;
end if;
end if;
end Check;
--------------------------
-- Check_Linker_Options --
--------------------------
procedure Check_Linker_Options
(E_Stamp : Time_Stamp_Type;
O_File : out File_Name_Type;
O_Stamp : out Time_Stamp_Type)
is
procedure Check_File (File : File_Name_Type);
-- Update O_File and O_Stamp if the given file is younger than E_Stamp
-- and O_Stamp, or if O_File is No_File and File does not exist.
function Get_Library_File (Name : String) return File_Name_Type;
-- Return the full file name including path of a library based
-- on the name specified with the -l linker option, using the
-- Ada object path. Return No_File if no such file can be found.
type Char_Array is array (Natural) of Character;
type Char_Array_Access is access constant Char_Array;
Template : Char_Array_Access;
pragma Import (C, Template, "__gnat_library_template");
----------------
-- Check_File --
----------------
procedure Check_File (File : File_Name_Type) is
Stamp : Time_Stamp_Type;
Name : File_Name_Type := File;
begin
Get_Name_String (Name);
-- Remove any trailing NUL characters
while Name_Len >= Name_Buffer'First
and then Name_Buffer (Name_Len) = NUL
loop
Name_Len := Name_Len - 1;
end loop;
if Name_Len <= 0 then
return;
elsif Name_Buffer (1) = Get_Switch_Character
or else Name_Buffer (1) = '-'
then
-- Do not check if File is a switch other than "-l"
if Name_Buffer (2) /= 'l' then
return;
end if;
-- The argument is a library switch, get actual name. It
-- is necessary to make a copy of the relevant part of
-- Name_Buffer as Get_Library_Name uses Name_Buffer as well.
declare
Base_Name : constant String := Name_Buffer (3 .. Name_Len);
begin
Name := Get_Library_File (Base_Name);
end;
if Name = No_File then
return;
end if;
end if;
Stamp := File_Stamp (Name);
-- Find the youngest object file that is younger than the
-- executable. If no such file exist, record the first object
-- file that is not found.
if (O_Stamp < Stamp and then E_Stamp < Stamp)
or else (O_File = No_File and then Stamp (Stamp'First) = ' ')
then
O_Stamp := Stamp;
O_File := Name;
-- Strip the trailing NUL if present
Get_Name_String (O_File);
if Name_Buffer (Name_Len) = NUL then
Name_Len := Name_Len - 1;
O_File := Name_Find;
end if;
end if;
end Check_File;
----------------------
-- Get_Library_Name --
----------------------
-- See comments in a-adaint.c about template syntax
function Get_Library_File (Name : String) return File_Name_Type is
File : File_Name_Type := No_File;
begin
Name_Len := 0;
for Ptr in Template'Range loop
case Template (Ptr) is
when '*' =>
Add_Str_To_Name_Buffer (Name);
when ';' =>
File := Full_Lib_File_Name (Name_Find);
exit when File /= No_File;
Name_Len := 0;
when NUL =>
exit;
when others =>
Add_Char_To_Name_Buffer (Template (Ptr));
end case;
end loop;
-- The for loop exited because the end of the template
-- was reached. File contains the last possible file name
-- for the library.
if File = No_File and then Name_Len > 0 then
File := Full_Lib_File_Name (Name_Find);
end if;
return File;
end Get_Library_File;
-- Start of processing for Check_Linker_Options
begin
O_File := No_File;
O_Stamp := (others => ' ');
-- Process linker options from the ALI files.
for Opt in 1 .. Linker_Options.Last loop
Check_File (Linker_Options.Table (Opt).Name);
end loop;
-- Process options given on the command line.
for Opt in Linker_Switches.First .. Linker_Switches.Last loop
-- Check if the previous Opt has one of the two switches
-- that take an extra parameter. (See GCC manual.)
if Opt = Linker_Switches.First
or else (Linker_Switches.Table (Opt - 1).all /= "-u"
and then
Linker_Switches.Table (Opt - 1).all /= "-Xlinker")
then
Name_Len := 0;
Add_Str_To_Name_Buffer (Linker_Switches.Table (Opt).all);
Check_File (Name_Find);
end if;
end loop;
end Check_Linker_Options;
---------------------
-- Compile_Sources --
---------------------
procedure Compile_Sources
(Main_Source : File_Name_Type;
Args : Argument_List;
First_Compiled_File : out Name_Id;
Most_Recent_Obj_File : out Name_Id;
Most_Recent_Obj_Stamp : out Time_Stamp_Type;
Main_Unit : out Boolean;
Compilation_Failures : out Natural;
Check_Readonly_Files : Boolean := False;
Do_Not_Execute : Boolean := False;
Force_Compilations : Boolean := False;
Keep_Going : Boolean := False;
In_Place_Mode : Boolean := False;
Initialize_ALI_Data : Boolean := True;
Max_Process : Positive := 1)
is
function Compile
(S : Name_Id;
L : Name_Id;
Args : Argument_List)
return Process_Id;
-- Compiles S using Args. If S is a GNAT predefined source
-- "-gnatpg" is added to Args. Non blocking call. L corresponds to the
-- expected library file name. Process_Id of the process spawned to
-- execute the compile.
type Compilation_Data is record
Pid : Process_Id;
Full_Source_File : File_Name_Type;
Lib_File : File_Name_Type;
Source_Unit : Unit_Name_Type;
end record;
Running_Compile : array (1 .. Max_Process) of Compilation_Data;
-- Used to save information about outstanding compilations.
Outstanding_Compiles : Natural := 0;
-- Current number of outstanding compiles
Source_Unit : Unit_Name_Type;
-- Current source unit
Source_File : File_Name_Type;
-- Current source file
Full_Source_File : File_Name_Type;
-- Full name of the current source file
Lib_File : File_Name_Type;
-- Current library file
Full_Lib_File : File_Name_Type;
-- Full name of the current library file
Obj_File : File_Name_Type;
-- Full name of the object file corresponding to Lib_File.
Obj_Stamp : Time_Stamp_Type;
-- Time stamp of the current object file.
Sfile : File_Name_Type;
-- Contains the source file of the units withed by Source_File
ALI : ALI_Id;
-- ALI Id of the current ALI file
Compilation_OK : Boolean;
Need_To_Compile : Boolean;
Pid : Process_Id;
Text : Text_Buffer_Ptr;
Data : Prj.Project_Data;
Arg_Index : Natural;
-- Index in Special_Args.Table of a given compilation file
Need_To_Check_Standard_Library : Boolean := Check_Readonly_Files;
procedure Add_Process
(Pid : Process_Id;
Sfile : File_Name_Type;
Afile : File_Name_Type;
Uname : Unit_Name_Type);
-- Adds process Pid to the current list of outstanding compilation
-- processes and record the full name of the source file Sfile that
-- we are compiling, the name of its library file Afile and the
-- name of its unit Uname.
procedure Await_Compile
(Sfile : out File_Name_Type;
Afile : out File_Name_Type;
Uname : out Unit_Name_Type;
OK : out Boolean);
-- Awaits that an outstanding compilation process terminates. When
-- it does set Sfile to the name of the source file that was compiled
-- Afile to the name of its library file and Uname to the name of its
-- unit. Note that this time stamp can be used to check whether the
-- compilation did generate an object file. OK is set to True if the
-- compilation succeeded. Note that Sfile, Afile and Uname could be
-- resp. No_File, No_File and No_Name if there were no compilations
-- to wait for.
procedure Collect_Arguments_And_Compile;
-- Collect arguments from project file (if any) and compile
package Good_ALI is new Table.Table (
Table_Component_Type => ALI_Id,
Table_Index_Type => Natural,
Table_Low_Bound => 1,
Table_Initial => 50,
Table_Increment => 100,
Table_Name => "Make.Good_ALI");
-- Contains the set of valid ALI files that have not yet been scanned.
procedure Record_Good_ALI (A : ALI_Id);
-- Records in the previous set the Id of an ALI file.
function Good_ALI_Present return Boolean;
-- Returns True if any ALI file was recorded in the previous set.
function Get_Next_Good_ALI return ALI_Id;
-- Returns the next good ALI_Id record;
procedure Record_Failure
(File : File_Name_Type;
Unit : Unit_Name_Type;
Found : Boolean := True);
-- Records in the previous table that the compilation for File failed.
-- If Found is False then the compilation of File failed because we
-- could not find it. Records also Unit when possible.
function Bad_Compilation_Count return Natural;
-- Returns the number of compilation failures.
procedure Debug_Msg (S : String; N : Name_Id);
-- If Debug.Debug_Flag_W is set outputs string S followed by name N.
function Configuration_Pragmas_Switch
(For_Project : Project_Id)
return Argument_List;
-- Return an argument list of one element, if there is a configuration
-- pragmas file to be specified for For_Project,
-- otherwise return an empty argument list.
-----------------
-- Add_Process --
-----------------
procedure Add_Process
(Pid : Process_Id;
Sfile : File_Name_Type;
Afile : File_Name_Type;
Uname : Unit_Name_Type)
is
OC1 : constant Positive := Outstanding_Compiles + 1;
begin
pragma Assert (OC1 <= Max_Process);
pragma Assert (Pid /= Invalid_Pid);
Running_Compile (OC1).Pid := Pid;
Running_Compile (OC1).Full_Source_File := Sfile;
Running_Compile (OC1).Lib_File := Afile;
Running_Compile (OC1).Source_Unit := Uname;
Outstanding_Compiles := OC1;
end Add_Process;
--------------------
-- Await_Compile --
-------------------
procedure Await_Compile
(Sfile : out File_Name_Type;
Afile : out File_Name_Type;
Uname : out File_Name_Type;
OK : out Boolean)
is
Pid : Process_Id;
begin
pragma Assert (Outstanding_Compiles > 0);
Sfile := No_File;
Afile := No_File;
Uname := No_Name;
OK := False;
Wait_Process (Pid, OK);
if Pid = Invalid_Pid then
return;
end if;
for J in Running_Compile'First .. Outstanding_Compiles loop
if Pid = Running_Compile (J).Pid then
Sfile := Running_Compile (J).Full_Source_File;
Afile := Running_Compile (J).Lib_File;
Uname := Running_Compile (J).Source_Unit;
-- To actually remove this Pid and related info from
-- Running_Compile replace its entry with the last valid
-- entry in Running_Compile.
if J = Outstanding_Compiles then
null;
else
Running_Compile (J) :=
Running_Compile (Outstanding_Compiles);
end if;
Outstanding_Compiles := Outstanding_Compiles - 1;
return;
end if;
end loop;
raise Program_Error;
end Await_Compile;
---------------------------
-- Bad_Compilation_Count --
---------------------------
function Bad_Compilation_Count return Natural is
begin
return Bad_Compilation.Last - Bad_Compilation.First + 1;
end Bad_Compilation_Count;
-----------------------------------
-- Collect_Arguments_And_Compile --
-----------------------------------
procedure Collect_Arguments_And_Compile is
begin
-- If no project file is used, then just call Compile with
-- the specified Args.
if Main_Project = No_Project then
Pid := Compile (Full_Source_File, Lib_File, Args);
-- A project file was used
else
-- First check if the current source is an immediate
-- source of a project file.
if Opt.Verbose_Mode then
Write_Eol;
Write_Line ("Establishing Project context.");
end if;
declare
Source_File_Name : constant String :=
Name_Buffer (1 .. Name_Len);
Current_Project : Prj.Project_Id;
Path_Name : File_Name_Type := Source_File;
Compiler_Package : Prj.Package_Id;
Switches : Prj.Variable_Value;
Object_File : String_Access;
begin
if Opt.Verbose_Mode then
Write_Str ("Checking if the Project File exists for """);
Write_Str (Source_File_Name);
Write_Line (""".");
end if;
Prj.Env.
Get_Reference
(Source_File_Name => Source_File_Name,
Project => Current_Project,
Path => Path_Name);
if Current_Project = No_Project then
-- The current source is not an immediate source of any
-- project file. Call Compile with the specified Args plus
-- the saved gcc switches.
if Opt.Verbose_Mode then
Write_Str ("No Project File.");
Write_Eol;
end if;
Pid := Compile
(Full_Source_File,
Lib_File,
Args & The_Saved_Gcc_Switches.all);
-- We now know the project of the current source
else
-- Set ADA_INCLUDE_PATH and ADA_OBJECTS_PATH if the project
-- has changed.
-- Note: this will modify these environment variables only
-- for the current gnatmake process and all of its children
-- (invocations of the compiler, the binder and the linker).
-- The caller's ADA_INCLUDE_PATH and ADA_OBJECTS_PATH are
-- not affected.
Set_Ada_Paths (Current_Project, True);
Data := Projects.Table (Current_Project);
-- Check if it is a library project that needs to be
-- processed, only if it is not the main project.
if MLib.Tgt.Libraries_Are_Supported
and then Current_Project /= Main_Project
and then Data.Library
and then not Data.Flag1
then
-- Add to the Q all sources of the project that have
-- not been marked
Insert_Project_Sources
(The_Project => Current_Project, Into_Q => True);
-- Now mark the project as processed
Data.Flag1 := True;
Projects.Table (Current_Project).Flag1 := True;
end if;
Get_Name_String (Data.Object_Directory);
if Name_Buffer (Name_Len) = '/'
or else Name_Buffer (Name_Len) = Directory_Separator
then
Object_File :=
new String'
(Name_Buffer (1 .. Name_Len) &
Object_File_Name (Source_File_Name));
else
Object_File :=
new String'
(Name_Buffer (1 .. Name_Len) &
Directory_Separator &
Object_File_Name (Source_File_Name));
end if;
if Opt.Verbose_Mode then
Write_Str ("Project file is """);
Write_Str (Get_Name_String (Data.Name));
Write_Str (""".");
Write_Eol;
end if;
-- We know look for package Compiler
-- and get the switches from this package.
if Opt.Verbose_Mode then
Write_Str ("Checking package Compiler.");
Write_Eol;
end if;
Compiler_Package :=
Prj.Util.Value_Of
(Name => Name_Compiler,
In_Packages => Data.Decl.Packages);
if Compiler_Package /= No_Package then
if Opt.Verbose_Mode then
Write_Str ("Getting the switches.");
Write_Eol;
end if;
-- If package Gnatmake.Compiler exists, we get
-- the specific switches for the current source,
-- or the global switches, if any.
Switches := Switches_Of
(Source_File => Source_File,
Source_File_Name => Source_File_Name,
Naming =>
Projects.Table (Current_Project).Naming,
In_Package => Compiler_Package,
Allow_ALI => False);
end if;
case Switches.Kind is
-- We have a list of switches. We add to Args
-- these switches, plus the saved gcc switches.
when List =>
declare
Current : String_List_Id := Switches.Values;
Element : String_Element;
Number : Natural := 0;
begin
while Current /= Nil_String loop
Element := String_Elements.Table (Current);
Number := Number + 1;
Current := Element.Next;
end loop;
declare
New_Args : Argument_List (1 .. Number);
begin
Current := Switches.Values;
for Index in New_Args'Range loop
Element := String_Elements.Table (Current);
String_To_Name_Buffer (Element.Value);
New_Args (Index) :=
new String' (Name_Buffer (1 .. Name_Len));
Test_If_Relative_Path (New_Args (Index));
Current := Element.Next;
end loop;
Pid := Compile
(Path_Name,
Lib_File,
Args & Output_Flag & Object_File &
Configuration_Pragmas_Switch
(Current_Project) &
New_Args & The_Saved_Gcc_Switches.all);
end;
end;
-- We have a single switch. We add to Args
-- this switch, plus the saved gcc switches.
when Single =>
String_To_Name_Buffer (Switches.Value);
declare
New_Args : constant Argument_List :=
(1 => new String'
(Name_Buffer (1 .. Name_Len)));
begin
Test_If_Relative_Path (New_Args (1));
Pid := Compile
(Path_Name,
Lib_File,
Args &
Output_Flag &
Object_File &
New_Args &
Configuration_Pragmas_Switch (Current_Project) &
The_Saved_Gcc_Switches.all);
end;
-- We have no switches from Gnatmake.Compiler.
-- We add to Args the saved gcc switches.
when Undefined =>
if Opt.Verbose_Mode then
Write_Str ("There are no switches.");
Write_Eol;
end if;
Pid := Compile
(Path_Name,
Lib_File,
Args & Output_Flag & Object_File &
Configuration_Pragmas_Switch (Current_Project) &
The_Saved_Gcc_Switches.all);
end case;
end if;
end;
end if;
end Collect_Arguments_And_Compile;
-------------
-- Compile --
-------------
function Compile (S : Name_Id; L : Name_Id; Args : Argument_List)
return Process_Id
is
Comp_Args : Argument_List (Args'First .. Args'Last + 7);
Comp_Next : Integer := Args'First;
Comp_Last : Integer;
function Ada_File_Name (Name : Name_Id) return Boolean;
-- Returns True if Name is the name of an ada source file
-- (i.e. suffix is .ads or .adb)
-------------------
-- Ada_File_Name --
-------------------
function Ada_File_Name (Name : Name_Id) return Boolean is
begin
Get_Name_String (Name);
return
Name_Len > 4
and then Name_Buffer (Name_Len - 3 .. Name_Len - 1) = ".ad"
and then (Name_Buffer (Name_Len) = 'b'
or else
Name_Buffer (Name_Len) = 's');
end Ada_File_Name;
-- Start of processing for Compile
begin
Comp_Args (Comp_Next) := Comp_Flag;
Comp_Next := Comp_Next + 1;
-- Optimize the simple case where the gcc command line looks like
-- gcc -c -I. ... -I- file.adb --into-> gcc -c ... file.adb
if Args (Args'First).all = "-I" & Normalized_CWD
and then Args (Args'Last).all = "-I-"
and then S = Strip_Directory (S)
then
Comp_Last := Comp_Next + Args'Length - 3;
Comp_Args (Comp_Next .. Comp_Last) :=
Args (Args'First + 1 .. Args'Last - 1);
else
Comp_Last := Comp_Next + Args'Length - 1;
Comp_Args (Comp_Next .. Comp_Last) := Args;
end if;
-- Set -gnatpg for predefined files (for this purpose the renamings
-- such as Text_IO do not count as predefined). Note that we strip
-- the directory name from the source file name becase the call to
-- Fname.Is_Predefined_File_Name cannot deal with directory prefixes.
declare
Fname : constant File_Name_Type := Strip_Directory (S);
begin
if Is_Predefined_File_Name (Fname, False) then
if Check_Readonly_Files then
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := GNAT_Flag;
else
Fail
("not allowed to compile """ &
Get_Name_String (Fname) &
"""; use -a switch.");
end if;
end if;
end;
-- Now check if the file name has one of the suffixes familiar to
-- the gcc driver. If this is not the case then add the ada flag
-- "-x ada".
if not Ada_File_Name (S) then
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := Ada_Flag_1;
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := Ada_Flag_2;
end if;
if L /= Strip_Directory (L) then
-- Build -o argument.
Get_Name_String (L);
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Name_Len := J + Object_Suffix'Length - 1;
Name_Buffer (J .. Name_Len) := Object_Suffix;
exit;
end if;
end loop;
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := Output_Flag;
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len));
end if;
Get_Name_String (S);
Comp_Last := Comp_Last + 1;
Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len));
Display (Gcc.all, Comp_Args (Args'First .. Comp_Last));
if Gcc_Path = null then
Osint.Fail ("error, unable to locate " & Gcc.all);
end if;
return
GNAT.OS_Lib.Non_Blocking_Spawn
(Gcc_Path.all, Comp_Args (Args'First .. Comp_Last));
end Compile;
----------------------------------
-- Configuration_Pragmas_Switch --
----------------------------------
function Configuration_Pragmas_Switch
(For_Project : Project_Id)
return Argument_List
is
begin
Prj.Env.Create_Config_Pragmas_File (For_Project, Main_Project);
if Projects.Table (For_Project).Config_File_Name /= No_Name then
return
(1 => new String'("-gnatec" &
Get_Name_String
(Projects.Table (For_Project).Config_File_Name)));
else
return (1 .. 0 => null);
end if;
end Configuration_Pragmas_Switch;
---------------
-- Debug_Msg --
---------------
procedure Debug_Msg (S : String; N : Name_Id) is
begin
if Debug.Debug_Flag_W then
Write_Str (" ... ");
Write_Str (S);
Write_Str (" ");
Write_Name (N);
Write_Eol;
end if;
end Debug_Msg;
-----------------------
-- Get_Next_Good_ALI --
-----------------------
function Get_Next_Good_ALI return ALI_Id is
ALI : ALI_Id;
begin
pragma Assert (Good_ALI_Present);
ALI := Good_ALI.Table (Good_ALI.Last);
Good_ALI.Decrement_Last;
return ALI;
end Get_Next_Good_ALI;
----------------------
-- Good_ALI_Present --
----------------------
function Good_ALI_Present return Boolean is
begin
return Good_ALI.First <= Good_ALI.Last;
end Good_ALI_Present;
--------------------
-- Record_Failure --
--------------------
procedure Record_Failure
(File : File_Name_Type;
Unit : Unit_Name_Type;
Found : Boolean := True)
is
begin
Bad_Compilation.Increment_Last;
Bad_Compilation.Table (Bad_Compilation.Last) := (File, Unit, Found);
end Record_Failure;
---------------------
-- Record_Good_ALI --
---------------------
procedure Record_Good_ALI (A : ALI_Id) is
begin
Good_ALI.Increment_Last;
Good_ALI.Table (Good_ALI.Last) := A;
end Record_Good_ALI;
-- Start of processing for Compile_Sources
begin
pragma Assert (Args'First = 1);
-- Package and Queue initializations.
Good_ALI.Init;
Bad_Compilation.Init;
Output.Set_Standard_Error;
Init_Q;
if Initialize_ALI_Data then
Initialize_ALI;
Initialize_ALI_Source;
end if;
-- The following two flags affect the behavior of ALI.Set_Source_Table.
-- We set Opt.Check_Source_Files to True to ensure that source file
-- time stamps are checked, and we set Opt.All_Sources to False to
-- avoid checking the presence of the source files listed in the
-- source dependency section of an ali file (which would be a mistake
-- since the ali file may be obsolete).
Opt.Check_Source_Files := True;
Opt.All_Sources := False;
-- If the main source is marked, there is nothing to compile.
-- This can happen when we have several main subprograms.
-- For the first main, we always insert in the Q.
if not Is_Marked (Main_Source) then
Insert_Q (Main_Source);
Mark (Main_Source);
end if;
First_Compiled_File := No_File;
Most_Recent_Obj_File := No_File;
Main_Unit := False;
-- Keep looping until there is no more work to do (the Q is empty)
-- and all the outstanding compilations have terminated
Make_Loop : while not Empty_Q or else Outstanding_Compiles > 0 loop
-- If the user does not want to keep going in case of errors then
-- wait for the remaining outstanding compiles and then exit.
if Bad_Compilation_Count > 0 and then not Keep_Going then
while Outstanding_Compiles > 0 loop
Await_Compile
(Full_Source_File, Lib_File, Source_Unit, Compilation_OK);
if not Compilation_OK then
Record_Failure (Full_Source_File, Source_Unit);
end if;
end loop;
exit Make_Loop;
end if;
-- PHASE 1: Check if there is more work that we can do (ie the Q
-- is non empty). If there is, do it only if we have not yet used
-- up all the available processes.
if not Empty_Q and then Outstanding_Compiles < Max_Process then
Extract_From_Q (Source_File, Source_Unit);
Full_Source_File := Osint.Full_Source_Name (Source_File);
Lib_File := Osint.Lib_File_Name (Source_File);
Full_Lib_File := Osint.Full_Lib_File_Name (Lib_File);
-- If the library file is an Ada library skip it
if Full_Lib_File /= No_File
and then In_Ada_Lib_Dir (Full_Lib_File)
then
Verbose_Msg (Lib_File, "is in an Ada library", Prefix => " ");
-- If the library file is a read-only library skip it
elsif Full_Lib_File /= No_File
and then not Check_Readonly_Files
and then Is_Readonly_Library (Full_Lib_File)
then
Verbose_Msg
(Lib_File, "is a read-only library", Prefix => " ");
-- The source file that we are checking cannot be located
elsif Full_Source_File = No_File then
Record_Failure (Source_File, Source_Unit, False);
-- Source and library files can be located but are internal
-- files
elsif not Check_Readonly_Files
and then Full_Lib_File /= No_File
and then Is_Internal_File_Name (Source_File)
then
if Force_Compilations then
Fail
("not allowed to compile """ &
Get_Name_String (Source_File) &
"""; use -a switch.");
end if;
Verbose_Msg
(Lib_File, "is an internal library", Prefix => " ");
-- The source file that we are checking can be located
else
-- Don't waste any time if we have to recompile anyway
Obj_Stamp := Empty_Time_Stamp;
Need_To_Compile := Force_Compilations;
if not Force_Compilations then
Check (Lib_File, ALI, Obj_File, Obj_Stamp);
Need_To_Compile := (ALI = No_ALI_Id);
end if;
if not Need_To_Compile then
-- The ALI file is up-to-date. Record its Id.
Record_Good_ALI (ALI);
-- Record the time stamp of the most recent object file
-- as long as no (re)compilations are needed.
if First_Compiled_File = No_File
and then (Most_Recent_Obj_File = No_File
or else Obj_Stamp > Most_Recent_Obj_Stamp)
then
Most_Recent_Obj_File := Obj_File;
Most_Recent_Obj_Stamp := Obj_Stamp;
end if;
else
-- Is this the first file we have to compile?
if First_Compiled_File = No_File then
First_Compiled_File := Full_Source_File;
Most_Recent_Obj_File := No_File;
if Do_Not_Execute then
exit Make_Loop;
end if;
end if;
if In_Place_Mode then
-- If the library file was not found, then save the
-- library file near the source file.
if Full_Lib_File = No_File then
Get_Name_String (Full_Source_File);
for J in reverse 1 .. Name_Len loop
if Name_Buffer (J) = '.' then
Name_Buffer (J + 1 .. J + 3) := "ali";
Name_Len := J + 3;
exit;
end if;
end loop;
Lib_File := Name_Find;
-- If the library file was found, then save the
-- library file in the same place.
else
Lib_File := Full_Lib_File;
end if;
end if;
-- Check for special compilation flags
Arg_Index := 0;
Get_Name_String (Source_File);
-- Start the compilation and record it. We can do this
-- because there is at least one free process.
Collect_Arguments_And_Compile;
-- Make sure we could successfully start the compilation
if Pid = Invalid_Pid then
Record_Failure (Full_Source_File, Source_Unit);
else
Add_Process
(Pid, Full_Source_File, Lib_File, Source_Unit);
end if;
end if;
end if;
end if;
-- PHASE 2: Now check if we should wait for a compilation to
-- finish. This is the case if all the available processes are
-- busy compiling sources or there is nothing else to do
-- (that is the Q is empty and there are no good ALIs to process).
if Outstanding_Compiles = Max_Process
or else (Empty_Q
and then not Good_ALI_Present
and then Outstanding_Compiles > 0)
then
Await_Compile
(Full_Source_File, Lib_File, Source_Unit, Compilation_OK);
if not Compilation_OK then
Record_Failure (Full_Source_File, Source_Unit);
else
-- Re-read the updated library file
Text := Read_Library_Info (Lib_File);
-- If no ALI file was generated by this compilation nothing
-- more to do, otherwise scan the ali file and record it.
-- If the scan fails, a previous ali file is inconsistent with
-- the unit just compiled.
if Text /= null then
ALI :=
Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True);
if ALI = No_ALI_Id then
Inform
(Lib_File, "incompatible ALI file, please recompile");
Record_Failure (Full_Source_File, Source_Unit);
else
Free (Text);
Record_Good_ALI (ALI);
end if;
-- If we could not read the ALI file that was just generated
-- then there could be a problem reading either the ALI or the
-- corresponding object file (if Opt.Check_Object_Consistency
-- is set Read_Library_Info checks that the time stamp of the
-- object file is more recent than that of the ALI). For an
-- example of problems caught by this test see [6625-009].
else
Inform
(Lib_File,
"WARNING: ALI or object file not found after compile");
Record_Failure (Full_Source_File, Source_Unit);
end if;
end if;
end if;
exit Make_Loop when Unique_Compile;
-- PHASE 3: Check if we recorded good ALI files. If yes process
-- them now in the order in which they have been recorded. There
-- are two occasions in which we record good ali files. The first is
-- in phase 1 when, after scanning an existing ALI file we realise
-- it is up-to-date, the second instance is after a successful
-- compilation.
while Good_ALI_Present loop
ALI := Get_Next_Good_ALI;
-- If we are processing the library file corresponding to the
-- main source file check if this source can be a main unit.
if ALIs.Table (ALI).Sfile = Main_Source then
Main_Unit := ALIs.Table (ALI).Main_Program /= None;
end if;
-- The following adds the standard library (s-stalib) to the
-- list of files to be handled by gnatmake: this file and any
-- files it depends on are always included in every bind,
-- except in No_Run_Time mode, even if they are not
-- in the explicit dependency list.
-- However, to avoid annoying output about s-stalib.ali being
-- read only, when "-v" is used, we add the standard library
-- only when "-a" is used.
if Need_To_Check_Standard_Library then
Need_To_Check_Standard_Library := False;
if not ALIs.Table (ALI).No_Run_Time then
declare
Sfile : Name_Id;
begin
Name_Len := Standard_Library_Package_Body_Name'Length;
Name_Buffer (1 .. Name_Len) :=
Standard_Library_Package_Body_Name;
Sfile := Name_Enter;
if not Is_Marked (Sfile) then
Insert_Q (Sfile);
Mark (Sfile);
end if;
end;
end if;
end if;
-- Now insert in the Q the unmarked source files (i.e. those
-- which have neever been inserted in the Q and hence never
-- considered).
for J in
ALIs.Table (ALI).First_Unit .. ALIs.Table (ALI).Last_Unit
loop
for K in
Units.Table (J).First_With .. Units.Table (J).Last_With
loop
Sfile := Withs.Table (K).Sfile;
if Sfile = No_File then
Debug_Msg ("Skipping generic:", Withs.Table (K).Uname);
elsif Is_Marked (Sfile) then
Debug_Msg ("Skipping marked file:", Sfile);
elsif not Check_Readonly_Files
and then Is_Internal_File_Name (Sfile)
then
Debug_Msg ("Skipping internal file:", Sfile);
else
Insert_Q (Sfile, Withs.Table (K).Uname);
Mark (Sfile);
end if;
end loop;
end loop;
end loop;
if Opt.Display_Compilation_Progress then
Write_Str ("completed ");
Write_Int (Int (Q_Front));
Write_Str (" out of ");
Write_Int (Int (Q.Last));
Write_Str (" (");
Write_Int (Int ((Q_Front * 100) / (Q.Last - Q.First)));
Write_Str ("%)...");
Write_Eol;
end if;
end loop Make_Loop;
Compilation_Failures := Bad_Compilation_Count;
-- Compilation is finished
-- Delete any temporary configuration pragma file
if Main_Project /= No_Project then
declare
Success : Boolean;
begin
for Project in 1 .. Projects.Last loop
if Projects.Table (Project).Config_File_Temp then
if Opt.Verbose_Mode then
Write_Str ("Deleting temp configuration file """);
Write_Str (Get_Name_String
(Projects.Table (Project).Config_File_Name));
Write_Line ("""");
end if;
Delete_File
(Name => Get_Name_String
(Projects.Table (Project).Config_File_Name),
Success => Success);
-- Make sure that we don't have a config file for this
-- project, in case when there are several mains.
-- In this case, we will recreate another config file:
-- we cannot reuse the one that we just deleted!
Projects.Table (Project).Config_Checked := False;
Projects.Table (Project).Config_File_Name := No_Name;
Projects.Table (Project).Config_File_Temp := False;
end if;
end loop;
end;
end if;
end Compile_Sources;
-------------
-- Display --
-------------
procedure Display (Program : String; Args : Argument_List) is
begin
pragma Assert (Args'First = 1);
if Display_Executed_Programs then
Write_Str (Program);
for J in Args'Range loop
Write_Str (" ");
Write_Str (Args (J).all);
end loop;
Write_Eol;
end if;
end Display;
----------------------
-- Display_Commands --
----------------------
procedure Display_Commands (Display : Boolean := True) is
begin
Display_Executed_Programs := Display;
end Display_Commands;
-------------
-- Empty_Q --
-------------
function Empty_Q return Boolean is
begin
if Debug.Debug_Flag_P then
Write_Str (" Q := [");
for J in Q_Front .. Q.Last - 1 loop
Write_Str (" ");
Write_Name (Q.Table (J).File);
Write_Eol;
Write_Str (" ");
end loop;
Write_Str ("]");
Write_Eol;
end if;
return Q_Front >= Q.Last;
end Empty_Q;
---------------------
-- Extract_Failure --
---------------------
procedure Extract_Failure
(File : out File_Name_Type;
Unit : out Unit_Name_Type;
Found : out Boolean)
is
begin
File := Bad_Compilation.Table (Bad_Compilation.Last).File;
Unit := Bad_Compilation.Table (Bad_Compilation.Last).Unit;
Found := Bad_Compilation.Table (Bad_Compilation.Last).Found;
Bad_Compilation.Decrement_Last;
end Extract_Failure;
--------------------
-- Extract_From_Q --
--------------------
procedure Extract_From_Q
(Source_File : out File_Name_Type;
Source_Unit : out Unit_Name_Type)
is
File : constant File_Name_Type := Q.Table (Q_Front).File;
Unit : constant Unit_Name_Type := Q.Table (Q_Front).Unit;
begin
if Debug.Debug_Flag_Q then
Write_Str (" Q := Q - [ ");
Write_Name (File);
Write_Str (" ]");
Write_Eol;
end if;
Q_Front := Q_Front + 1;
Source_File := File;
Source_Unit := Unit;
end Extract_From_Q;
--------------
-- Gnatmake --
--------------
procedure Gnatmake is
Main_Source_File : File_Name_Type;
-- The source file containing the main compilation unit
Compilation_Failures : Natural;
Is_Main_Unit : Boolean;
-- Set to True by Compile_Sources if the Main_Source_File can be a
-- main unit.
Main_ALI_File : File_Name_Type;
-- The ali file corresponding to Main_Source_File
Executable : File_Name_Type := No_File;
-- The file name of an executable
Non_Std_Executable : Boolean := False;
-- Non_Std_Executable is set to True when there is a possibility
-- that the linker will not choose the correct executable file name.
Executable_Obsolete : Boolean := False;
-- Executable_Obsolete is set to True for the first obsolete main
-- and is never reset to False. Any subsequent main will always
-- be rebuild (if we rebuild mains), even in the case when it is not
-- really necessary, because it is too hard to decide.
Mapping_File_Name : Temp_File_Name;
-- The name of the temporary mapping file that is copmmunicated
-- to the compiler through a -gnatem switch, when using project files.
begin
Do_Compile_Step := True;
Do_Bind_Step := True;
Do_Link_Step := True;
Make.Initialize;
if Hostparm.Java_VM then
Gcc := new String'("jgnat");
Gnatbind := new String'("jgnatbind");
Gnatlink := new String '("jgnatlink");
-- Do not check for an object file (".o") when compiling to
-- Java bytecode since ".class" files are generated instead.
Opt.Check_Object_Consistency := False;
end if;
if Opt.Verbose_Mode then
Write_Eol;
Write_Str ("GNATMAKE ");
Write_Str (Gnatvsn.Gnat_Version_String);
Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc.");
Write_Eol;
end if;
-- If no mains have been specified on the command line,
-- and we are using a project file, we either find the main(s)
-- in the attribute Main of the main project, or we put all
-- the sources of the project file as mains.
if Main_Project /= No_Project and then Osint.Number_Of_Files = 0 then
Name_Len := 4;
Name_Buffer (1 .. 4) := "main";
declare
Main_Id : constant Name_Id := Name_Find;
Mains : constant Prj.Variable_Value :=
Prj.Util.Value_Of
(Variable_Name => Main_Id,
In_Variables =>
Projects.Table (Main_Project).Decl.Attributes);
Value : String_List_Id := Mains.Values;
begin
-- The attribute Main is an empty list or not specified,
-- or else gnatmake was invoked with the switch "-u".
if Value = Prj.Nil_String or else Unique_Compile then
-- First make sure that the binder and the linker
-- will not be invoked.
Do_Bind_Step := False;
Do_Link_Step := False;
-- Put all the sources in the queue
Insert_Project_Sources
(The_Project => Main_Project, Into_Q => False);
else
-- The attribute Main is not an empty list.
-- Put all the main subprograms in the list as if there were
-- specified on the command line.
while Value /= Prj.Nil_String loop
String_To_Name_Buffer (String_Elements.Table (Value).Value);
Osint.Add_File (Name_Buffer (1 .. Name_Len));
Value := String_Elements.Table (Value).Next;
end loop;
end if;
end;
end if;
-- Output usage information if no files. Note that this can happen
-- in the case of a project file that contains only subunits.
if Osint.Number_Of_Files = 0 then
Makeusg;
Exit_Program (E_Fatal);
end if;
-- If -l was specified behave as if -n was specified
if Opt.List_Dependencies then
Opt.Do_Not_Execute := True;
end if;
-- Note that Osint.Next_Main_Source will always return the (possibly
-- abbreviated file) without any directory information.
Main_Source_File := Next_Main_Source;
if Project_File_Name = null then
Add_Switch ("-I-", Compiler, And_Save => True);
Add_Switch ("-I-", Binder, And_Save => True);
if Opt.Look_In_Primary_Dir then
Add_Switch
("-I" &
Normalize_Directory_Name
(Get_Primary_Src_Search_Directory.all).all,
Compiler, Append_Switch => False,
And_Save => False);
Add_Switch ("-aO" & Normalized_CWD,
Binder,
Append_Switch => False,
And_Save => False);
end if;
end if;
-- If the user wants a program without a main subprogram, add the
-- appropriate switch to the binder.
if Opt.No_Main_Subprogram then
Add_Switch ("-z", Binder, And_Save => True);
end if;
if Main_Project /= No_Project then
Change_Dir
(Get_Name_String (Projects.Table (Main_Project).Object_Directory));
-- Find the file name of the main unit
declare
Main_Source_File_Name : constant String :=
Get_Name_String (Main_Source_File);
Main_Unit_File_Name : constant String :=
Prj.Env.File_Name_Of_Library_Unit_Body
(Name => Main_Source_File_Name,
Project => Main_Project);
The_Packages : constant Package_Id :=
Projects.Table (Main_Project).Decl.Packages;
Gnatmake : constant Prj.Package_Id :=
Prj.Util.Value_Of
(Name => Name_Builder,
In_Packages => The_Packages);
Binder_Package : constant Prj.Package_Id :=
Prj.Util.Value_Of
(Name => Name_Binder,
In_Packages => The_Packages);
Linker_Package : constant Prj.Package_Id :=
Prj.Util.Value_Of
(Name => Name_Linker,
In_Packages => The_Packages);
begin
-- We fail if we cannot find the main source file
-- as an immediate source of the main project file.
if Main_Unit_File_Name = "" then
Fail ('"' & Main_Source_File_Name &
""" is not a unit of project " &
Project_File_Name.all & ".");
else
-- Remove any directory information from the main
-- source file name.
declare
Pos : Natural := Main_Unit_File_Name'Last;
begin
loop
exit when Pos < Main_Unit_File_Name'First or else
Main_Unit_File_Name (Pos) = Directory_Separator;
Pos := Pos - 1;
end loop;
Name_Len := Main_Unit_File_Name'Last - Pos;
Name_Buffer (1 .. Name_Len) :=
Main_Unit_File_Name
(Pos + 1 .. Main_Unit_File_Name'Last);
Main_Source_File := Name_Find;
-- We only output the main source file if there is only one
if Opt.Verbose_Mode and then Osint.Number_Of_Files = 1 then
Write_Str ("Main source file: """);
Write_Str (Main_Unit_File_Name
(Pos + 1 .. Main_Unit_File_Name'Last));
Write_Line (""".");
end if;
end;
end if;
-- If there is a package gnatmake in the main project file, add
-- the switches from it. We also add the switches from packages
-- gnatbind and gnatlink, if any.
if Gnatmake /= No_Package then
-- If there is only one main, we attempt to get the gnatmake
-- switches for this main (if any). If there are no specific
-- switch for this particular main, get the general gnatmake
-- switches (if any).
if Osint.Number_Of_Files = 1 then
if Opt.Verbose_Mode then
Write_Str ("Adding gnatmake switches for """);
Write_Str (Main_Unit_File_Name);
Write_Line (""".");
end if;
Add_Switches
(File_Name => Main_Unit_File_Name,
The_Package => Gnatmake,
Program => None);
else
-- If there are several mains, we always get the general
-- gnatmake switches (if any).
-- Note: As there is never a source with name " ",
-- we are guaranteed to always get the gneneral switches.
Add_Switches
(File_Name => " ",
The_Package => Gnatmake,
Program => None);
end if;
end if;
if Binder_Package /= No_Package then
-- If there is only one main, we attempt to get the gnatbind
-- switches for this main (if any). If there are no specific
-- switch for this particular main, get the general gnatbind
-- switches (if any).
if Osint.Number_Of_Files = 1 then
if Opt.Verbose_Mode then
Write_Str ("Adding binder switches for """);
Write_Str (Main_Unit_File_Name);
Write_Line (""".");
end if;
Add_Switches
(File_Name => Main_Unit_File_Name,
The_Package => Binder_Package,
Program => Binder);
else
-- If there are several mains, we always get the general
-- gnatbind switches (if any).
-- Note: As there is never a source with name " ",
-- we are guaranteed to always get the gneneral switches.
Add_Switches
(File_Name => " ",
The_Package => Binder_Package,
Program => Binder);
end if;
end if;
if Linker_Package /= No_Package then
-- If there is only one main, we attempt to get the
-- gnatlink switches for this main (if any). If there are
-- no specific switch for this particular main, we get the
-- general gnatlink switches (if any).
if Osint.Number_Of_Files = 1 then
if Opt.Verbose_Mode then
Write_Str ("Adding linker switches for""");
Write_Str (Main_Unit_File_Name);
Write_Line (""".");
end if;
Add_Switches
(File_Name => Main_Unit_File_Name,
The_Package => Linker_Package,
Program => Linker);
else
-- If there are several mains, we always get the general
-- gnatlink switches (if any).
-- Note: As there is never a source with name " ",
-- we are guaranteed to always get the general switches.
Add_Switches
(File_Name => " ",
The_Package => Linker_Package,
Program => Linker);
end if;
end if;
end;
end if;
Display_Commands (not Opt.Quiet_Output);
-- We now put in the Binder_Switches and Linker_Switches tables,
-- the binder and linker switches of the command line that have been
-- put in the Saved_ tables. If a project file was used, then the
-- command line switches will follow the project file switches.
for J in 1 .. Saved_Binder_Switches.Last loop
Add_Switch
(Saved_Binder_Switches.Table (J),
Binder,
And_Save => False);
end loop;
for J in 1 .. Saved_Linker_Switches.Last loop
Add_Switch
(Saved_Linker_Switches.Table (J),
Linker,
And_Save => False);
end loop;
-- If no project file is used, we just put the gcc switches
-- from the command line in the Gcc_Switches table.
if Main_Project = No_Project then
for J in 1 .. Saved_Gcc_Switches.Last loop
Add_Switch
(Saved_Gcc_Switches.Table (J),
Compiler,
And_Save => False);
end loop;
else
-- And we put the command line gcc switches in the variable
-- The_Saved_Gcc_Switches. They are going to be used later
-- in procedure Compile_Sources.
The_Saved_Gcc_Switches :=
new Argument_List (1 .. Saved_Gcc_Switches.Last + 2);
for J in 1 .. Saved_Gcc_Switches.Last loop
The_Saved_Gcc_Switches (J) := Saved_Gcc_Switches.Table (J);
Test_If_Relative_Path (The_Saved_Gcc_Switches (J));
end loop;
-- We never use gnat.adc when a project file is used
The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last - 1) :=
No_gnat_adc;
-- Create a temporary mapping file and add the switch -gnatem
-- with its name to the compiler.
Prj.Env.Create_Mapping_File (Name => Mapping_File_Name);
The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) :=
new String'("-gnatem" & Mapping_File_Name);
-- Check if there are any relative search paths in the switches.
-- Fail if there is one.
for J in 1 .. Gcc_Switches.Last loop
Test_If_Relative_Path (Gcc_Switches.Table (J));
end loop;
for J in 1 .. Binder_Switches.Last loop
Test_If_Relative_Path (Binder_Switches.Table (J));
end loop;
for J in 1 .. Linker_Switches.Last loop
Test_If_Relative_Path (Linker_Switches.Table (J));
end loop;
end if;
-- If there was a --GCC, --GNATBIND or --GNATLINK switch on
-- the command line, then we have to use it, even if there was
-- another switch in the project file.
if Saved_Gcc /= null then
Gcc := Saved_Gcc;
end if;
if Saved_Gnatbind /= null then
Gnatbind := Saved_Gnatbind;
end if;
if Saved_Gnatlink /= null then
Gnatlink := Saved_Gnatlink;
end if;
Gcc_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all);
Gnatbind_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatbind.all);
Gnatlink_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gnatlink.all);
-- If we have specified -j switch both from the project file
-- and on the command line, the one from the command line takes
-- precedence.
if Saved_Maximum_Processes = 0 then
Saved_Maximum_Processes := Opt.Maximum_Processes;
end if;
-- If either -c, -b or -l has been specified, we will not necessarily
-- execute all steps.
if Compile_Only or else Bind_Only or else Link_Only then
Do_Compile_Step := Do_Compile_Step and Compile_Only;
Do_Bind_Step := Do_Bind_Step and Bind_Only;
Do_Link_Step := Do_Link_Step and Link_Only;
-- If -c has been specified, but not -b, ignore any potential -l
if Do_Compile_Step and then not Do_Bind_Step then
Do_Link_Step := False;
end if;
end if;
-- Here is where the make process is started
-- We do the same process for each main
Multiple_Main_Loop : for N_File in 1 .. Osint.Number_Of_Files loop
if Do_Compile_Step then
Recursive_Compilation_Step : declare
Args : Argument_List (1 .. Gcc_Switches.Last);
First_Compiled_File : Name_Id;
Youngest_Obj_File : Name_Id;
Youngest_Obj_Stamp : Time_Stamp_Type;
Executable_Stamp : Time_Stamp_Type;
-- Executable is the final executable program.
begin
Executable := No_File;
Non_Std_Executable := False;
for J in 1 .. Gcc_Switches.Last loop
Args (J) := Gcc_Switches.Table (J);
end loop;
-- Look inside the linker switches to see if the name
-- of the final executable program was specified.
for
J in reverse Linker_Switches.First .. Linker_Switches.Last
loop
if Linker_Switches.Table (J).all = Output_Flag.all then
pragma Assert (J < Linker_Switches.Last);
-- We cannot specify a single executable for several
-- main subprograms!
if Osint.Number_Of_Files > 1 then
Fail
("cannot specify a single executable " &
"for several mains");
end if;
Name_Len := Linker_Switches.Table (J + 1)'Length;
Name_Buffer (1 .. Name_Len) :=
Linker_Switches.Table (J + 1).all;
-- If target has an executable suffix and it has not been
-- specified then it is added here.
if Executable_Suffix'Length /= 0
and then Linker_Switches.Table (J + 1)
(Name_Len - Executable_Suffix'Length + 1
.. Name_Len) /= Executable_Suffix
then
Name_Buffer (Name_Len + 1 ..
Name_Len + Executable_Suffix'Length) :=
Executable_Suffix;
Name_Len := Name_Len + Executable_Suffix'Length;
end if;
Executable := Name_Enter;
Verbose_Msg (Executable, "final executable");
end if;
end loop;
-- If the name of the final executable program was not
-- specified then construct it from the main input file.
if Executable = No_File then
if Main_Project = No_Project then
Executable :=
Executable_Name (Strip_Suffix (Main_Source_File));
else
-- If we are using a project file, we attempt to
-- remove the body (or spec) termination of the main
-- subprogram. We find it the the naming scheme of the
-- project file. This will avoid to generate an
-- executable "main.2" for a main subprogram
-- "main.2.ada", when the body termination is ".2.ada".
declare
Body_Append : constant String :=
Get_Name_String
(Projects.Table
(Main_Project).
Naming.Current_Impl_Suffix);
Spec_Append : constant String :=
Get_Name_String
(Projects.Table
(Main_Project).
Naming.Current_Spec_Suffix);
begin
Get_Name_String (Main_Source_File);
if Name_Len > Body_Append'Length
and then Name_Buffer
(Name_Len - Body_Append'Length + 1 .. Name_Len) =
Body_Append
then
-- We have found the body termination. We remove it
-- add the executable termination, if any.
Name_Len := Name_Len - Body_Append'Length;
Executable := Executable_Name (Name_Find);
elsif Name_Len > Spec_Append'Length
and then
Name_Buffer
(Name_Len - Spec_Append'Length + 1 .. Name_Len) =
Spec_Append
then
-- We have found the spec termination. We remove
-- it, add the executable termination, if any.
Name_Len := Name_Len - Spec_Append'Length;
Executable := Executable_Name (Name_Find);
else
Executable :=
Executable_Name (Strip_Suffix (Main_Source_File));
end if;
end;
end if;
end if;
if Main_Project /= No_Project then
declare
Exec_File_Name : constant String :=
Get_Name_String (Executable);
begin
if not Is_Absolute_Path (Exec_File_Name) then
for Index in Exec_File_Name'Range loop
if Exec_File_Name (Index) = Directory_Separator then
Fail ("relative executable (""" &
Exec_File_Name &
""") with directory part not allowed " &
"when using project files");
end if;
end loop;
Get_Name_String (Projects.Table
(Main_Project).Exec_Directory);
if
Name_Buffer (Name_Len) /= Directory_Separator
then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Directory_Separator;
end if;
Name_Buffer (Name_Len + 1 ..
Name_Len + Exec_File_Name'Length) :=
Exec_File_Name;
Name_Len := Name_Len + Exec_File_Name'Length;
Executable := Name_Find;
Non_Std_Executable := True;
end if;
end;
end if;
-- Now we invoke Compile_Sources for the current main
Compile_Sources
(Main_Source => Main_Source_File,
Args => Args,
First_Compiled_File => First_Compiled_File,
Most_Recent_Obj_File => Youngest_Obj_File,
Most_Recent_Obj_Stamp => Youngest_Obj_Stamp,
Main_Unit => Is_Main_Unit,
Compilation_Failures => Compilation_Failures,
Check_Readonly_Files => Opt.Check_Readonly_Files,
Do_Not_Execute => Opt.Do_Not_Execute,
Force_Compilations => Opt.Force_Compilations,
In_Place_Mode => Opt.In_Place_Mode,
Keep_Going => Opt.Keep_Going,
Initialize_ALI_Data => True,
Max_Process => Saved_Maximum_Processes);
if Opt.Verbose_Mode then
Write_Str ("End of compilation");
Write_Eol;
end if;
if Compilation_Failures /= 0 then
List_Bad_Compilations;
raise Compilation_Failed;
end if;
-- Regenerate libraries, if any and if object files
-- have been regenerated
if Main_Project /= No_Project
and then MLib.Tgt.Libraries_Are_Supported
then
for Proj in Projects.First .. Projects.Last loop
if Proj /= Main_Project
and then Projects.Table (Proj).Flag1
then
MLib.Prj.Build_Library (For_Project => Proj);
end if;
end loop;
end if;
if Opt.List_Dependencies then
if First_Compiled_File /= No_File then
Inform
(First_Compiled_File,
"must be recompiled. Can't generate dependence list.");
else
List_Depend;
end if;
elsif First_Compiled_File = No_File
and then not Do_Bind_Step
and then not Opt.Quiet_Output
and then Osint.Number_Of_Files = 1
then
if Unique_Compile then
Inform (Msg => "object up to date.");
else
Inform (Msg => "objects up to date.");
end if;
elsif Opt.Do_Not_Execute
and then First_Compiled_File /= No_File
then
Write_Name (First_Compiled_File);
Write_Eol;
end if;
-- Stop after compile step if any of:
-- 1) -n (Do_Not_Execute) specified
-- 2) -l (List_Dependencies) specified (also sets
-- Do_Not_Execute above, so this is probably superfluous).
-- 3) -c (Compile_Only) specified, but not -b (Bind_Only)
-- 4) Made unit cannot be a main unit
if (Opt.Do_Not_Execute
or Opt.List_Dependencies
or not Do_Bind_Step
or not Is_Main_Unit)
and then not No_Main_Subprogram
then
if Osint.Number_Of_Files = 1 then
exit Multiple_Main_Loop;
else
goto Next_Main;
end if;
end if;
-- If the objects were up-to-date check if the executable file
-- is also up-to-date. For now always bind and link on the JVM
-- since there is currently no simple way to check the
-- up-to-date status of objects
if not Hostparm.Java_VM
and then First_Compiled_File = No_File
then
Executable_Stamp := File_Stamp (Executable);
-- Once Executable_Obsolete is set to True, it is never
-- reset to False, because it is too hard to accurately
-- decide if a subsequent main need to be rebuilt or not.
Executable_Obsolete :=
Executable_Obsolete
or else Youngest_Obj_Stamp > Executable_Stamp;
if not Executable_Obsolete then
-- If no Ada object files obsolete the executable, check
-- for younger or missing linker files.
Check_Linker_Options
(Executable_Stamp,
Youngest_Obj_File,
Youngest_Obj_Stamp);
Executable_Obsolete := Youngest_Obj_File /= No_File;
end if;
-- Return if the executable is up to date
-- and otherwise motivate the relink/rebind.
if not Executable_Obsolete then
if not Opt.Quiet_Output then
Inform (Executable, "up to date.");
end if;
if Osint.Number_Of_Files = 1 then
exit Multiple_Main_Loop;
else
goto Next_Main;
end if;
end if;
if Executable_Stamp (1) = ' ' then
Verbose_Msg (Executable, "missing.", Prefix => " ");
elsif Youngest_Obj_Stamp (1) = ' ' then
Verbose_Msg
(Youngest_Obj_File,
"missing.",
Prefix => " ");
elsif Youngest_Obj_Stamp > Executable_Stamp then
Verbose_Msg
(Youngest_Obj_File,
"(" & String (Youngest_Obj_Stamp) & ") newer than",
Executable,
"(" & String (Executable_Stamp) & ")");
else
Verbose_Msg
(Executable, "needs to be rebuild.",
Prefix => " ");
end if;
end if;
end Recursive_Compilation_Step;
end if;
-- If we are here, it means that we need to rebuilt the current
-- main. So we set Executable_Obsolete to True to make sure that
-- the subsequent mains will be rebuilt.
Executable_Obsolete := True;
Main_ALI_In_Place_Mode_Step :
declare
ALI_File : File_Name_Type;
Src_File : File_Name_Type;
begin
Src_File := Strip_Directory (Main_Source_File);
ALI_File := Lib_File_Name (Src_File);
Main_ALI_File := Full_Lib_File_Name (ALI_File);
-- When In_Place_Mode, the library file can be located in the
-- Main_Source_File directory which may not be present in the
-- library path. In this case, use the corresponding library file
-- name.
if Main_ALI_File = No_File and then Opt.In_Place_Mode then
Get_Name_String (Get_Directory (Full_Source_Name (Src_File)));
Get_Name_String_And_Append (ALI_File);
Main_ALI_File := Name_Find;
Main_ALI_File := Full_Lib_File_Name (Main_ALI_File);
end if;
if Main_ALI_File = No_File then
Fail ("could not find the main ALI file");
end if;
end Main_ALI_In_Place_Mode_Step;
if Do_Bind_Step then
Bind_Step : declare
Args : Argument_List
(Binder_Switches.First .. Binder_Switches.Last);
begin
-- Get all the binder switches
for J in Binder_Switches.First .. Binder_Switches.Last loop
Args (J) := Binder_Switches.Table (J);
end loop;
if Main_Project /= No_Project then
-- Put all the source directories in ADA_INCLUDE_PATH,
-- and all the object directories in ADA_OBJECTS_PATH
Set_Ada_Paths (Main_Project, False);
end if;
Bind (Main_ALI_File, Args);
end Bind_Step;
end if;
if Do_Link_Step then
Link_Step : declare
There_Are_Libraries : Boolean := False;
Linker_Switches_Last : constant Integer := Linker_Switches.Last;
begin
if Main_Project /= No_Project then
if MLib.Tgt.Libraries_Are_Supported then
Set_Libraries (Main_Project, There_Are_Libraries);
end if;
if There_Are_Libraries then
-- Add -L<lib_dir> -lgnarl -lgnat -Wl,-rpath,<lib_dir>
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-L" & MLib.Utl.Lib_Directory);
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnarl");
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-lgnat");
declare
Option : constant String_Access :=
MLib.Tgt.Linker_Library_Path_Option
(MLib.Utl.Lib_Directory);
begin
if Option /= null then
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
Option;
end if;
end;
end if;
-- Put the object directories in ADA_OBJECTS_PATH
Set_Ada_Paths (Main_Project, False);
end if;
declare
Args : Argument_List
(Linker_Switches.First .. Linker_Switches.Last + 2);
Last_Arg : Integer := Linker_Switches.First - 1;
Skip : Boolean := False;
begin
-- Get all the linker switches
for J in Linker_Switches.First .. Linker_Switches.Last loop
if Skip then
Skip := False;
elsif Non_Std_Executable
and then Linker_Switches.Table (J).all = "-o"
then
Skip := True;
else
Last_Arg := Last_Arg + 1;
Args (Last_Arg) := Linker_Switches.Table (J);
end if;
end loop;
-- And invoke the linker
if Non_Std_Executable then
Last_Arg := Last_Arg + 1;
Args (Last_Arg) := new String'("-o");
Last_Arg := Last_Arg + 1;
Args (Last_Arg) :=
new String'(Get_Name_String (Executable));
Link (Main_ALI_File, Args (Args'First .. Last_Arg));
else
Link
(Main_ALI_File,
Args (Args'First .. Last_Arg));
end if;
end;
Linker_Switches.Set_Last (Linker_Switches_Last);
end Link_Step;
end if;
-- We go to here when we skip the bind and link steps.
<<Next_Main>>
-- We go to the next main, if we did not process the last one
if N_File < Osint.Number_Of_Files then
Main_Source_File := Next_Main_Source;
if Main_Project /= No_Project then
-- Find the file name of the main unit
declare
Main_Source_File_Name : constant String :=
Get_Name_String (Main_Source_File);
Main_Unit_File_Name : constant String :=
Prj.Env.
File_Name_Of_Library_Unit_Body
(Name => Main_Source_File_Name,
Project => Main_Project);
begin
-- We fail if we cannot find the main source file
-- as an immediate source of the main project file.
if Main_Unit_File_Name = "" then
Fail ('"' & Main_Source_File_Name &
""" is not a unit of project " &
Project_File_Name.all & ".");
else
-- Remove any directory information from the main
-- source file name.
declare
Pos : Natural := Main_Unit_File_Name'Last;
begin
loop
exit when Pos < Main_Unit_File_Name'First
or else
Main_Unit_File_Name (Pos) = Directory_Separator;
Pos := Pos - 1;
end loop;
Name_Len := Main_Unit_File_Name'Last - Pos;
Name_Buffer (1 .. Name_Len) :=
Main_Unit_File_Name
(Pos + 1 .. Main_Unit_File_Name'Last);
Main_Source_File := Name_Find;
end;
end if;
end;
end if;
end if;
end loop Multiple_Main_Loop;
-- Delete the temporary mapping file that was created if we are
-- using project files.
if Main_Project /= No_Project then
declare
Success : Boolean;
begin
Delete_File (Name => Mapping_File_Name, Success => Success);
end;
end if;
Exit_Program (E_Success);
exception
when Bind_Failed =>
Osint.Fail ("*** bind failed.");
when Compilation_Failed =>
Exit_Program (E_Fatal);
when Link_Failed =>
Osint.Fail ("*** link failed.");
when X : others =>
Write_Line (Exception_Information (X));
Osint.Fail ("INTERNAL ERROR. Please report.");
end Gnatmake;
--------------------
-- In_Ada_Lib_Dir --
--------------------
function In_Ada_Lib_Dir (File : File_Name_Type) return Boolean is
D : constant Name_Id := Get_Directory (File);
B : constant Byte := Get_Name_Table_Byte (D);
begin
return (B and Ada_Lib_Dir) /= 0;
end In_Ada_Lib_Dir;
------------
-- Inform --
------------
procedure Inform (N : Name_Id := No_Name; Msg : String) is
begin
Osint.Write_Program_Name;
Write_Str (": ");
if N /= No_Name then
Write_Str ("""");
Write_Name (N);
Write_Str (""" ");
end if;
Write_Str (Msg);
Write_Eol;
end Inform;
------------
-- Init_Q --
------------
procedure Init_Q is
begin
First_Q_Initialization := False;
Q_Front := Q.First;
Q.Set_Last (Q.First);
end Init_Q;
----------------
-- Initialize --
----------------
procedure Initialize is
Next_Arg : Positive;
begin
-- Override default initialization of Check_Object_Consistency
-- since this is normally False for GNATBIND, but is True for
-- GNATMAKE since we do not need to check source consistency
-- again once GNATMAKE has looked at the sources to check.
Opt.Check_Object_Consistency := True;
-- Package initializations. The order of calls is important here.
Output.Set_Standard_Error;
Osint.Initialize (Osint.Make);
Gcc_Switches.Init;
Binder_Switches.Init;
Linker_Switches.Init;
Csets.Initialize;
Namet.Initialize;
Snames.Initialize;
Prj.Initialize;
Next_Arg := 1;
Scan_Args : while Next_Arg <= Argument_Count loop
Scan_Make_Arg (Argument (Next_Arg), And_Save => True);
Next_Arg := Next_Arg + 1;
end loop Scan_Args;
if Usage_Requested then
Makeusg;
end if;
-- Test for trailing -o switch
if Opt.Output_File_Name_Present
and then not Output_File_Name_Seen
then
Fail ("output file name missing after -o");
end if;
if Project_File_Name /= null then
-- A project file was specified by a -P switch
if Opt.Verbose_Mode then
Write_Eol;
Write_Str ("Parsing Project File """);
Write_Str (Project_File_Name.all);
Write_Str (""".");
Write_Eol;
end if;
-- Avoid looking in the current directory for ALI files
-- Opt.Look_In_Primary_Dir := False;
-- Set the project parsing verbosity to whatever was specified
-- by a possible -vP switch.
Prj.Pars.Set_Verbosity (To => Current_Verbosity);
-- Parse the project file.
-- If there is an error, Main_Project will still be No_Project.
Prj.Pars.Parse
(Project => Main_Project,
Project_File_Name => Project_File_Name.all);
if Main_Project = No_Project then
Fail ("""" & Project_File_Name.all &
""" processing failed");
end if;
if Opt.Verbose_Mode then
Write_Eol;
Write_Str ("Parsing of Project File """);
Write_Str (Project_File_Name.all);
Write_Str (""" is finished.");
Write_Eol;
end if;
-- We add the source directories and the object directories
-- to the search paths.
Add_Source_Directories (Main_Project);
Add_Object_Directories (Main_Project);
end if;
Osint.Add_Default_Search_Dirs;
-- Mark the GNAT libraries if needed.
-- Source file lookups should be cached for efficiency.
-- Source files are not supposed to change.
Osint.Source_File_Data (Cache => True);
-- Read gnat.adc file to initialize Fname.UF
Fname.UF.Initialize;
begin
Fname.SF.Read_Source_File_Name_Pragmas;
exception
when Err : SFN_Scan.Syntax_Error_In_GNAT_ADC =>
Osint.Fail (Exception_Message (Err));
end;
end Initialize;
-----------------------------------
-- Insert_Project_Sources_Into_Q --
-----------------------------------
procedure Insert_Project_Sources
(The_Project : Project_Id;
Into_Q : Boolean)
is
Unit : Com.Unit_Data;
Sfile : Name_Id;
begin
-- For all the sources in the project files,
for Id in Com.Units.First .. Com.Units.Last loop
Unit := Com.Units.Table (Id);
Sfile := No_Name;
-- If there is a source for the body,
if Unit.File_Names (Com.Body_Part).Name /= No_Name then
-- And it is a source of the specified project
if Unit.File_Names (Com.Body_Part).Project = The_Project then
-- If we don't have a spec, we cannot consider the source
-- if it is a subunit
if Unit.File_Names (Com.Specification).Name = No_Name then
declare
Src_Ind : Source_File_Index;
begin
Src_Ind := Sinput.L.Load_Source_File
(Unit.File_Names (Com.Body_Part).Name);
-- If it is a subunit, discard it
if Sinput.L.Source_File_Is_Subunit (Src_Ind) then
Sfile := No_Name;
else
Sfile := Unit.File_Names (Com.Body_Part).Name;
end if;
end;
else
Sfile := Unit.File_Names (Com.Body_Part).Name;
end if;
end if;
elsif Unit.File_Names (Com.Specification).Name /= No_Name
and then Unit.File_Names (Com.Specification).Project = The_Project
then
-- If there is no source for the body, but there is a source
-- for the spec, then we take this one.
Sfile := Unit.File_Names (Com.Specification).Name;
end if;
-- If Into_Q is True, we insert into the Q
if Into_Q then
-- For the first source inserted into the Q, we need
-- to initialize the Q, but not for the subsequent sources.
if First_Q_Initialization then
Init_Q;
end if;
-- And of course, we only insert in the Q if the source
-- is not marked.
if Sfile /= No_Name and then not Is_Marked (Sfile) then
Insert_Q (Sfile);
Mark (Sfile);
end if;
elsif Sfile /= No_Name then
-- If Into_Q is False, we add the source as it it were
-- specified on the command line.
Osint.Add_File (Get_Name_String (Sfile));
end if;
end loop;
end Insert_Project_Sources;
--------------
-- Insert_Q --
--------------
procedure Insert_Q
(Source_File : File_Name_Type;
Source_Unit : Unit_Name_Type := No_Name)
is
begin
if Debug.Debug_Flag_Q then
Write_Str (" Q := Q + [ ");
Write_Name (Source_File);
Write_Str (" ] ");
Write_Eol;
end if;
Q.Table (Q.Last).File := Source_File;
Q.Table (Q.Last).Unit := Source_Unit;
Q.Increment_Last;
end Insert_Q;
----------------------------
-- Is_External_Assignment --
----------------------------
function Is_External_Assignment (Argv : String) return Boolean is
Start : Positive := 3;
Finish : Natural := Argv'Last;
Equal_Pos : Natural;
begin
if Argv'Last < 5 then
return False;
elsif Argv (3) = '"' then
if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then
return False;
else
Start := 4;
Finish := Argv'Last - 1;
end if;
end if;
Equal_Pos := Start;
while Equal_Pos <= Finish and then Argv (Equal_Pos) /= '=' loop
Equal_Pos := Equal_Pos + 1;
end loop;
if Equal_Pos = Start
or else Equal_Pos >= Finish
then
return False;
else
Prj.Ext.Add
(External_Name => Argv (Start .. Equal_Pos - 1),
Value => Argv (Equal_Pos + 1 .. Finish));
return True;
end if;
end Is_External_Assignment;
---------------
-- Is_Marked --
---------------
function Is_Marked (Source_File : File_Name_Type) return Boolean is
begin
return Get_Name_Table_Byte (Source_File) /= 0;
end Is_Marked;
----------
-- Link --
----------
procedure Link (ALI_File : File_Name_Type; Args : Argument_List) is
Link_Args : Argument_List (Args'First .. Args'Last + 1);
Success : Boolean;
begin
Link_Args (Args'Range) := Args;
Get_Name_String (ALI_File);
Link_Args (Args'Last + 1) := new String'(Name_Buffer (1 .. Name_Len));
Display (Gnatlink.all, Link_Args);
if Gnatlink_Path = null then
Osint.Fail ("error, unable to locate " & Gnatlink.all);
end if;
GNAT.OS_Lib.Spawn (Gnatlink_Path.all, Link_Args, Success);
if not Success then
raise Link_Failed;
end if;
end Link;
---------------------------
-- List_Bad_Compilations --
---------------------------
procedure List_Bad_Compilations is
begin
for J in Bad_Compilation.First .. Bad_Compilation.Last loop
if Bad_Compilation.Table (J).File = No_File then
null;
elsif not Bad_Compilation.Table (J).Found then
Inform (Bad_Compilation.Table (J).File, "not found");
else
Inform (Bad_Compilation.Table (J).File, "compilation error");
end if;
end loop;
end List_Bad_Compilations;
-----------------
-- List_Depend --
-----------------
procedure List_Depend is
Lib_Name : Name_Id;
Obj_Name : Name_Id;
Src_Name : Name_Id;
Len : Natural;
Line_Pos : Natural;
Line_Size : constant := 77;
begin
Set_Standard_Output;
for A in ALIs.First .. ALIs.Last loop
Lib_Name := ALIs.Table (A).Afile;
-- We have to provide the full library file name in In_Place_Mode
if Opt.In_Place_Mode then
Lib_Name := Full_Lib_File_Name (Lib_Name);
end if;
Obj_Name := Object_File_Name (Lib_Name);
Write_Name (Obj_Name);
Write_Str (" :");
Get_Name_String (Obj_Name);
Len := Name_Len;
Line_Pos := Len + 2;
for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop
Src_Name := Sdep.Table (D).Sfile;
if Is_Internal_File_Name (Src_Name)
and then not Check_Readonly_Files
then
null;
else
if not Opt.Quiet_Output then
Src_Name := Full_Source_Name (Src_Name);
end if;
Get_Name_String (Src_Name);
Len := Name_Len;
if Line_Pos + Len + 1 > Line_Size then
Write_Str (" \");
Write_Eol;
Line_Pos := 0;
end if;
Line_Pos := Line_Pos + Len + 1;
Write_Str (" ");
Write_Name (Src_Name);
end if;
end loop;
Write_Eol;
end loop;
Set_Standard_Error;
end List_Depend;
----------
-- Mark --
----------
procedure Mark (Source_File : File_Name_Type) is
begin
Set_Name_Table_Byte (Source_File, 1);
end Mark;
-------------------
-- Mark_Dir_Path --
-------------------
procedure Mark_Dir_Path
(Path : String_Access;
Mark : Lib_Mark_Type)
is
Dir : String_Access;
begin
if Path /= null then
Osint.Get_Next_Dir_In_Path_Init (Path);
loop
Dir := Osint.Get_Next_Dir_In_Path (Path);
exit when Dir = null;
Mark_Directory (Dir.all, Mark);
end loop;
end if;
end Mark_Dir_Path;
--------------------
-- Mark_Directory --
--------------------
procedure Mark_Directory
(Dir : String;
Mark : Lib_Mark_Type)
is
N : Name_Id;
B : Byte;
begin
-- Dir last character is supposed to be a directory separator.
Name_Len := Dir'Length;
Name_Buffer (1 .. Name_Len) := Dir;
if not Is_Directory_Separator (Name_Buffer (Name_Len)) then
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := Directory_Separator;
end if;
-- Add flags to the already existing flags
N := Name_Find;
B := Get_Name_Table_Byte (N);
Set_Name_Table_Byte (N, B or Mark);
end Mark_Directory;
----------------------
-- Object_File_Name --
----------------------
function Object_File_Name (Source : String) return String is
Pos : Natural := Source'Last;
begin
while Pos >= Source'First and then
Source (Pos) /= '.' loop
Pos := Pos - 1;
end loop;
if Pos >= Source'First then
Pos := Pos - 1;
end if;
return Source (Source'First .. Pos) & Object_Suffix;
end Object_File_Name;
-------------------
-- Scan_Make_Arg --
-------------------
procedure Scan_Make_Arg (Argv : String; And_Save : Boolean) is
begin
pragma Assert (Argv'First = 1);
if Argv'Length = 0 then
return;
end if;
-- If the previous switch has set the Output_File_Name_Present
-- flag (that is we have seen a -o), then the next argument is
-- the name of the output executable.
if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then
Output_File_Name_Seen := True;
if Argv (1) = Switch_Character or else Argv (1) = '-' then
Fail ("output file name missing after -o");
else
Add_Switch ("-o", Linker, And_Save => And_Save);
-- Automatically add the executable suffix if it has not been
-- specified explicitly.
if Executable_Suffix'Length /= 0
and then Argv (Argv'Last - Executable_Suffix'Length + 1
.. Argv'Last) /= Executable_Suffix
then
Add_Switch
(Argv & Executable_Suffix,
Linker,
And_Save => And_Save);
else
Add_Switch (Argv, Linker, And_Save => And_Save);
end if;
end if;
-- Then check if we are dealing with a -cargs, -bargs or -largs
elsif (Argv (1) = Switch_Character or else Argv (1) = '-')
and then (Argv (2 .. Argv'Last) = "cargs"
or else Argv (2 .. Argv'Last) = "bargs"
or else Argv (2 .. Argv'Last) = "largs"
or else Argv (2 .. Argv'Last) = "margs")
then
case Argv (2) is
when 'c' => Program_Args := Compiler;
when 'b' => Program_Args := Binder;
when 'l' => Program_Args := Linker;
when 'm' => Program_Args := None;
when others =>
raise Program_Error;
end case;
-- A special test is needed for the -o switch within a -largs
-- since that is another way to specify the name of the final
-- executable.
elsif Program_Args = Linker
and then (Argv (1) = Switch_Character or else Argv (1) = '-')
and then Argv (2 .. Argv'Last) = "o"
then
Fail ("switch -o not allowed within a -largs. Use -o directly.");
-- Check to see if we are reading switches after a -cargs,
-- -bargs or -largs switch. If yes save it.
elsif Program_Args /= None then
-- Check to see if we are reading -I switches in order
-- to take into account in the src & lib search directories.
if Argv'Length > 2 and then Argv (1 .. 2) = "-I" then
if Argv (3 .. Argv'Last) = "-" then
Opt.Look_In_Primary_Dir := False;
elsif Program_Args = Compiler then
if Argv (3 .. Argv'Last) /= "-" then
Add_Src_Search_Dir (Argv (3 .. Argv'Last));
end if;
elsif Program_Args = Binder then
Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
end if;
end if;
Add_Switch (Argv, Program_Args, And_Save => And_Save);
-- Handle non-default compiler, binder, linker
elsif Argv'Length > 2 and then Argv (1 .. 2) = "--" then
if Argv'Length > 6
and then Argv (1 .. 6) = "--GCC="
then
declare
Program_Args : Argument_List_Access :=
Argument_String_To_List
(Argv (7 .. Argv'Last));
begin
if And_Save then
Saved_Gcc := new String'(Program_Args.all (1).all);
else
Gcc := new String'(Program_Args.all (1).all);
end if;
for J in 2 .. Program_Args.all'Last loop
Add_Switch
(Program_Args.all (J).all,
Compiler,
And_Save => And_Save);
end loop;
end;
elsif Argv'Length > 11
and then Argv (1 .. 11) = "--GNATBIND="
then
declare
Program_Args : Argument_List_Access :=
Argument_String_To_List
(Argv (12 .. Argv'Last));
begin
if And_Save then
Saved_Gnatbind := new String'(Program_Args.all (1).all);
else
Gnatbind := new String'(Program_Args.all (1).all);
end if;
for J in 2 .. Program_Args.all'Last loop
Add_Switch
(Program_Args.all (J).all, Binder, And_Save => And_Save);
end loop;
end;
elsif Argv'Length > 11
and then Argv (1 .. 11) = "--GNATLINK="
then
declare
Program_Args : Argument_List_Access :=
Argument_String_To_List
(Argv (12 .. Argv'Last));
begin
if And_Save then
Saved_Gnatlink := new String'(Program_Args.all (1).all);
else
Gnatlink := new String'(Program_Args.all (1).all);
end if;
for J in 2 .. Program_Args.all'Last loop
Add_Switch (Program_Args.all (J).all, Linker);
end loop;
end;
else
Fail ("unknown switch: ", Argv);
end if;
-- If we have seen a regular switch process it
elsif Argv (1) = Switch_Character or else Argv (1) = '-' then
if Argv'Length = 1 then
Fail ("switch character cannot be followed by a blank");
-- -I-
elsif Argv (2 .. Argv'Last) = "I-" then
Opt.Look_In_Primary_Dir := False;
-- Forbid -?- or -??- where ? is any character
elsif (Argv'Length = 3 and then Argv (3) = '-')
or else (Argv'Length = 4 and then Argv (4) = '-')
then
Fail ("trailing ""-"" at the end of ", Argv, " forbidden.");
-- -Idir
elsif Argv (2) = 'I' then
Add_Src_Search_Dir (Argv (3 .. Argv'Last));
Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
Add_Switch (Argv, Compiler, And_Save => And_Save);
Add_Switch ("-aO" & Argv (3 .. Argv'Last),
Binder,
And_Save => And_Save);
-- No need to pass any source dir to the binder
-- since gnatmake call it with the -x flag
-- (ie do not check source time stamp)
-- -aIdir (to gcc this is like a -I switch)
elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aI" then
Add_Src_Search_Dir (Argv (4 .. Argv'Last));
Add_Switch ("-I" & Argv (4 .. Argv'Last),
Compiler,
And_Save => And_Save);
-- -aOdir
elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aO" then
Add_Lib_Search_Dir (Argv (4 .. Argv'Last));
Add_Switch (Argv, Binder, And_Save => And_Save);
-- -aLdir (to gnatbind this is like a -aO switch)
elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aL" then
Mark_Directory (Argv (4 .. Argv'Last), Ada_Lib_Dir);
Add_Lib_Search_Dir (Argv (4 .. Argv'Last));
Add_Switch ("-aO" & Argv (4 .. Argv'Last),
Binder,
And_Save => And_Save);
-- -Adir (to gnatbind this is like a -aO switch, to gcc like a -I)
elsif Argv (2) = 'A' then
Mark_Directory (Argv (3 .. Argv'Last), Ada_Lib_Dir);
Add_Src_Search_Dir (Argv (3 .. Argv'Last));
Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
Add_Switch ("-I" & Argv (3 .. Argv'Last),
Compiler,
And_Save => And_Save);
Add_Switch ("-aO" & Argv (3 .. Argv'Last),
Binder,
And_Save => And_Save);
-- -Ldir
elsif Argv (2) = 'L' then
Add_Switch (Argv, Linker, And_Save => And_Save);
-- For -gxxxxx,-pg : give the switch to both the compiler and the
-- linker (except for -gnatxxx which is only for the compiler)
elsif
(Argv (2) = 'g' and then (Argv'Last < 5
or else Argv (2 .. 5) /= "gnat"))
or else Argv (2 .. Argv'Last) = "pg"
then
Add_Switch (Argv, Compiler, And_Save => And_Save);
Add_Switch (Argv, Linker, And_Save => And_Save);
-- -d
elsif Argv (2) = 'd'
and then Argv'Last = 2
then
Opt.Display_Compilation_Progress := True;
-- -j (need to save the result)
elsif Argv (2) = 'j' then
Scan_Make_Switches (Argv);
if And_Save then
Saved_Maximum_Processes := Maximum_Processes;
end if;
-- -m
elsif Argv (2) = 'm'
and then Argv'Last = 2
then
Opt.Minimal_Recompilation := True;
-- -u
elsif Argv (2) = 'u'
and then Argv'Last = 2
then
Unique_Compile := True;
Opt.Compile_Only := True;
Do_Bind_Step := False;
Do_Link_Step := False;
-- -Pprj (only once, and only on the command line)
elsif Argv'Last > 2
and then Argv (2) = 'P'
then
if Project_File_Name /= null then
Fail ("cannot have several project files specified");
elsif not And_Save then
-- It could be a tool other than gnatmake (i.e, gnatdist)
-- or a -P switch inside a project file.
Fail
("either the tool is not ""project-aware"" or " &
"a project file is specified inside a project file");
else
Project_File_Name := new String' (Argv (3 .. Argv'Last));
end if;
-- -S (Assemble)
-- Since no object file is created, don't check object
-- consistency.
elsif Argv (2) = 'S'
and then Argv'Last = 2
then
Opt.Check_Object_Consistency := False;
Add_Switch (Argv, Compiler, And_Save => And_Save);
-- -vPx (verbosity of the parsing of the project files)
elsif Argv'Last = 4
and then Argv (2 .. 3) = "vP"
and then Argv (4) in '0' .. '2'
then
if And_Save then
case Argv (4) is
when '0' =>
Current_Verbosity := Prj.Default;
when '1' =>
Current_Verbosity := Prj.Medium;
when '2' =>
Current_Verbosity := Prj.High;
when others =>
null;
end case;
end if;
-- -Wx (need to save the result)
elsif Argv (2) = 'W' then
Scan_Make_Switches (Argv);
if And_Save then
Saved_WC_Encoding_Method := Wide_Character_Encoding_Method;
Saved_WC_Encoding_Method_Set := True;
end if;
-- -Xext=val (External assignment)
elsif Argv (2) = 'X'
and then Is_External_Assignment (Argv)
then
-- Is_External_Assignment has side effects
-- when it returns True;
null;
-- If -gnath is present, then generate the usage information
-- right now for the compiler, and do not pass this option
-- on to the compiler calls.
elsif Argv = "-gnath" then
null;
-- If -gnatc is specified, make sure the bind step and the link
-- step are not executed.
elsif Argv'Length >= 6 and then Argv (2 .. 6) = "gnatc" then
-- If -gnatc is specified, make sure the bind step and the link
-- step are not executed.
Add_Switch (Argv, Compiler, And_Save => And_Save);
Opt.Operating_Mode := Opt.Check_Semantics;
Opt.Check_Object_Consistency := False;
Opt.Compile_Only := True;
Do_Bind_Step := False;
Do_Link_Step := False;
elsif Argv (2 .. Argv'Last) = "nostdlib" then
-- Don't pass -nostdlib to gnatlink, it will disable
-- linking with all standard library files.
Opt.No_Stdlib := True;
Add_Switch (Argv, Binder, And_Save => And_Save);
elsif Argv (2 .. Argv'Last) = "nostdinc" then
-- Pass -nostdinv to the Compiler and to gnatbind
Opt.No_Stdinc := True;
Add_Switch (Argv, Compiler, And_Save => And_Save);
Add_Switch (Argv, Binder, And_Save => And_Save);
-- By default all switches with more than one character
-- or one character switches which are not in 'a' .. 'z'
-- (except 'M') are passed to the compiler, unless we are dealing
-- with a debug switch (starts with 'd')
elsif Argv (2) /= 'd'
and then Argv (2 .. Argv'Last) /= "M"
and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z')
then
Add_Switch (Argv, Compiler, And_Save => And_Save);
-- All other options are handled by Scan_Make_Switches
else
Scan_Make_Switches (Argv);
end if;
-- If not a switch it must be a file name
else
Set_Main_File_Name (Argv);
end if;
end Scan_Make_Arg;
-------------------
-- Set_Ada_Paths --
-------------------
procedure Set_Ada_Paths
(For_Project : Prj.Project_Id;
Including_Libraries : Boolean)
is
New_Ada_Include_Path : constant String_Access :=
Prj.Env.Ada_Include_Path (For_Project);
New_Ada_Objects_Path : constant String_Access :=
Prj.Env.Ada_Objects_Path
(For_Project, Including_Libraries);
begin
-- If ADA_INCLUDE_PATH needs to be changed (we are not using the same
-- project file), set the new ADA_INCLUDE_PATH
if New_Ada_Include_Path /= Current_Ada_Include_Path then
Current_Ada_Include_Path := New_Ada_Include_Path;
if Original_Ada_Include_Path'Length = 0 then
Setenv ("ADA_INCLUDE_PATH",
New_Ada_Include_Path.all);
else
-- If there existed an ADA_INCLUDE_PATH at the invocation of
-- gnatmake, concatenate new ADA_INCLUDE_PATH with the original.
Setenv ("ADA_INCLUDE_PATH",
Original_Ada_Include_Path.all &
Path_Separator &
New_Ada_Include_Path.all);
end if;
if Opt.Verbose_Mode then
declare
Include_Path : constant String_Access :=
Getenv ("ADA_INCLUDE_PATH");
begin
-- Display the new ADA_INCLUDE_PATH
Write_Str ("ADA_INCLUDE_PATH = """);
Prj.Util.Write_Str
(S => Include_Path.all,
Max_Length => Max_Line_Length,
Separator => Path_Separator);
Write_Str ("""");
Write_Eol;
end;
end if;
end if;
-- If ADA_OBJECTS_PATH needs to be changed (we are not using the same
-- project file), set the new ADA_OBJECTS_PATH
if New_Ada_Objects_Path /= Current_Ada_Objects_Path then
Current_Ada_Objects_Path := New_Ada_Objects_Path;
if Original_Ada_Objects_Path'Length = 0 then
Setenv ("ADA_OBJECTS_PATH",
New_Ada_Objects_Path.all);
else
-- If there existed an ADA_OBJECTS_PATH at the invocation of
-- gnatmake, concatenate new ADA_OBJECTS_PATH with the original.
Setenv ("ADA_OBJECTS_PATH",
Original_Ada_Objects_Path.all &
Path_Separator &
New_Ada_Objects_Path.all);
end if;
if Opt.Verbose_Mode then
declare
Objects_Path : constant String_Access :=
Getenv ("ADA_OBJECTS_PATH");
begin
-- Display the new ADA_OBJECTS_PATH
Write_Str ("ADA_OBJECTS_PATH = """);
Prj.Util.Write_Str
(S => Objects_Path.all,
Max_Length => Max_Line_Length,
Separator => Path_Separator);
Write_Str ("""");
Write_Eol;
end;
end if;
end if;
end Set_Ada_Paths;
---------------------
-- Set_Library_For --
---------------------
procedure Set_Library_For
(Project : Project_Id;
There_Are_Libraries : in out Boolean)
is
begin
-- Case of library project
if Projects.Table (Project).Library then
There_Are_Libraries := True;
-- Add the -L switch
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-L" &
Get_Name_String
(Projects.Table (Project).Library_Dir));
-- Add the -l switch
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
new String'("-l" &
Get_Name_String
(Projects.Table (Project).Library_Name));
-- Add the Wl,-rpath switch if library non static
if Projects.Table (Project).Library_Kind /= Static then
declare
Option : constant String_Access :=
MLib.Tgt.Linker_Library_Path_Option
(Get_Name_String
(Projects.Table (Project).Library_Dir));
begin
if Option /= null then
Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) :=
Option;
end if;
end;
end if;
end if;
end Set_Library_For;
-----------------
-- Switches_Of --
-----------------
function Switches_Of
(Source_File : Name_Id;
Source_File_Name : String;
Naming : Naming_Data;
In_Package : Package_Id;
Allow_ALI : Boolean)
return Variable_Value
is
Switches : Variable_Value;
Defaults : constant Array_Element_Id :=
Prj.Util.Value_Of
(Name => Name_Default_Switches,
In_Arrays =>
Packages.Table (In_Package).Decl.Arrays);
Switches_Array : constant Array_Element_Id :=
Prj.Util.Value_Of
(Name => Name_Switches,
In_Arrays =>
Packages.Table (In_Package).Decl.Arrays);
begin
Switches :=
Prj.Util.Value_Of
(Index => Source_File,
In_Array => Switches_Array);
if Switches = Nil_Variable_Value then
declare
Name : String (1 .. Source_File_Name'Length + 3);
Last : Positive := Source_File_Name'Length;
Spec_Suffix : constant String :=
Get_Name_String (Naming.Current_Spec_Suffix);
Impl_Suffix : constant String :=
Get_Name_String (Naming.Current_Impl_Suffix);
Truncated : Boolean := False;
begin
Name (1 .. Last) := Source_File_Name;
if Last > Impl_Suffix'Length
and then Name (Last - Impl_Suffix'Length + 1 .. Last) =
Impl_Suffix
then
Truncated := True;
Last := Last - Impl_Suffix'Length;
end if;
if not Truncated
and then Last > Spec_Suffix'Length
and then Name (Last - Spec_Suffix'Length + 1 .. Last) =
Spec_Suffix
then
Truncated := True;
Last := Last - Spec_Suffix'Length;
end if;
if Truncated then
Name_Len := Last;
Name_Buffer (1 .. Name_Len) := Name (1 .. Last);
Switches :=
Prj.Util.Value_Of
(Index => Name_Find,
In_Array => Switches_Array);
if Switches = Nil_Variable_Value then
Last := Source_File_Name'Length;
while Name (Last) /= '.' loop
Last := Last - 1;
end loop;
Name (Last + 1 .. Last + 3) := "ali";
Name_Len := Last + 3;
Name_Buffer (1 .. Name_Len) := Name (1 .. Name_Len);
Switches :=
Prj.Util.Value_Of
(Index => Name_Find,
In_Array => Switches_Array);
end if;
end if;
end;
end if;
if Switches = Nil_Variable_Value then
Switches := Prj.Util.Value_Of
(Index => Name_Ada, In_Array => Defaults);
end if;
return Switches;
end Switches_Of;
---------------------------
-- Test_If_Relative_Path --
---------------------------
procedure Test_If_Relative_Path (Switch : String_Access) is
begin
if Switch /= null then
declare
Sw : String (1 .. Switch'Length);
Start : Positive;
begin
Sw := Switch.all;
if Sw (1) = '-' then
if Sw'Length >= 3
and then (Sw (2) = 'A'
or else Sw (2) = 'I'
or else Sw (2) = 'L')
then
Start := 3;
if Sw = "-I-" then
return;
end if;
elsif Sw'Length >= 4
and then (Sw (2 .. 3) = "aL"
or else Sw (2 .. 3) = "aO"
or else Sw (2 .. 3) = "aI")
then
Start := 4;
else
return;
end if;
if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then
Fail ("relative search path switches (""" &
Sw & """) are not allowed when using project files");
end if;
end if;
end;
end if;
end Test_If_Relative_Path;
------------
-- Unmark --
------------
procedure Unmark (Source_File : File_Name_Type) is
begin
Set_Name_Table_Byte (Source_File, 0);
end Unmark;
-----------------
-- Verbose_Msg --
-----------------
procedure Verbose_Msg
(N1 : Name_Id;
S1 : String;
N2 : Name_Id := No_Name;
S2 : String := "";
Prefix : String := " -> ")
is
begin
if not Opt.Verbose_Mode then
return;
end if;
Write_Str (Prefix);
Write_Str ("""");
Write_Name (N1);
Write_Str (""" ");
Write_Str (S1);
if N2 /= No_Name then
Write_Str (" """);
Write_Name (N2);
Write_Str (""" ");
end if;
Write_Str (S2);
Write_Eol;
end Verbose_Msg;
end Make;
|
ejercicios6/datos.ads | iyan22/AprendeAda | 0 | 5247 | <reponame>iyan22/AprendeAda
package Datos is
type Nodo;
type Lista is access Nodo;
type Nodo is record
Info : Integer;
Sig : Lista;
end record;
end Datos; |
src/zmq-sockets-indefinite_typed_generic.ads | persan/zeromq-Ada | 33 | 20880 | <reponame>persan/zeromq-Ada<filename>src/zmq-sockets-indefinite_typed_generic.ads
-------------------------------------------------------------------------------
-- --
-- 0MQ Ada-binding --
-- --
-- Z M Q . S O C K E T S . I N D E F I N I T E _ T Y P E D _ G E N E R I C --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020-2030, <EMAIL> --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files --
-- (the "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and / or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions : --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, --
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL --
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR --
-- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, --
-- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR --
-- OTHER DEALINGS IN THE SOFTWARE. --
-------------------------------------------------------------------------------
with Ada.Streams;
generic
type Element_Type (<>) is private;
Initial_Size : Ada.Streams.Stream_Element_Offset := 1024;
package ZMQ.Sockets.Indefinite_Typed_Generic is
-- This package provides a wraper for first serializeing any object
-- then send the serialized data over the socket.
type Socket is new ZMQ.Sockets.Socket with private;
not overriding
procedure Send
(This : in out Socket;
Msg : Element_Type);
not overriding
procedure Recv
(This : in Socket;
Msg : out Element_Type);
private
type Socket is new ZMQ.Sockets.Socket with record
Acutal_Initial_Size : Ada.Streams.Stream_Element_Offset := Initial_Size;
end record;
end ZMQ.Sockets.Indefinite_Typed_Generic;
|
oeis/091/A091545.asm | neoneye/loda-programs | 11 | 102057 | <filename>oeis/091/A091545.asm
; A091545: First column sequence of the array (7,2)-Stirling2 A091747.
; Submitted by <NAME>
; 1,42,5544,1507968,696681216,489070213632,485157651922944,646229992361361408,1112808046846264344576,2405890997281623512973312,6380422924790865556405223424,20366309975932442856045473169408
mov $1,1
mov $2,2
lpb $0
sub $0,1
add $2,4
mul $1,$2
add $2,1
mul $1,$2
lpe
mov $0,$1
|
examples/SPARK2005/packages/polypaver-integers.ads | michalkonecny/polypaver | 1 | 8449 | package PolyPaver.Integers is
--# function Is_Integer(Variable : Integer) return Boolean;
--# function Is_Range(Variable : Integer; Min : Integer; Max : Integer) return Boolean;
end PolyPaver.Integers;
|
oeis/135/A135713.asm | neoneye/loda-programs | 11 | 164079 | ; A135713: a(n) = n*(n+1)*(4*n+1)/2.
; 0,5,27,78,170,315,525,812,1188,1665,2255,2970,3822,4823,5985,7320,8840,10557,12483,14630,17010,19635,22517,25668,29100,32825,36855,41202,45878,50895,56265,62000,68112,74613,81515,88830,96570,104747,113373,122460,132020,142065,152607,163658,175230,187335,199985,213192,226968,241325,256275,271830,288002,304803,322245,340340,359100,378537,398663,419490,441030,463295,486297,510048,534560,559845,585915,612782,640458,668955,698285,728460,759492,791393,824175,857850,892430,927927,964353,1001720
add $0,1
mov $1,$0
bin $0,2
mul $1,4
sub $1,3
mul $0,$1
|
libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dlt.asm | meesokim/z88dk | 0 | 168155 | <filename>libsrc/_DEVELOPMENT/math/float/math48/lm/c/sccz80/dlt.asm
SECTION code_fp_math48
PUBLIC dlt
EXTERN cm48_sccz80p_dlt
defc dlt = cm48_sccz80p_dlt
|
programs/oeis/158/A158229.asm | karttu/loda | 1 | 168948 | <gh_stars>1-10
; A158229: 225n + 1.
; 226,451,676,901,1126,1351,1576,1801,2026,2251,2476,2701,2926,3151,3376,3601,3826,4051,4276,4501,4726,4951,5176,5401,5626,5851,6076,6301,6526,6751,6976,7201,7426,7651,7876,8101,8326,8551,8776,9001,9226,9451,9676,9901,10126,10351,10576,10801,11026,11251,11476,11701,11926,12151,12376,12601,12826,13051,13276,13501,13726,13951,14176,14401,14626,14851,15076,15301,15526,15751,15976,16201,16426,16651,16876,17101,17326,17551,17776,18001,18226,18451,18676,18901,19126,19351,19576,19801,20026,20251,20476,20701,20926,21151,21376,21601,21826,22051,22276,22501,22726,22951,23176,23401,23626,23851,24076,24301,24526,24751,24976,25201,25426,25651,25876,26101,26326,26551,26776,27001,27226,27451,27676,27901,28126,28351,28576,28801,29026,29251,29476,29701,29926,30151,30376,30601,30826,31051,31276,31501,31726,31951,32176,32401,32626,32851,33076,33301,33526,33751,33976,34201,34426,34651,34876,35101,35326,35551,35776,36001,36226,36451,36676,36901,37126,37351,37576,37801,38026,38251,38476,38701,38926,39151,39376,39601,39826,40051,40276,40501,40726,40951,41176,41401,41626,41851,42076,42301,42526,42751,42976,43201,43426,43651,43876,44101,44326,44551,44776,45001,45226,45451,45676,45901,46126,46351,46576,46801,47026,47251,47476,47701,47926,48151,48376,48601,48826,49051,49276,49501,49726,49951,50176,50401,50626,50851,51076,51301,51526,51751,51976,52201,52426,52651,52876,53101,53326,53551,53776,54001,54226,54451,54676,54901,55126,55351,55576,55801,56026,56251
mov $1,$0
mul $1,225
add $1,226
|
programs/oeis/140/A140153.asm | karttu/loda | 0 | 88175 | <gh_stars>0
; A140153: a(1)=1, a(n) = a(n-1) + n^3 if n odd, a(n) = a(n-1) + n^1 if n is even.
; 1,3,30,34,159,165,508,516,1245,1255,2586,2598,4795,4809,8184,8200,13113,13131,19990,20010,29271,29293,41460,41484,57109,57135,76818,76846,101235,101265,131056,131088,167025,167059,209934,209970,260623,260661,319980,320020,388941,388983,468490,468534,559659,559705,663528,663576,781225,781275,913926,913978,1062855,1062909,1229284,1229340,1414533,1414591,1619970,1620030,1847011,1847073,2097120,2097184,2371809,2371875,2672638,2672706,3001215,3001285,3359196,3359268,3748285,3748359,4170234,4170310,4626843,4626921,5119960,5120040,5651481,5651563,6223350,6223434,6837559,6837645,7496148,7496236,8201205,8201295,8954866,8954958,9759315,9759409,10616784,10616880,11529553,11529651,12499950,12500050,13530351,13530453,14623180,14623284,15780909,15781015,17006058,17006166,18301195,18301305,19668936,19669048,21111945,21112059,22632934,22633050,24234663,24234781,25919940,25920060,27691621,27691743,29552610,29552734,31505859,31505985,33554368,33554496,35701185,35701315,37949406,37949538,40302175,40302309,42762684,42762820,45334173,45334311,48019930,48020070,50823291,50823433,53747640,53747784,56796409,56796555,59973078,59973226,63281175,63281325,66724276,66724428,70306005,70306159,74030034,74030190,77900083,77900241,81919920,81920080,86093361,86093523,90424270,90424434,94916559,94916725,99574188,99574356,104401165,104401335,109401546,109401718,114579435,114579609,119938984,119939160,125484393,125484571,131219910,131220090,137149831,137150013,143278500,143278684,149610309,149610495,156149698,156149886,162901155,162901345,169869216,169869408,177058465,177058659,184473534,184473730,192119103,192119301,199999900,200000100,208120701,208120903,216486330,216486534,225101659,225101865,233971608,233971816,243101145,243101355,252495286,252495498,262159095,262159309,272097684,272097900,282316213,282316431,292819890,292820110,303613971,303614193,314703760,314703984,326094609,326094835,337791918,337792146,349801135,349801365,362127756,362127988,374777325,374777559,387755434,387755670,401067723,401067961,414719880,414720120,428717641,428717883,443066790,443067034,457773159,457773405,472842628,472842876,488281125,488281375
mov $3,$0
add $3,1
mov $4,$0
lpb $3,1
mov $0,$4
sub $3,1
sub $0,$3
mov $2,3
add $2,$0
add $0,1
mod $2,2
mul $2,2
sub $5,$5
add $5,1
add $5,$2
pow $0,$5
add $0,1
mov $6,$0
sub $6,1
add $1,$6
lpe
|
test/asset/agda-stdlib-1.0/Data/String/Properties.agda | omega12345/agda-mode | 0 | 9345 | <reponame>omega12345/agda-mode<gh_stars>0
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of operations on strings
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.String.Properties where
open import Data.Bool.Base
open import Data.String.Base
import Data.Char.Properties as Charₚ
import Data.List.Properties as Listₚ
open import Function
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (map′; ⌊_⌋)
open import Relation.Binary using (Decidable; Setoid; DecSetoid; StrictTotalOrder)
open import Relation.Binary.PropositionalEquality.Core
open import Data.List.Relation.Binary.Lex.Strict as StrictLex
import Relation.Binary.Construct.On as On
import Relation.Binary.PropositionalEquality as PropEq
------------------------------------------------------------------------
-- Primitive properties
open import Agda.Builtin.String.Properties public
renaming ( primStringToListInjective to toList-injective)
------------------------------------------------------------------------
-- Equality
infix 4 _≟_
_≟_ : Decidable {A = String} _≡_
x ≟ y = map′ (toList-injective x y) (cong toList)
$ Listₚ.≡-dec Charₚ._≟_ (toList x) (toList y)
setoid : Setoid _ _
setoid = PropEq.setoid String
decSetoid : DecSetoid _ _
decSetoid = PropEq.decSetoid _≟_
------------------------------------------------------------------------
-- Lexicographic ordering on strings.
strictTotalOrder : StrictTotalOrder _ _ _
strictTotalOrder =
On.strictTotalOrder
(StrictLex.<-strictTotalOrder Charₚ.strictTotalOrder)
toList
------------------------------------------------------------------------
-- Alternative Boolean equality test.
--
-- Why is the definition _==_ = primStringEquality not used? One
-- reason is that the present definition can sometimes improve type
-- inference, at least with the version of Agda that is current at the
-- time of writing: see unit-test below.
infix 4 _==_
_==_ : String → String → Bool
s₁ == s₂ = ⌊ s₁ ≟ s₂ ⌋
private
-- The following unit test does not type-check (at the time of
-- writing) if _==_ is replaced by primStringEquality.
data P : (String → Bool) → Set where
p : (c : String) → P (_==_ c)
unit-test : P (_==_ "")
unit-test = p _
|
programs/oeis/034/A034115.asm | karttu/loda | 1 | 163895 | ; A034115: Fractional part of square root of a(n) starts with 9: first term of runs.
; 35,48,63,80,99,119,142,167,194,223,253,286,321,358,397,437,480,525,572,621,671,724,779,836,895,955,1018,1083,1150,1219,1289,1362,1437,1514,1593,1673,1756,1841,1928,2017,2107,2200,2295,2392,2491,2591,2694
mov $1,24
mov $4,$0
div $0,5
sub $1,$0
add $1,11
mov $2,$4
mul $2,12
add $1,$2
mov $3,$4
mul $3,$4
add $1,$3
|
programs/oeis/211/A211433.asm | karttu/loda | 0 | 179268 | <filename>programs/oeis/211/A211433.asm
; A211433: Number of ordered triples (w,x,y) with all terms in {-n,...,0,...,n} and w+2x+4y=0.
; 1,1,7,11,23,27,45,53,77,85,115,127,163,175,217,233,281,297,351,371,431,451,517,541,613,637,715,743,827,855,945,977,1073,1105,1207,1243,1351,1387,1501,1541,1661,1701,1827,1871,2003,2047,2185,2233,2377,2425,2575,2627,2783,2835,2997,3053,3221,3277,3451,3511,3691,3751,3937,4001,4193,4257,4455,4523,4727,4795,5005,5077,5293,5365,5587,5663,5891,5967,6201,6281,6521,6601,6847,6931,7183,7267,7525,7613,7877,7965,8235,8327,8603,8695,8977,9073,9361,9457,9751,9851,10151,10251,10557,10661,10973,11077,11395,11503,11827,11935,12265,12377,12713,12825,13167,13283,13631,13747,14101,14221,14581,14701,15067,15191,15563,15687,16065,16193,16577,16705,17095,17227,17623,17755,18157,18293,18701,18837,19251,19391,19811,19951,20377,20521,20953,21097,21535,21683,22127,22275,22725,22877,23333,23485,23947,24103,24571,24727,25201,25361,25841,26001,26487,26651,27143,27307,27805,27973,28477,28645,29155,29327,29843,30015,30537,30713,31241,31417,31951,32131,32671,32851,33397,33581,34133,34317,34875,35063,35627,35815,36385,36577,37153,37345,37927,38123,38711,38907,39501,39701,40301,40501,41107,41311,41923,42127,42745,42953,43577,43785,44415,44627,45263,45475,46117,46333,46981,47197,47851,48071,48731,48951,49617,49841,50513,50737,51415,51643,52327,52555,53245,53477,54173,54405,55107,55343,56051,56287,57001,57241,57961,58201,58927,59171,59903,60147,60885,61133,61877,62125
mov $2,$0
mov $3,$0
div $3,2
add $3,$0
mov $0,$3
div $0,3
mov $1,2
add $1,$2
sub $1,1
mov $4,$1
div $1,4
add $1,2
lpb $0,1
sub $0,1
add $1,$4
lpe
sub $1,2
mul $1,2
add $1,1
|
game.asm | adamsmasher/bustfree | 0 | 19611 | <filename>game.asm
INCLUDE "ball.inc"
INCLUDE "game.inc"
INCLUDE "paddle.inc"
INCLUDE "powerup.inc"
WINDOW_Y EQU 136
NUM_OF_STAGES EQU 2
GET_READY EQU 0
PLAYING EQU 1
NEXT_LEVEL EQU 2
GET_READY_JINGLE_LENGTH EQU 150
NEXT_LEVEL_JINGLE_LENGTH EQU 150
SECTION "GameVars", WRAM0
GameState: DS 1
GameTimer: DS 1
NoOfLives:: DS 1
BricksBroken:: DS 1
Score:: DS SCORE_BYTES
ReplacementTile: DS 1
ReplacementBrick:: DS 1
BrickDestroyed:: DS 1
SECTION "Game", ROM0
StartGame:: CALL InitGameVBlank
CALL InitGameStatHandler
CALL SetupWindowInterrupt
CALL LoadFont
CALL LoadBGGfx
CALL LoadSpriteGfx
CALL NewGame
CALL DrawStage
CALL DrawStatus
CALL TurnOnScreen
LD HL, GameLoopPtr
LD A, LOW(Game)
LD [HLI], A
LD [HL], HIGH(Game)
RET
SetupWindowInterrupt: ; fire interrupt on LYC=LY coincidence
LD A, %01000000
LDH [$41], A
; set LYC to the top of the window
LD A, WINDOW_Y
LDH [$45], A
; enable STAT interrupt
LD HL, $FFFF
SET 1, [HL]
RET
DisableWindowInterrupt: ; disable stat interrupt
LD HL, $FFFF
RES 1, [HL]
RET
Game: LD A, [GameState]
CP GET_READY
JP Z, DoGetReady
CP PLAYING
JP Z, DoPlaying
CP NEXT_LEVEL
JP Z, DoNextLevel
DoGetReady: LD HL, GameTimer
DEC [HL]
JP Z, StartPlaying
RET
DoNextLevel: LD HL, GameTimer
DEC [HL]
JP Z, LevelComplete
RET
StartPlaying: LD A, PLAYING
LD [GameState], A
RET
StartNextLevel: LD A, NEXT_LEVEL
LD [GameState], A
LD A, NEXT_LEVEL_JINGLE_LENGTH
RET
DoPlaying: CALL UpdateBall
CALL UpdatePaddle
CALL UpdateFlash
CALL UpdateEffect
CALL UpdateLasers
CALL UpdatePowerUps
CALL SetupBallOAM
CALL SetupPaddleOAM
CALL SetupFlashOAM
CALL SetupEffectOAM
CALL SetupLasersOAM
CALL SetupPowerUpOAM
RET
TurnOnScreen: ; enable display
; BG tiles at $8800
; map at $9800
; window map at $9C00
; sprites enabled
; bg enabled
; window enabled
LD A, %11100011
LDH [$40], A
; set window position
LD A, 136
LDH [$4A], A
LD A, 7
LDH [$4B], A
RET
ClearScore: LD HL, Score
XOR A
LD B, SCORE_BYTES
.loop LD [HLI], A
DEC B
JR NZ, .loop
RET
CapScore: LD A, $99
LD B, SCORE_BYTES
LD HL, Score
.loop LD [HLI], A
DEC B
JR NZ, .loop
RET
AddLifeOnScore: LD HL, Score
LD A, [HLI]
AND A
RET NZ
LD A, [HL]
AND $0F
CP $05
RET NZ
LD HL, NoOfLives
INC [HL]
RET
IncrementScore:: LD HL, Score
.loop LD A, L
CP LOW(Score) + SCORE_BYTES
JP Z, CapScore
LD A, [HL]
ADD 1 ; clears the carry flag, unlike INC
DAA
LD [HLI], A
JR C, .loop
CALL AddLifeOnScore
CALL DrawStatus
RET
NewGame: LD A, STARTING_LIVES
LD [NoOfLives], A
XOR A
LD [BricksBroken], A
LD [CurrentStage], A
CALL ClearScore
CALL InitGame
RET
GetReady: LD A, GET_READY
LD [GameState], A
LD A, GET_READY_JINGLE_LENGTH
LD [GameTimer], A
RET
InitGame: CALL InitBall
CALL InitPaddle
CALL InitFlash
CALL InitEffect
CALL InitLasers
CALL InitPowerUps
CALL InitStage
CALL GetReady
RET
LevelComplete: LD HL, CurrentStage
LD A, [HL]
INC A
CP NUM_OF_STAGES
JP Z, GameOver
LD [HL], A
CALL WaitForVBlank
CALL TurnOffScreen
CALL InitGame
CALL DrawStage
CALL ClearOAM
CALL TurnOnScreen
RET
GameOver: CALL WaitForVBlank
CALL TurnOffScreen
CALL DisableWindowInterrupt
CALL ClearVRAM
CALL StartGameOver
RET
PlayerDie:: LD HL, NoOfLives
DEC [HL]
JP Z, GameOver
LD A, BALL_ON_PADDLE
LD [BallState], A
LD A, NO_POWERUP
LD [PowerUpState], A
LD A, 1
LD [PaddleWidthTiles], A
LD A, PADDLE_WIDTH
LD [PaddleWidthPixels], A
CALL DrawStatus
RET
SetupReplaceBrickTransfer: ; compute destination and put in DE
LD D, $98
LD A, [HitBrickRow]
SRL A
ADD 2
SWAP A
ADD A
LD E, A
JR NC, .nc
INC D
.nc LD A, [HitBrickCol]
ADD 2
ADD E
LD E, A
; get pointer to next free update slot
LD A, [VRAMUpdateLen]
SLA A
SLA A
ADD LOW(VRAMUpdates)
LD L, A
LD H, HIGH(VRAMUpdates)
; write destination
LD A, E
LD [HLI], A
LD A, D
LD [HLI], A
; write tile to write
LD A, [ReplacementTile]
LD [HLI], A
; increment number of used slots
LD HL, VRAMUpdateLen
INC [HL]
RET
; writes into ReplacementTile the result of replacing the hit brick with ReplacementBrick
GetReplacementTile: ; determine if we care about the top or the bottom
LD A, [HitBrickRow]
RRCA
LD A, [ReplacementBrick]
LD B, A
LD A, [CollisionTile]
JR C, .bottom
.top SWAP B
AND $0F
JR .write
.bottom AND $F0
.write OR B
LD [ReplacementTile], A
RET
ReplaceHitBrick:: CALL GetReplacementTile
CALL SetupReplaceBrickTransfer
CALL ReplaceBrickOnStageMap
RET
ReplaceBrickOnStageMap: LD H, HIGH(StageMap)
LD A, [HitBrickRow]
SRL A ; divide 4px row by 2 to get 8px row
SWAP A
LD L, A
LD A, [HitBrickCol]
ADD L
LD L, A
LD A, [ReplacementTile]
LD [HL], A
RET
; TODO: implement a better random number generator
SpawnRandomPowerUp: LDH A, [$04]
BIT 2, A
RET Z
AND $03
RET Z ; TODO: when multiball is implemented, 0 should summon it
CP %01
JP Z, SpawnExtendPowerUp
CP %10
JP Z, SpawnLaserPowerUp
JP SpawnSpikePowerUp
OnBrickDestroyed:: CALL StartEffectAtHitBrick
CALL SpawnRandomPowerUp
CALL IncrementScore
LD A, 1
LD [BrickDestroyed], A
LD A, [TotalBricks]
LD B, A
LD HL, BricksBroken
LD A, [HL]
INC A
CP B
JP Z, StartNextLevel
LD [HL], A
RET
GameStatHandler: LD HL, $FF40
RES 1, [HL]
RET
InitGameStatHandler: LD HL, StatHandler
LD A, LOW(GameStatHandler)
LD [HLI], A
LD [HL], HIGH(GameStatHandler)
RET
|
Transynther/x86/_processed/NONE/_ht_zr_un_/i7-7700_9_0x48_notsx.log_31_1018.asm | ljhsiun2/medusa | 9 | 178227 | .global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xcfe1, %rsi
lea addresses_WT_ht+0x10181, %rdi
inc %r9
mov $7, %rcx
rep movsl
nop
nop
nop
and %r12, %r12
lea addresses_WT_ht+0x12999, %r10
nop
nop
nop
nop
nop
dec %rcx
mov $0x6162636465666768, %rdi
movq %rdi, (%r10)
nop
nop
nop
nop
nop
xor $34552, %r10
lea addresses_WC_ht+0x5fe1, %r9
nop
nop
nop
nop
nop
and $50349, %rax
movb $0x61, (%r9)
nop
sub %rdi, %rdi
lea addresses_A_ht+0x13ce1, %rsi
inc %r10
and $0xffffffffffffffc0, %rsi
movaps (%rsi), %xmm6
vpextrq $1, %xmm6, %rdi
nop
nop
sub $37278, %r9
lea addresses_UC_ht+0x1c4e9, %rsi
lea addresses_A_ht+0x6fe1, %rdi
nop
nop
nop
nop
xor $18784, %r10
mov $35, %rcx
rep movsb
nop
nop
nop
nop
nop
sub $40178, %rcx
lea addresses_A_ht+0x19ce1, %rdi
nop
nop
nop
nop
add $36027, %r10
movb $0x61, (%rdi)
and $65473, %rdi
lea addresses_UC_ht+0x54c1, %rsi
lea addresses_WT_ht+0x187e1, %rdi
nop
nop
nop
and $13009, %rbx
mov $5, %rcx
rep movsq
nop
nop
nop
nop
nop
xor %r10, %r10
lea addresses_WT_ht+0x130a1, %rsi
lea addresses_normal_ht+0x1b2a5, %rdi
nop
nop
nop
nop
and $59039, %r9
mov $15, %rcx
rep movsw
nop
add $11196, %rcx
lea addresses_UC_ht+0x17f89, %r10
nop
nop
nop
nop
nop
dec %rax
movb (%r10), %cl
nop
nop
nop
nop
nop
cmp %rax, %rax
lea addresses_A_ht+0x178a1, %r10
nop
nop
nop
nop
cmp $48174, %rsi
movups (%r10), %xmm5
vpextrq $0, %xmm5, %rax
nop
nop
nop
nop
nop
and %r12, %r12
lea addresses_WT_ht+0x7e0b, %r12
nop
nop
nop
nop
nop
sub $46074, %r10
movb (%r12), %cl
nop
nop
nop
nop
sub $64305, %r9
lea addresses_UC_ht+0xfde1, %rbx
sub %rax, %rax
movw $0x6162, (%rbx)
nop
nop
nop
nop
xor $32653, %r10
lea addresses_UC_ht+0x5961, %rsi
lea addresses_WT_ht+0x1a2e1, %rdi
nop
nop
nop
nop
cmp $61075, %rax
mov $9, %rcx
rep movsq
nop
and $19565, %rcx
lea addresses_A_ht+0xf951, %rax
nop
nop
nop
nop
add $59142, %r10
mov (%rax), %rdi
nop
inc %rsi
lea addresses_normal_ht+0x7fe1, %rdi
xor %rcx, %rcx
mov (%rdi), %r10d
nop
nop
nop
nop
mfence
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r8
push %r9
push %rbp
push %rdx
// Store
lea addresses_normal+0x43e1, %rdx
nop
sub $31373, %r9
movw $0x5152, (%rdx)
cmp %r9, %r9
// Store
lea addresses_normal+0x1c1e1, %rbp
nop
nop
nop
nop
nop
and $14366, %r11
mov $0x5152535455565758, %r14
movq %r14, %xmm7
movups %xmm7, (%rbp)
nop
dec %r11
// Store
lea addresses_UC+0xbe61, %r8
sub %r9, %r9
movb $0x51, (%r8)
// Exception!!!
nop
nop
nop
nop
nop
mov (0), %r9
nop
nop
nop
nop
add $12618, %r11
// Faulty Load
lea addresses_A+0x2be1, %r9
and $10361, %r8
vmovups (%r9), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rbp
lea oracles, %r8
and $0xff, %rbp
shlq $12, %rbp
mov (%r8,%rbp,1), %rbp
pop %rdx
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_A', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal', 'congruent': 8}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC', 'congruent': 7}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 3}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 10}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 6}}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 3, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC_ht', 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 4}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 1}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC_ht', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 4}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 8}}
{'45': 1, '95': 9, '00': 21}
00 00 00 00 00 95 95 00 00 95 95 00 00 95 00 00 00 95 00 00 95 00 45 95 95 00 00 00 00 00 00
*/
|
src/test/resources/data/searchtests/test4-expected.asm | cpcitor/mdlz80optimizer | 36 | 243656 | ld b, c
|
src/test01/src/mytasks.ads | hannesb0/rtpl18 | 0 | 20768 | <filename>src/test01/src/mytasks.ads
-- Task 2 of RTPL WS17/18
-- Team members: <NAME>. and <NAME>.
package myTasks with SPARK_Mode is
-- Procedure for option 5
procedure opt5;
-- Procedure for option 6
procedure opt6;
-- Procedure for option 7
procedure opt7;
-- User defined task for growing of elements
task type myGrow;
-- To stop myGrow task enable this flag
myGrowEnd : Boolean := False;
private
-- Float values for user input
-- F1 : Float := 1.0;
-- F2 : Float := 2.0;
-- Integer value for user input
I1 : Integer := 0;
-- Control character for user input
C1 : Character := ' ';
-- Amount to store
Amount : Integer := 0;
-- Mutex if Amount can be changed
Available : Boolean := True;
-- Grow enabled / disabled
GrowEnable : Boolean := False;
-- User defined task to add / remove elements
task type myAmount is
entry Sub (min : in Integer);
entry Add (sum : in Integer);
end myAmount;
end myTasks;
|
audio/music/newbarktown.asm | Dev727/ancientplatinum | 28 | 97609 | Music_NewBarkTown:
musicheader 3, 1, Music_NewBarkTown_Ch1
musicheader 1, 2, Music_NewBarkTown_Ch2
musicheader 1, 3, Music_NewBarkTown_Ch3
db $3
Music_NewBarkTown_Ch1:
tempo 187
volume $77
stereopanning $f
vibrato $12, $23
notetype $c, $87
note __, 4
Music_NewBarkTown_branch_eb2eb:
dutycycle $0
callchannel Music_NewBarkTown_branch_eb349
octave 3
note C#, 1
note __, 1
octave 2
note A_, 1
note __, 1
octave 3
note G_, 2
note F#, 2
dutycycle $2
intensity $82
note E_, 1
note F#, 1
note E_, 1
note D_, 1
note C#, 1
octave 2
note B_, 1
note A_, 1
note G_, 1
dutycycle $0
intensity $87
callchannel Music_NewBarkTown_branch_eb349
octave 3
note C#, 1
note __, 1
octave 2
note A_, 1
note __, 1
octave 3
note E_, 2
dutycycle $2
intensity $82
note C#, 1
note __, 1
octave 2
note A_, 1
octave 3
note C#, 1
note E_, 1
note G_, 1
note A_, 1
octave 4
note C#, 1
note E_, 1
note A_, 1
dutycycle $1
intensity $5e
callchannel Music_NewBarkTown_branch_eb37c
callchannel Music_NewBarkTown_branch_eb37c
callchannel Music_NewBarkTown_branch_eb37c
octave 2
note G_, 2
note B_, 2
octave 3
note D_, 2
note F#, 4
note G_, 4
note D_, 2
octave 2
note A_, 2
octave 3
note C#, 2
note E_, 2
note G_, 4
note A_, 4
note B_, 2
intensity $87
loopchannel 0, Music_NewBarkTown_branch_eb2eb
Music_NewBarkTown_branch_eb349:
octave 3
note F#, 1
note __, 1
note D_, 1
note __, 1
note A_, 2
note D_, 1
note __, 1
note F#, 1
note __, 1
note D_, 1
note __, 1
note A#, 2
note D_, 1
note __, 1
note F#, 1
note __, 1
note D_, 1
note __, 1
note B_, 2
note F#, 1
note __, 1
note F#, 1
note __, 1
note D_, 1
note __, 1
octave 4
note C_, 2
octave 3
note D_, 1
note __, 1
octave 2
note B_, 1
note __, 1
note G_, 1
note __, 1
octave 3
note G_, 2
octave 2
note B_, 1
note __, 1
note B_, 1
note __, 1
note G#, 1
note __, 1
octave 3
note E_, 2
octave 2
note B_, 1
note __, 1
endchannel
Music_NewBarkTown_branch_eb37c:
octave 2
note G_, 2
note B_, 2
octave 3
note D_, 2
note F#, 4
note G_, 4
note D_, 2
octave 2
note A_, 2
octave 3
note C#, 2
note E_, 2
note G_, 4
note A_, 4
note E_, 2
endchannel
Music_NewBarkTown_Ch2:
stereopanning $ff
vibrato $12, $23
notetype $6, $a7
note __, 8
Music_NewBarkTown_branch_eb396:
dutycycle $2
notetype $6, $a7
callchannel Music_NewBarkTown_branch_eb3bf
callchannel Music_NewBarkTown_branch_eb3bf
callchannel Music_NewBarkTown_branch_eb3f2
intensity $87
octave 5
note B_, 6
note A_, 6
intensity $77
octave 6
note D_, 4
note C#, 16
callchannel Music_NewBarkTown_branch_eb3f2
intensity $87
octave 5
note B_, 6
note A_, 6
intensity $77
octave 6
note D_, 4
note E_, 16
loopchannel 0, Music_NewBarkTown_branch_eb396
Music_NewBarkTown_branch_eb3bf:
octave 2
note D_, 4
note __, 8
note D_, 1
note __, 1
note D_, 1
note __, 1
note D_, 2
note __, 2
note D_, 8
note A#, 2
note __, 2
note D_, 4
note __, 8
note D_, 1
note __, 1
note D_, 1
note __, 1
note D_, 2
note __, 2
note D_, 8
octave 3
note C_, 2
note __, 2
octave 2
note G_, 4
note __, 8
note G_, 1
note __, 1
note G_, 1
note __, 1
octave 1
note G#, 2
note __, 2
note G#, 8
octave 2
note D_, 2
note __, 2
note A_, 4
note __, 8
note A_, 1
note __, 1
note A_, 1
note __, 1
octave 1
note A_, 2
note __, 2
note A_, 8
octave 2
note C#, 4
endchannel
Music_NewBarkTown_branch_eb3f2:
notetype $6, $97
dutycycle $2
octave 4
note B_, 12
note A_, 12
note G_, 8
notetype $c, $97
note E_, 16
endchannel
Music_NewBarkTown_Ch3:
stereopanning $f0
notetype $c, $10
octave 5
note D_, 2
note E_, 2
Music_NewBarkTown_branch_eb408:
vibrato $16, $23
note F#, 4
note A_, 4
note G_, 2
note F#, 2
note E_, 2
note G_, 2
note F#, 6
note D_, 2
octave 4
note A_, 6
note G_, 1
note A_, 1
note B_, 4
octave 5
note D_, 4
note E_, 2
note D_, 2
note C#, 2
note D_, 2
note E_, 6
note F#, 2
note E_, 4
note __, 2
note D_, 1
note E_, 1
note F#, 4
note A_, 4
note A#, 2
note A_, 2
note G_, 2
note A#, 2
note A_, 6
octave 6
note C#, 2
note D_, 6
octave 5
note E_, 1
note F#, 1
note G_, 6
note A_, 2
note B_, 8
note A_, 6
note G_, 1
note F#, 1
note E_, 4
note __, 4
intensity $25
vibrato $12, $53
octave 2
note G_, 16
note A_, 16
note G_, 16
note A_, 16
note G_, 16
note A_, 16
note G_, 16
note A_, 14
intensity $10
vibrato $16, $23
octave 5
note D_, 1
note E_, 1
loopchannel 0, Music_NewBarkTown_branch_eb408
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.