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
compiler/ti-cgt-arm_18.12.4.LTS/lib/src/i_tofd16.asm
JosiahCraw/TI-Arm-Docker
0
90896
<gh_stars>0 ;****************************************************************************** ;* I_TOFD16.ASM - 16 BIT STATE - * ;* * ;* Copyright (c) 1996 Texas Instruments Incorporated * ;* http://www.ti.com/ * ;* * ;* 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 Texas Instruments Incorporated nor the names * ;* of its contributors may be used to endorse or promote products * ;* derived from this software without specific prior written * ;* permission. * ;* * ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * ;* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * ;* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * ;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * ;* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * ;* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * ;* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ;* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ;* * ;****************************************************************************** ;**************************************************************************** ;* I$TOFD - CONVERT AN SIGNED 32 BIT INTEGER INTO AN IEEE 754 FORMAT ;* DOUBLE PRECISION FLOATING POINT ;**************************************************************************** ;* ;* o INPUT OP IS IN r0 ;* o RESULT IS RETURNED IN r0:r1 ;* ;**************************************************************************** ;* ;* +------------------------------------------------------------------+ ;* | DOUBLE PRECISION FLOATING POINT FORMAT | ;* | 64-bit representation | ;* | 31 30 20 19 0 | ;* | +-+----------+---------------------+ | ;* | |S| E | M1 | | ;* | +-+----------+---------------------+ | ;* | | ;* | 31 0 | ;* | +----------------------------------+ | ;* | | M2 | | ;* | +----------------------------------+ | ;* | | ;* | <S> SIGN FIELD : 0 - POSITIVE VALUE | ;* | 1 - NEGATIVE VALUE | ;* | | ;* | <E> EXPONENT FIELD: 0000000000 - ZERO IFF M == 0 | ;* | 0000000001..1111111110 - EXPONENT VALUE(1023 BIAS) | ;* | 1111111111 - INFINITY | ;* | | ;* | <M1:M2> MANTISSA FIELDS: FRACTIONAL MAGNITUDE WITH IMPLIED 1 | ;* +------------------------------------------------------------------+ ;* ;**************************************************************************** .thumb .if __TI_EABI_ASSEMBLER ; ASSIGN EXTERNAL NAMES BASED ON .asg __aeabi_i2d, __TI_I$TOFD ; RTS BEING BUILT .else .clink .asg I$TOFD, __TI_I$TOFD .endif .if .TMS470_BIG_DOUBLE rp1_hi .set r0 ; High word of regpair 1 rp1_lo .set r1 ; Low word of regpair 1 .else rp1_hi .set r1 ; High word of regpair 1 rp1_lo .set r0 ; Low word of regpair 1 .endif e0 .set r2 .if __TI_ARM9ABI_ASSEMBLER | __TI_EABI_ASSEMBLER .thumbfunc __TI_I$TOFD .endif .global __TI_I$TOFD __TI_I$TOFD: .asmfunc stack_usage(4) PUSH {r2} ; SAVE CONTEXT MOVS e0, #0x4 ; PRESETUP FOR EXPONENT FIELD CMP r0, #0 ; IF ZERO, RETURN ZERO BNE $1 ; MOVS r1, #0 ; POP {r2} ; BX lr ; $1: BPL $2 ; IF NEGATIVE, ENCODE SIGN IN THE ADDS e0, #0x8 ; EXPONENT FIELD NEGS r0, r0 ; $2: LSLS e0, e0, #8 ; SETUP REMAINDER OF THE EXPONENT FIELD ADDS e0, #0x1F ; .if .TMS470_LITTLE_DOUBLE MOVS rp1_hi, r0 ; .endif loop: SUBS e0, e0, #0x1 ; NORMALIZE THE MANTISSA LSLS rp1_hi, rp1_hi, #1 ; ADJUSTING THE EXPONENT, ACCORDINGLY BCC loop ; done: LSLS rp1_lo, rp1_hi, #20 ; SETUP LOW HALF OF RESULT LSRS rp1_hi, rp1_hi, #12 ; SETUP HIGH HALF OF RESULT LSLS e0, e0, #20 ; ORRS rp1_hi, e0 ; POP {r2} ; BX lr ; .endasmfunc .end
custom_procs/readnum.asm
YuraIz/tasm-labs
0
12429
<reponame>YuraIz/tasm-labs .model small .code main: call readnum mov ax, bx call printnum exit: mov ah, 04Ch mov al, 0 int 21h readnum: mov bx, 0 mov ah, 01h int 21h cmp al, 2dh je negative call analyze ret negative: call rpos not bx add bx, 1 ret rpos: mov ah, 01h int 21h analyze: cmp al, 0dh je endl cmp al, 10 je endl sub al, 48 mov ah, 0 push ax mov ax, 10 mul bx mov bx, ax pop ax add bx, ax call rpos endl: ret printnum: cmp ax, 0 jz pzero jnl ppos mov dl, '-' push ax mov ah, 02h int 21h pop ax not ax add ax, 1 ppos: ;used: ax dx bx cmp ax, 0 jz zero mov dx, 0 mov bx, 10 div bx add dl, 48 push dx call ppos pop dx push ax mov ah, 02h int 21h pop ax zero: ret pzero: mov dl, 30h mov ah, 02h int 21h ret end main
rewrite-maven/src/main/antlr/VersionRangeLexer.g4
kevinvandervlist/rewrite
457
3232
<reponame>kevinvandervlist/rewrite<gh_stars>100-1000 lexer grammar VersionRangeLexer; COMMA : ',' ; PROPERTY_OPEN : '${'; PROPERTY_CLOSE : '}'; OPEN_RANGE_OPEN : '(' ; OPEN_RANGE_CLOSE : ')' ; CLOSED_RANGE_OPEN : '[' ; CLOSED_RANGE_CLOSE : ']' ; Version : [0-9+\-_.a-zA-Z]+; WS : [ \t\r\n\u000C]+ -> skip ;
src/util-serialize-mappers-record_mapper.ads
Letractively/ada-util
60
27999
<reponame>Letractively/ada-util ----------------------------------------------------------------------- -- Util.Serialize.Mappers.Record_Mapper -- Mapper for record types -- Copyright (C) 2010, 2011, 2012 <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.Beans.Objects; with Util.Serialize.IO; generic type Element_Type (<>) is limited private; type Element_Type_Access is access all Element_Type; type Fields is (<>); -- The <b>Set_Member</b> procedure will be called by the mapper when a mapping associated -- with <b>Field</b> is recognized. The <b>Value</b> holds the value that was extracted -- according to the mapping. The <b>Set_Member</b> procedure should save in the target -- object <b>Into</b> the value. If an error is detected, the procedure can raise the -- <b>Util.Serialize.Mappers.Field_Error</b> exception. The exception message will be -- reported by the IO reader as an error. with procedure Set_Member (Into : in out Element_Type; Field : in Fields; Value : in Util.Beans.Objects.Object); -- Adding a second function/procedure as generic parameter makes the -- Vector_Mapper generic package fail to instantiate a valid package. -- The failure occurs in Vector_Mapper in the 'with package Element_Mapper' instantiation. -- -- with function Get_Member (From : in Element_Type; -- Field : in Fields) return Util.Beans.Objects.Object; package Util.Serialize.Mappers.Record_Mapper is type Get_Member_Access is access function (From : in Element_Type; Field : in Fields) return Util.Beans.Objects.Object; -- Procedure to give access to the <b>Element_Type</b> object from the context. type Process_Object is not null access procedure (Ctx : in out Util.Serialize.Contexts.Context'Class; Attr : in Mapping'Class; Value : in Util.Beans.Objects.Object; Process : not null access procedure (Attr : in Mapping'Class; Item : in out Element_Type; Value : in Util.Beans.Objects.Object)); type Proxy_Object is not null access procedure (Attr : in Mapping'Class; Element : in out Element_Type; Value : in Util.Beans.Objects.Object); -- Set the attribute member described by the <b>Attr</b> mapping -- into the value passed in <b>Element</b>. This operation will call -- the package parameter function of the same name. procedure Set_Member (Attr : in Mapping'Class; Element : in out Element_Type; Value : in Util.Beans.Objects.Object); -- ----------------------- -- Data context -- ----------------------- -- Data context to get access to the target element. type Element_Data is new Util.Serialize.Contexts.Data with private; type Element_Data_Access is access all Element_Data'Class; -- Get the element object. function Get_Element (Data : in Element_Data) return Element_Type_Access; -- Set the element object. When <b>Release</b> is set, the element <b>Element</b> -- will be freed when the reader context is deleted (by <b>Finalize</b>). procedure Set_Element (Data : in out Element_Data; Element : in Element_Type_Access; Release : in Boolean := False); -- Finalize the object when it is removed from the reader context. -- If the <b>Release</b> parameter was set, the target element will be freed. overriding procedure Finalize (Data : in out Element_Data); -- ----------------------- -- Record mapper -- ----------------------- type Mapper is new Util.Serialize.Mappers.Mapper with private; type Mapper_Access is access all Mapper'Class; -- Execute the mapping operation on the object associated with the current context. -- The object is extracted from the context and the <b>Execute</b> operation is called. procedure Execute (Handler : in Mapper; Map : in Mapping'Class; Ctx : in out Util.Serialize.Contexts.Context'Class; Value : in Util.Beans.Objects.Object); -- Add a mapping for setting a member. When the attribute rule defined by <b>Path</b> -- is matched, the <b>Set_Member</b> procedure will be called with the value and the -- <b>Field</b> identification. procedure Add_Mapping (Into : in out Mapper; Path : in String; Field : in Fields); -- Add a mapping associated with the path and described by a mapper object. -- The <b>Proxy</b> procedure is in charge of giving access to the target -- object used by the <b>Map</b> mapper. procedure Add_Mapping (Into : in out Mapper; Path : in String; Map : in Util.Serialize.Mappers.Mapper_Access; Proxy : in Proxy_Object); -- Clone the <b>Handler</b> instance and get a copy of that single object. overriding function Clone (Handler : in Mapper) return Util.Serialize.Mappers.Mapper_Access; -- procedure Bind (Into : in out Mapper; Getter : in Get_Member_Access); procedure Bind (Into : in out Mapper; From : in Mapper_Access); function Get_Getter (From : in Mapper) return Get_Member_Access; -- Set the element in the context. When <b>Release</b> is set, the element <b>Element</b> -- will be freed when the reader context is deleted (by <b>Finalize</b>). procedure Set_Context (Ctx : in out Util.Serialize.Contexts.Context'Class; Element : in Element_Type_Access; Release : in Boolean := False); -- Build a default mapping based on the <b>Fields</b> enumeration. -- The enumeration name is used for the mapping name with the optional <b>FIELD_</b> -- prefix stripped. procedure Add_Default_Mapping (Into : in out Mapper); -- Write the element on the stream using the mapper description. procedure Write (Handler : in Mapper; Stream : in out Util.Serialize.IO.Output_Stream'Class; Element : in Element_Type); -- Write the element on the stream using the mapper description. procedure Write (Handler : in Util.Serialize.Mappers.Mapper'Class; Getter : in Get_Member_Access; Stream : in out Util.Serialize.IO.Output_Stream'Class; Element : in Element_Type); private type Element_Data is new Util.Serialize.Contexts.Data with record Element : Element_Type_Access; Release : Boolean; end record; type Mapper is new Util.Serialize.Mappers.Mapper with record Execute : Proxy_Object := Set_Member'Access; Get_Member : Get_Member_Access; end record; type Attribute_Mapping is new Mapping with record Index : Fields; end record; type Attribute_Mapping_Access is access all Attribute_Mapping'Class; procedure Set_Member (Attr : in Attribute_Mapping; Element : in out Element_Type; Value : in Util.Beans.Objects.Object); type Proxy_Mapper is new Mapper with null record; type Proxy_Mapper_Access is access all Proxy_Mapper'Class; -- Find the mapper associated with the given name. -- Returns null if there is no mapper. overriding function Find_Mapper (Controller : in Proxy_Mapper; Name : in String; Attribute : in Boolean := False) return Util.Serialize.Mappers.Mapper_Access; end Util.Serialize.Mappers.Record_Mapper;
fnv1hash.asm
JonathonReinhart/h2incn
1
246409
; ; FNV1HASH.ASM : FNV-1 Hash algorithm ; Author : <NAME> ; ; Copyright (C)2010 Piranha Designs, LLC - All rights reserved. ; Source code is licensed under the new/simplified 2-clause BSD OSI license. ; ; This function implements the FNV-1 hash algorithm. ; This source file is formatted for Nasm compatibility although it ; is small enough to be easily converted into another assembler format. ; ; Example C/C++ call: ; ; #ifdef __cplusplus ; extern "C" { ; #endif ; ; unsigned int FNV1Hash(char *buffer, unsigned int len, unsigned int offset_basis); ; ; #ifdef __cplusplus ; } ; #endif ; ; int hash; ; ; /* obtain 32-bit FNV1 hash */ ; hash = FNV1Hash(buffer, len, 2166136261); ; ; /* if desired - convert from a 32-bit to 16-bit hash */ ; hash = ((hash >> 16) ^ (hash & 0xFFFF)); ; ; uncomment the following line to get FNV1A behavior %define FNV1A 1 [section .text] %ifidni __BITS__,32 ; ; 32-bit C calling convention ; %define buffer [ebp+8] %define len [ebp+12] %define offset_basis [ebp+16] global _FNV1Hash _FNV1Hash: push ebp ; set up stack frame mov ebp, esp push esi ; save registers used push edi push ebx mov esi, buffer ; esi = ptr to buffer mov ecx, len ; ecx = length of buffer (counter) mov eax, offset_basis ; set to 2166136261 for FNV-1 mov edi, 1000193h ; FNV_32_PRIME = 16777619 xor ebx, ebx ; ebx = 0 nextbyte: %ifdef FNV1A mov bl, byte[esi] ; bl = byte from esi xor eax, ebx ; al = al xor bl mul edi ; eax = eax * FNV_32_PRIME %else mul edi ; eax = eax * FNV_32_PRIME mov bl, byte[esi] ; bl = byte from esi xor eax, ebx ; al = al xor bl %endif inc esi ; esi = esi + 1 (buffer pos) dec ecx ; ecx = ecx - 1 (counter) jnz nextbyte ; if ecx != 0, jmp to nextbyte pop ebx ; restore registers pop edi pop esi mov esp, ebp ; restore stack frame pop ebp ret ; eax = fnv1 hash %elifidni __BITS__,64 ; ; 64-bit function ; %ifidni __OUTPUT_FORMAT__,win64 ; ; 64-bit Windows fastcall convention: ; ints/longs/ptrs: RCX, RDX, R8, R9 ; floats/doubles: XMM0 to XMM3 ; global FNV1Hash FNV1Hash: xchg rcx, rdx ; rcx = length of buffer xchg r8, rdx ; r8 = ptr to buffer %elifidni __OUTPUT_FORMAT__,elf64 ; ; 64-bit Linux fastcall convention ; ints/longs/ptrs: RDI, RSI, RDX, RCX, R8, R9 ; floats/doubles: XMM0 to XMM7 global _FNV1Hash _FNV1Hash: mov rcx, rsi mov r8, rdi %endif mov rax, rdx ; rax = offset_basis - set to 14695981039346656037 for FNV-1 mov r9, 100000001B3h ; r9 = FNV_64_PRIME = 1099511628211 mov r10, rbx ; r10 = saved copy of rbx xor rbx, rbx ; rbx = 0 nextbyte: %ifdef FNV1A mov bl, byte[r8] ; bl = byte from r8 xor rax, rbx ; al = al xor bl mul r9 ; rax = rax * FNV_64_PRIME %else mul r9 ; rax = rax * FNV_64_PRIME mov bl, byte[r8] ; bl = byte from r8 xor rax, rbx ; al = al xor bl %endif inc r8 ; inc buffer pos dec rcx ; rcx = rcx - 1 (counter) jnz nextbyte ; if rcx != 0, jmp to nextbyte mov rbx, r10 ; restore rbx ret ; rax = fnv1 hash %endif
BigIntSimple/Mul.asm
andreasimonassi/bigint
0
179232
.data .code ;int LongMulAsm( ; qword * A, RCX ; int ASizeInQWords, RDX ; qword * B, R8 ; int BSizeInQWords, R9 ; qword * R ON STACK ; ); ; RAX, RCX, RDX, R8, R9, R10, R11 VOLATILE ; RAX used to store cpu flags LongMulAsm proc ; mul by zero ret 0 xor rax, rax test rdx, rdx jz immediate_ret test r9,r9 jz immediate_ret ;stack frame push rbp mov rbp, rsp ;non volatile push rdi push rsi push rbx push r12 push r13 push r14 push r15 mov rdi, qword ptr [rbp + 60o] mov rsi, rdx ;compute result size for zeroing output array mov rax, rdx add rax, r9 sub rax, 1 reset_output_loop_start: js reset_output_loop_end mov qword ptr [rdi+rax*8], 0 sub rax, 1 jmp reset_output_loop_start reset_output_loop_end: ; j = 0 xor rbx, rbx xor r15,r15 sub r15, 1 ;while (j < m ) left_number_loop_start: cmp rbx, rdx jnl left_number_loop_ends ; A[j] in rax mov rax, qword ptr [rcx + rbx * 8] ; if(A[j] == 0) continue; low cost optimization skip inner loop if number is zero ;test rax, rax ;that branch not going to be smart ;jz left_number_loop_continue ;i=0; xor r10, r10 mov [rbp + 60o], rax ;save A[j] in [rbp + 60o] ;while(i < n) right_number_loop_start: cmp r10, r9 ; r9 size of right number jnl right_number_loop_ends ;unsigned k = i + j; mov r11, rbx ; k = j add r11, r10 ; k += i ; B[i] in r13 mov r13, qword ptr [r8 + r10 * 8] ; B[i] in R13 ; if(B[i] == 0) continue; ;test r13,r13 ;that branch not that smart ;jz right_number_loop_continue ;low cost optimization, skip loop if zero ;rax <-A[j] mov rax, [rbp + 60o]; ; rdx:rax = B[i] * A[j] mul r13 ; if cf then overflow so dx has higher order digit mov r13, rax ; save value of rax, i need rax to store flags mov r14, r11 add r14, 1 add qword ptr [rdi+r11*8], r13 ; R[k] = R[k] + loword cmovnz r15, r11 adc qword ptr [rdi+r14*8], rdx ; cmovnz r15, r14 propagate_carry: jnc no_more_carry inc r14 ; inc preserve carry adc qword ptr [rdi+r14*8], 0; cmovnz r15, r14 jmp propagate_Carry no_more_carry: right_number_loop_continue: add r10, 1 jmp right_number_loop_start right_number_loop_ends: left_number_loop_continue: add rbx, 1 mov rdx, rsi; recover rdx from shadow copy jmp left_number_loop_start left_number_loop_ends: ; msd in rax to return mov rax , r15 add rax, 1 ; resume stack frame & non volatile pop r15 pop r14 pop r13 pop r12 pop rbx pop rsi pop rdi mov rsp, rbp pop rbp immediate_ret: ret LongMulAsm endp end
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_1709.asm
ljhsiun2/medusa
9
84793
<reponame>ljhsiun2/medusa<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r15 push %r8 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1072c, %rsi lea addresses_WC_ht+0x1846c, %rdi nop nop nop dec %r10 mov $74, %rcx rep movsl nop nop add $34241, %r14 lea addresses_normal_ht+0x39e1, %r8 nop nop nop nop mfence movw $0x6162, (%r8) nop nop nop nop nop cmp %r10, %r10 lea addresses_WC_ht+0x528c, %r15 nop nop nop nop nop dec %r10 movw $0x6162, (%r15) add %rcx, %rcx lea addresses_D_ht+0x1bbee, %r15 nop add $7793, %r14 movl $0x61626364, (%r15) nop nop inc %r15 lea addresses_WC_ht+0x12a4c, %rsi lea addresses_D_ht+0x16a6c, %rdi xor %r13, %r13 mov $57, %rcx rep movsq nop nop nop nop nop xor $48864, %rcx lea addresses_UC_ht+0x1ab2c, %r15 clflush (%r15) nop nop nop nop xor %rdi, %rdi and $0xffffffffffffffc0, %r15 movntdqa (%r15), %xmm1 vpextrq $1, %xmm1, %rsi nop nop nop nop inc %r15 lea addresses_UC_ht+0x1226c, %rsi lea addresses_A_ht+0x1542c, %rdi nop nop nop dec %r8 mov $125, %rcx rep movsq nop and %rcx, %rcx lea addresses_WC_ht+0x944c, %r15 dec %r10 mov $0x6162636465666768, %rsi movq %rsi, %xmm7 movups %xmm7, (%r15) nop nop nop and %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %r8 pop %r15 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r9 push %rax push %rsi // Faulty Load lea addresses_D+0x212c, %r12 xor %r9, %r9 movups (%r12), %xmm7 vpextrq $0, %xmm7, %rsi lea oracles, %r15 and $0xff, %rsi shlq $12, %rsi mov (%r15,%rsi,1), %rsi pop %rsi pop %rax pop %r9 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_D', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}} {'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'src': {'NT': True, 'same': False, 'congruent': 9, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
math16_test/math16_test.asm
nealvis/nv_c64_util_test
0
99832
////////////////////////////////////////////////////////////////////////////// // math16_test.asm // Copyright(c) 2021 <NAME>. // License: MIT. See LICENSE file in root directory. ////////////////////////////////////////////////////////////////////////////// // This program tests the 16bit math operations in the nv_c64_util // repository in the file nv_math16_macs.asm // such as add, subtract, and compare, etc. ////////////////////////////////////////////////////////////////////////////// // import all nv_c64_util macros and data. The data // will go in default place #import "../../nv_c64_util/nv_c64_util_macs_and_data.asm" *=$0800 "BASIC Start" .byte 0 // first byte should be 0 // location to put a 1 line basic program so we can just // type run to execute the assembled program. // will just call assembled program at correct location // 10 SYS (4096) // These bytes are a one line basic program that will // do a sys call to assembly language portion of // of the program which will be at $1000 or 4096 decimal // basic line is: // 10 SYS (4096) .byte $0E, $08 // Forward address to next basic line .byte $0A, $00 // this will be line 10 ($0A) .byte $9E // basic token for SYS .byte $20, $28, $34, $30, $39, $36, $29 // ASCII for " (4096)" .byte $00, $00, $00 // end of basic program (addr $080E from above) *=$0820 "Vars" .const dollar_sign = $24 result_byte: .byte 0 // program variables carry_str: .text @"(C) \$00" carry_and_overflow_str: .text @"(CV) \$00" overflow_str: .text @"(V) \$00" plus_str: .text @"+\$00" minus_str: .text @"-\$00" equal_str: .text@"=\$00" lsr_str: .text@">>\$00" asl_str: .text@"<<\$00" title_str: .text @"MATH16\$00" // null terminated string to print // via the BASIC routine title_adc16_str: .text @"TEST ADC16 \$00" title_adc16_mem8u_str: .text @"TEST ADC16 MEM8U \$00" title_adc16_a8u_str: .text @"TEST ADC16 A8U \$00" title_adc16_8s_str: .text @"TEST ADC16 8S \$00" title_adc16_immediate_str: .text @"TEST ADC16 IMMED\$00" title_lsr16_str: .text @"TEST LSR16 \$00" title_asl16_str: .text @"TEST ASL16 \$00" title_sbc16_str: .text @"TEST SBC16 \$00" #import "../test_util/test_util_op16_data.asm" #import "../test_util/test_util_op8_data.asm" *=$1000 "Main Start" .var row = 0 nv_screen_print_str(normal_control_str) nv_screen_clear() nv_screen_plot_cursor(row++, 33) nv_screen_print_str(title_str) test_adc16(0) test_adc16_immediate(0) test_adc16_8u(false, 0) test_adc16_8u(true, 0) test_adc16_8s(0) test_lsr16(0) test_asl16(0) rts ////////////////////////////////////////////////////////////////////////////// // .macro test_adc16(init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) nv_screen_print_str(title_adc16_str) ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_FFFF, op16_FFFF, result, $FFFE, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_0001, op16_0002, result, $0003, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_7FFF, op16_0002, result, $8001, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_0001, op16_FFFF, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_FFFF, op16_0000, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_00FF, op16_0001, result, $0100, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_00FF, op16_FF00, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_FF00, op16_00FF, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_7FFF, op16_FFFF, result, $7FFE, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_7FFF, op16_0001, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_7FFF, op16_0002, result, $8001, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_FFFE, op16_0002, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_FFFE, op16_0001, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_007F, op16_0001, result, $0080, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16(op16_557F, op16_2201, result, $7780, false, false, false) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // .macro test_adc16_8u(use_a, init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) .if (use_a) { nv_screen_print_str(title_adc16_a8u_str) } else { nv_screen_print_str(title_adc16_mem8u_str) } ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFF, op8_FF, result, $00FE, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_0001, op8_02, result, $0003, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_0001, op8_FF, result, $0100, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFF, op8_00, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_00FF, op8_01, result, $0100, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_00FF, op8_7F, result, $017E, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FF00, op8_FF, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_7FFF, op8_01, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_BEEF, op8_0F, result, $BEFE, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_BEEF, op8_F0, result, $BFDF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFF, op8_F0, result, $00EF, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFF, op8_FF, result, $00FE, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_7FFF, op8_FF, result, $80FE, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_7FFF, op8_01, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_7FFF, op8_02, result, $8001, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFE, op8_02, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8u(use_a, op16_FFFE, op8_01, result, $FFFF, false, false, true) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // .macro test_adc16_8s(init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) nv_screen_print_str(title_adc16_8s_str) ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFF, op8_FF, result, $FFFE, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_0001, op8_02, result, $0003, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_0001, op8_FF, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFF, op8_00, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_0001, op8_80, result, $FF81, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_0080, op8_80, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_0081, op8_80, result, $0001, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_00FF, op8_01, result, $0100, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_00FF, op8_7F, result, $017E, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FF00, op8_FF, result, $FEFF, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_7FFF, op8_01, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_BEEF, op8_0F, result, $BEFE, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_BEEF, op8_F0, result, $BEDF, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFF, op8_F0, result, $FFEF, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFF, op8_FF, result, $FFFE, true, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_7FFF, op8_FF, result, $7FFE, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_7FFF, op8_01, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_7FFF, op8_02, result, $8001, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFE, op8_02, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_8s(op16_FFFE, op8_01, result, $FFFF, false, false, true) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // .macro test_adc16_immediate(init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) nv_screen_print_str(title_adc16_immediate_str) ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_FFFF, $36B1, result, $36B0, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_0001, $0002, result, $0003, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_0001, $FFFF, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_FFFF, $0000, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_00FF, $0001, result, $0100, false, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_00FF, $FF00, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_FF00, $00FF, result, $FFFF, false, false, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_7FFF, $FFFF, result, $7FFE, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_7FFF, $0001, result, $8000, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_7FFF, $0002, result, $8001, false, true, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_FFFE, $0002, result, $0000, true, false, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) // C V N print_adc16_immediate(op16_FFFE, $0001, result, $FFFF, false, false, true) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // .macro test_lsr16(init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) nv_screen_print_str(title_lsr16_str) ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 0, $8000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 1, $4000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 2, $2000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 3, $1000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 4, $0800, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 5, $0400, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 6, $0200, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 7, $0100, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 8, $0080, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 9, $0040, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 10, $0020, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 11, $0010, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 12, $0008, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 13, $0004, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 14, $0002, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 15, $0001, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_8000, 16, $0000, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_FFFF, 1, $7FFF, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_FFFF, 2, $3FFF, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_lsr16(op16_FFFF, 3, $1FFF, true) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // .macro test_asl16(init_row) { .var row = init_row ////////////////////////////////////////////////////////////////////////// nv_screen_plot_cursor(row++, 0) nv_screen_print_str(title_asl16_str) ////////////////////////////////////////////////////////////////////////// .eval row++ ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_8000, 0, $8000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_8000, 1, $0000, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_8000, 2, $0000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 0, $0001, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 1, $0002, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 2, $0004, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 3, $0008, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 4, $0010, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 5, $0020, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 6, $0040, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 7, $0080, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 8, $0100, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 9, $0200, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 10, $0400, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 11, $0800, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 12, $1000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 13, $2000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 14, $4000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 15, $8000, false) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 16, $0000, true) ///////////////////////////// nv_screen_plot_cursor(row++, 0) print_asl16(op16_0001, 17, $0000, false) wait_and_clear_at_row(row, title_str) } ////////////////////////////////////////////////////////////////////////////// // Print macros ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specified addition at the current curor location // nv_adc16x is used to do the addition. .macro print_adc16(op1, op2, result, expected_result, expect_carry_set, expect_overflow_set, expect_neg_set) { lda #1 sta passed //nv_screen_print_hex_word_mem(op1, true) nv_xfer16_mem_mem(op1, word_to_print) jsr PrintHexWord nv_screen_print_str(plus_str) //nv_screen_print_hex_word_mem(op2, true) nv_xfer16_mem_mem(op2, word_to_print) jsr PrintHexWord nv_screen_print_str(equal_str) nv_adc16x(op1, op2, result) php nv_beq16_immed(result, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(result, true) nv_xfer16_mem_mem(result, word_to_print) jsr PrintHexWord plp pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, expect_neg_set) jsr PrintPassed } ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specified addition at the current curor location // nv_adc16x_mem16x_mem8u or nv_adc16x_mem16x_a8u is used to do the addition. // it will look like this with no carry: // $2222 + $33 = $2255 // or look like this if there is a carry: // $FFFF + $01 = (C) $0000 .macro print_adc16_8u(use_a, op16, op8, result, expected_result, expect_carry_set, expect_overflow_set, expect_neg_set) { lda #1 sta passed //nv_screen_print_hex_word_mem(op16, true) nv_xfer16_mem_mem(op16, word_to_print) jsr PrintHexWord nv_screen_print_str(plus_str) //nv_screen_print_hex_byte_mem(op8, true) lda op8 jsr PrintHexByteAccum nv_screen_print_str(equal_str) .if (use_a) { lda op8 nv_adc16x_mem16x_a8u(op16, result) } else { nv_adc16x_mem16x_mem8u(op16, op8, result) } php nv_beq16_immed(result, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(result, true) nv_xfer16_mem_mem(result, word_to_print) jsr PrintHexWord plp pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, expect_neg_set) jsr PrintPassed } ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specified addition at the current curor location // nv_adc16_8s us used to do the addition. // it will look like this with no carry: // $2222 + $33 = $2255 // or look like this if there is a carry: // $FFFF + $01 = (C) $0000 .macro print_adc16_8s(op16, op8, result, expected_result, expect_carry_set, expect_overflow_set, expect_neg_set) { lda #1 sta passed //nv_screen_print_hex_word_mem(op16, true) nv_xfer16_mem_mem(op16, word_to_print) jsr PrintHexWord nv_screen_print_str(plus_str) //nv_screen_print_hex_byte_mem(op8, true) lda op8 jsr PrintHexByteAccum nv_screen_print_str(equal_str) nv_adc16x_mem16x_mem8s(op16, op8, result) php nv_beq16_immed(result, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(result, true) nv_xfer16_mem_mem(result, word_to_print) jsr PrintHexWord plp pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, expect_neg_set) jsr PrintPassed } ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specified addition at the current curor location // nv_adc16x_mem_immed us used to do the addition. // it will look like this with no carry: // $2222 + $3333 = $5555 // or look like this if there is a carry: // $FFFF + $0001 = (C) $0000 .macro print_adc16_immediate(op1, num, result, expected_result, expect_carry_set, expect_overflow_set, expect_neg_set) { lda #1 sta passed //nv_screen_print_hex_word_mem(op1, true) nv_xfer16_mem_mem(op1, word_to_print) jsr PrintHexWord nv_screen_print_str(plus_str) //nv_screen_print_hex_word_immed(num, true) nv_store16_immed(word_to_print, num) jsr PrintHexWord nv_screen_print_str(equal_str) nv_adc16x_mem_immed(op1, num, result) php nv_beq16_immed(result, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(result, true) nv_xfer16_mem_mem(result, word_to_print) jsr PrintHexWord plp pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, expect_neg_set) jsr PrintPassed } ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specifiied logical shift right at the current // cursor position. nv_lsr16 will be used to do the operation. // it will look like this // $0001 >> 3 = $0004 // op1 is the address of the LSB of the 16 bit number to shift // num_rots is the number of rotations to do .macro print_lsr16(op1, num_rots, expected_result, expect_carry_set) { lda #1 sta passed lda op1 sta temp_lsr16 lda op1+1 sta temp_lsr16 + 1 //nv_screen_print_hex_word_mem(temp_lsr16, true) nv_xfer16_mem_mem(temp_lsr16, word_to_print) jsr PrintHexWord nv_screen_print_str(lsr_str) //nv_screen_print_hex_word_immed(num_rots, true) nv_store16_immed(word_to_print, num_rots) jsr PrintHexWord nv_screen_print_str(equal_str) nv_lsr16u_mem16u_immed8u(temp_lsr16, num_rots) php nv_beq16_immed(temp_lsr16, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(temp_lsr16, true) nv_xfer16_mem_mem(temp_lsr16, word_to_print) jsr PrintHexWord plp pass_or_fail_carry(expect_carry_set) jsr PrintPassed } temp_lsr16: .word 0 ////////////////////////////////////////////////////////////////////////////// // inline macro to print the specifiied shift left at the current // cursor position. nv_asl16_xxxx will be used to do the operation. // it will look like this // $0001 << 3 = $0008 PASSED // op1 is the address of the LSB of the 16 bit number to shift // num_rots is the number of rotations to do .macro print_asl16(op1, num_rots, expected_result, expect_carry_set) { lda #1 sta passed lda op1 sta temp_asl16 lda op1+1 sta temp_asl16 + 1 //nv_screen_print_hex_word_mem(temp_asl16, true) nv_xfer16_mem_mem(temp_asl16, word_to_print) jsr PrintHexWord nv_screen_print_str(asl_str) //nv_screen_print_hex_word_immed(num_rots, true) nv_store16_immed(word_to_print, num_rots) jsr PrintHexWord nv_screen_print_str(equal_str) nv_asl16u_mem16u_immed8u(temp_asl16, num_rots) php nv_beq16_immed(temp_asl16, expected_result, ResultGood) lda #0 sta passed ResultGood: //nv_screen_print_hex_word_mem(temp_asl16, true) nv_xfer16_mem_mem(temp_asl16, word_to_print) jsr PrintHexWord plp pass_or_fail_carry(expect_carry_set) //pass_or_fail_status_flags(expect_carry_set, expect_overflow_set, // expect_neg_set) jsr PrintPassed } temp_asl16: .word 0 #import "../test_util/test_util_code.asm"
oeis/232/A232994.asm
neoneye/loda-programs
11
9602
; A232994: a(n) = 6*(n - 3)*(n - 4)*2^(n-3)*n^(n-4). ; Submitted by <NAME> ; 0,0,240,10368,395136,15728640,680244480,32256000000,1676208500736,95105071448064,5863863973294080,390979732037959680,28060084800000000000,2158269056624017539072,177206054288314912014336,15475174380451335052984320,1432670891083019685105500160,140187732541440000000000000000 mov $1,$0 sub $1,2 mov $2,$0 bin $0,2 add $1,1 add $2,1 mul $2,2 add $2,4 pow $2,$1 mul $0,$2 mul $0,24
programs/oeis/023/A023537.asm
neoneye/loda
22
95589
<filename>programs/oeis/023/A023537.asm ; A023537: a(n) = Lucas(n+4) - (3*n+7). ; 1,5,13,28,54,98,171,291,487,806,1324,2164,3525,5729,9297,15072,24418,39542,64015,103615,167691,271370,439128,710568,1149769,1860413,3010261,4870756,7881102,12751946,20633139,33385179,54018415,87403694,141422212,228826012,370248333,599074457,969322905,1568397480,2537720506,4106118110,6643838743,10749956983,17393795859,28143752978,45537548976,73681302096,119218851217,192900153461,312119004829,505019158444,817138163430,1322157322034,2139295485627,3461452807827,5600748293623,9062201101622,14662949395420,23725150497220,38388099892821,62113250390225,100501350283233,162614600673648,263115950957074,425730551630918,688846502588191,1114577054219311,1803423556807707,2918000611027226,4721424167835144,7639424778862584,12360848946697945,20000273725560749,32361122672258917,52361396397819892,84722519070079038,137083915467899162,221806434537978435,358890350005877835,580696784543856511,939587134549734590,1520283919093591348,2459871053643326188,3980154972736917789,6440026026380244233,10420180999117162281,16860207025497406776,27280388024614569322,44140595050111976366,71420983074726545959,115561578124838522599,186982561199565068835,302544139324403591714,489526700523968660832,792070839848372252832,1281597540372340913953,2073668380220713167077,3355265920593054081325,5428934300813767248700 sub $1,$0 seq $0,23550 ; Convolution of natural numbers >= 2 and (F(2), F(3), F(4), ...). add $1,$0 sub $1,1 mov $0,$1
samples/json.adb
Letractively/ada-util
0
10165
----------------------------------------------------------------------- -- json -- JSON Reader -- Copyright (C) 2010, 2011, 2014 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Command_Line; with Util.Serialize.IO.JSON; with Ada.Containers; with Mapping; with Util.Serialize.Mappers.Vector_Mapper; with Util.Streams.Texts; with Util.Streams.Buffered; procedure Json is use Util.Streams.Buffered; use Ada.Strings.Unbounded; use type Mapping.Person_Access; use type Ada.Containers.Count_Type; Reader : Util.Serialize.IO.JSON.Parser; Count : constant Natural := Ada.Command_Line.Argument_Count; package Person_Vector_Mapper is new Util.Serialize.Mappers.Vector_Mapper (Vectors => Person_Vector, Element_Mapper => Person_Mapper); subtype Person_Vector_Context is Person_Vector_Mapper.Vector_Data; -- Mapping for a list of Person records (stored as a Vector). Person_Vector_Mapping : aliased Person_Vector_Mapper.Mapper; procedure Print (P : in Mapping.Person_Vector.Cursor); procedure Print (P : in Mapping.Person); procedure Print (P : in Mapping.Person) is begin Ada.Text_IO.Put_Line ("Name : " & To_String (P.Name)); Ada.Text_IO.Put_Line ("first_name : " & To_String (P.First_Name)); Ada.Text_IO.Put_Line ("last_name : " & To_String (P.Last_Name)); Ada.Text_IO.Put_Line ("Age : " & Natural'Image (P.Age)); Ada.Text_IO.Put_Line ("Street : " & To_String (P.Addr.Street)); Ada.Text_IO.Put_Line ("City : " & To_String (P.Addr.City)); Ada.Text_IO.Put_Line ("Zip : " & Natural'Image (P.Addr.Zip)); Ada.Text_IO.Put_Line ("Country : " & To_String (P.Addr.Country)); Ada.Text_IO.Put_Line ("Info : " & To_String (P.Addr.Info.Name) & "=" & To_String (P.Addr.Info.Value)); end Print; procedure Print (P : in Mapping.Person_Vector.Cursor) is begin Print (Mapping.Person_Vector.Element (P)); end Print; begin if Count = 0 then Ada.Text_IO.Put_Line ("Usage: json file..."); return; end if; Person_Vector_Mapping.Set_Mapping (Mapping.Get_Person_Mapper); Reader.Add_Mapping ("/list", Mapping.Get_Person_Vector_Mapper.all'Access); Reader.Add_Mapping ("/person", Mapping.Get_Person_Mapper.all'Access); for I in 1 .. Count loop declare S : constant String := Ada.Command_Line.Argument (I); List : aliased Mapping.Person_Vector.Vector; P : aliased Mapping.Person; begin Mapping.Person_Vector_Mapper.Set_Context (Reader, List'Unchecked_Access); Mapping.Person_Mapper.Set_Context (Reader, P'Unchecked_Access); Reader.Parse (S); -- The list now contains our elements. List.Iterate (Process => Print'Access); if List.Length = 0 then Print (P); end if; declare Output : Util.Serialize.IO.JSON.Output_Stream; begin Output.Initialize (Size => 10000); Mapping.Get_Person_Mapper.Write (Output, P); Ada.Text_IO.Put_Line ("Person: " & Util.Streams.Texts.To_String (Buffered_Stream (Output))); end; declare Output : Util.Serialize.IO.JSON.Output_Stream; begin Output.Initialize (Size => 10000); Output.Write ("{""list"":"); Mapping.Get_Person_Vector_Mapper.Write (Output, List); Output.Write ("}"); Ada.Text_IO.Put_Line ("IO:"); Ada.Text_IO.Put_Line (Util.Streams.Texts.To_String (Buffered_Stream (Output))); end; end; end loop; end Json;
examples/fib_tr.asm
cs101course/microprocessorExamples
0
161444
// Main // Push parameters // n LDR0 13 PUSH // b LDR0 1 PUSH // a LDR0 0 PUSH CALL FIB // R1 := return val // Release parameters POP POP POP SWAP PRINT HALT FIB: // N.B. // n is (Frame+4) // b is (Frame+3) // a is (Frame+2) // return address is (Frame+1) // locals PUSH // result (Frame+0) // End initialisation // result := a LSR0 2 SSR0 0 // IF (n != 0) // (unless n == 0) LSR0 4 // R0 := n JZ FIB_END_IF // Push parameters // n - 1 LSR0 4 DEC PUSH // (+1 from stack frame) // a + b LSR0 3 // account for push (2+1) LSR1 4 // account for push (3+1) ADD PUSH // (+2 from stack frame) // b LSR0 5 // account for push (3+2) PUSH // recurse CALL FIB // release parameters POP POP POP // result := R1 SSR1 0 FIB_END_IF: // R1 := result LSR1 0 // release result POP RET
source/numerics/i386/sse2/a-nudsge.adb
ytomino/drake
33
5799
with Ada.Unchecked_Conversion; package body Ada.Numerics.dSFMT.Generating is -- SSE2 version use type Interfaces.Unsigned_64; type v2df is array (0 .. 1) of Long_Float; for v2df'Alignment use 16; pragma Machine_Attribute (v2df, "vector_type"); pragma Machine_Attribute (v2df, "may_alias"); pragma Suppress_Initialization (v2df); function mm_add_pd (a, b : v2df) return v2df with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_addpd"; function mm_sub_pd (a, b : v2df) return v2df with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_subpd"; type v4si is array (0 .. 3) of Unsigned_32; for v4si'Alignment use 16; pragma Machine_Attribute (v4si, "vector_type"); pragma Machine_Attribute (v4si, "may_alias"); pragma Suppress_Initialization (v4si); function mm_shuffle_epi32 (a : v4si; b : Integer) return v4si with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pshufd"; type v2di is array (0 .. 1) of Unsigned_64; for v2di'Alignment use 16; pragma Machine_Attribute (v2di, "vector_type"); pragma Machine_Attribute (v2di, "may_alias"); pragma Suppress_Initialization (v2di); function mm_and_si128 (a, b : v2di) return v2di with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pand128"; function mm_or_si128 (a, b : v2di) return v2di with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_por128"; function mm_xor_si128 (a, b : v2di) return v2di with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pxor128"; function mm_slli_epi64 (a : v2di; b : Integer) return v2di with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllqi128"; function mm_srli_epi64 (a : v2di; b : Integer) return v2di with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlqi128"; function To_v2df is new Unchecked_Conversion (v2di, v2df); function To_v2df is new Unchecked_Conversion (w128_t, v2df); function To_v2di is new Unchecked_Conversion (v4si, v2di); function To_v2di is new Unchecked_Conversion (w128_t, v2di); function To_w128_t is new Unchecked_Conversion (v2df, w128_t); function To_w128_t is new Unchecked_Conversion (v2di, w128_t); SSE2_SHUFF : constant := 16#1b#; -- 1 in 64bit for sse2 sse2_int_one : constant v2di := (1, 1); -- 2.0 double for sse2 sse2_double_two : constant v2df := (2.0, 2.0); -- -1.0 double for sse2 sse2_double_m_one : constant v2df := (-1.0, -1.0); -- implementation procedure do_recursion ( r : aliased out w128_t; a, b : aliased w128_t; lung : aliased in out w128_t) is type v4si_Access is access all v4si; type w128_t_Access is access all w128_t; function To_v4si is new Unchecked_Conversion (w128_t_Access, v4si_Access); -- mask data for sse2 sse2_param_mask : constant v2di := (MSK1, MSK2); v, w, x, y, z : v2di; begin x := To_v2di (a); z := mm_slli_epi64 (x, SL1); y := To_v2di (mm_shuffle_epi32 (To_v4si (lung'Access).all, SSE2_SHUFF)); z := mm_xor_si128 (z, To_v2di (b)); y := mm_xor_si128 (y, z); v := mm_srli_epi64 (y, SR); w := mm_and_si128 (y, sse2_param_mask); v := mm_xor_si128 (v, x); v := mm_xor_si128 (v, w); r := To_w128_t (v); lung := To_w128_t (y); end do_recursion; procedure convert_c0o1 (w : aliased in out w128_t) is begin w := To_w128_t (mm_add_pd (To_v2df (w), sse2_double_m_one)); end convert_c0o1; procedure convert_o0c1 (w : aliased in out w128_t) is begin w := To_w128_t (mm_sub_pd (sse2_double_two, To_v2df (w))); end convert_o0c1; procedure convert_o0o1 (w : aliased in out w128_t) is begin w := To_w128_t ( mm_add_pd ( To_v2df (mm_or_si128 (To_v2di (w), sse2_int_one)), sse2_double_m_one)); end convert_o0o1; end Ada.Numerics.dSFMT.Generating;
libsrc/_DEVELOPMENT/sound/ay/c/sccz80/ay_wyz_effect_init.asm
Frodevan/z88dk
640
22902
<reponame>Frodevan/z88dk IF !__CPU_INTEL__ & !__CPU_GBZ80__ SECTION code_sound_ay PUBLIC ay_wyz_effect_init EXTERN asm_wyz_TABLA_EFECTOS ;void ay_wyz_effect_init(wyz_effects *effects) __z88dk_fastcall ay_wyz_effect_init: ld (asm_wyz_TABLA_EFECTOS),hl ret ; SDCC bridge for Classic IF __CLASSIC PUBLIC _ay_wyz_effect_init defc _ay_wyz_effect_init = ay_wyz_effect_init ENDIF ENDIF
proofs/AKS/Nat/GCD.agda
mckeankylej/thesis
1
13102
<gh_stars>1-10 open import Relation.Nullary using (yes; no; ¬_) open import Relation.Nullary.Decidable using (True; False) open import Relation.Nullary.Negation using (contradiction) open import Relation.Binary using (Antisymmetric; Irrelevant; Decidable) open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl; sym; cong; cong₂; module ≡-Reasoning) open import Relation.Binary.PropositionalEquality.WithK using (≡-irrelevant) open ≡-Reasoning open import Function using (_$_) module AKS.Nat.GCD where open import AKS.Nat.Base using (ℕ; _+_; _*_; zero; suc; _<_; _≤_; lte; _≟_; _∸_) open import AKS.Nat.Properties using (≢⇒¬≟; ≤-antisym; <⇒≱) open import Data.Nat.Properties using (*-distribʳ-∸; m+n∸n≡m) open import AKS.Nat.Divisibility using (modₕ; _/_; _%_; n%m<m; m≡m%n+[m/n]*n; m%n≡m∸m/n*n; /-cancelʳ; Euclidean✓) renaming (_div_ to _ediv_) open import Data.Nat.Properties using (*-+-commutativeSemiring; *-zeroʳ; +-comm; *-comm; *-assoc) open import AKS.Algebra.Structures ℕ _≡_ using (module Modulus) open import AKS.Algebra.Divisibility *-+-commutativeSemiring public open import AKS.Unsafe using (≢-irrelevant) auto-∣ : ∀ {d a} {{ d≢0 : False (d ≟ 0) }} {{ pf : True (a ≟ (a / d) {d≢0} * d)}} → d ∣ a auto-∣ {d} {a} {{ d≢0 }} with a ≟ (a / d) {d≢0} * d ... | yes pf = divides (a / d) pf ∣-antisym : Antisymmetric _≡_ _∣_ ∣-antisym {x} {y} (divides zero refl) (divides q₂ refl) = *-zeroʳ q₂ ∣-antisym {x} {y} (divides (suc q₁) refl) (divides zero refl) = sym (*-zeroʳ (suc q₁)) ∣-antisym {x} {y} (divides (suc q₁) refl) (divides (suc q₂) pf₂) = ≤-antisym (lte (q₁ * x) refl) (lte (q₂ * y) (sym pf₂)) -- The euclidean norm is just the identity function on ℕ ∣_∣ : ∀ n {n≉0 : n ≢ 0} → ℕ ∣ n ∣ = n _div_ : ∀ (n m : ℕ) {m≢0 : m ≢ 0} → ℕ (n div m) {m≢0} = (n / m) {≢⇒¬≟ m≢0} _mod_ : ∀ (n m : ℕ) {m≢0 : m ≢ 0} → ℕ (n mod m) {m≢0} = (n % m) {≢⇒¬≟ m≢0} division : ∀ n m {m≢0 : m ≢ 0} → n ≡ m * (n div m) {m≢0} + (n mod m) {m≢0} division n m {m≢0} = begin n ≡⟨ m≡m%n+[m/n]*n n m {≢⇒¬≟ m≢0} ⟩ (n % m) + (n / m) * m ≡⟨ +-comm (n % m) (n / m * m) ⟩ (n / m) * m + (n % m) ≡⟨ cong (λ t → t + (n % m) {≢⇒¬≟ m≢0}) (*-comm (n / m) m) ⟩ m * (n div m) {m≢0} + (n mod m) {m≢0} ∎ open Modulus 0 ∣_∣ _mod_ modulus : ∀ n m {m≢0} → Remainder n m {m≢0} modulus n m {m≢0} with (n mod m) {m≢0} ≟ 0 ... | yes r≡0 = 0≈ r≡0 ... | no r≢0 = 0≉ r≢0 (n%m<m n m) mod-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≡ x₂ → y₁ ≡ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ mod y₁) {y₁≉0} ≡ (x₂ mod y₂) {y₂≉0} mod-cong refl refl {y₁≢0} {y₂≢0} rewrite ≢-irrelevant y₁≢0 y₂≢0 = refl mod-distribʳ-* : ∀ c a b {b≢0} {b*c≢0} → ((a * c) mod (b * c)) {b*c≢0} ≡ (a mod b) {b≢0} * c mod-distribʳ-* c a b {b≢0} {b*c≢0} = begin (a * c) mod (b * c) ≡⟨ m%n≡m∸m/n*n (a * c) (b * c) ⟩ (a * c) ∸ ((a * c) / (b * c)) * (b * c) ≡⟨ cong (λ x → a * c ∸ x) (sym (*-assoc ((a * c) / (b * c)) b c)) ⟩ (a * c) ∸ (((a * c) / (b * c)) * b) * c ≡⟨ sym (*-distribʳ-∸ c a (((a * c) / (b * c)) * b)) ⟩ (a ∸ ((a * c) / (b * c)) * b) * c ≡⟨ cong (λ x → (a ∸ x * b) * c) (/-cancelʳ c a b) ⟩ (a ∸ (a / b) * b) * c ≡⟨ cong (λ x → x * c) (sym (m%n≡m∸m/n*n a b)) ⟩ a mod b * c ∎ open Euclidean (λ n → n) _div_ _mod_ _≟_ ≡-irrelevant ≢-irrelevant division modulus mod-cong mod-distribʳ-* using (gcdₕ; gcd; gcd-isGCD; Identity; +ʳ; +ˡ; Bézout; lemma; bézout) public open IsGCD gcd-isGCD public open GCD gcd-isGCD ∣-antisym using ( _⊥_; ⊥-sym; ⊥-respˡ; ⊥-respʳ ) public renaming ( gcd[a,1]≈1 to gcd[a,1]≡1 ; gcd[1,a]≈1 to gcd[1,a]≡1 ; a≉0⇒gcd[a,b]≉0 to a≢0⇒gcd[a,b]≢0 ; b≉0⇒gcd[a,b]≉0 to b≢0⇒gcd[a,b]≢0 ; gcd[0,a]≈a to gcd[0,a]≡a ; gcd[a,0]≈a to gcd[a,0]≡a ; gcd[0,a]≈1⇒a≈1 to gcd[0,a]≡1⇒a≡1 ; gcd[a,0]≈1⇒a≈1 to gcd[a,0]≡1⇒a≡1 ) public ∣n+m∣m⇒∣n : ∀ {i n m} → i ∣ n + m → i ∣ m → i ∣ n ∣n+m∣m⇒∣n {i} {n} {m} (divides q₁ n+m≡q₁*i) (divides q₂ m≡q₂*i) = divides (q₁ ∸ q₂) $ begin n ≡⟨ sym (m+n∸n≡m n m) ⟩ (n + m) ∸ m ≡⟨ cong₂ (λ x y → x ∸ y) n+m≡q₁*i m≡q₂*i ⟩ q₁ * i ∸ q₂ * i ≡⟨ sym (*-distribʳ-∸ i q₁ q₂) ⟩ (q₁ ∸ q₂) * i ∎ ∣⇒≤ : ∀ {m n} {n≢0 : False (n ≟ 0)} → m ∣ n → m ≤ n ∣⇒≤ {m} {suc n} (divides (suc q) 1+n≡m+q*m) = lte (q * m) (sym 1+n≡m+q*m) _∣?_ : Decidable _∣_ d ∣? a with d ≟ 0 d ∣? a | yes refl with a ≟ 0 d ∣? a | yes refl | yes refl = yes ∣-refl d ∣? a | yes refl | no a≢0 = no λ 0∣a → contradiction (0∣n⇒n≈0 0∣a) a≢0 d ∣? a | no d≢0 with (a ediv d) {≢⇒¬≟ d≢0} d ∣? a | no d≢0 | Euclidean✓ q r pf r<d with r ≟ 0 d ∣? a | no d≢0 | Euclidean✓ q r pf r<d | yes refl = yes $ divides q $ begin a ≡⟨ pf ⟩ 0 + d * q ≡⟨⟩ d * q ≡⟨ *-comm d q ⟩ q * d ∎ d ∣? a | no d≢0 | Euclidean✓ q r pf r<d | no r≢0 = no ¬d∣a where ¬d∣a : ¬ (d ∣ a) ¬d∣a d∣a = contradiction d≤r (<⇒≱ r<d) where d∣r+d*q : d ∣ r + d * q d∣r+d*q = ∣-respʳ pf d∣a d∣r : d ∣ r d∣r = ∣n+m∣m⇒∣n d∣r+d*q (∣n⇒∣n*m _ _ _ ∣-refl) d≤r : d ≤ r d≤r = ∣⇒≤ {n≢0 = ≢⇒¬≟ r≢0} d∣r
src/Relation/Ternary/Separation/Construct/ListOf.agda
laMudri/linear.agda
34
7675
<filename>src/Relation/Ternary/Separation/Construct/ListOf.agda open import Relation.Ternary.Separation module Relation.Ternary.Separation.Construct.ListOf {a} (A : Set a) {{ r : RawSep A }} {{ _ : IsSep r }} where open import Level open import Data.Product open import Data.List open import Data.List.Properties using (++-isMonoid) open import Data.List.Relation.Binary.Equality.Propositional open import Data.List.Relation.Binary.Permutation.Inductive open import Relation.Binary.PropositionalEquality as P hiding ([_]) open import Relation.Unary hiding (_∈_; _⊢_) open import Relation.Ternary.Separation.Morphisms private Carrier = List A variable xˡ xʳ x y z : A xsˡ xsʳ xs ys zs : Carrier data Split : (xs ys zs : Carrier) → Set a where divide : xˡ ⊎ xʳ ≣ x → Split xs ys zs → Split (xˡ ∷ xs) (xʳ ∷ ys) (x ∷ zs) to-left : Split xs ys zs → Split (z ∷ xs) ys (z ∷ zs) to-right : Split xs ys zs → Split xs (z ∷ ys) (z ∷ zs) [] : Split [] [] [] -- Split yields a separation algebra instance splits : RawSep Carrier RawSep._⊎_≣_ splits = Split split-is-sep : IsSep splits -- commutes IsSep.⊎-comm split-is-sep (divide τ σ) = divide (⊎-comm τ) (⊎-comm σ) IsSep.⊎-comm split-is-sep (to-left σ) = to-right (⊎-comm σ) IsSep.⊎-comm split-is-sep (to-right σ) = to-left (⊎-comm σ) IsSep.⊎-comm split-is-sep [] = [] -- reassociates IsSep.⊎-assoc split-is-sep σ₁ (to-right σ₂) with ⊎-assoc σ₁ σ₂ ... | _ , σ₄ , σ₅ = -, to-right σ₄ , to-right σ₅ IsSep.⊎-assoc split-is-sep (to-left σ₁) (divide τ σ₂) with ⊎-assoc σ₁ σ₂ ... | _ , σ₄ , σ₅ = -, divide τ σ₄ , to-right σ₅ IsSep.⊎-assoc split-is-sep (to-right σ₁) (divide τ σ₂) with ⊎-assoc σ₁ σ₂ ... | _ , σ₄ , σ₅ = -, to-right σ₄ , divide τ σ₅ IsSep.⊎-assoc split-is-sep (divide τ σ₁) (to-left σ) with ⊎-assoc σ₁ σ ... | _ , σ₄ , σ₅ = -, divide τ σ₄ , to-left σ₅ IsSep.⊎-assoc split-is-sep (to-left σ₁) (to-left σ) with ⊎-assoc σ₁ σ ... | _ , σ₄ , σ₅ = -, to-left σ₄ , σ₅ IsSep.⊎-assoc split-is-sep (to-right σ₁) (to-left σ) with ⊎-assoc σ₁ σ ... | _ , σ₄ , σ₅ = -, to-right σ₄ , to-left σ₅ IsSep.⊎-assoc split-is-sep [] [] = -, [] , [] IsSep.⊎-assoc split-is-sep (divide lr σ₁) (divide rl σ₂) with ⊎-assoc σ₁ σ₂ | ⊎-assoc lr rl ... | _ , σ₃ , σ₄ | _ , τ₃ , τ₄ = -, divide τ₃ σ₃ , divide τ₄ σ₄ split-is-unital : IsUnitalSep splits [] IsUnitalSep.⊎-idˡ split-is-unital {[]} = [] IsUnitalSep.⊎-idˡ split-is-unital {x ∷ Φ} = to-right ⊎-idˡ IsUnitalSep.⊎-id⁻ˡ split-is-unital (to-right σ) rewrite ⊎-id⁻ˡ σ = refl IsUnitalSep.⊎-id⁻ˡ split-is-unital [] = refl split-has-concat : IsConcattative splits IsConcattative._∙_ split-has-concat = _++_ IsConcattative.⊎-∙ₗ split-has-concat {Φₑ = []} σ = σ IsConcattative.⊎-∙ₗ split-has-concat {Φₑ = x ∷ Φₑ} σ = to-left (⊎-∙ₗ σ) split-separation : Separation _ split-separation = record { Carrier = List A } split-monoidal : MonoidalSep _ split-monoidal = record { monoid = ++-isMonoid } list-positive : IsPositive splits list-positive = record { ⊎-εˡ = λ where [] → refl } unspliceᵣ : ∀ {xs ys zs : Carrier} {y} → xs ⊎ (y ∷ ys) ≣ zs → ∃ λ zs₁ → xs ⊎ [ y ] ≣ zs₁ × zs₁ ⊎ ys ≣ zs unspliceᵣ σ with ⊎-unassoc σ (⊎-∙ {Φₗ = [ _ ]}) ... | _ , σ₁ , σ₂ = -, σ₁ , σ₂
case-studies/performance/verification/alloy/ppc/tests/rfe004.als
uwplse/memsynth
19
1233
<gh_stars>10-100 module tests/rfe004 open program open model /** PPC rfe004 "DpdW Wse Rfe DpdW Wse Rfe" Cycle=DpdW Wse Rfe DpdW Wse Rfe Relax=Rfe Safe=Wse DpdW { 0:r2=x; 0:r5=y; 1:r2=y; 2:r2=y; 2:r5=x; 3:r2=x; } P0 | P1 | P2 | P3 ; lwz r1,0(r2) | li r1,2 | lwz r1,0(r2) | li r1,2 ; xor r3,r1,r1 | stw r1,0(r2) | xor r3,r1,r1 | stw r1,0(r2) ; li r4,1 | | li r4,1 | ; stwx r4,r3,r5 | | stwx r4,r3,r5 | ; exists (x=2 /\ y=2 /\ 0:r1=2 /\ 2:r1=2) **/ one sig x, y extends Location {} one sig P1, P2, P3, P4 extends Processor {} one sig op1 extends Read {} one sig op2 extends Write {} one sig op3 extends Write {} one sig op4 extends Read {} one sig op5 extends Write {} one sig op6 extends Write {} fact { P1.read[1, op1, x, 2] P1.write[2, op2, y, 1] and op2.dep[op1] P2.write[3, op3, y, 2] P3.read[4, op4, y, 2] P3.write[5, op5, x, 1] and op5.dep[op4] P4.write[6, op6, x, 2] } fact { y.final[2] x.final[2] } Allowed: run { Allowed_PPC } for 4 int expect 1
programs/oeis/188/A188555.asm
jmorken/loda
1
4527
<reponame>jmorken/loda ; A188555: Number of 4 X n binary arrays without the pattern 0 1 diagonally, vertically, antidiagonally or horizontally. ; 5,9,16,28,48,80,129,201,303,443,630,874,1186,1578,2063,2655,3369,4221,5228,6408,7780,9364,11181,13253,15603,18255,21234,24566,28278,32398,36955,41979,47501,53553,60168,67380,75224,83736,92953,102913,113655 mov $1,$0 mov $2,2 mov $5,$0 add $5,$0 sub $5,$0 mov $6,$0 lpb $0 add $2,$1 add $1,$3 add $1,1 trn $3,$0 sub $0,1 add $3,$5 sub $3,1 lpe mov $4,$2 add $4,5 mov $1,$4 add $1,3 lpb $6 add $1,3 sub $6,1 lpe sub $1,5
programs/oeis/229/A229004.asm
jmorken/loda
1
212
; A229004: Indices of Bell numbers divisible by 3. ; 4,8,9,11,17,21,22,24,30,34,35,37,43,47,48,50,56,60,61,63,69,73,74,76,82,86,87,89,95,99,100,102,108,112,113,115,121,125,126,128,134,138,139,141,147,151,152,154,160,164,165,167,173,177,178,180,186,190,191,193,199,203,204,206,212,216,217,219,225,229,230,232,238,242,243,245,251,255,256,258,264,268,269,271,277,281,282,284,290,294,295,297,303,307,308,310,316,320,321,323,329,333,334,336,342,346,347,349,355,359,360,362,368,372,373,375,381,385,386,388,394,398,399,401,407,411,412,414,420,424,425,427,433,437,438,440,446,450,451,453,459,463,464,466,472,476,477,479,485,489,490,492,498,502,503,505,511,515,516,518,524,528,529,531,537,541,542,544,550,554,555,557,563,567,568,570,576,580,581,583,589,593,594,596,602,606,607,609,615,619,620,622,628,632,633,635,641,645,646,648,654,658,659,661,667,671,672,674,680,684,685,687,693,697,698,700,706,710,711,713,719,723,724,726,732,736,737,739,745,749,750,752,758,762,763,765,771,775,776,778,784,788,789,791,797,801,802,804,810,814 mov $3,$0 mov $5,$0 add $5,1 lpb $5 mov $0,$3 sub $5,1 sub $0,$5 sub $0,1 mod $0,4 mov $2,4 mov $4,1 lpb $0 mov $2,$0 sub $0,1 mul $4,$2 lpe add $4,$2 sub $4,1 add $1,$4 lpe
Transynther/x86/_processed/US/_st_4k_sm_/i7-7700_9_0xca_notsx.log_26_1571.asm
ljhsiun2/medusa
9
102412
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r9 push %rsi lea addresses_normal_ht+0x2d82, %rsi clflush (%rsi) sub %r12, %r12 movw $0x6162, (%rsi) nop dec %r9 pop %rsi pop %r9 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r15 push %rbx push %rcx push %rsi // Store lea addresses_WC+0x1f5c2, %rcx nop nop nop cmp %r15, %r15 mov $0x5152535455565758, %r10 movq %r10, (%rcx) nop nop nop nop nop sub %r15, %r15 // Load lea addresses_WT+0x11b82, %rsi nop and $30081, %r13 movb (%rsi), %r10b nop nop nop nop nop cmp %r14, %r14 // Store lea addresses_normal+0x55c2, %r14 nop nop dec %r13 mov $0x5152535455565758, %r10 movq %r10, (%r14) nop nop sub $60925, %r10 // Load lea addresses_WT+0x23c2, %r13 nop nop nop nop inc %r15 mov (%r13), %r14d nop inc %rsi // Load lea addresses_WT+0x1d1c2, %rcx nop and %rbx, %rbx mov (%rcx), %r10w inc %r13 // Store mov $0x20cd1c0000000ac2, %r13 nop sub $52153, %r15 movb $0x51, (%r13) nop nop nop add $43501, %r15 // Store lea addresses_UC+0x18ac2, %r13 clflush (%r13) xor %r10, %r10 movb $0x51, (%r13) nop sub %r13, %r13 // Store lea addresses_PSE+0x14852, %r10 nop nop nop nop add %r14, %r14 mov $0x5152535455565758, %r13 movq %r13, %xmm5 vmovups %ymm5, (%r10) nop nop nop nop and $46197, %rcx // Store lea addresses_US+0x1f5c2, %rcx clflush (%rcx) nop nop nop nop add $28658, %r14 mov $0x5152535455565758, %rbx movq %rbx, (%rcx) nop nop nop nop cmp %rsi, %rsi // Faulty Load lea addresses_US+0x1f5c2, %r15 nop nop nop and %rcx, %rcx mov (%r15), %ebx lea oracles, %r13 and $0xff, %rbx shlq $12, %rbx mov (%r13,%rbx,1), %rbx pop %rsi pop %rcx pop %rbx pop %r15 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 10, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_NC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'58': 26} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/root-level_1.ads
best08618/asylo
7
26086
package Root.Level_1 is type Level_1_Type (First : Natural; Second : Natural) is new Root_Type with private; private type Level_1_Type (First : Natural; Second : Natural) is new Root_Type (First => First) with record Buffer_1 : Buffer_Type (1 .. Second); end record; end Root.Level_1;
oeis/152/A152107.asm
neoneye/loda-programs
11
242629
<reponame>neoneye/loda-programs ; A152107: a(n) = ((6+sqrt(5))^n+(6-sqrt(5))^n)/2. ; Submitted by <NAME> ; 1,6,41,306,2401,19326,157481,1290666,10606081,87262326,718359401,5915180706,48713027041,401185722606,3304124833001,27212740595226,224125017319681,1845905249384166,15202987455699881,125212786737489426,1031260829723176801,8493533567815949406,69953317092372912041,576140264506180512906,4745130344210605881601,39081215930835674679126,321875550499499313819881,2650988912138085850785666,21833724880172551481011681,179824042285789956397784526,1481043036144130380862052201,12197971122870075922013306106 mov $1,6 lpb $0 sub $0,1 mov $2,$3 mul $2,5 mul $3,6 add $3,$1 mul $1,6 add $1,$2 lpe mov $0,$1 div $0,6
oeis/024/A024199.asm
neoneye/loda-programs
11
5431
; A024199: a(n) = (2n-1)!! * Sum_{k=0..n-1}(-1)^k/(2k+1). ; Submitted by <NAME> ; 0,1,2,13,76,789,7734,110937,1528920,28018665,497895210,11110528485,241792844580,6361055257725,163842638377950,4964894559637425,147721447995130800,5066706567801827025,171002070002301095250,6548719685561840296125,247199273204273879989500,10455001188148106850385125,436451980632680605963119750,20204201158151210778288335625,924223663097480648631894165000,46479527684550985906502721725625,2312020070466153009178183333616250,125517291648449420361169945875583125,6745498961236322643503856875879212500 mov $2,1 lpb $0 mov $1,$0 sub $0,1 add $1,$0 mul $3,$1 div $3,-1 add $3,$2 mul $2,$1 lpe mov $0,$3
oeis/120/A120718.asm
neoneye/loda-programs
11
98857
; A120718: Expansion of 3*x/(1 - 2*x^2 - 2*x + x^3). ; Submitted by <NAME>(s3) ; 0,3,6,18,45,120,312,819,2142,5610,14685,38448,100656,263523,689910,1806210,4728717,12379944,32411112,84853395,222149070,581593818,1522632381,3986303328,10436277600,27322529475,71531310822,187271402994,490282898157,1283577291480,3360448976280,8797769637363,23032859935806,60300810170058,157869570574365,413307901553040,1082054134084752,2832854500701219,7416509368018902,19416673603355490,50833511442047565,133083860722787208,348418070726314056,912170351456154963,2388092983642150830 mov $3,1 lpb $0 sub $0,1 mov $2,$3 add $3,$1 mov $1,$2 lpe mul $1,$3 mov $0,$1 mul $0,3
test/Fail/Issue4999.agda
cagix/agda
1,989
7614
open import Agda.Builtin.Char open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.String open import Agda.Builtin.String.Properties data ⊥ : Set where ∷⁻¹ : ∀ {A : Set} {x y : A} {xs ys} → x ∷ xs ≡ y ∷ ys → x ≡ y ∷⁻¹ refl = refl xD800 = primNatToChar 0xD800 xD801 = primNatToChar 0xD801 legit : '\xD800' ∷ [] ≡ '\xD801' ∷ [] legit = primStringFromListInjective _ _ refl actually : xD800 ≡ xD801 actually = refl nope : xD800 ≡ xD801 → ⊥ nope () boom : ⊥ boom = nope (∷⁻¹ legit) errorAlsoInLHS : Char → String errorAlsoInLHS '\xD8AA' = "bad" errorAlsoInLHS _ = "meh"
AppleScripts/Applications/Pro Tools/Create Clip Group and Rename with Reason.applescript
fantopop/post-production-scripts
16
3332
<filename>AppleScripts/Applications/Pro Tools/Create Clip Group and Rename with Reason.applescript -- -- AppleScripts for Avid Pro Tools. -- -- Script description: -- Creates Clip Group for selection and switches keyboard input source to RU -- Adds [R] template for ADR markup reasons (EDI CUE or PGPTSession) -- -- (C) 2020 <NAME> -- -- -- In order to work properly install xkbswitch. -- Open Terminal and perform 3 commands: -- -- 1. Download binary: -- curl -LJO https://raw.githubusercontent.com/myshov/xkbswitch-macosx/master/bin/xkbswitch -- -- 2. Add execution rights -- chmod 755 xkbswitch -- -- 3. Move to proper folder -- mv xkbswitch /usr/local/bin tell application "Finder" tell application "System Events" set PT to the first application process whose creator type is "PTul" tell PT activate set frontmost to true # Check if the menu item Copy is enabled. # If edit selection is void, this item won't be enabled. set checkSelection to enabled of menu item "Copy" of menu "Edit" of menu bar item "Edit" of menu bar 1 if checkSelection is true then # Create Clip Group key code 5 using {command down, option down} delay 0.1 do shell script "/usr/local/bin/xkbswitch -se US" # Rename key code 15 using {command down, shift down} delay 0.1 # Add Reason template set the clipboard to " [R]" keystroke "v" using command down # Move cursor to the beginning of the line key code 126 # Switch to Russian do shell script "/usr/local/bin/xkbswitch -se RussianWin" #key code 49 using {command down} else display dialog "Can't create a clip group - edit selection is void" buttons {"OK"} default button {"OK"} with icon caution with title "AppleScript error" end if end tell end tell end tell
programs/oeis/266/A266594.asm
neoneye/loda
22
10069
<reponame>neoneye/loda ; A266594: Total number of ON (black) cells after n iterations of the "Rule 37" elementary cellular automaton starting with a single ON (black) cell. ; 1,2,5,7,10,16,19,29,32,46,49,67,70,92,95,121,124,154,157,191,194,232,235,277,280,326,329,379,382,436,439,497,500,562,565,631,634,704,707,781,784,862,865,947,950,1036,1039,1129,1132,1226,1229,1327,1330,1432,1435,1541,1544,1654,1657,1771,1774,1892,1895,2017,2020,2146,2149,2279,2282,2416,2419,2557,2560,2702,2705,2851,2854,3004,3007,3161,3164,3322,3325,3487,3490,3656,3659,3829,3832,4006,4009,4187,4190,4372,4375,4561,4564,4754,4757,4951 mov $7,$0 trn $0,1 add $0,2 mov $3,5 lpb $0 sub $0,1 trn $2,3 mov $4,$3 mov $3,$0 add $4,$5 mov $1,$4 mov $5,$0 mov $6,$2 add $2,$4 sub $2,$6 add $3,$6 lpe lpb $7 add $1,1 sub $7,1 lpe sub $1,1 mov $0,$1
3-mid/opengl/source/platform/egl/private/opengl-surface-privvy.ads
charlie5/lace
20
9521
with eGL; package opengl.Surface.privvy is function to_eGL (Self : in Surface.item'Class) return egl.EGLSurface; end opengl.Surface.privvy;
src/Delay-monad/Sized/Bisimilarity.agda
nad/delay-monad
0
10568
<gh_stars>0 ------------------------------------------------------------------------ -- A combined definition of strong and weak bisimilarity and -- expansion, along with various properties ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Delay-monad.Sized.Bisimilarity where open import Equality.Propositional as E using (_≡_) open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size open import Function-universe E.equality-with-J hiding (_∘_; Kind) open import Delay-monad.Sized open import Delay-monad.Bisimilarity.Kind ------------------------------------------------------------------------ -- The code below is defined for a fixed type family A module _ {a} {A : Size → Type a} where ---------------------------------------------------------------------- -- The relations mutual -- A combined definition of all three relations. The definition -- uses mixed induction and coinduction. -- -- Note that this type is not defined in the same way as Delay. -- One might argue that the now constructor should have the -- following type, using a /sized/ identity type Id: -- -- now : ∀ {x y} → -- Id (A ∞) i x y → -- [ i ] now x ∼ now y infix 4 [_]_⟨_⟩_ [_]_⟨_⟩′_ data [_]_⟨_⟩_ (i : Size) : Delay A ∞ → Kind → Delay A ∞ → Type a where now : ∀ {k x} → [ i ] now x ⟨ k ⟩ now x later : ∀ {k x₁ x₂} → [ i ] force x₁ ⟨ k ⟩′ force x₂ → [ i ] later x₁ ⟨ k ⟩ later x₂ laterˡ : ∀ {k x₁ x₂} → [ i ] force x₁ ⟨ other k ⟩ x₂ → [ i ] later x₁ ⟨ other k ⟩ x₂ laterʳ : ∀ {x₁ x₂} → [ i ] x₁ ⟨ other weak ⟩ force x₂ → [ i ] x₁ ⟨ other weak ⟩ later x₂ record [_]_⟨_⟩′_ (i : Size) (x₁ : Delay A ∞) (k : Kind) (x₂ : Delay A ∞) : Type a where coinductive field force : {j : Size< i} → [ j ] x₁ ⟨ k ⟩ x₂ open [_]_⟨_⟩′_ public -- Strong bisimilarity. infix 4 [_]_∼_ [_]_∼′_ _∼_ _∼′_ [_]_∼_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_∼_ = [_]_⟨ strong ⟩_ [_]_∼′_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_∼′_ = [_]_⟨ strong ⟩′_ _∼_ : Delay A ∞ → Delay A ∞ → Type a _∼_ = [ ∞ ]_∼_ _∼′_ : Delay A ∞ → Delay A ∞ → Type a _∼′_ = [ ∞ ]_∼′_ -- Expansion. infix 4 [_]_≳_ [_]_≳′_ _≳_ _≳′_ [_]_≳_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≳_ = [_]_⟨ other expansion ⟩_ [_]_≳′_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≳′_ = [_]_⟨ other expansion ⟩′_ _≳_ : Delay A ∞ → Delay A ∞ → Type a _≳_ = [ ∞ ]_≳_ _≳′_ : Delay A ∞ → Delay A ∞ → Type a _≳′_ = [ ∞ ]_≳′_ -- The converse of expansion. infix 4 [_]_≲_ [_]_≲′_ _≲_ _≲′_ [_]_≲_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≲_ i = flip [ i ]_⟨ other expansion ⟩_ [_]_≲′_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≲′_ i = flip [ i ]_⟨ other expansion ⟩′_ _≲_ : Delay A ∞ → Delay A ∞ → Type a _≲_ = [ ∞ ]_≲_ _≲′_ : Delay A ∞ → Delay A ∞ → Type a _≲′_ = [ ∞ ]_≲′_ -- Weak bisimilarity. infix 4 [_]_≈_ [_]_≈′_ _≈_ _≈′_ [_]_≈_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≈_ = [_]_⟨ other weak ⟩_ [_]_≈′_ : Size → Delay A ∞ → Delay A ∞ → Type a [_]_≈′_ = [_]_⟨ other weak ⟩′_ _≈_ : Delay A ∞ → Delay A ∞ → Type a _≈_ = [ ∞ ]_≈_ _≈′_ : Delay A ∞ → Delay A ∞ → Type a _≈′_ = [ ∞ ]_≈′_ ---------------------------------------------------------------------- -- Conversions -- Strong bisimilarity is contained in the other relations (and -- itself). ∼→ : ∀ {k i x y} → [ i ] x ∼ y → [ i ] x ⟨ k ⟩ y ∼→ now = now ∼→ (later p) = later λ { .force → ∼→ (force p) } -- Expansion is contained in weak bisimilarity (and expansion). ≳→ : ∀ {k i x y} → [ i ] x ≳ y → [ i ] x ⟨ other k ⟩ y ≳→ now = now ≳→ (later p) = later λ { .force → ≳→ (force p) } ≳→ (laterˡ p) = laterˡ (≳→ p) -- In some cases weak bisimilarity is contained in expansion (and -- itself). ≈→-now : ∀ {k i x y} → [ i ] x ≈ now y → [ i ] x ⟨ other k ⟩ now y ≈→-now now = now ≈→-now (laterˡ p) = laterˡ (≈→-now p) -- In some cases all three relations are contained in strong -- bisimilarity. →∼-neverˡ : ∀ {k i x} → [ i ] never ⟨ k ⟩ x → [ i ] never ∼ x →∼-neverˡ (later p) = later λ { .force → →∼-neverˡ (force p) } →∼-neverˡ (laterˡ p) = →∼-neverˡ p →∼-neverˡ (laterʳ p) = later λ { .force → →∼-neverˡ p } →∼-neverʳ : ∀ {k i x} → [ i ] x ⟨ k ⟩ never → [ i ] x ∼ never →∼-neverʳ (later p) = later λ { .force → →∼-neverʳ (force p) } →∼-neverʳ (laterˡ p) = later λ { .force → →∼-neverʳ p } →∼-neverʳ (laterʳ p) = →∼-neverʳ p ---------------------------------------------------------------------- -- Removing later constructors -- Later constructors can sometimes be removed. drop-laterʳ : ∀ {k i} {j : Size< i} {x y} → [ i ] x ⟨ other k ⟩ y → [ j ] x ⟨ other k ⟩ drop-later y drop-laterʳ now = now drop-laterʳ (later p) = laterˡ (force p) drop-laterʳ (laterʳ p) = p drop-laterʳ (laterˡ p) = laterˡ (drop-laterʳ p) drop-laterˡ : ∀ {i} {j : Size< i} {x y} → [ i ] x ≈ y → [ j ] drop-later x ≈ y drop-laterˡ now = now drop-laterˡ (later p) = laterʳ (force p) drop-laterˡ (laterʳ p) = laterʳ (drop-laterˡ p) drop-laterˡ (laterˡ p) = p drop-laterˡʳ : ∀ {k i} {j : Size< i} {x y} → [ i ] x ⟨ k ⟩ y → [ j ] drop-later x ⟨ k ⟩ drop-later y drop-laterˡʳ now = now drop-laterˡʳ (later p) = force p drop-laterˡʳ (laterʳ p) = drop-laterˡ p drop-laterˡʳ (laterˡ p) = drop-laterʳ p -- Special cases of the functions above. laterʳ⁻¹ : ∀ {k i} {j : Size< i} {x y} → [ i ] x ⟨ other k ⟩ later y → [ j ] x ⟨ other k ⟩ force y laterʳ⁻¹ = drop-laterʳ laterˡ⁻¹ : ∀ {i} {j : Size< i} {x y} → [ i ] later x ≈ y → [ j ] force x ≈ y laterˡ⁻¹ = drop-laterˡ later⁻¹ : ∀ {k i} {j : Size< i} {x y} → [ i ] later x ⟨ k ⟩ later y → [ j ] force x ⟨ k ⟩ force y later⁻¹ = drop-laterˡʳ -- The following size-preserving variant of laterʳ⁻¹ and laterˡ⁻¹ -- can be defined. -- -- Several other variants cannot be defined if ∀ i → A i is -- inhabited, see Delay-monad.Bisimilarity.Sized.Negative. laterˡʳ⁻¹ : ∀ {k i x y} → [ i ] later x ⟨ other k ⟩ force y → [ i ] force x ⟨ other k ⟩ later y → [ i ] force x ⟨ other k ⟩ force y laterˡʳ⁻¹ {k} {i} p q = laterˡʳ⁻¹′ p q E.refl E.refl where laterˡʳ⁻¹″ : ∀ {x′ y′ x y} → ({j : Size< i} → [ j ] x′ ⟨ other k ⟩ force y) → ({j : Size< i} → [ j ] force x ⟨ other k ⟩ y′) → x′ ≡ later x → y′ ≡ later y → [ i ] later x ⟨ other k ⟩ later y laterˡʳ⁻¹″ p q E.refl E.refl = later λ { .force → laterˡʳ⁻¹ p q } laterˡʳ⁻¹′ : ∀ {x′ y′ x y} → [ i ] later x ⟨ other k ⟩ y′ → [ i ] x′ ⟨ other k ⟩ later y → force x ≡ x′ → force y ≡ y′ → [ i ] x′ ⟨ other k ⟩ y′ laterˡʳ⁻¹′ (later p) (later q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (force p) (force q) ≡x′ ≡y′ laterˡʳ⁻¹′ (laterʳ p) (later q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (λ { {_} → laterˡ⁻¹ p }) (force q) ≡x′ ≡y′ laterˡʳ⁻¹′ (later p) (laterˡ q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (force p) (λ { {_} → laterʳ⁻¹ q }) ≡x′ ≡y′ laterˡʳ⁻¹′ (laterʳ p) (laterˡ q) ≡x′ ≡y′ = laterˡʳ⁻¹″ (λ { {_} → laterˡ⁻¹ p }) (λ { {_} → laterʳ⁻¹ q }) ≡x′ ≡y′ laterˡʳ⁻¹′ (laterˡ p) _ E.refl E.refl = p laterˡʳ⁻¹′ _ (laterʳ q) E.refl ≡y′ = E.subst ([ i ] _ ⟨ _ ⟩_) ≡y′ q ---------------------------------------------------------------------- -- Reflexivity, symmetry/antisymmetry, transitivity -- All three relations are reflexive. reflexive : ∀ {k i} x → [ i ] x ⟨ k ⟩ x reflexive (now _) = now reflexive (later x) = later λ { .force → reflexive (force x) } -- Strong and weak bisimilarity are symmetric. symmetric : ∀ {k i x y} {¬≳ : if k ≟-Kind other expansion then ⊥ else ⊤} → [ i ] x ⟨ k ⟩ y → [ i ] y ⟨ k ⟩ x symmetric now = now symmetric (laterˡ {k = weak} p) = laterʳ (symmetric p) symmetric (laterʳ p) = laterˡ (symmetric p) symmetric {¬≳ = ¬≳} (later p) = later λ { .force → symmetric {¬≳ = ¬≳} (force p) } symmetric {¬≳ = ()} (laterˡ {k = expansion} _) -- Some special cases of symmetry hold for expansion. symmetric-neverˡ : ∀ {i x} → [ i ] never ≳ x → [ i ] x ≳ never symmetric-neverˡ = ∼→ ∘ symmetric ∘ →∼-neverˡ symmetric-neverʳ : ∀ {i x} → [ i ] x ≳ never → [ i ] never ≳ x symmetric-neverʳ = ∼→ ∘ symmetric ∘ →∼-neverʳ -- The expansion relation is antisymmetric (up to weak -- bisimilarity). antisymmetric-≳ : ∀ {i x y} → [ i ] x ≳ y → [ i ] y ≳ x → [ i ] x ≈ y antisymmetric-≳ p _ = ≳→ p -- Several more or less size-preserving variants of transitivity. -- -- Many size-preserving variants cannot be defined if ∀ i → A i is -- inhabited, see Delay-monad.Sized.Bisimilarity.Negative. transitive-∼ʳ : ∀ {k i x y z} {¬≈ : if k ≟-Kind other weak then ⊥ else ⊤} → [ i ] x ⟨ k ⟩ y → [ i ] y ∼ z → [ i ] x ⟨ k ⟩ z transitive-∼ʳ now now = now transitive-∼ʳ {¬≈ = ¬≈} (laterˡ p) q = laterˡ (transitive-∼ʳ {¬≈ = ¬≈} p q) transitive-∼ʳ {¬≈ = ()} (laterʳ _) _ transitive-∼ʳ {¬≈ = ¬≈} (later p) (later q) = later λ { .force → transitive-∼ʳ {¬≈ = ¬≈} (force p) (force q) } transitive-∼ˡ : ∀ {k i x y z} → x ∼ y → [ i ] y ⟨ k ⟩ z → [ i ] x ⟨ k ⟩ z transitive-∼ˡ now now = now transitive-∼ˡ (later p) (later q) = later λ { .force → transitive-∼ˡ (force p) (force q) } transitive-∼ˡ (later p) (laterˡ q) = laterˡ (transitive-∼ˡ (force p) q) transitive-∼ˡ p (laterʳ q) = laterʳ (transitive-∼ˡ p q) transitive-∞∼ʳ : ∀ {k i x y z} → [ i ] x ⟨ k ⟩ y → y ∼ z → [ i ] x ⟨ k ⟩ z transitive-∞∼ʳ now now = now transitive-∞∼ʳ (later p) (later q) = later λ { .force → transitive-∞∼ʳ (force p) (force q) } transitive-∞∼ʳ (laterˡ p) q = laterˡ (transitive-∞∼ʳ p q) transitive-∞∼ʳ (laterʳ p) (later q) = laterʳ (transitive-∞∼ʳ p (force q)) transitive-≳ˡ : ∀ {k i x y z} → x ≳ y → [ i ] y ⟨ other k ⟩ z → [ i ] x ⟨ other k ⟩ z transitive-≳ˡ now now = now transitive-≳ˡ (later p) (later q) = later λ { .force → transitive-≳ˡ (force p) (force q) } transitive-≳ˡ (later p) (laterˡ q) = laterˡ (transitive-≳ˡ (force p) q) transitive-≳ˡ (laterˡ p) q = laterˡ (transitive-≳ˡ p q) transitive-≳ˡ p (laterʳ q) = laterʳ (transitive-≳ˡ p q) transitive-≈≲ : ∀ {i x y z} → [ i ] x ≈ y → y ≲ z → [ i ] x ≈ z transitive-≈≲ p q = symmetric (transitive-≳ˡ q (symmetric p)) transitive-≈-now : ∀ {i x′ y z} → let x = now x′ in [ i ] x ≈ y → y ≈ z → [ i ] x ≈ z transitive-≈-now now now = now transitive-≈-now (laterʳ p) q = transitive-≈-now p (laterˡ⁻¹ q) transitive-≈-now p (laterʳ q) = laterʳ (transitive-≈-now p q) mutual transitive-≈-later : ∀ {i x′ y z} → let x = later x′ in x ≈ y → y ≈ z → [ i ] x ≈ z transitive-≈-later p (later q) = later λ { .force → transitive-≈ (later⁻¹ p) (force q) } transitive-≈-later p (laterʳ q) = laterʳ (transitive-≈-later p q) transitive-≈-later p (laterˡ q) = transitive-≈ (laterʳ⁻¹ p) q transitive-≈-later (laterˡ p) q = laterˡ (transitive-≈ p q) transitive-≈ : ∀ {i x y z} → x ≈ y → y ≈ z → [ i ] x ≈ z transitive-≈ {x = now x} p q = transitive-≈-now p q transitive-≈ {x = later x} p q = transitive-≈-later p q -- Equational reasoning combinators. infix -1 _∎ finally finally-≳ finally-≈ infixr -2 step-∼ˡ step-∼∼ step-≳∼ step-≈∼ step-?∼ step-≳ˡ step-≈ _≳⟨⟩_ step-≡ˡ _∼⟨⟩_ _∎ : ∀ {k i} x → [ i ] x ⟨ k ⟩ x _∎ = reflexive finally : ∀ {k i} x y → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ y finally _ _ x?y = x?y syntax finally x y x≈y = x ?⟨ x≈y ⟩∎ y ∎ finally-≳ : ∀ {i} x y → [ i ] x ≳ y → [ i ] x ≳ y finally-≳ _ _ x≳y = x≳y syntax finally-≳ x y x≳y = x ≳⟨ x≳y ⟩∎ y ∎ finally-≈ : ∀ {i} x y → [ i ] x ≈ y → [ i ] x ≈ y finally-≈ _ _ x≈y = x≈y syntax finally-≈ x y x≈y = x ≈⟨ x≈y ⟩∎ y ∎ step-∼ˡ : ∀ {k i} x {y z} → [ i ] y ⟨ k ⟩ z → x ∼ y → [ i ] x ⟨ k ⟩ z step-∼ˡ _ y⟨⟩z x∼y = transitive-∼ˡ x∼y y⟨⟩z syntax step-∼ˡ x y⟨⟩z x∼y = x ∼⟨ x∼y ⟩ y⟨⟩z step-∼∼ : ∀ {i} x {y z} → [ i ] y ∼ z → [ i ] x ∼ y → [ i ] x ∼ z step-∼∼ _ y∼z x∼y = transitive-∼ʳ x∼y y∼z syntax step-∼∼ x y∼z x∼y = x ∼⟨ x∼y ⟩∼ y∼z step-≳∼ : ∀ {i} x {y z} → [ i ] y ∼ z → [ i ] x ≳ y → [ i ] x ≳ z step-≳∼ _ y∼z x≳y = transitive-∼ʳ x≳y y∼z syntax step-≳∼ x y∼z x≳y = x ≳⟨ x≳y ⟩∼ y∼z step-≈∼ : ∀ {k i} x {y z} → y ∼ z → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ z step-≈∼ _ y∼z x≈y = transitive-∞∼ʳ x≈y y∼z syntax step-≈∼ x y∼z x≈y = x ≈⟨ x≈y ⟩∼ y∼z step-?∼ : ∀ {k i} x {y z} → y ∼ z → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ z step-?∼ _ y∼z x?y = transitive-∞∼ʳ x?y y∼z syntax step-?∼ x y∼z x?y = x ?⟨ x?y ⟩∼ y∼z step-≳ˡ : ∀ {k i} x {y z} → [ i ] y ⟨ other k ⟩ z → x ≳ y → [ i ] x ⟨ other k ⟩ z step-≳ˡ _ y≳≈z x≳y = transitive-≳ˡ x≳y y≳≈z syntax step-≳ˡ x y≳≈z x≳y = x ≳⟨ x≳y ⟩ y≳≈z step-≈ : ∀ {i} x {y z} → y ≈ z → x ≈ y → [ i ] x ≈ z step-≈ _ y≈z x≈y = transitive-≈ x≈y y≈z syntax step-≈ x y≈z x≈y = x ≈⟨ x≈y ⟩ y≈z _≳⟨⟩_ : ∀ {k i} x {y} → [ i ] drop-later x ⟨ other k ⟩ y → [ i ] x ⟨ other k ⟩ y now _ ≳⟨⟩ p = p later _ ≳⟨⟩ p = laterˡ p step-≡ˡ : ∀ {k i} x {y z} → [ i ] y ⟨ k ⟩ z → x ≡ y → [ i ] x ⟨ k ⟩ z step-≡ˡ _ y⟨⟩z E.refl = y⟨⟩z syntax step-≡ˡ x y⟨⟩z x≡y = x ≡⟨ x≡y ⟩ y⟨⟩z _∼⟨⟩_ : ∀ {k i} x {y} → [ i ] x ⟨ k ⟩ y → [ i ] x ⟨ k ⟩ y _ ∼⟨⟩ x≈y = x≈y ---------------------------------------------------------------------- -- Some results related to negation -- The computation never is not related to now x. never≉now : ∀ {k i x} → ¬ [ i ] never ⟨ k ⟩ now x never≉now (laterˡ p) = never≉now p -- The computation now x is not related to never. now≉never : ∀ {k i x} → ¬ [ i ] now x ⟨ k ⟩ never now≉never (laterʳ p) = now≉never p -- If A ∞ is uninhabited, then the three relations defined above are -- trivial. uninhabited→trivial : ∀ {k i} → ¬ A ∞ → ∀ x y → [ i ] x ⟨ k ⟩ y uninhabited→trivial ¬A (now x) _ = ⊥-elim (¬A x) uninhabited→trivial ¬A (later x) (now y) = ⊥-elim (¬A y) uninhabited→trivial ¬A (later x) (later y) = later λ { .force → uninhabited→trivial ¬A (force x) (force y) } -- Expansion and weak bisimilarity are not pointwise propositional. ¬-≳≈-propositional : ∀ {k} → ¬ (∀ {x y} → E.Is-proposition ([ ∞ ] x ⟨ other k ⟩ y)) ¬-≳≈-propositional {k} = (∀ {x y} → E.Is-proposition ([ ∞ ] x ⟨ other k ⟩ y)) ↝⟨ (λ prop → prop {x = never} {y = never}) ⟩ E.Is-proposition ([ ∞ ] never ⟨ other k ⟩ never) ↝⟨ (λ irr → irr _ _) ⟩ proof₁ ≡ proof₂ ↝⟨ (λ ()) ⟩□ ⊥₀ □ where proof₁ : ∀ {i} → [ i ] never ⟨ other k ⟩ never proof₁ = later λ { .force → proof₁ } proof₂ : ∀ {i} → [ i ] never ⟨ other k ⟩ never proof₂ = laterˡ proof₁ ------------------------------------------------------------------------ -- A statement of extensionality for strong bisimilarity -- A statement of extensionality: strongly bisimilar computations are -- equal. Extensionality : (ℓ : Level) → Type (lsuc ℓ) Extensionality a = {A : Size → Type a} {x y : Delay A ∞} → x ∼ y → x ≡ y
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/a-tags.adb
djamal2727/Main-Bearing-Analytical-Model
0
17274
<gh_stars>0 ------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T A G S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Exceptions; with Ada.Unchecked_Conversion; with System.HTable; with System.Storage_Elements; use System.Storage_Elements; with System.WCh_Con; use System.WCh_Con; with System.WCh_StW; use System.WCh_StW; pragma Elaborate (System.HTable); -- Elaborate needed instead of Elaborate_All to avoid elaboration cycles -- when polling is turned on. This is safe because HTable doesn't do anything -- at elaboration time; it just contains a generic package we want to -- instantiate. package body Ada.Tags is ----------------------- -- Local Subprograms -- ----------------------- function Get_External_Tag (T : Tag) return System.Address; -- Returns address of a null terminated string containing the external name function Is_Primary_DT (T : Tag) return Boolean; -- Given a tag returns True if it has the signature of a primary dispatch -- table. This is Inline_Always since it is called from other Inline_ -- Always subprograms where we want no out of line code to be generated. function IW_Membership (Descendant_TSD : Type_Specific_Data_Ptr; T : Tag) return Boolean; -- Subsidiary function of IW_Membership and CW_Membership which factorizes -- the functionality needed to check if a given descendant implements an -- interface tag T. function Length (Str : Cstring_Ptr) return Natural; -- Length of string represented by the given pointer (treating the string -- as a C-style string, which is Nul terminated). See comment in body -- explaining why we cannot use the normal strlen built-in. function OSD (T : Tag) return Object_Specific_Data_Ptr; -- Ada 2005 (AI-251): Given a pointer T to a secondary dispatch table, -- retrieve the address of the record containing the Object Specific -- Data table. function SSD (T : Tag) return Select_Specific_Data_Ptr; -- Ada 2005 (AI-251): Given a pointer T to a dispatch Table, retrieves the -- address of the record containing the Select Specific Data in T's TSD. pragma Inline_Always (Get_External_Tag); pragma Inline_Always (Is_Primary_DT); pragma Inline_Always (OSD); pragma Inline_Always (SSD); -- Unchecked conversions function To_Address is new Unchecked_Conversion (Cstring_Ptr, System.Address); function To_Cstring_Ptr is new Unchecked_Conversion (System.Address, Cstring_Ptr); -- Disable warnings on possible aliasing problem function To_Tag is new Unchecked_Conversion (Integer_Address, Tag); function To_Addr_Ptr is new Ada.Unchecked_Conversion (System.Address, Addr_Ptr); function To_Address is new Ada.Unchecked_Conversion (Tag, System.Address); function To_Dispatch_Table_Ptr is new Ada.Unchecked_Conversion (Tag, Dispatch_Table_Ptr); function To_Dispatch_Table_Ptr is new Ada.Unchecked_Conversion (System.Address, Dispatch_Table_Ptr); function To_Object_Specific_Data_Ptr is new Ada.Unchecked_Conversion (System.Address, Object_Specific_Data_Ptr); function To_Tag_Ptr is new Ada.Unchecked_Conversion (System.Address, Tag_Ptr); function To_Type_Specific_Data_Ptr is new Ada.Unchecked_Conversion (System.Address, Type_Specific_Data_Ptr); ------------------------------- -- Inline_Always Subprograms -- ------------------------------- -- Inline_always subprograms must be placed before their first call to -- avoid defeating the frontend inlining mechanism and thus ensure the -- generation of their correct debug info. ------------------- -- CW_Membership -- ------------------- -- Canonical implementation of Classwide Membership corresponding to: -- Obj in Typ'Class -- Each dispatch table contains a reference to a table of ancestors (stored -- in the first part of the Tags_Table) and a count of the level of -- inheritance "Idepth". -- Obj is in Typ'Class if Typ'Tag is in the table of ancestors that are -- contained in the dispatch table referenced by Obj'Tag . Knowing the -- level of inheritance of both types, this can be computed in constant -- time by the formula: -- TSD (Obj'tag).Tags_Table (TSD (Obj'tag).Idepth - TSD (Typ'tag).Idepth) -- = Typ'tag function CW_Membership (Obj_Tag : Tag; Typ_Tag : Tag) return Boolean is Obj_TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (Obj_Tag) - DT_Typeinfo_Ptr_Size); Typ_TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (Typ_Tag) - DT_Typeinfo_Ptr_Size); Obj_TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (Obj_TSD_Ptr.all); Typ_TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (Typ_TSD_Ptr.all); Pos : constant Integer := Obj_TSD.Idepth - Typ_TSD.Idepth; begin return Pos >= 0 and then Obj_TSD.Tags_Table (Pos) = Typ_Tag; end CW_Membership; ---------------------- -- Get_External_Tag -- ---------------------- function Get_External_Tag (T : Tag) return System.Address is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); begin return To_Address (TSD.External_Tag); end Get_External_Tag; ----------------- -- Is_Abstract -- ----------------- function Is_Abstract (T : Tag) return Boolean is TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); return TSD.Is_Abstract; end Is_Abstract; ------------------- -- Is_Primary_DT -- ------------------- function Is_Primary_DT (T : Tag) return Boolean is begin return DT (T).Signature = Primary_DT; end Is_Primary_DT; --------- -- OSD -- --------- function OSD (T : Tag) return Object_Specific_Data_Ptr is OSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); begin return To_Object_Specific_Data_Ptr (OSD_Ptr.all); end OSD; --------- -- SSD -- --------- function SSD (T : Tag) return Select_Specific_Data_Ptr is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); begin return TSD.SSD; end SSD; ------------------------- -- External_Tag_HTable -- ------------------------- type HTable_Headers is range 1 .. 64; -- The following internal package defines the routines used for the -- instantiation of a new System.HTable.Static_HTable (see below). See -- spec in g-htable.ads for details of usage. package HTable_Subprograms is procedure Set_HT_Link (T : Tag; Next : Tag); function Get_HT_Link (T : Tag) return Tag; function Hash (F : System.Address) return HTable_Headers; function Equal (A, B : System.Address) return Boolean; end HTable_Subprograms; package External_Tag_HTable is new System.HTable.Static_HTable ( Header_Num => HTable_Headers, Element => Dispatch_Table, Elmt_Ptr => Tag, Null_Ptr => null, Set_Next => HTable_Subprograms.Set_HT_Link, Next => HTable_Subprograms.Get_HT_Link, Key => System.Address, Get_Key => Get_External_Tag, Hash => HTable_Subprograms.Hash, Equal => HTable_Subprograms.Equal); ------------------------ -- HTable_Subprograms -- ------------------------ -- Bodies of routines for hash table instantiation package body HTable_Subprograms is ----------- -- Equal -- ----------- function Equal (A, B : System.Address) return Boolean is Str1 : constant Cstring_Ptr := To_Cstring_Ptr (A); Str2 : constant Cstring_Ptr := To_Cstring_Ptr (B); J : Integer; begin J := 1; loop if Str1 (J) /= Str2 (J) then return False; elsif Str1 (J) = ASCII.NUL then return True; else J := J + 1; end if; end loop; end Equal; ----------------- -- Get_HT_Link -- ----------------- function Get_HT_Link (T : Tag) return Tag is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); begin return TSD.HT_Link.all; end Get_HT_Link; ---------- -- Hash -- ---------- function Hash (F : System.Address) return HTable_Headers is function H is new System.HTable.Hash (HTable_Headers); Str : constant Cstring_Ptr := To_Cstring_Ptr (F); Res : constant HTable_Headers := H (Str (1 .. Length (Str))); begin return Res; end Hash; ----------------- -- Set_HT_Link -- ----------------- procedure Set_HT_Link (T : Tag; Next : Tag) is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); begin TSD.HT_Link.all := Next; end Set_HT_Link; end HTable_Subprograms; ------------------ -- Base_Address -- ------------------ function Base_Address (This : System.Address) return System.Address is begin return This + Offset_To_Top (This); end Base_Address; --------------- -- Check_TSD -- --------------- procedure Check_TSD (TSD : Type_Specific_Data_Ptr) is T : Tag; E_Tag_Len : constant Integer := Length (TSD.External_Tag); E_Tag : String (1 .. E_Tag_Len); for E_Tag'Address use TSD.External_Tag.all'Address; pragma Import (Ada, E_Tag); Dup_Ext_Tag : constant String := "duplicated external tag """; begin -- Verify that the external tag of this TSD is not registered in the -- runtime hash table. T := External_Tag_HTable.Get (To_Address (TSD.External_Tag)); if T /= null then -- Avoid concatenation, as it is not allowed in no run time mode declare Msg : String (1 .. Dup_Ext_Tag'Length + E_Tag_Len + 1); begin Msg (1 .. Dup_Ext_Tag'Length) := Dup_Ext_Tag; Msg (Dup_Ext_Tag'Length + 1 .. Dup_Ext_Tag'Length + E_Tag_Len) := E_Tag; Msg (Msg'Last) := '"'; raise Program_Error with Msg; end; end if; end Check_TSD; -------------------- -- Descendant_Tag -- -------------------- function Descendant_Tag (External : String; Ancestor : Tag) return Tag is Int_Tag : constant Tag := Internal_Tag (External); begin if not Is_Descendant_At_Same_Level (Int_Tag, Ancestor) then raise Tag_Error; else return Int_Tag; end if; end Descendant_Tag; -------------- -- Displace -- -------------- function Displace (This : System.Address; T : Tag) return System.Address is Iface_Table : Interface_Data_Ptr; Obj_Base : System.Address; Obj_DT : Dispatch_Table_Ptr; Obj_DT_Tag : Tag; begin if System."=" (This, System.Null_Address) then return System.Null_Address; end if; Obj_Base := Base_Address (This); Obj_DT_Tag := To_Tag_Ptr (Obj_Base).all; Obj_DT := DT (To_Tag_Ptr (Obj_Base).all); Iface_Table := To_Type_Specific_Data_Ptr (Obj_DT.TSD).Interfaces_Table; if Iface_Table /= null then for Id in 1 .. Iface_Table.Nb_Ifaces loop if Iface_Table.Ifaces_Table (Id).Iface_Tag = T then -- Case of Static value of Offset_To_Top if Iface_Table.Ifaces_Table (Id).Static_Offset_To_Top then Obj_Base := Obj_Base - Iface_Table.Ifaces_Table (Id).Offset_To_Top_Value; -- Otherwise call the function generated by the expander to -- provide the value. else Obj_Base := Obj_Base - Iface_Table.Ifaces_Table (Id).Offset_To_Top_Func.all (Obj_Base); end if; return Obj_Base; end if; end loop; end if; -- Check if T is an immediate ancestor. This is required to handle -- conversion of class-wide interfaces to tagged types. if CW_Membership (Obj_DT_Tag, T) then return Obj_Base; end if; -- If the object does not implement the interface we must raise CE raise Constraint_Error with "invalid interface conversion"; end Displace; -------- -- DT -- -------- function DT (T : Tag) return Dispatch_Table_Ptr is Offset : constant SSE.Storage_Offset := To_Dispatch_Table_Ptr (T).Prims_Ptr'Position; begin return To_Dispatch_Table_Ptr (To_Address (T) - Offset); end DT; ------------------- -- IW_Membership -- ------------------- function IW_Membership (Descendant_TSD : Type_Specific_Data_Ptr; T : Tag) return Boolean is Iface_Table : Interface_Data_Ptr; begin Iface_Table := Descendant_TSD.Interfaces_Table; if Iface_Table /= null then for Id in 1 .. Iface_Table.Nb_Ifaces loop if Iface_Table.Ifaces_Table (Id).Iface_Tag = T then return True; end if; end loop; end if; -- Look for the tag in the ancestor tags table. This is required for: -- Iface_CW in Typ'Class for Id in 0 .. Descendant_TSD.Idepth loop if Descendant_TSD.Tags_Table (Id) = T then return True; end if; end loop; return False; end IW_Membership; ------------------- -- IW_Membership -- ------------------- -- Canonical implementation of Classwide Membership corresponding to: -- Obj in Iface'Class -- Each dispatch table contains a table with the tags of all the -- implemented interfaces. -- Obj is in Iface'Class if Iface'Tag is found in the table of interfaces -- that are contained in the dispatch table referenced by Obj'Tag. function IW_Membership (This : System.Address; T : Tag) return Boolean is Obj_Base : System.Address; Obj_DT : Dispatch_Table_Ptr; Obj_TSD : Type_Specific_Data_Ptr; begin Obj_Base := Base_Address (This); Obj_DT := DT (To_Tag_Ptr (Obj_Base).all); Obj_TSD := To_Type_Specific_Data_Ptr (Obj_DT.TSD); return IW_Membership (Obj_TSD, T); end IW_Membership; ------------------- -- Expanded_Name -- ------------------- function Expanded_Name (T : Tag) return String is Result : Cstring_Ptr; TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Result := TSD.Expanded_Name; return Result (1 .. Length (Result)); end Expanded_Name; ------------------ -- External_Tag -- ------------------ function External_Tag (T : Tag) return String is Result : Cstring_Ptr; TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Result := TSD.External_Tag; return Result (1 .. Length (Result)); end External_Tag; --------------------- -- Get_Entry_Index -- --------------------- function Get_Entry_Index (T : Tag; Position : Positive) return Positive is begin return SSD (T).SSD_Table (Position).Index; end Get_Entry_Index; ---------------------- -- Get_Prim_Op_Kind -- ---------------------- function Get_Prim_Op_Kind (T : Tag; Position : Positive) return Prim_Op_Kind is begin return SSD (T).SSD_Table (Position).Kind; end Get_Prim_Op_Kind; ---------------------- -- Get_Offset_Index -- ---------------------- function Get_Offset_Index (T : Tag; Position : Positive) return Positive is begin if Is_Primary_DT (T) then return Position; else return OSD (T).OSD_Table (Position); end if; end Get_Offset_Index; --------------------- -- Get_Tagged_Kind -- --------------------- function Get_Tagged_Kind (T : Tag) return Tagged_Kind is begin return DT (T).Tag_Kind; end Get_Tagged_Kind; ----------------------------- -- Interface_Ancestor_Tags -- ----------------------------- function Interface_Ancestor_Tags (T : Tag) return Tag_Array is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); Iface_Table : constant Interface_Data_Ptr := TSD.Interfaces_Table; begin if Iface_Table = null then declare Table : Tag_Array (1 .. 0); begin return Table; end; else declare Table : Tag_Array (1 .. Iface_Table.Nb_Ifaces); begin for J in 1 .. Iface_Table.Nb_Ifaces loop Table (J) := Iface_Table.Ifaces_Table (J).Iface_Tag; end loop; return Table; end; end if; end Interface_Ancestor_Tags; ------------------ -- Internal_Tag -- ------------------ -- Internal tags have the following format: -- "Internal tag at 16#ADDRESS#: <full-name-of-tagged-type>" Internal_Tag_Header : constant String := "Internal tag at "; Header_Separator : constant Character := '#'; function Internal_Tag (External : String) return Tag is pragma Unsuppress (All_Checks); -- To make T'Class'Input robust in the case of bad data Res : Tag := null; begin -- Raise Tag_Error for empty strings and very long strings. This makes -- T'Class'Input robust in the case of bad data, for example -- -- String (123456789..1234) -- -- The limit of 10,000 characters is arbitrary, but is unlikely to be -- exceeded by legitimate external tag names. if External'Length not in 1 .. 10_000 then raise Tag_Error; end if; -- Handle locally defined tagged types if External'Length > Internal_Tag_Header'Length and then External (External'First .. External'First + Internal_Tag_Header'Length - 1) = Internal_Tag_Header then declare Addr_First : constant Natural := External'First + Internal_Tag_Header'Length; Addr_Last : Natural; Addr : Integer_Address; begin -- Search the second separator (#) to identify the address Addr_Last := Addr_First; for J in 1 .. 2 loop while Addr_Last <= External'Last and then External (Addr_Last) /= Header_Separator loop Addr_Last := Addr_Last + 1; end loop; -- Skip the first separator if J = 1 then Addr_Last := Addr_Last + 1; end if; end loop; if Addr_Last <= External'Last then -- Protect the run-time against wrong internal tags. We -- cannot use exception handlers here because it would -- disable the use of this run-time compiling with -- restriction No_Exception_Handler. declare C : Character; Wrong_Tag : Boolean := False; begin if External (Addr_First) /= '1' or else External (Addr_First + 1) /= '6' or else External (Addr_First + 2) /= '#' then Wrong_Tag := True; else for J in Addr_First + 3 .. Addr_Last - 1 loop C := External (J); if not (C in '0' .. '9') and then not (C in 'A' .. 'F') and then not (C in 'a' .. 'f') then Wrong_Tag := True; exit; end if; end loop; end if; -- Convert the numeric value into a tag if not Wrong_Tag then Addr := Integer_Address'Value (External (Addr_First .. Addr_Last)); -- Internal tags never have value 0 if Addr /= 0 then return To_Tag (Addr); end if; end if; end; end if; end; -- Handle library-level tagged types else -- Make NUL-terminated copy of external tag string declare Ext_Copy : aliased String (External'First .. External'Last + 1); pragma Assert (Ext_Copy'Length > 1); -- See Length check at top begin Ext_Copy (External'Range) := External; Ext_Copy (Ext_Copy'Last) := ASCII.NUL; Res := External_Tag_HTable.Get (Ext_Copy'Address); end; end if; if Res = null then declare Msg1 : constant String := "unknown tagged type: "; Msg2 : String (1 .. Msg1'Length + External'Length); begin Msg2 (1 .. Msg1'Length) := Msg1; Msg2 (Msg1'Length + 1 .. Msg1'Length + External'Length) := External; Ada.Exceptions.Raise_Exception (Tag_Error'Identity, Msg2); end; end if; return Res; end Internal_Tag; --------------------------------- -- Is_Descendant_At_Same_Level -- --------------------------------- function Is_Descendant_At_Same_Level (Descendant : Tag; Ancestor : Tag) return Boolean is begin if Descendant = Ancestor then return True; else declare D_TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (Descendant) - DT_Typeinfo_Ptr_Size); A_TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (Ancestor) - DT_Typeinfo_Ptr_Size); D_TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (D_TSD_Ptr.all); A_TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (A_TSD_Ptr.all); begin return D_TSD.Access_Level = A_TSD.Access_Level and then (CW_Membership (Descendant, Ancestor) or else IW_Membership (D_TSD, Ancestor)); end; end if; end Is_Descendant_At_Same_Level; ------------ -- Length -- ------------ -- Note: This unit is used in the Ravenscar runtime library, so it cannot -- depend on System.CTRL. Furthermore, this happens on CPUs where the GCC -- intrinsic strlen may not be available, so we need to recode our own Ada -- version here. function Length (Str : Cstring_Ptr) return Natural is Len : Integer; begin Len := 1; while Str (Len) /= ASCII.NUL loop Len := Len + 1; end loop; return Len - 1; end Length; ------------------- -- Offset_To_Top -- ------------------- function Offset_To_Top (This : System.Address) return SSE.Storage_Offset is Tag_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); type Storage_Offset_Ptr is access SSE.Storage_Offset; function To_Storage_Offset_Ptr is new Unchecked_Conversion (System.Address, Storage_Offset_Ptr); Curr_DT : Dispatch_Table_Ptr; begin Curr_DT := DT (To_Tag_Ptr (This).all); -- See the documentation of Dispatch_Table_Wrapper.Offset_To_Top if Curr_DT.Offset_To_Top = SSE.Storage_Offset'Last then -- The parent record type has variable-size components, so the -- instance-specific offset is stored in the tagged record, right -- after the reference to Curr_DT (which is a secondary dispatch -- table). return To_Storage_Offset_Ptr (This + Tag_Size).all; else -- The offset is compile-time known, so it is simply stored in the -- Offset_To_Top field. return Curr_DT.Offset_To_Top; end if; end Offset_To_Top; ------------------------ -- Needs_Finalization -- ------------------------ function Needs_Finalization (T : Tag) return Boolean is TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); begin return TSD.Needs_Finalization; end Needs_Finalization; ----------------- -- Parent_Size -- ----------------- function Parent_Size (Obj : System.Address; T : Tag) return SSE.Storage_Count is Parent_Slot : constant Positive := 1; -- The tag of the parent is always in the first slot of the table of -- ancestor tags. TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (TSD_Ptr.all); -- Pointer to the TSD Parent_Tag : constant Tag := TSD.Tags_Table (Parent_Slot); Parent_TSD_Ptr : constant Addr_Ptr := To_Addr_Ptr (To_Address (Parent_Tag) - DT_Typeinfo_Ptr_Size); Parent_TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (Parent_TSD_Ptr.all); begin -- Here we compute the size of the _parent field of the object return SSE.Storage_Count (Parent_TSD.Size_Func.all (Obj)); end Parent_Size; ---------------- -- Parent_Tag -- ---------------- function Parent_Tag (T : Tag) return Tag is TSD_Ptr : Addr_Ptr; TSD : Type_Specific_Data_Ptr; begin if T = No_Tag then raise Tag_Error; end if; TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size); TSD := To_Type_Specific_Data_Ptr (TSD_Ptr.all); -- The Parent_Tag of a root-level tagged type is defined to be No_Tag. -- The first entry in the Ancestors_Tags array will be null for such -- a type, but it's better to be explicit about returning No_Tag in -- this case. if TSD.Idepth = 0 then return No_Tag; else return TSD.Tags_Table (1); end if; end Parent_Tag; ------------------------------- -- Register_Interface_Offset -- ------------------------------- procedure Register_Interface_Offset (Prim_T : Tag; Interface_T : Tag; Is_Static : Boolean; Offset_Value : SSE.Storage_Offset; Offset_Func : Offset_To_Top_Function_Ptr) is Prim_DT : constant Dispatch_Table_Ptr := DT (Prim_T); Iface_Table : constant Interface_Data_Ptr := To_Type_Specific_Data_Ptr (Prim_DT.TSD).Interfaces_Table; begin -- Save Offset_Value in the table of interfaces of the primary DT. -- This data will be used by the subprogram "Displace" to give support -- to backward abstract interface type conversions. -- Register the offset in the table of interfaces if Iface_Table /= null then for Id in 1 .. Iface_Table.Nb_Ifaces loop if Iface_Table.Ifaces_Table (Id).Iface_Tag = Interface_T then if Is_Static or else Offset_Value = 0 then Iface_Table.Ifaces_Table (Id).Static_Offset_To_Top := True; Iface_Table.Ifaces_Table (Id).Offset_To_Top_Value := Offset_Value; else Iface_Table.Ifaces_Table (Id).Static_Offset_To_Top := False; Iface_Table.Ifaces_Table (Id).Offset_To_Top_Func := Offset_Func; end if; return; end if; end loop; end if; -- If we arrive here there is some error in the run-time data structure raise Program_Error; end Register_Interface_Offset; ------------------ -- Register_Tag -- ------------------ procedure Register_Tag (T : Tag) is begin External_Tag_HTable.Set (T); end Register_Tag; ------------------- -- Secondary_Tag -- ------------------- function Secondary_Tag (T, Iface : Tag) return Tag is Iface_Table : Interface_Data_Ptr; Obj_DT : Dispatch_Table_Ptr; begin if not Is_Primary_DT (T) then raise Program_Error; end if; Obj_DT := DT (T); Iface_Table := To_Type_Specific_Data_Ptr (Obj_DT.TSD).Interfaces_Table; if Iface_Table /= null then for Id in 1 .. Iface_Table.Nb_Ifaces loop if Iface_Table.Ifaces_Table (Id).Iface_Tag = Iface then return Iface_Table.Ifaces_Table (Id).Secondary_DT; end if; end loop; end if; -- If the object does not implement the interface we must raise CE raise Constraint_Error with "invalid interface conversion"; end Secondary_Tag; --------------------- -- Set_Entry_Index -- --------------------- procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive) is begin SSD (T).SSD_Table (Position).Index := Value; end Set_Entry_Index; ------------------------------- -- Set_Dynamic_Offset_To_Top -- ------------------------------- procedure Set_Dynamic_Offset_To_Top (This : System.Address; Prim_T : Tag; Interface_T : Tag; Offset_Value : SSE.Storage_Offset; Offset_Func : Offset_To_Top_Function_Ptr) is Sec_Base : System.Address; Sec_DT : Dispatch_Table_Ptr; begin -- Save the offset to top field in the secondary dispatch table if Offset_Value /= 0 then Sec_Base := This - Offset_Value; Sec_DT := DT (To_Tag_Ptr (Sec_Base).all); Sec_DT.Offset_To_Top := SSE.Storage_Offset'Last; end if; Register_Interface_Offset (Prim_T, Interface_T, False, Offset_Value, Offset_Func); end Set_Dynamic_Offset_To_Top; ---------------------- -- Set_Prim_Op_Kind -- ---------------------- procedure Set_Prim_Op_Kind (T : Tag; Position : Positive; Value : Prim_Op_Kind) is begin SSD (T).SSD_Table (Position).Kind := Value; end Set_Prim_Op_Kind; -------------------- -- Unregister_Tag -- -------------------- procedure Unregister_Tag (T : Tag) is begin External_Tag_HTable.Remove (Get_External_Tag (T)); end Unregister_Tag; ------------------------ -- Wide_Expanded_Name -- ------------------------ WC_Encoding : Character; pragma Import (C, WC_Encoding, "__gl_wc_encoding"); -- Encoding method for source, as exported by binder function Wide_Expanded_Name (T : Tag) return Wide_String is S : constant String := Expanded_Name (T); W : Wide_String (1 .. S'Length); L : Natural; begin String_To_Wide_String (S, W, L, Get_WC_Encoding_Method (WC_Encoding)); return W (1 .. L); end Wide_Expanded_Name; ----------------------------- -- Wide_Wide_Expanded_Name -- ----------------------------- function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String is S : constant String := Expanded_Name (T); W : Wide_Wide_String (1 .. S'Length); L : Natural; begin String_To_Wide_Wide_String (S, W, L, Get_WC_Encoding_Method (WC_Encoding)); return W (1 .. L); end Wide_Wide_Expanded_Name; end Ada.Tags;
Bitmaps/src/bitmaps.ads
kochab/simulatedannealing-ada
0
10674
<filename>Bitmaps/src/bitmaps.ads package Bitmaps is type Luminance is mod 2**8; end Bitmaps;
oeis/342/A342449.asm
neoneye/loda-programs
11
98626
<reponame>neoneye/loda-programs ; A342449: a(n) = Sum_{k=1..n} gcd(k,n)^k. ; Submitted by <NAME>(s2) ; 1,5,29,262,3129,46705,823549,16777544,387421251,10000003469,285311670621,8916100581446,302875106592265,11112006826387025,437893890391180013,18446744073743123788,827240261886336764193,39346408075299116257065 add $0,1 mov $2,$0 lpb $2 mov $3,$2 gcd $3,$0 pow $3,$2 add $1,$3 sub $2,1 lpe mov $0,$1
src/kernel/pkernel.asm
tishion/PiscisOS
86
14472
<reponame>tishion/PiscisOS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Kernel of the PiscisOS ;; The only one main source file to be assembled ;; ;; 23/01/2012 ;; Copyright (C) tishion ;; E-Mail:<EMAIL> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include ".\include\sys32.h" include ".\include\process.h" include ".\include\ascii.h" include ".\include\drivers\console.h" include ".\include\drivers\i8259A.h" include ".\include\drivers\keyboard.h" include ".\include\drivers\ramdiskfs.h" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Kernel base an offset KERNEL_BASE equ 1000h KERNEL_OFFSET equ 0000h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Address of some CONST MEMORY_SIZE equ 0f000h ;address of memory size of system[4Byte] sys_tic equ 0f010h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LOW_MEMORY_SAVE_BASE equ 0290000h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Diskette bases DISKIMG_BASE equ 100000h RAW_FAT_BASE equ 100200h NEW_FAT_BASE equ 280000h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Cursor row_start equ 08000h ;address of number of current screen row x_cursor equ 08002h ;address of number of current column y_cursor equ 08004h ;address of number of current row ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; 16 BIT CODE ENTRY AFTER BOOTSECTOR ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use16 org 00h kernel_start: jmp start_of_code16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; 16 BIT DATAS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; macro title_ver_row { times 33 db 32 db 'Piscis OS v1.0' times 33 db 32 } macro title_sep_row { times 80 db 205 } initscreen: title_ver_row title_sep_row str_debug db 0dh, 0ah, 'Piscis_Debug_String', 0 str_not386 db 0dh, 0ah, 'CPU is unsupported. 386+ is requried.', 0 str_loaddisk db 0dh, 0ah, 'Loading floppy cache: 00 %', 8, 8, 8, 8, 0 str_memmovefailed db 0dh, 0ah, 'Fatal - Floppy image move failed.', 0 str_badsect db 0dh, 0ah, 'Fatal - Floppy damaged.', 0 str_memsizeunknow db 0dh, 0ah, 'Fatal - Memory size unknown.', 0 str_notenoughmem db 0dh, 0ah, 'Fatal - Memory not enough. At least 16M', 0 str_pros db '00', 8, 8, 0 str_okt db ' ... OK', 0 char_backspace db 8, 0 char_newline db 0dh, 0ah, 0 mem_range_count dw 0 mem_range_buffer db 20 dup 0 mem_size dd 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; 16 BIT PROCS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PrintStr: push ax push bx cld .next_char: lodsb cmp al, 0 je .exit_p mov ah, 0eh xor bh, bh int 10h jmp .next_char .exit_p: pop bx pop ax ret PrintByte: ;use al push bx mov ah, 0eh push ax xor bh, bh shr al, 4 add al, 30h cmp al, 3ah jb .notalpha_h add al, 7 .notalpha_h: int 10h pop ax xor bh, bh and al, 0fh add al, 30h cmp al, 3ah jb .notalpha_l add al, 7 .notalpha_l: int 10h pop bx ret PrintWord: ;use ax push ax shr ax, 8 call PrintByte pop ax and ax, 00ffh call PrintByte ret PrintDWord: ;use eax push eax shr eax, 16 call PrintWord pop eax and eax, 0000ffffh call PrintWord ret DrawInitScreen: pusha mov ax, 0b800h mov es, ax mov di, 0 mov si, initscreen mov cx, 80*2 mov ah, 00000111b .loop_0: cld lodsb stosw loop .loop_0 mov cx, 80*23 mov ah, 00000111b mov al, 32 .loop_1: stosw loop .loop_1 mov ah, 02h mov bh, 0 mov dh, 2 mov dl, 0 int 10h popa ret ;;entry point of the 16 bit code. start_of_code16: ;;Code of 16 bit mov ax, KERNEL_BASE mov es, ax mov ds, ax mov ax, KERNEL_STACK_BASE mov ss, ax mov sp, STACK_SIZE_16BIT xor ax, ax xor bx, bx xor cx, cx xor dx, dx xor si, si xor di, di xor bp, bp call DrawInitScreen ;;Test cup 386+ ? testcpu: pushf pop ax mov dx, ax xor ax, 4000h push ax popf pushf pop ax and ax, 4000h and dx, 4000h cmp ax,dx jnz testcpu_ok mov si, str_not386 call PrintStr jmp $ testcpu_ok: resetregs: ;;Reset the 32 bit registers and stack mov ax, KERNEL_BASE mov es, ax mov ds, ax mov ax, KERNEL_STACK_BASE ; init stack segment base regester mov ss, ax mov sp, STACK_SIZE_16BIT ; int stack pointer regester-indicate the size of stack xor eax, eax xor ebx, ebx xor ecx, ecx xor edx, edx xor esi, esi xor edi, edi xor ebp, ebp resetregs_ok: memsize: mov ebx, 0 mov di, mem_range_buffer .next_range: clc mov eax, 0e820h mov ecx, 20 mov edx, 0534d4150h int 15h jc .fail inc word [mem_range_count] ; One AddressRangeMemory has been read done mov eax, dword [di+16] cmp eax, 1 ; Type is 1 ? jne .is_last ; Not 1, but 2 or others, goto test is this one the last AddressRangeMemory ? mov eax, dword [di] ; Type is 1, BaseAddressLow mov esi, dword [di+8] ; LengthLow add eax, esi ; Add the LengthLow to the BaseAddressLow mov [mem_size], eax ; Save the memory size; ;;;;;;;;;;;;;;;;;;;;;;;;DEBUG_CODE;;;;;;;;;;;;;;;;;;;;;;;; ; mov si, char_newline ; call PrintStr ; mov eax, [mem_size] ; call PrintDWord ;;;;;;;;;;;;;;;;;;;;;;;;DEBUG_CODE;;;;;;;;;;;;;;;;;;;;;;;; .is_last: test ebx, ebx ; Is the last AddressRangeMemory ? jz .memsize_ok ; Yes, get memory size done jne .next_range ; No, get next AddressRangeMemory .fail: mov si, str_memsizeunknow call PrintStr jmp $ .memsize_ok: mov eax, [mem_size] cmp eax, 01000000h ;At least 16M jae memsize_end mov si, str_notenoughmem call PrintStr jmp $ memsize_end: storememsize: push es xor ax, ax mov es, ax mov dword [es:MEMORY_SIZE], eax pop es storememsize_end: ;;Load diskette to memory. Each time read and move 18 sectors(One track or One cylinder). loadfloppyimage: mov si, str_loaddisk call PrintStr mov ax, 0000h ; Reset drive mov dx, 0000h int 13h mov cx, 0001h ; Number of start cyl and sector mov dx, 0000h ; Number of start head and drive push word 80*2 ; Count of tracks .readmove_loop: pusha xor si, si ; Error count .read18sectors: push word 0 pop es mov bx, 0a000h ; es:bx -> data area mov al, 18; ; Number of sectors to read mov ah, 02h ; Read int 13h cmp ah, 0 jz .read18sectorsOK add si, 1 cmp si, 10 jnz .read18sectors mov si, str_badsect call PrintStr jmp $ .read18sectorsOK: ; move -> 1mb mov si, .movedesc push word 1000h pop es mov cx, 256*18 mov ah, 0x87 int 15h cmp ah, 00h ; Move ok ? je .moveok mov dx, 03f2fh ; Floppy motor off mov al, 00h out dx, al mov si, str_memmovefailed call PrintStr jmp $ .moveok: mov eax, [.movedesc+18h+2] add eax, 512*18 mov [.movedesc+18h+2], eax popa inc dh ; Head+1 cmp dh, 2 ; Current head is number 1 ? jnz .headinc ; No, read the other track on current Cylinder mov dh, 0 ; Yes, read next two track on next Cylinder(Cylinder+1) inc ch ; Cylinder+1; pusha ; Display prosentage push word KERNEL_BASE pop es xor eax, eax ; 5 mov al, ch shr eax, 2 and eax, 1 mov ebx, 5 mul bx add al, 30h mov [str_pros+1], al xor eax, eax ; 10 mov al, ch shr eax, 3 add al, 30h mov [str_pros], al mov si, str_pros call PrintStr popa .headinc: pop ax dec ax push ax cmp ax, 0 ; All read and move done? jnz .readmove_loop ; No, read and move next 18 sectors mov dx, 03f2h ; Floppy motor off mov al, 0 out dx, al jmp .readmovedone ; Yes, all sectors read and move done .movedesc: db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved db 0xff,0xff ; segment length db 0x0,0xa0,0x00 ; source address db 0x93 ; access privalige db 0x0,0x0 ; reserved db 0xff,0xff ; segment length db 0x00,0x00,0x10 ; dest address db 0x93 ; access privalige db 0x0,0x0 ; reserved db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 ; reserved .readmovedone: pop ax mov si, char_backspace call PrintStr mov si, str_okt call PrintStr loadfloppyimage_end: ;;;;;;;;;;;;;;;;;;;;;;;;DEBUG_CODE;;;;;;;;;;;;;;;;;;;;;;;; ; mov si, str_debug ; call PrintStr ;;;;;;;;;;;;;;;;;;;;;;;;DEBUG_CODE;;;;;;;;;;;;;;;;;;;;;;;; ; mov si, char_newline ; call PrintStr ; mov ax, [cs:gdts-KERNEL_BASE*16] ; call PrintWord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; SWITCH TO PROTECTMODEL OF 32 BIT ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; sel_os_code equ os_code_l - gdts + 0 sel_os_data equ os_data_l - gdts + 0 sel_os_stack equ os_stack_l - gdts + 0 sel_video_data equ video_data_l - gdts + 3 sel_int_stack equ int_stack_l - gdts +0 sel_sysc_stack equ sysc_stack_l - gdts + 0 sel_ring1_code equ ring1_code_l - gdts + 1 sel_ring1_data equ ring1_data_l - gdts + 1 sel_ring1_stack equ ring1_stack_l - gdts + 1 sel_ring2_code equ ring2_code_l - gdts + 2 sel_ring2_data equ ring2_data_l - gdts + 2 sel_ring2_stack equ ring2_stack_l - gdts + 2 sel_tss_int0 equ tss_interrupt0_l - gdts + 0 sel_tss_process0 equ tss_process0_l - gdts + 0 sel_tg_process0 equ tg_process0_l - gdts + 0 sel_tss_sysc0 equ tss_syscall0_l - gdts + 0 sel_user_code equ user_code_l - gdts + 3 sel_user_data equ user_data_l - gdts + 3 ;; Set CR0 register - Protect mode. cli lgdt [cs:gdts-KERNEL_BASE*16] ; Load GDT in al, 92h ; Enable A20 or al, 02h out 92h, al mov eax, cr0 or eax, 01h mov cr0, eax jmp pword sel_os_code:pm32_entry use32 kernel_32bit: org (KERNEL_BASE*16 + (kernel_32bit - kernel_start)) macro align value { rb (value-1) - ($ + value-1) mod value } boot_debug db 'debug string.', 0dh, 0ah, 'debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...debugstring...', 0 boot_str_rcpuid db 'Reading CPUIDs...', 0 boot_str_rpirqs db 'Setting all IRQs...', 0 boot_str_setitss db 'Setting interrupt TSS...', 0 boot_str_setitssdesc db 'Setting GDT with interrupt TSS descriptors...', 0 boot_str_setitaskgate db 'Setting IDT with interrupt task gate...', 0 boot_str_setrdfs db 'Setting ramdisk file system...', 0 boot_str_setsysctss db 'Setting syscall TSS...', 0 boot_str_setsysctssdesc db 'Setting GDT with syscall TSS descriptors...', 0 boot_str_setsysctaskgate db 'Setting IDT with syscall task gate...', 0 boot_str_setptss db 'Setting process TSS...', 0 boot_str_setpcb db 'Setting process control block...', 0 boot_str_setptssdesc db 'Setting GDT with process TSS descriptors...', 0 boot_str_setptaskgate db 'Setting GDT with process task gate...', 0 boot_str_setprocessseg db 'Setting GDT with process segment descriptor...', 0 boot_str_settimer db 'Setting timer(8259)...', 0 boot_str_setostask db 'Setting system process...', 0 boot_str_enirqs db 'Enabling all IRQs...', 0 boot_str_initshell db 'Initializing PShell...', 0 boot_str_presenter db 'All settings have done! Press ENTER key to start!', 0 shell_path db '\shell', 0 promot_row db 0 promot_ok db '[ OK ]', 0 promot_failed db '[FAILED]', 0 cpuid_0 dd 0, 0, 0, 0 cpuid_1 dd 0, 0, 0, 0 cpuid_2 dd 0, 0, 0, 0 cpuid_3 dd 0, 0, 0, 0 byte2HexStr: ;; Convert byte data to hex string ;; al:[in] byte to convert ;; ds-edi:[in] dest buffer to save hex chars push edi push eax push eax shr al, 4 add al, 30h cmp al, 3ah jb .notalpha_h add al, 7 .notalpha_h: mov [edi], al pop eax and al, 0fh add al, 30h cmp al, 3ah jb .notalpha_l add al, 7 .notalpha_l: mov [edi+1], al pop eax pop edi ret word2Hstr: push edi push eax push eax shr ax, 8 call byte2HexStr pop eax add edi, 2 call byte2HexStr pop eax pop edi ret dword2HexStr: push edi push eax push eax shr eax, 16 call word2Hstr pop eax add edi, 4 call word2Hstr pop eax pop edi ret boot_promot: pusha xor eax, eax mov al, [promot_row] mov ecx, 160 mul ecx ; x*80*2 mov edi, eax cld mov ah, 0fh ; Black background, White forground, and Hilght .next_char: lodsb cmp al, 0 je .exit_p mov [gs:edi], ax add edi, 2 jmp .next_char .exit_p: popa ret boot_promot_status: pusha jc .failed .ok: mov esi, promot_ok push 0a00h ; Black background, Green forground, and Hilght jmp .show_string .failed: mov esi, promot_failed push 0c00h ; Black background, Red forground, and Hilght .show_string: xor eax, eax mov al, [promot_row] mov ecx, 160 mul ecx ; x*80*2 add eax, 50*2 mov edi, eax cld pop eax .next_char: lodsb cmp al, 0 je .exit_p mov [gs:edi], ax add edi, 2 jmp .next_char .exit_p: mov al, [promot_row] inc al mov [promot_row], al popa ret read_cpuid: stc pushfd ; get current flags pop eax mov ecx, eax xor eax, 00200000h ; attempt to toggle ID bit push eax popfd pushfd ; get new EFLAGS pop eax push ecx ; restore original flags popfd and eax, 00200000h ; if we couldn't toggle ID, and ecx, 00200000h ; then this is i486 cmp eax, ecx jz .exit_p ; It's not Pentium or later. ret mov edi, cpuid_0 ; It's Pentium use CPUID instruction read again mov esi, 0 .cpuid_new_read: mov eax, esi cpuid mov [edi+00h], eax mov [edi+04h], ebx mov [edi+08h], ecx mov [edi+0ch], edx add edi, 4*4 cmp esi, 3 jge .exit_p cmp esi, [cpuid_0] jge .exit_p inc esi jmp .cpuid_new_read .exit_p: clc ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; 32 BIT CODE ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 4 pm32_entry: ;; Set ds, es, fs, ss, esp gs mov ax, sel_os_data ;;0 mov ds, ax mov es, ax mov fs, ax mov ax, sel_os_stack mov ss, ax mov esp, STACK_SIZE_32BIT mov ax, sel_video_data mov gs, ax ;;Clear screen push es mov ax, gs mov es, ax xor edi, edi mov ecx, 80*25*8 mov ax, 0720h cld rep stosw pop es ;;Set paging tables ;;Set Pageing Directory Entrys SetPDEs: xor edx, edx mov eax, dword [ds:MEMORY_SIZE] mov ebx, 400000h div ebx mov ecx, eax test edx, edx jz .no_remainder inc ecx .no_remainder: push ecx mov ax, sel_os_data mov es, ax mov edi, PDE_OFFSET mov eax, PTE_OFFSET+7 cld .loop_0: stosd add eax, 4096 ; One PDE has 1024 PTEs(4Byte) loop .loop_0 SetPDEs_ok: ;;Set paging table entry 4 kb paging SetPTEs: mov ax, sel_os_data mov es, ax pop eax mov ebx, 1024 mul ebx mov ecx, eax ;Count of PTEs =1024*count of PDEs mov edi, PTE_OFFSET mov eax, 0+7 ; For 0 M cld .loop_0: stosd add eax, 4096 loop .loop_0 SetPTEs_ok: EnablePaging: mov eax, PDE_OFFSET+8+16 ; Page directory and enable caches mov cr3, eax mov eax, cr0 or eax, 80000000h mov cr0, eax jmp short EnablePaging_ok EnablePaging_ok: ;;Save & clear 0h-0efffh mov esi, 0x0000 mov edi, LOW_MEMORY_SAVE_BASE mov ecx, 0f000h / 4 cld rep movsd xor eax, eax mov edi, 0 mov ecx, 0f000h / 4 cld rep stosd ;;debugcode ; mov di, 0 ; mov cx, 20 ; mov al, 'a' ; debug_loop: ; mov ah, 07h ; mov [gs:di], ax ; inc al ; add di, 2 ; loop debug_loop ; mov di, ((80*4)+0)*2 ; mov cx, 20 ; mov al, 'A' ; debug_loop2: ; mov ah, 0ch ; mov [gs:di], ax ; inc al ; add di, 2 ; loop debug_loop2 ;;Set Row start and cursor position call CrtfnDisableCursor mov ax, 0 mov [row_start], ax call CrtfnSetStartRow mov ax, 0 mov [y_cursor], ax mov cx, 0 mov [x_cursor], cx call CrtfnSetCursorPos ;;Redirect all IRQs to INTs 020h~02fh mov esi, boot_str_rpirqs call boot_promot call ResetIRQs call boot_promot_status ;;Set interrupts mov esi, boot_str_setitss call boot_promot call set_interrupt_tss call boot_promot_status mov esi, boot_str_setitssdesc call boot_promot call set_gdt_interrupt_tss_descriptor call boot_promot_status mov esi, boot_str_setitaskgate call boot_promot call set_idt_interrupt_taskgate_descriptor call boot_promot_status lidt [cs:idts] ;;Set ramdisk file system mov esi, boot_str_setrdfs call boot_promot mov eax, DISKIMG_BASE mov ebx, NEW_FAT_BASE call RdfsInit call boot_promot_status ;;Set syscalls mov esi, boot_str_setsysctss call boot_promot call set_syscall_tss call boot_promot_status mov esi, boot_str_setsysctssdesc call boot_promot call set_gdt_syscall_tss_descriptor call boot_promot_status mov esi, boot_str_setsysctaskgate call boot_promot call set_idt_syscall_taskgate_descriptor call boot_promot_status ;;Set timer to 1/100 s mov esi, boot_str_settimer call boot_promot mov al, 34h ; Set model 2, 16 bit counter out 43h, al mov al, 9bh ; [msb:lsb]=[2e9bh]=[11931] lsb=9bh out 40h, al mov al, 2eh ; msb=2eh out 40h, al clc call boot_promot_status ;;Read CPUID mov esi,boot_str_rcpuid call boot_promot call read_cpuid call boot_promot_status ;;Set processes mov esi, boot_str_setptss call boot_promot call set_process_tss call boot_promot_status mov esi, boot_str_setpcb call boot_promot call set_process_control_block call boot_promot_status mov esi, boot_str_setptssdesc call boot_promot call set_gdt_process_tss_descriptor call boot_promot_status mov esi, boot_str_setptaskgate call boot_promot call set_gdt_process_taskgate_descriptor call boot_promot_status mov esi, boot_str_setprocessseg call boot_promot call set_gdt_process_segment_descriptor call boot_promot_status ;;;;;;;;;;;;;;;;Debug;;;;;;;;;;;;;;;;;;;;;; ;mov [400000h], byte 0h ;jmp $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Set OS task mov esi, boot_str_setostask call boot_promot mov ax, sel_tss_process0 ;set tss to save the temp task add ax, (max_processes+1)*8 ltr ax mov [ts.eflags], dword 0x11202 ; sti and resume mov [ts.ss0], sel_os_stack mov [ts.ss1], sel_ring1_stack mov [ts.ss2], sel_ring2_stack mov [ts.esp0], RING0_ESP_0 mov [ts.esp1], RING1_ESP_1 mov [ts.esp2], RING2_ESP_2 mov eax, cr3 mov [ts.cr3], eax mov [ts.eip], mainosloop mov [ts.esp], STACK_SIZE_32BIT mov [ts.cs], sel_os_code mov [ts.ss], sel_os_stack mov [ts.ds], sel_os_data mov [ts.es], sel_os_data mov [ts.fs], sel_os_data mov [ts.gs], sel_video_data mov esi, tss_struct mov edi, 0 imul edi, tss_unit_process_size add edi, tss_block_process_base mov ecx, 120/4 cld rep movsd mov edi, 0 imul edi, PCB_SIZE add edi, PCB_TABLE_BASE mov [edi+PID_OFFSET], dword 0 ;;pid mov [edi+PPID_OFFSET], dword 0 ;;ppid mov [edi+MLOC_OFFSET], dword 0 ;;mlocation mov [edi+TICK_OFFSET], dword 0 ;;tickcount mov [edi+STAT_OFFSET], byte PS_READY ;;status mov [edi+PCBS_OFFSET], byte PCBS_USED ;;pcb status mov [pcb_current_base], edi mov [pcb_current_no], dword 0 mov [pcb_total_count], dword 1 clc call boot_promot_status ;;Set test task a ; mov [ts.eflags], dword 0x11202 ; sti and resume ; mov [ts.ss0], sel_os_stack ; mov [ts.ss1], sel_ring1_stack ; mov [ts.ss2], sel_ring2_stack ; mov [ts.esp0], RING0_ESP_0 ; mov [ts.esp1], RING1_ESP_1 ; mov [ts.esp2], RING2_ESP_2 ; mov eax, cr3 ; mov [ts.cr3], eax ; mov [ts.eip], 0 ; mov [ts.esp], STACK_SIZE_32BIT ; mov ax, sel_user_code ; add ax, 8 ; mov [ts.cs], ax ; mov ax, sel_user_data ; add ax, 8 ; mov [ts.ss], ax ; mov [ts.ds], ax ; mov [ts.es], ax ; mov [ts.fs], ax ; mov [ts.gs], sel_video_data ; mov esi, tss_struct ; mov edi, 1 ; imul edi, tss_unit_process_size ; add edi, tss_block_process_base ; mov ecx, 120/4 ; cld ; rep movsd ; mov ebx, 1 ; mov edi, 1 ; imul edi, PCB_SIZE ; add edi, PCB_TABLE_BASE ; mov [edi+PID_OFFSET], dword 1000 ;;pid ; mov [edi+PPID_OFFSET], dword 0 ;;ppid ; mov eax, app_mem_size ; imul eax, ebx ; add eax, app_mem_base ; mov [edi+MLOC_OFFSET], eax ;;mlocation ; mov [edi+TICK_OFFSET], dword 0 ;;tickcount ; mov [edi+STAT_OFFSET], byte PS_READY ;;status ; mov [edi+PCBS_OFFSET], byte PCBS_USED ;;pcb status ; mov [pcb_current_base], dword PCB_TABLE_BASE ; mov [pcb_current_no], dword 0 ; mov [pcb_total_count], dword 2 mov esi, boot_str_initshell call boot_promot mov esi, shell_path mov eax, 0 call create_process clc call boot_promot_status ;;Set test task b ; mov [ts.eflags], dword 0x11202 ; sti and resume ; mov [ts.ss0], sel_os_stack ; mov [ts.ss1], sel_ring1_stack ; mov [ts.ss2], sel_ring2_stack ; mov [ts.esp0], RING0_ESP_0 ; mov [ts.esp1], RING1_ESP_1 ; mov [ts.esp2], RING2_ESP_2 ; mov eax, cr3 ; mov [ts.cr3], eax ; mov [ts.eip], testproc_b ; mov [ts.esp], STACK_SIZE_32BIT ; mov [ts.cs], sel_os_code ; mov [ts.ss], sel_os_stack ; mov [ts.ds], sel_os_data ; mov [ts.es], sel_os_data ; mov [ts.fs], sel_os_data ; mov [ts.gs], sel_video_data ; mov esi, tss_struct ; mov edi, 2 ; imul edi, tss_unit_process_size ; add edi, tss_block_process_base ; mov ecx, 120/4 ; cld ; rep movsd ; mov edi, 2 ; imul edi, PCB_SIZE ; add edi, PCB_TABLE_BASE ; mov [edi+PID_OFFSET], dword 1001 ;;pid ; mov [edi+PPID_OFFSET], dword 0 ;;ppid ; mov [edi+MLOC_OFFSET], dword 0 ;;mlocation ; mov [edi+TICK_OFFSET], dword 0 ;;tickcount ; mov [edi+STAT_OFFSET], byte PS_READY ;;status ; mov [pcb_current_base], dword PCB_TABLE_BASE ; mov [pcb_current_no], dword 0 ; mov [pcb_total_count], dword 3 ;;Test function area ; mov ax, 22 ; mov [y_cursor], ax ; mov cx, 0 ; mov [x_cursor], cx ; call CrtfnSetCursorPos ; mov esi, .shelln ; call rdfsFindInRootDir ; push eax ; mov esi, shell_path ; mov edi, 0a00000h ; call RdfsLoadFile ; mov edi, .fat_num ; call word2Hstr ; mov esi, .fatstr ; call Kfn_PrintString ; pop eax ; push eax ; mov edi, 0a00000h ; call RdfsReadFile ; jmp test_ok ; .shelln db 'SHELL BIN', 0 ; .path db '\readme', 0 ; .dirn db 'BIN ', 0 ; .fn db 'EYES RAW', 0 ; .fatstr db 'FAT=0x' ; .fat_num db '0000', 0 ; test_ok: ;;Wait for ENTER key add [promot_row], byte 3 mov esi, boot_str_presenter call boot_promot .waitkey: in al, 64h test al, 01 jz .waitkey in al, 60h cmp al, 9ch jne .waitkey ;;Clear screen push es mov ax, gs mov es, ax xor edi, edi mov ecx, 80*25*8 mov ax, 0720h cld rep stosw pop es ;;Reset cursor postion call CrtfnEnableCursor mov ax, 0 mov [row_start], ax call CrtfnSetStartRow mov ax, 0 mov [y_cursor], ax mov cx, 0 mov [x_cursor], cx call CrtfnSetCursorPos ;;Enalbe all IRQs call EnableAllIRQs call FlushAllIRQs sti jmp $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Main OS Loop ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;main os task loop (idle task) mainosloop: call oslfn_checkkbled jmp mainosloop jmp $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; 32 BIT INCLUDE CODE ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; include ".\misc.inc" include ".\sys32.inc" include ".\process.inc" include ".\drivers\console.inc" include ".\drivers\i8259A.inc" include ".\drivers\keyboard.inc" include ".\drivers\ramdiskfs.inc" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; KERNEL FUNCTIONS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; oslfn_checkkbled: cmp [kbled_stat_change], byte 0 je .notchange call KbChangeLeds mov [kbled_stat_change], byte 0 .notchange: ret io_delay: jmp .id_ret .id_ret: ret Kfn_WriteVideoBuffer: ;; write source buffer to the vide buffer at specified offset ;; ds:esi = source buffer ;; edi = dest offset in video buffer ;; ecx = count of word to write push esi push edi push ecx push es mov ax, gs mov es, ax cld rep movsw pop es pop ecx pop edi pop esi ret Kfn_WriteCharToCursor: ;; write char to current position of cursor ;; al = char ;; ah = attribute push ebx push edi push ecx push edx mov ecx, eax cmp al, 20h jb .is_cr mov ax, [y_cursor] mov bx, 80 mul bx mov di, ax mov ax, [x_cursor] add di, ax mov ax, di inc ax xor edx, edx mov bx, 80 div bx mov word [x_cursor], dx mov word [y_cursor], ax mov ax, [row_start] mov bx, 80 mul bx add di, ax shl di, 1 mov eax, ecx mov [gs:di], ax jmp .move_cursor .is_cr: cmp al, ASC_CC_CR ;if al=return jne .is_lf mov word [x_cursor], 0 jmp .move_cursor .is_lf: cmp al, ASC_CC_LF ;if al=linefeed jne .is_bs inc word [y_cursor] jmp .move_cursor .is_bs: cmp al, ASC_CC_BS jne .invalidchar mov ax, [x_cursor] add ax, 79 xor edx, edx mov bx, 80 div bx mov word [x_cursor], dx dec word [y_cursor] add word [y_cursor], ax mov ax, [y_cursor] mov bx, 80 mul bx mov di, ax mov ax, [x_cursor] add di, ax mov ax, [row_start] mov bx, 80 mul bx add di, ax shl di, 1 mov ax, 0720h mov [gs:di], ax jmp .move_cursor .invalidchar: mov cl, 20h mov ax, [y_cursor] mov bx, 80 mul bx mov di, ax mov ax, [x_cursor] add di, ax mov di, ax inc ax xor edx, edx mov bx, 80 div bx mov word [x_cursor], dx add word [y_cursor], ax mov ax, [row_start] mov bx, 80 mul bx add di, ax shl di, 1 mov eax, ecx mov [gs:di], ax jmp .move_cursor .move_cursor: cmp [y_cursor], word 25 jne .noturnpage cmp [x_cursor], word 0 jne .noturnpage inc word [row_start] mov ax, [row_start] call CrtfnSetStartRow mov [y_cursor], word 24 .noturnpage: mov ax, [row_start] add ax, [y_cursor] mov cx, [x_cursor] call CrtfnSetCursorPos pop edx pop ecx pop edi pop ebx ret Kfn_PrintString: ;; Print string at the cursor position ;; ds:esi = string buffer push eax push esi cld .next_char: lodsb cmp al, 0 je .exit_p mov ah, 07h call Kfn_WriteCharToCursor jmp .next_char .exit_p: pop esi pop eax ret delay_ms: ; delay in 1/1000 sec push eax push ecx mov ecx, esi imul ecx, 33941 shr ecx, 9 in al, 61h and al, 10h mov ah, al cld .loop_0: in al, 61h and al, 10h cmp al, ah jz .loop_0 mov ah, al loop .loop_0 pop ecx pop eax ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; SYSTEM CALL FUNCTIONS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 4 sysc_gettick: cli mov eax, [sys_tic] sti mov [esp+36], eax ret sysc_getkey: cmp byte [kasbuf_count], 0 je .kbufempty movzx edi, byte [kasbuf_head] add edi, kasbuf_base mov cl, [edi] movzx ax, byte [kasbuf_head] inc ax mov bh, kasbuf_len idiv bh mov [kasbuf_head], ah dec byte [kasbuf_count] mov al, cl jmp .ret .kbufempty: mov eax, 0ffffffffh .ret: sti mov [esp+36], eax ret sysc_screenandcursor: cli cmp eax, 0 je .clearsc cmp eax, 1 je .setcursor cmp eax, 2 je .getcursor .clearsc: push es push eax push ecx mov ax, gs mov es, ax xor edi, edi mov ecx, 80*25*8 mov ax, 0720h cld rep stosw pop ecx pop eax pop es sti ret .setcursor: push ebx mov [y_cursor], bx shr ebx, 16 mov [x_cursor], bx pop ebx call CrtfnSetCursorPos sti ret .getcursor: xor ebx, ebx mov bx, [x_cursor] shl ebx, 16 mov bx, [y_cursor] sti ret sysc_putchar: mov ah, 07h cli call Kfn_WriteCharToCursor sti ret sysc_print: push edi mov edi, [pcb_current_base] add esi, [edi+MLOC_OFFSET] pop edi cld .next_char: lodsb cmp al, 0 je .print_done mov ah, 07h cli call Kfn_WriteCharToCursor sti jmp .next_char .print_done: ret align 4 sysc_time: cli .test_status: mov al, 0ah out 70h, al call io_delay in al, 71h test al, 1000000b jnz .test_status mov al, 0 out 70h, al in al, 71h ; seconds movzx ecx, al shl ecx, 16 mov al, 02 out 70h, al in al, 71h ; minutes movzx edx, al shl edx, 8 add ecx, edx mov al, 04 out 70h, al in al, 71h ; hours movzx edx, al add ecx, edx sti mov [esp+36], ecx ; ecx:|notuse|s|m|h| BCD ret align 4 sysc_date: cli .test_status: mov al, 0ah out 70h, al call io_delay in al, 71h test al, 1000000b jnz .test_status mov al, 6 out 70h, al call io_delay in al, 71h ; day of week mov ch, al mov al, 7 out 70h, al call io_delay in al, 71h ; date mov cl, al shl ecx, 16 mov al, 8 out 70h, al call io_delay in al, 71h ; month mov ch, al mov al, 9 out 70h, al call io_delay in al, 71h ; year mov cl, al sti mov [esp+36], ecx ; ecx:|dw|d|m|y| ret align 4 sysc_createprocess: cli mov edi, [pcb_current_base] add esi, [edi+MLOC_OFFSET] add eax, [edi+MLOC_OFFSET] call create_process sti mov [esp+36], eax ret align 4 sysc_exitprocess: mov eax, [pcb_current_no] call terminate_process ret align 4 sysc_waitpid: cli call wait_process_id sti mov [esp+36], eax ret FSOP_FATTR equ 00h FSOP_FREAD equ 01h FSOP_FWRITE equ 02h align 4 sysc_rdfs: cli cmp eax, FSOP_FATTR je .fattr cmp eax, FSOP_FREAD je .fread cmp eax, FSOP_FWRITE je .fwrite .fattr: mov edi, [pcb_current_base] add ebx, [edi+MLOC_OFFSET] add esi, [edi+MLOC_OFFSET] mov edi, ebx call RdfsGetFileItem mov [esp+36], eax sti ret .fread: mov edi, [pcb_current_base] add ebx, [edi+MLOC_OFFSET] add esi, [edi+MLOC_OFFSET] mov edi, ebx call RdfsReadFile mov [esp+36], eax sti ret .fwrite: mov [esp+36], eax sti ret
alloy4fun_models/trashltl/models/9/2DDyPzTn2fYrBJr84.als
Kaixi26/org.alloytools.alloy
0
1791
<gh_stars>0 open main pred id2DDyPzTn2fYrBJr84_prop10 { all p: Protected | historically p in Protected and always p in Protected } pred __repair { id2DDyPzTn2fYrBJr84_prop10 } check __repair { id2DDyPzTn2fYrBJr84_prop10 <=> prop10o }
samples/call.asm
KirillTemnov/stack-vm
2
178042
<gh_stars>1-10 ; -------------------------------------------------------------------------------- ;; this example handles call procedure ; -------------------------------------------------------------------------------- .data num1 sw 1 num2 sw 5 num3 sw 4 .code main: load num1 load num2 load num3 call make_sum_of_three stor num1 stat halt ; int0 ? make_sum_of_three: add add retn
adsr.asm
neilbaldwin/Pulsar
11
178475
;--------------------------------------------------------------- ; ADSR Routine ;--------------------------------------------------------------- ENVELOPE_INIT_PHASE = 5 ENVELOPE_ATTACK_PHASE = 4 ENVELOPE_DECAY_PHASE = 3 ENVELOPE_SUSTAIN_PHASE = 2 ENVELOPE_RELEASE_PHASE = 1 ENVELOPE_OFF_PHASE = 0 .MACRO doADSR _track ; .IF (_track=2) ; lda envelopePhase+_track ; beq @killC ; lda #$81 ; sta envelopeAmp+_track ; lda plyrInstrumentCopy + (_track * STEPS_PER_INSTRUMENT) + INSTRUMENT_ROW_GATE ; beq @noKillC ; cmp plyrNoteCounter+_track ; bcs @noKillC ; lda #$00 ;@killC: sta envelopeAmp+_track ;@noKillC: rts ; .ELSE lda #<SRAM_ENVELOPES sta plyrEnvelopeVector lda #>SRAM_ENVELOPES sta plyrEnvelopeVector+1 .IF SRAM_MAP=32 lda #SRAM_ENVELOPE_BANK jsr setMMC1r1 .ENDIF ldy envelopePhase+_track ;get phase address (-1) lda @envelopePhasesHi,y ;and push onto stack for RTS trick pha lda @envelopePhasesLo,y pha lda plyrInstrumentCopy + (_track * STEPS_PER_INSTRUMENT) + INSTRUMENT_ROW_ENVELOPE asl a asl a clc adc envelopePhaseIndexes,y tay rts @envelopePhasesLo: .LOBYTES @adsrOff-1,@adsrRelease-1,@adsrSustain-1,@adsrDecay-1,@adsrAttack-1,@adsrInit-1 @envelopePhasesHi: .HIBYTES @adsrOff-1,@adsrRelease-1,@adsrSustain-1,@adsrDecay-1,@adsrAttack-1,@adsrInit-1 @adsrInit: lda #$00 ;initialise amplitude, counter sta envelopeAmp+_track sta envelopeCounter+_track dec envelopePhase+_track ;then move to Attack phase ;drop through @adsrAttack: lda (plyrEnvelopeVector),y ;if Attack = 0, set max amp and move to Decay bne @attA dec envelopePhase+_track iny lda (plyrEnvelopeVector),y bne @attC iny lda (plyrEnvelopeVector),y sta envelopeAmp+_track rts @attC: lda #$0F sta envelopeAmp+_track rts @attA: clc ;otherwise, add Attack rate to counter adc envelopeCounter+_track sta envelopeCounter+_track lda envelopeAmp+_track ;if counter overflows, carry is set and the ADC #$00 adc #$00 ;will increment amplitude cmp #$10 ;exceeded max (0F)? bcc @attB dec envelopePhase+_track ;yes, move to Decay rts @attB: sta envelopeAmp+_track ;no, store new amplitude value rts @adsrDecay:lda (plyrEnvelopeVector),y ;if Decay = 0, move to Sustain phase bne @decA iny lda (plyrEnvelopeVector),y sta envelopeAmp+_track dec envelopePhase+_track rts @decA: clc ;otherwise, add Decay speed to counter adc envelopeCounter+_track sta envelopeCounter+_track ;if counter overflow, carry is set ror a ;this time we need to subtract from amplitude eor #$80 ;so use ROR A to push carry into bit 7 asl a ;invert bit 7 and push back into carry lda envelopeAmp+_track ;so that SBC #$00 will subtract 1 if carry set after overflow sbc #$00 iny cmp (plyrEnvelopeVector),y ;reached sustain? bcc @decB bmi @decB sta envelopeAmp+_track ;no, store new amplitude rts @decB: dec envelopePhase+_track ;yes, move to Sustain phase lda #$00 ;and zero counter because it will be indeterminate at this point sta envelopeCounter+_track rts @adsrSustain: ;lda gateTime ;if Gate Time = 0, sustain forever. In practicality, you'd ;only use 0 gate time if you had a command to force the envelope ;into the release phase, as in a MIDI Key Off command lda plyrInstrumentCopy + (_track * STEPS_PER_INSTRUMENT) + INSTRUMENT_ROW_GATE beq @susA inc envelopeCounter+_track ;otherwise, increment counter until >= Gate Time cmp envelopeCounter+_track bcs @susA dec envelopePhase+_track ;the move to Release Phase @susA: rts @adsrRelease: lda (plyrEnvelopeVector),y ;add Release speed to counter bne @relB lda #$00 sta envelopeAmp+_track beq @relA @relB: clc adc envelopeCounter+_track sta envelopeCounter+_track ror a ;same trick as Decay, invert the carry and do a SBC #$00 eor #$80 asl a lda envelopeAmp+_track sbc #$00 beq @relA ;subtract 1 from amplitude until >=$00 sta envelopeAmp+_track rts @relA: dec envelopePhase+_track ;move to Off phase, envelope done rts @adsrOff: lda #$00 ;could replace with just "STY envelopAmp" becase Y=0 at this point sta envelopeAmp+_track rts ;.ENDIF .ENDMACRO
src/secret.adb
stcarrez/ada-libsecret
2
12282
<filename>src/secret.adb ----------------------------------------------------------------------- -- Secret -- Ada wrapper for Secret Service -- Copyright (C) 2017 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Secret is -- ------------------------------ -- Check if the value is empty. -- ------------------------------ function Is_Null (Value : in Object_Type'Class) return Boolean is begin return Value.Opaque = System.Null_Address; end Is_Null; -- ------------------------------ -- Internal operation to set the libsecret internal pointer. -- ------------------------------ procedure Set_Opaque (Into : in out Object_Type'Class; Data : in Opaque_Type) is begin Into.Opaque := Data; end Set_Opaque; -- ------------------------------ -- Internal operation to get the libsecret internal pointer. -- ------------------------------ function Get_Opaque (From : in Object_Type'Class) return Opaque_Type is begin return From.Opaque; end Get_Opaque; end Secret;
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c39006f2.ada
best08618/asylo
7
703
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c39006f2.ada<gh_stars>1-10 -- C39006F2.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT NO PROGRAM_ERROR IS RAISED IF A SUBPROGRAM'S BODY HAS -- BEEN ELABORATED BEFORE IT IS CALLED. CHECK THE FOLLOWING: -- B) FOR A SUBPROGRAM LIBRARY UNIT USED IN ANOTHER UNIT, NO -- PROGRAM_ERROR IS RAISED IF PRAGMA ELABORATE NAMES THE -- SUBPROGRAM. -- THIS LIBRARY PACKAGE BODY IS USED BY C39006F3M.ADA. -- HISTORY: -- TBN 08/22/86 CREATED ORIGINAL TEST. -- BCB 03/29/90 CORRECTED HEADER. CHANGED TEST NAME IN CALL -- TO 'TEST'. -- PWN 05/25/94 ADDED A PROCEDURE TO KEEP PACKAGE BODIES LEGAL. WITH C39006F0; WITH REPORT; USE REPORT; PRAGMA ELABORATE (C39006F0, REPORT); PACKAGE BODY C39006F1 IS PROCEDURE REQUIRE_BODY IS BEGIN NULL; END; BEGIN TEST ("C39006F", "CHECK THAT NO PROGRAM_ERROR IS RAISED IF A " & "SUBPROGRAM'S BODY HAS BEEN ELABORATED " & "BEFORE IT IS CALLED, WHEN A SUBPROGRAM " & "LIBRARY UNIT IS USED IN ANOTHER UNIT AND " & "PRAGMA ELABORATE IS USED"); BEGIN DECLARE VAR1 : INTEGER := C39006F0 (IDENT_INT(1)); BEGIN IF VAR1 /= IDENT_INT(1) THEN FAILED ("INCORRECT RESULTS - 1"); END IF; END; EXCEPTION WHEN PROGRAM_ERROR => FAILED ("PROGRAM_ERROR RAISED - 1"); WHEN OTHERS => FAILED ("UNEXPECTED EXCEPTION RAISED - 1"); END; DECLARE VAR2 : INTEGER := 1; PROCEDURE CHECK (B : IN OUT INTEGER) IS BEGIN B := C39006F0 (IDENT_INT(2)); EXCEPTION WHEN PROGRAM_ERROR => FAILED ("PROGRAM_ERROR RAISED - 2"); WHEN OTHERS => FAILED ("UNEXPECTED EXCEPTION RAISED - 2"); END CHECK; BEGIN CHECK (VAR2); IF VAR2 /= IDENT_INT(2) THEN FAILED ("INCORRECT RESULTS - 2"); END IF; END; DECLARE PACKAGE P IS VAR3 : INTEGER; END P; PACKAGE BODY P IS BEGIN VAR3 := C39006F0 (IDENT_INT(3)); IF VAR3 /= IDENT_INT(3) THEN FAILED ("INCORRECT RESULTS - 3"); END IF; EXCEPTION WHEN PROGRAM_ERROR => FAILED ("PROGRAM_ERROR RAISED - 3"); WHEN OTHERS => FAILED ("UNEXPECTED EXCEPTION - 3"); END P; BEGIN NULL; END; DECLARE GENERIC VAR4 : INTEGER := 1; PACKAGE Q IS TYPE ARRAY_TYP1 IS ARRAY (1 .. VAR4) OF INTEGER; ARRAY_1 : ARRAY_TYP1; END Q; PACKAGE NEW_Q IS NEW Q (C39006F0 (IDENT_INT(4))); USE NEW_Q; BEGIN IF ARRAY_1'LAST /= IDENT_INT(4) THEN FAILED ("INCORRECT RESULTS - 4"); END IF; END; END C39006F1;
Application Support/BBEdit/AppleScript/Distraction Free Writing Mode.applescript
bhdicaire/bbeditSetup
0
2141
tell application "BBEdit" tell window 1 set show line numbers to (not show line numbers) set show toolbar to (not show toolbar) set show gutter to (not show gutter) set show navigation bar to (not show navigation bar) -- set show status bar to false end tell end tell
src/implementation/yaml-dom-node_memory.adb
persan/AdaYaml
32
8509
-- part of AdaYaml, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" package body Yaml.Dom.Node_Memory is procedure Visit (Object : in out Instance; Value : not null access Node.Instance; Previously_Visited : out Boolean) is begin if Object.Data.Contains (Node_Pointer (Value)) then Previously_Visited := True; else Object.Data.Include (Node_Pointer (Value)); Previously_Visited := False; end if; end Visit; procedure Forget (Object : in out Instance; Value : not null access Node.Instance) is begin Object.Data.Exclude (Node_Pointer (Value)); end Forget; function Pop_First (Object : in out Instance) return not null access Node.Instance is First : Pointer_Sets.Cursor := Object.Data.First; begin return Ptr : constant not null access Node.Instance := Pointer_Sets.Element (First) do Object.Data.Delete (First); end return; end Pop_First; function Is_Empty (Object : Instance) return Boolean is (Object.Data.Is_Empty); procedure Visit (Object : in out Pair_Instance; Left, Right : not null access Node.Instance; Previously_Visited : out Boolean) is Pair : constant Pointer_Pair := (Left => Left, Right => Right); begin if Object.Data.Contains (Pair) then Previously_Visited := True; else Object.Data.Include (Pair); Previously_Visited := False; end if; end Visit; end Yaml.Dom.Node_Memory;
argument-read.asm
BaseMax/FirstAssemblyNASM
7
173983
<gh_stars>1-10 %include "linux64.inc" section .data texta db "Argument(s): ",0 textb1 db "Argument #",0 textb2 db ": ",0 newline db 10,0 section .bss argc resb 8 argPos resb 8 section .text global _start _start: mov rax, 0 mov [argPos], rax print texta pop rax mov [argc], rax printVal rax print newline _printArgsLoop: print textb1 mov rax, [argPos] inc rax mov [argPos], rax printVal rax print textb2 pop rax print rax print newline mov rax, [argPos] mov rbx, [argc] cmp rax, rbx jne _printArgsLoop exit
_maps/obj26.asm
NatsumiFox/AMPS-Sonic-1-2005
2
246224
<reponame>NatsumiFox/AMPS-Sonic-1-2005 ; --------------------------------------------------------------------------- ; Sprite mappings - monitors ; --------------------------------------------------------------------------- dc.w byte_A5A2-Map_obj26, byte_A5A8-Map_obj26 dc.w byte_A5B3-Map_obj26, byte_A5BE-Map_obj26 dc.w byte_A5C9-Map_obj26, byte_A5D4-Map_obj26 dc.w byte_A5DF-Map_obj26, byte_A5EA-Map_obj26 dc.w byte_A5F5-Map_obj26, byte_A600-Map_obj26 dc.w byte_A60B-Map_obj26, byte_A616-Map_obj26 byte_A5A2: dc.b 1 ; static monitor dc.b $EF, $F, 0, 0, $F0 byte_A5A8: dc.b 2 ; static monitor dc.b $F5, 5, 0, $10, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5B3: dc.b 2 ; static monitor dc.b $F5, 5, 0, $14, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5BE: dc.b 2 ; Eggman monitor dc.b $F5, 5, 0, $18, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5C9: dc.b 2 ; Sonic monitor dc.b $F5, 5, 0, $1C, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5D4: dc.b 2 ; speed shoes monitor dc.b $F5, 5, 0, $24, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5DF: dc.b 2 ; shield monitor dc.b $F5, 5, 0, $28, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5EA: dc.b 2 ; invincibility monitor dc.b $F5, 5, 0, $2C, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A5F5: dc.b 2 ; 10 rings monitor dc.b $F5, 5, 0, $30, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A600: dc.b 2 ; 'S' monitor byte_A601: dc.b $F5, 5, 0, $34, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A60B: dc.b 2 ; goggles monitor dc.b $F5, 5, 0, $20, $F8 dc.b $EF, $F, 0, 0, $F0 byte_A616: dc.b 1 ; broken monitor dc.b $FF, $D, 0, $38, $F0 even
oeis/086/A086406.asm
neoneye/loda-programs
11
2590
<filename>oeis/086/A086406.asm ; A086406: Main diagonal of number array A086404. ; Submitted by <NAME> ; 1,2,11,84,857,10984,169803,3076688,63968273,1501465248,39277112843,1133193163840,35748951528681,1224258310112384,45233097633685643,1793524939926112512,75966131556225961121,3423203234058532082176 mov $1,$0 mov $2,1 mov $3,1 lpb $0 sub $0,1 mov $4,$3 mul $3,$1 add $3,$2 mul $2,$1 mul $4,3 add $2,$4 lpe mov $0,$3
vp8/common/arm/armv6/filter_v6.asm
CM-Archive/android_external_libvpx
3
7614
<gh_stars>1-10 ; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; EXPORT |vp8_filter_block2d_first_pass_armv6| EXPORT |vp8_filter_block2d_second_pass_armv6| EXPORT |vp8_filter4_block2d_second_pass_armv6| EXPORT |vp8_filter_block2d_first_pass_only_armv6| EXPORT |vp8_filter_block2d_second_pass_only_armv6| AREA |.text|, CODE, READONLY ; name this block of code ;------------------------------------- ; r0 unsigned char *src_ptr ; r1 short *output_ptr ; r2 unsigned int src_pixels_per_line ; r3 unsigned int output_width ; stack unsigned int output_height ; stack const short *vp8_filter ;------------------------------------- ; vp8_filter the input and put in the output array. Apply the 6 tap FIR filter with ; the output being a 2 byte value and the intput being a 1 byte value. |vp8_filter_block2d_first_pass_armv6| PROC stmdb sp!, {r4 - r11, lr} ldr r11, [sp, #40] ; vp8_filter address ldr r7, [sp, #36] ; output height sub r2, r2, r3 ; inside loop increments input array, ; so the height loop only needs to add ; r2 - width to the input pointer mov r3, r3, lsl #1 ; multiply width by 2 because using shorts add r12, r3, #16 ; square off the output sub sp, sp, #4 ;;IF ARCHITECTURE=6 ;pld [r0, #-2] ;;pld [r0, #30] ;;ENDIF ldr r4, [r11] ; load up packed filter coefficients ldr r5, [r11, #4] ldr r6, [r11, #8] str r1, [sp] ; push destination to stack mov r7, r7, lsl #16 ; height is top part of counter ; six tap filter |height_loop_1st_6| ldrb r8, [r0, #-2] ; load source data ldrb r9, [r0, #-1] ldrb r10, [r0], #2 orr r7, r7, r3, lsr #2 ; construct loop counter |width_loop_1st_6| ldrb r11, [r0, #-1] pkhbt lr, r8, r9, lsl #16 ; r9 | r8 pkhbt r8, r9, r10, lsl #16 ; r10 | r9 ldrb r9, [r0] smuad lr, lr, r4 ; apply the filter pkhbt r10, r10, r11, lsl #16 ; r11 | r10 smuad r8, r8, r4 pkhbt r11, r11, r9, lsl #16 ; r9 | r11 smlad lr, r10, r5, lr ldrb r10, [r0, #1] smlad r8, r11, r5, r8 ldrb r11, [r0, #2] sub r7, r7, #1 pkhbt r9, r9, r10, lsl #16 ; r10 | r9 pkhbt r10, r10, r11, lsl #16 ; r11 | r10 smlad lr, r9, r6, lr smlad r11, r10, r6, r8 ands r10, r7, #0xff ; test loop counter add lr, lr, #0x40 ; round_shift_and_clamp ldrneb r8, [r0, #-2] ; load data for next loop usat lr, #8, lr, asr #7 add r11, r11, #0x40 ldrneb r9, [r0, #-1] usat r11, #8, r11, asr #7 strh lr, [r1], r12 ; result is transposed and stored, which ; will make second pass filtering easier. ldrneb r10, [r0], #2 strh r11, [r1], r12 bne width_loop_1st_6 ;;add r9, r2, #30 ; attempt to load 2 adjacent cache lines ;;IF ARCHITECTURE=6 ;pld [r0, r2] ;;pld [r0, r9] ;;ENDIF ldr r1, [sp] ; load and update dst address subs r7, r7, #0x10000 add r0, r0, r2 ; move to next input line add r1, r1, #2 ; move over to next column str r1, [sp] bne height_loop_1st_6 add sp, sp, #4 ldmia sp!, {r4 - r11, pc} ENDP ;--------------------------------- ; r0 short *src_ptr, ; r1 unsigned char *output_ptr, ; r2 unsigned int output_pitch, ; r3 unsigned int cnt, ; stack const short *vp8_filter ;--------------------------------- |vp8_filter_block2d_second_pass_armv6| PROC stmdb sp!, {r4 - r11, lr} ldr r11, [sp, #36] ; vp8_filter address sub sp, sp, #4 mov r7, r3, lsl #16 ; height is top part of counter str r1, [sp] ; push destination to stack ldr r4, [r11] ; load up packed filter coefficients ldr r5, [r11, #4] ldr r6, [r11, #8] pkhbt r12, r5, r4 ; pack the filter differently pkhbt r11, r6, r5 sub r0, r0, #4 ; offset input buffer |height_loop_2nd| ldr r8, [r0] ; load the data ldr r9, [r0, #4] orr r7, r7, r3, lsr #1 ; loop counter |width_loop_2nd| smuad lr, r4, r8 ; apply filter sub r7, r7, #1 smulbt r8, r4, r8 ldr r10, [r0, #8] smlad lr, r5, r9, lr smladx r8, r12, r9, r8 ldrh r9, [r0, #12] smlad lr, r6, r10, lr smladx r8, r11, r10, r8 add r0, r0, #4 smlatb r10, r6, r9, r8 add lr, lr, #0x40 ; round_shift_and_clamp ands r8, r7, #0xff usat lr, #8, lr, asr #7 add r10, r10, #0x40 strb lr, [r1], r2 ; the result is transposed back and stored usat r10, #8, r10, asr #7 ldrne r8, [r0] ; load data for next loop ldrne r9, [r0, #4] strb r10, [r1], r2 bne width_loop_2nd ldr r1, [sp] ; update dst for next loop subs r7, r7, #0x10000 add r0, r0, #16 ; updata src for next loop add r1, r1, #1 str r1, [sp] bne height_loop_2nd add sp, sp, #4 ldmia sp!, {r4 - r11, pc} ENDP ;--------------------------------- ; r0 short *src_ptr, ; r1 unsigned char *output_ptr, ; r2 unsigned int output_pitch, ; r3 unsigned int cnt, ; stack const short *vp8_filter ;--------------------------------- |vp8_filter4_block2d_second_pass_armv6| PROC stmdb sp!, {r4 - r11, lr} ldr r11, [sp, #36] ; vp8_filter address mov r7, r3, lsl #16 ; height is top part of counter ldr r4, [r11] ; load up packed filter coefficients add lr, r1, r3 ; save final destination pointer ldr r5, [r11, #4] ldr r6, [r11, #8] pkhbt r12, r5, r4 ; pack the filter differently pkhbt r11, r6, r5 mov r4, #0x40 ; rounding factor (for smlad{x}) |height_loop_2nd_4| ldrd r8, [r0, #-4] ; load the data orr r7, r7, r3, lsr #1 ; loop counter |width_loop_2nd_4| ldr r10, [r0, #4]! smladx r6, r9, r12, r4 ; apply filter pkhbt r8, r9, r8 smlad r5, r8, r12, r4 pkhbt r8, r10, r9 smladx r6, r10, r11, r6 sub r7, r7, #1 smlad r5, r8, r11, r5 mov r8, r9 ; shift the data for the next loop mov r9, r10 usat r6, #8, r6, asr #7 ; shift and clamp usat r5, #8, r5, asr #7 strb r5, [r1], r2 ; the result is transposed back and stored tst r7, #0xff strb r6, [r1], r2 bne width_loop_2nd_4 subs r7, r7, #0x10000 add r0, r0, #16 ; update src for next loop sub r1, lr, r7, lsr #16 ; update dst for next loop bne height_loop_2nd_4 ldmia sp!, {r4 - r11, pc} ENDP ;------------------------------------ ; r0 unsigned char *src_ptr ; r1 unsigned char *output_ptr, ; r2 unsigned int src_pixels_per_line ; r3 unsigned int cnt, ; stack unsigned int output_pitch, ; stack const short *vp8_filter ;------------------------------------ |vp8_filter_block2d_first_pass_only_armv6| PROC stmdb sp!, {r4 - r11, lr} ldr r4, [sp, #36] ; output pitch ldr r11, [sp, #40] ; HFilter address sub sp, sp, #8 mov r7, r3 sub r2, r2, r3 ; inside loop increments input array, ; so the height loop only needs to add ; r2 - width to the input pointer sub r4, r4, r3 str r4, [sp] ; save modified output pitch str r2, [sp, #4] mov r2, #0x40 ldr r4, [r11] ; load up packed filter coefficients ldr r5, [r11, #4] ldr r6, [r11, #8] ; six tap filter |height_loop_1st_only_6| ldrb r8, [r0, #-2] ; load data ldrb r9, [r0, #-1] ldrb r10, [r0], #2 mov r12, r3, lsr #1 ; loop counter |width_loop_1st_only_6| ldrb r11, [r0, #-1] pkhbt lr, r8, r9, lsl #16 ; r9 | r8 pkhbt r8, r9, r10, lsl #16 ; r10 | r9 ldrb r9, [r0] ;; smuad lr, lr, r4 smlad lr, lr, r4, r2 pkhbt r10, r10, r11, lsl #16 ; r11 | r10 ;; smuad r8, r8, r4 smlad r8, r8, r4, r2 pkhbt r11, r11, r9, lsl #16 ; r9 | r11 smlad lr, r10, r5, lr ldrb r10, [r0, #1] smlad r8, r11, r5, r8 ldrb r11, [r0, #2] subs r12, r12, #1 pkhbt r9, r9, r10, lsl #16 ; r10 | r9 pkhbt r10, r10, r11, lsl #16 ; r11 | r10 smlad lr, r9, r6, lr smlad r10, r10, r6, r8 ;; add lr, lr, #0x40 ; round_shift_and_clamp ldrneb r8, [r0, #-2] ; load data for next loop usat lr, #8, lr, asr #7 ;; add r10, r10, #0x40 strb lr, [r1], #1 ; store the result usat r10, #8, r10, asr #7 ldrneb r9, [r0, #-1] strb r10, [r1], #1 ldrneb r10, [r0], #2 bne width_loop_1st_only_6 ;;add r9, r2, #30 ; attempt to load 2 adjacent cache lines ;;IF ARCHITECTURE=6 ;pld [r0, r2] ;;pld [r0, r9] ;;ENDIF ldr lr, [sp] ; load back output pitch ldr r12, [sp, #4] ; load back output pitch subs r7, r7, #1 add r0, r0, r12 ; updata src for next loop add r1, r1, lr ; update dst for next loop bne height_loop_1st_only_6 add sp, sp, #8 ldmia sp!, {r4 - r11, pc} ENDP ; |vp8_filter_block2d_first_pass_only_armv6| ;------------------------------------ ; r0 unsigned char *src_ptr, ; r1 unsigned char *output_ptr, ; r2 unsigned int src_pixels_per_line ; r3 unsigned int cnt, ; stack unsigned int output_pitch, ; stack const short *vp8_filter ;------------------------------------ |vp8_filter_block2d_second_pass_only_armv6| PROC stmdb sp!, {r4 - r11, lr} ldr r11, [sp, #40] ; VFilter address ldr r12, [sp, #36] ; output pitch mov r7, r3, lsl #16 ; height is top part of counter sub r0, r0, r2, lsl #1 ; need 6 elements for filtering, 2 before, 3 after sub sp, sp, #8 ldr r4, [r11] ; load up packed filter coefficients ldr r5, [r11, #4] ldr r6, [r11, #8] str r0, [sp] ; save r0 to stack str r1, [sp, #4] ; save dst to stack ; six tap filter |width_loop_2nd_only_6| ldrb r8, [r0], r2 ; load data orr r7, r7, r3 ; loop counter ldrb r9, [r0], r2 ldrb r10, [r0], r2 |height_loop_2nd_only_6| ; filter first column in this inner loop, than, move to next colum. ldrb r11, [r0], r2 pkhbt lr, r8, r9, lsl #16 ; r9 | r8 pkhbt r8, r9, r10, lsl #16 ; r10 | r9 ldrb r9, [r0], r2 smuad lr, lr, r4 pkhbt r10, r10, r11, lsl #16 ; r11 | r10 smuad r8, r8, r4 pkhbt r11, r11, r9, lsl #16 ; r9 | r11 smlad lr, r10, r5, lr ldrb r10, [r0], r2 smlad r8, r11, r5, r8 ldrb r11, [r0] sub r7, r7, #2 sub r0, r0, r2, lsl #2 pkhbt r9, r9, r10, lsl #16 ; r10 | r9 pkhbt r10, r10, r11, lsl #16 ; r11 | r10 smlad lr, r9, r6, lr smlad r10, r10, r6, r8 ands r9, r7, #0xff add lr, lr, #0x40 ; round_shift_and_clamp ldrneb r8, [r0], r2 ; load data for next loop usat lr, #8, lr, asr #7 add r10, r10, #0x40 strb lr, [r1], r12 ; store the result for the column usat r10, #8, r10, asr #7 ldrneb r9, [r0], r2 strb r10, [r1], r12 ldrneb r10, [r0], r2 bne height_loop_2nd_only_6 ldr r0, [sp] ldr r1, [sp, #4] subs r7, r7, #0x10000 add r0, r0, #1 ; move to filter next column str r0, [sp] add r1, r1, #1 str r1, [sp, #4] bne width_loop_2nd_only_6 add sp, sp, #8 ldmia sp!, {r4 - r11, pc} ENDP ; |vp8_filter_block2d_second_pass_only_armv6| END
source/core/tointeger.asm
paulscottrobson/rpl-65
1
245926
<filename>source/core/tointeger.asm ; ****************************************************************************** ; ****************************************************************************** ; ; Name : tointeger.asm ; Purpose : Try to convert string to a constant integer. ; Author : <NAME> (<EMAIL>) ; Created : 12th November 2019 ; ; ****************************************************************************** ; ****************************************************************************** ; ****************************************************************************** ; ; Convert String YX to Integer in YX. CS = Okay, CC = Failed. ; if okay returns characters consumed in A. ; ; ****************************************************************************** StringToInt: stx zTemp3 ; save string sty zTemp3+1 stz signCount ; signcount is the number of chars copied. ldx #16 ; base to use. ldy #1 ; character offset. ; lda (zTemp3) ; first character cmp #"$" ; is it hexadecimal beq _STIConvert ; convert from character 1, base 16. ; dey ; from character 0 ldx #10 ; base 10. ; ; Offset in token buffer in X, base to use in Y. ; _STIConvert: stx zTemp1 ; save base in zTemp1 lda (zTemp3),y ; get first character beq _STIFail ; if zero, then it has failed anyway. ; stz zTemp0 ; clear the result. stz zTemp0+1 ; _STILoop: lda (zTemp3),y ; check in range 0-9 A-F cmp #"0" bcc _STIFail cmp #"9"+1 bcc _STIOkay cmp #"A" bcc _STIFail cmp #"F"+1 bcs _STIFail _STIOkay: lda zTemp0 ; copy current to zTemp2 sta zTemp2 lda zTemp0+1 sta zTemp2+1 stz zTemp0 ; clear result stz zTemp0+1 ldx zTemp1 ; X contains the base. ; _STIMultiply: txa ; shift Y right into carry. lsr a tax bcc _STINoAdd ; skip if CC, e.g. LSB was zero ; clc lda zTemp2 ; add zTemp2 into zTemp0 adc zTemp0 sta zTemp0 lda zTemp2+1 adc zTemp0+1 sta zTemp0+1 ; _STINoAdd: asl zTemp2 ; shift zTemp2 left e.g. x 2 rol zTemp2+1 cpx #0 ; multiply finished ? bne _STIMultiply ; ; sec ; hex adjust lda (zTemp3),y ; get digit. cmp #58 bcc _STIDecimal sec sbc #7 _STIDecimal: sec sbc #48 cmp zTemp1 ; if >= base then fail. bcs _STIFail ; cld adc zTemp0 ; add into the current value sta zTemp0 bcc _STINoCarry inc zTemp0+1 _STINoCarry: ; lda (zTemp3),y ; get character just done. iny ; point to next inc SignCount bra _STILoop ; and go round again. ; _STIFail: ; done the conversion. lda SignCount ; if converted 0 charactes, fail. beq _STINoConvert tya ; convert count in A. ldx zTemp0 ; return result ldy zTemp0+1 sec rts _STINoConvert: clc rts
s1/music-original/Mus8C - Boss.asm
Cancer52/flamedriver
9
12883
Mus8C_Boss_Header: smpsHeaderStartSong 1 smpsHeaderVoice Mus8C_Boss_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $02, $04 smpsHeaderDAC Mus8C_Boss_DAC smpsHeaderFM Mus8C_Boss_FM1, $F4, $12 smpsHeaderFM Mus8C_Boss_FM2, $E8, $08 smpsHeaderFM Mus8C_Boss_FM3, $F4, $0F smpsHeaderFM Mus8C_Boss_FM4, $F4, $12 smpsHeaderFM Mus8C_Boss_FM5, $E8, $0F smpsHeaderPSG Mus8C_Boss_PSG1, $D0, $03, $00, fTone_05 smpsHeaderPSG Mus8C_Boss_PSG2, $D0, $03, $00, fTone_05 smpsHeaderPSG Mus8C_Boss_PSG3, $DC, $01, $00, fTone_08 ; FM5 Data Mus8C_Boss_FM5: smpsSetvoice $05 Mus8C_Boss_Jump03: dc.b nFs7, $0C, nFs7, nFs7, nFs7 smpsAlterVol $02 smpsCall Mus8C_Boss_Call03 dc.b nA6, nFs6, nG6, nFs6, nE6, nFs6, nA6, nFs6, nG6, nFs6, nCs7, nFs6 dc.b nE6, nFs6 smpsCall Mus8C_Boss_Call03 dc.b nB6, nFs6, nA6, nFs6, nG6, nFs6, nA6, nFs6, nB6, nFs6, nCs7, nB6 dc.b nF7, nCs7 smpsAlterVol $FE Mus8C_Boss_Loop01: dc.b nFs7, $03, nD7, $03, nFs7, $03, nD7, $03 smpsLoop $00, $04, Mus8C_Boss_Loop01 smpsJump Mus8C_Boss_Jump03 Mus8C_Boss_Call03: dc.b nB6, $06, nFs6, nD7, nFs6, nB6, nFs6, nE6, nFs6, nB6, nFs6, nD7 dc.b nFs6, nB6, nFs6, nA6, nFs6, nG6, nFs6 smpsReturn ; FM2 Data Mus8C_Boss_FM2: smpsSetvoice $00 Mus8C_Boss_Jump02: smpsNop $01 dc.b nFs4, $06, nFs5, nFs4, nFs5, nFs4, nFs5, nFs4, nFs5 smpsCall Mus8C_Boss_Call02 dc.b nB3, $06, nE4, nE4, $0C, nB3, $06 smpsCall Mus8C_Boss_Call02 dc.b nE4, $06, nD4, nD4, $0C, nD4, $06, nCs4, $30 smpsNop $01 smpsJump Mus8C_Boss_Jump02 Mus8C_Boss_Call02: dc.b nB3, $06, nB3, nD4, nD4, nCs4, nCs4, nC4, nC4, nB3, $12, nFs4 dc.b $06, nB4, $0C, nA4, nG4, $06, nG4, $0C, nD4, $06, nG4, nG4 dc.b $0C, nFs4, $06, nE4, nE4, $0C smpsReturn ; PSG2 Data Mus8C_Boss_PSG2: smpsAlterNote $02 smpsJump Mus8C_Boss_Jump01 ; FM3 Data Mus8C_Boss_FM3: smpsSetvoice $01 smpsPan panLeft, $00 Mus8C_Boss_Jump01: dc.b nRst, $30 smpsCall Mus8C_Boss_Call01 dc.b nE5, $12, nRst, nD6, $03, nRst, nCs6, nRst, nA5, $12 smpsCall Mus8C_Boss_Call01 dc.b nE5, $0C, nB5, $03, nRst, nE6, nRst, nE6, $0C, nE6, $03, nRst dc.b nF6, nRst, nF6, $0C, nF6, $03, nRst, nFs6, $30 smpsJump Mus8C_Boss_Jump01 Mus8C_Boss_Call01: dc.b nRst, $1E, nFs5, $03, nRst, nB5, nRst, nCs6, nRst, nD6, $30, nRst dc.b $12, nB5, $03, nRst, nG5, nRst smpsReturn ; FM1 Data Mus8C_Boss_FM1: smpsAlterNote $03 smpsJump Mus8C_Boss_Jump00 ; FM4 Data Mus8C_Boss_FM4: smpsPan panRight, $00 Mus8C_Boss_Jump00: smpsSetvoice $02 smpsModSet $0C, $01, $04, $06 ; PSG1 Data Mus8C_Boss_PSG1: dc.b nRst, $30 smpsCall Mus8C_Boss_Call00 dc.b nE7 smpsCall Mus8C_Boss_Call00 dc.b nE7, $18, nF7, nFs7, $30 smpsJump Mus8C_Boss_PSG1 Mus8C_Boss_Call00: dc.b nB6, $04, nA6, nC7, nB6, $24, nRst, $0C, nFs6, nB6, nCs7, nD7 dc.b $30 smpsReturn ; PSG3 Data Mus8C_Boss_PSG3: smpsStop ; DAC Data Mus8C_Boss_DAC: dc.b dHiTimpani, $06, dLowTimpani, dHiTimpani, dLowTimpani, dHiTimpani, dLowTimpani, dHiTimpani, dLowTimpani Mus8C_Boss_Loop00: dc.b dSnare, $0C, dSnare, $04, dSnare, dSnare, dSnare, $06, dSnare, $0C, dSnare, $06 dc.b dSnare, $12, dSnare, $06, dSnare, $0C, dSnare, $0C smpsLoop $00, $03, Mus8C_Boss_Loop00 dc.b dSnare, $0C, dSnare, $04, dSnare, dSnare, dSnare, $06, dSnare, $0C, dSnare, $06 dc.b dSnare, $06, dSnare, $0C, dSnare, $06, dSnare, $06, dSnare, $0C, dSnare, $06 dc.b dSnare, $01, dHiTimpani, $05, dLowTimpani, $06, dHiTimpani, dLowTimpani, dHiTimpani, dLowTimpani, dHiTimpani, dLowTimpani smpsJump Mus8C_Boss_DAC Mus8C_Boss_Voices: ; Voice $00 ; $08 ; $0A, $70, $30, $00, $1F, $1F, $5F, $5F, $12, $0E, $0A, $0A ; $00, $04, $04, $03, $2F, $2F, $2F, $2F, $24, $2D, $13, $80 smpsVcAlgorithm $00 smpsVcFeedback $01 smpsVcUnusedBits $00 smpsVcDetune $00, $03, $07, $00 smpsVcCoarseFreq $00, $00, $00, $0A smpsVcRateScale $01, $01, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0A, $0A, $0E, $12 smpsVcDecayRate2 $03, $04, $04, $00 smpsVcDecayLevel $02, $02, $02, $02 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $13, $2D, $24 ; Voice $01 ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53, $0E, $0E, $0E, $03 ; $00, $00, $00, $00, $1F, $FF, $1F, $0F, $18, $28, $27, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $01, $01, $07, $01 smpsVcRateScale $01, $02, $02, $02 smpsVcAttackRate $13, $0D, $0E, $0E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $03, $0E, $0E, $0E smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $00, $01, $0F, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $27, $28, $18 ; Voice $02 ; $3D ; $01, $02, $02, $02, $14, $0E, $8C, $0E, $08, $05, $02, $05 ; $00, $00, $00, $00, $1F, $1F, $1F, $1F, $1A, $92, $A7, $80 smpsVcAlgorithm $05 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $00, $00 smpsVcCoarseFreq $02, $02, $02, $01 smpsVcRateScale $00, $02, $00, $00 smpsVcAttackRate $0E, $0C, $0E, $14 smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $05, $02, $05, $08 smpsVcDecayRate2 $00, $00, $00, $00 smpsVcDecayLevel $01, $01, $01, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $27, $12, $1A ; Voice $03 ; $30 ; $30, $30, $30, $30, $9E, $D8, $DC, $DC, $0E, $0A, $04, $05 ; $08, $08, $08, $08, $BF, $BF, $BF, $BF, $14, $3C, $14, $80 smpsVcAlgorithm $00 smpsVcFeedback $06 smpsVcUnusedBits $00 smpsVcDetune $03, $03, $03, $03 smpsVcCoarseFreq $00, $00, $00, $00 smpsVcRateScale $03, $03, $03, $02 smpsVcAttackRate $1C, $1C, $18, $1E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $05, $04, $0A, $0E smpsVcDecayRate2 $08, $08, $08, $08 smpsVcDecayLevel $0B, $0B, $0B, $0B smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $14, $3C, $14 ; Voice $04 ; $39 ; $01, $51, $00, $00, $1F, $5F, $5F, $5F, $10, $11, $09, $09 ; $07, $00, $00, $00, $2F, $2F, $2F, $1F, $20, $22, $20, $80 smpsVcAlgorithm $01 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $00, $05, $00 smpsVcCoarseFreq $00, $00, $01, $01 smpsVcRateScale $01, $01, $01, $00 smpsVcAttackRate $1F, $1F, $1F, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $09, $09, $11, $10 smpsVcDecayRate2 $00, $00, $00, $07 smpsVcDecayLevel $01, $02, $02, $02 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $20, $22, $20 ; Voice $05 ; $3A ; $42, $43, $14, $71, $1F, $12, $1F, $1F, $04, $02, $04, $0A ; $01, $01, $02, $0B, $1F, $1F, $1F, $1F, $1A, $16, $19, $80 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $07, $01, $04, $04 smpsVcCoarseFreq $01, $04, $03, $02 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $12, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0A, $04, $02, $04 smpsVcDecayRate2 $0B, $02, $01, $01 smpsVcDecayLevel $01, $01, $01, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $00, $19, $16, $1A
screenshot_themes.scpt
flowchartsman/clarion
15
2115
tell application "System Events" set allWindows to name of window of process whose visible is true end tell return allWindows set theWindowList to my subListsToOneList(myList) -- Flattening a list of lists return theWindowList on subListsToOneList(l) set newL to {} repeat with i in l set newL to newL & i end repeat return newL end subListsToOneList
bucket_34/gnatstudio/patches/patch-kernel_src_gtkada-search__entry.ads
jrmarino/ravensource
17
8318
<filename>bucket_34/gnatstudio/patches/patch-kernel_src_gtkada-search__entry.ads<gh_stars>10-100 --- kernel/src/gtkada-search_entry.ads.orig 2021-06-15 05:19:41 UTC +++ kernel/src/gtkada-search_entry.ads @@ -35,7 +35,7 @@ package Gtkada.Search_Entry is function Get_Icon_Position (Self : access Gtkada_Search_Entry_Record'Class; - Event : Gdk_Event_Button) return Gtk_Entry_Icon_Position; + Event : Gdk_Event) return Gtk_Entry_Icon_Position; -- Returns the icon which was clicked on. -- For some reason, gtk+ always seems to return the primary icon otherwise.
source/RASCAL-Error.ads
bracke/Meaning
0
28584
-------------------------------------------------------------------------------- -- -- -- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. -- -- -- -- This library 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. -- -- -- -- This library 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 this library; if not, write to the Free Software -- -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- -------------------------------------------------------------------------------- -- @brief Standard single tasking error window. -- $Author$ -- $Date$ -- $Revision$ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with RASCAL.OS; use RASCAL.OS; with RASCAL.Utility; use RASCAL.Utility; package RASCAL.Error is type Error_Type is record Msg_Handle: Messages_Handle_Type; Task_Name : Unbounded_String; end record; type Error_Pointer is access Error_Type; type Error_Category_Type is (None,Info,Warning,Program,Question,User1,User2); type Error_Return_Type is (Nothing,Ok,Cancel,XButton1,XButton2,XButton3); type Error_Flags_Type is new integer; Error_Flag_Ok : constant Error_Flags_Type := 1; Error_Flag_Cancel : constant Error_Flags_Type := 2; Error_Flag_Highlight : constant Error_Flags_Type := 4; Error_Flag_NoPrompt : constant Error_Flags_Type := 8; Error_Flag_NoPrefix : constant Error_Flags_Type := 16; Error_Flag_Immediate : constant Error_Flags_Type := 32; Error_Flag_Simulate : constant Error_Flags_Type := 64; Error_Flag_NoBeep : constant Error_Flags_Type := 128; type Error_Message_Type is record Spr_Area : System_Sprite_Pointer; Flags : Error_Flags_Type := Error_Flag_Ok; Category : Error_Category_Type := None; Spr_Name : String (1..13) := S(13 * ASCII.NUL); Buttons : String (1..256) := S(256 * ASCII.NUL); Message : String (1..252) := S(252 * ASCII.NUL); Token : String (1..256) := S(256 * ASCII.NUL); Param1 : String (1..256) := S(256 * ASCII.NUL); Param2 : String (1..256) := S(256 * ASCII.NUL); Param3 : String (1..256) := S(256 * ASCII.NUL); Param4 : String (1..256) := S(256 * ASCII.NUL); end record; type Error_Message_Pointer is access Error_Message_Type; No_Error_Message : Exception; -- -- Opens a standard non-multitasking WIMP Error window. -- --{/}How to use:{/} --#Tab --#fCode --E : Error_Pointer := Get_Error(Main_Task); --#Tab --declare -- Result\t:\tError_Return_Type; -- M\t:\tError_Message_Pointer := new Error_Message_Type; --#Tab --begin -- M.all.Token (1..5)\t:= "DUMMY"; -- M.all.Spr_Name(1..5)\t:= "!Dummy"; -- M.all.Category\t:= Info; -- -- Result := Show_Message ( E , M ); --end; --#f --#Tab -- function Show_Message (Error : in Error_Pointer; Message : in Error_Message_Pointer) return Error_Return_Type; end RASCAL.Error;
oeis/049/A049453.asm
neoneye/loda-programs
11
91694
<gh_stars>10-100 ; A049453: Second pentagonal numbers with even index: a(n) = n*(6*n+1). ; 0,7,26,57,100,155,222,301,392,495,610,737,876,1027,1190,1365,1552,1751,1962,2185,2420,2667,2926,3197,3480,3775,4082,4401,4732,5075,5430,5797,6176,6567,6970,7385,7812,8251,8702,9165,9640,10127,10626,11137,11660,12195,12742,13301,13872,14455,15050,15657,16276,16907,17550,18205,18872,19551,20242,20945,21660,22387,23126,23877,24640,25415,26202,27001,27812,28635,29470,30317,31176,32047,32930,33825,34732,35651,36582,37525,38480,39447,40426,41417,42420,43435,44462,45501,46552,47615,48690,49777,50876 mov $1,6 mul $1,$0 add $1,1 mul $1,$0 mov $0,$1
src/main/fragment/mos6502-common/vboaa=pbuz1_derefidx_vbuyy_eq_vbuaa.asm
jbrandwood/kickc
2
8719
eor ({z1}),y beq !+ lda #1 !: eor #1
tetris.asm
hny-gd/arkowski-tetris
1
15158
;Frame parametres frameHeight equ 8 * 20 frameWidth equ 8 * 10 frameBorderWidth equ 5 frameBeginningX equ 50 frameBeginningY equ 10 nextPieceFrameHeight equ 8 * 5 nextPieceFrameWidth equ 8 * 5 nextPieceFrameBorderWidth equ 5 nextPieceFrameBeginningX equ 155 nextPieceFrameBeginningY equ 10 boardColor equ 0 pieceSize equ 8 scorePosX equ 160 scorePosY equ 100 gameOverPosX equ 120 gameOverPosY equ 80 ; waitFactor*usleepMS should be approx 1sec ; If usleepMS is too long, we will miss keyboard input ; If it is too short, keypresses will be counted several times waitFactor equ 10 usleepMS equ 100000 section .data gameOver: db "GAME OVER",0 scoreString: db "SCORE",0 section .bss boardState: resb 20 * 10 nextPieceType: resb 1 pieceType: resb 1 pieceCol: resb 1 piecePos: resb 4 piecePivotPos: resb 1 temporaryPiecePos: resb 4 waitTime: resb 1 score: resw 1 scoreAsString: resb 6 ; 5 digits+0 extern gl_write,gl_setfont,gl_font8x8,gl_setfontcolors,gl_setwritemode,vga_init,vga_setmode,vga_setcolor,gl_fillbox,gl_setcontextvga,vga_getkey,usleep,rand extern exit,keyboard_init,keyboard_translatekeys,keyboard_update,keyboard_keypressed,keyboard_close section .text global main main: ;Initialization sub rsp,8 call vga_init mov rdi, 5 ; SVGALIB 5 = 320x200x256 (see vga.h) call vga_setmode mov rdi, 5 ; we need to init vgagl with the same mode call gl_setcontextvga mov rdi,8 mov rsi,8 mov rdx, [gl_font8x8] call gl_setfont ; see man gl_write(3) mov rdi,2 call gl_setwritemode mov rdi, 0 mov rsi, 15 call gl_setfontcolors call keyboard_init mov rdi, 7 call drawFrame call drawNextPieceFrame jmp gameInProgres endOfGame: call delayForLongWhile call displayGameOver call delayForLongWhile ;Return to previous video mode call keyboard_close mov rdi, 0 call vga_setmode ;Finish program ; we can not simply call return because we might be called from within ; gameInProgress mov rdi, 0 call exit ;/////DRAWING FUNCTIONS//// ;//////////////////////////////////////////////////////////// ;Draw Rectangle, rax - begin point, rcx - Height, rbx - Width, rdi - color drawRect: xor rdx, rdx ; clear dx for ax division push rdi ; Save colour push rcx ; Save height for later mov rcx, 320 ; divisor in cx div cx ; divide begin point/320 so we get y in ax and x in dx (remainder) mov rdi, rdx ; x1 (param 1) mov rsi, rax ; y1 (param 2) mov rdx, rbx ; width (param 3) pop rcx ; height (param 4, fetch again from stack) pop r8 ; Pass colour call gl_fillbox mov rdi, r8 ; ...and restore colour ret ;//////////////////////////////////////////////////////////// drawFrame: mov rdi, 7 ; colour ;Gora mov rax, frameBeginningY * 320 + frameBeginningX mov rcx, frameBorderWidth mov rbx, frameWidth + 2 * frameBorderWidth call drawRect ;Lewa mov rax, (frameBeginningY + frameBorderWidth) * 320 + frameBeginningX mov rcx, frameHeight mov rbx, frameBorderWidth call drawRect ;Prawa mov rax, (frameBeginningY + frameBorderWidth) * 320 + frameBeginningX + frameWidth + frameBorderWidth mov rcx, frameHeight mov rbx, frameBorderWidth call drawRect ;Dol mov rax, (frameBeginningY + frameHeight + frameBorderWidth) * 320 + frameBeginningX mov rcx, frameBorderWidth mov rbx, frameWidth + 2 * frameBorderWidth call drawRect ret ;//////////////////////////////////////////////////////////// drawNextPieceFrame: mov rdi, 7 ;Gora mov rax, nextPieceFrameBeginningY * 320 + nextPieceFrameBeginningX mov rcx, nextPieceFrameBorderWidth mov rbx, nextPieceFrameWidth + 2 * nextPieceFrameBorderWidth call drawRect ;Lewa mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth) * 320 + nextPieceFrameBeginningX mov rcx, nextPieceFrameHeight mov rbx, nextPieceFrameBorderWidth call drawRect ;Prawa mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth) * 320 + nextPieceFrameBeginningX + nextPieceFrameWidth + nextPieceFrameBorderWidth mov rcx, nextPieceFrameHeight mov rbx, nextPieceFrameBorderWidth call drawRect ;Dol mov rax, (nextPieceFrameBeginningY + nextPieceFrameHeight + nextPieceFrameBorderWidth) * 320 + nextPieceFrameBeginningX mov rcx, nextPieceFrameBorderWidth mov rbx, nextPieceFrameWidth + 2 * nextPieceFrameBorderWidth call drawRect ret ;//////////////////////////////////////////////////////////// drawBoardState: mov rbx, 200 drawBoardStateLoop1: dec rbx push rbx movzx rdi, byte[boardState + rbx] mov rax, rbx call drawOneSquare pop rbx cmp rbx, 0 jne drawBoardStateLoop1 ret ;//////////////////////////////////////////////////////////// clearBoard: mov rax, (frameBeginningY + frameBorderWidth) * 320 + frameBeginningX + frameBorderWidth mov rcx, frameHeight mov rbx, frameWidth mov rdi, boardColor call drawRect ret ;//////////////////////////////////////////////////////////// drawTetromino: movzx rax, byte[piecePos] movzx rdi, byte[pieceCol] call drawOneSquare movzx rax, byte[piecePos + 1] movzx rdi, byte[pieceCol] call drawOneSquare movzx rax, byte[piecePos + 2] movzx rdi, byte[pieceCol] call drawOneSquare movzx rax, byte[piecePos + 3] movzx rdi, byte[pieceCol] call drawOneSquare ret ;//////////////////////////////////////////////////////////// ;rax - PieceNumber, rdi - color drawOneSquare: mov BL, 10 div BL ;AH - X, AL - Y mov CX, AX ;Calculate Y offset mov AL, CL xor AH, AH mov BX, 320 * pieceSize mul BX push rax ;Calculate X offset mov AL, CH xor AH, AH mov BX, pieceSize mul BX pop rdx ;Move to fit frame add AX, DX add AX, (frameBeginningY + frameBorderWidth) * 320 + frameBeginningX + frameBorderWidth mov BX, pieceSize mov CX, pieceSize jmp drawRect ;/////GAME FUNCTIONS//// ;//////////////////////////////////////////////////////////// gameInProgres: ;-TO DO mov byte[waitTime], waitFactor call generateNextPieceNumber placeNext: call updateBoard call generateNextPiece call generateNextPieceNumber call setNewDelay call writeScore jmp checkIfNotEnd pieceInProgress: call clearBoard call drawBoardState call drawTetromino call scoreToString call getPlayerInput cmp AX, 0x0F0F ;AX = FFFF - Place Next Piece cmp AX, 0xFFFF je placeNext call moveOneDown cmp AX, 0xFFFF je placeNext jmp pieceInProgress ;--------- checkIfNotEnd: movzx rbx, byte[piecePos] mov AL, [boardState + rbx] cmp AL, boardColor jne endOfGame movzx rbx, byte[piecePos + 1] movzx rax, byte[boardState + rbx] cmp AL, boardColor jne endOfGame movzx rbx, byte[piecePos + 2] movzx rax, byte[boardState + rbx] cmp AL, boardColor jne endOfGame movzx rbx, byte[piecePos + 3] movzx rax, byte[boardState + rbx] cmp AL, boardColor jne endOfGame jmp pieceInProgress ;//////////////////////////////////////////////////////////// getPlayerInput: movzx rcx, byte[waitTime] waitForKey: dec CX cmp CX, 0 je noInput ; We need to run this in a loop with frequent polling. ; If we just check every second or so if a keyboard has been pressed, ; we miss out on key events with keyboard_update from svgalib push rcx ; we need to save the loop counter across the svgalib calls ; the various push/pops are not super-elegant, yes, I know... call delayForWhile ; we need to ensure that we don't call this too frequently ; otherwise the same keypress is returned again call keyboard_update pop rcx mov rdi, 75 ;SCANCODE_CURSORLEFT push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne moveOneLeft mov rdi, 97 ;SCANCODE_CURSORBLOCKLEFT push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne moveOneLeft mov rdi, 80 ;SCANCODE_CURSORSDOWN push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne downKey mov rdi, 100 ;SCANCODE_CURSORBLOCKDOWN push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne downKey mov rdi, 77 ;SCANCODE_CURSORRIGHT push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne moveOneRight mov rdi, 98 ;SCANCODE_CURSORBLOCKRIGHT push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne moveOneRight mov rdi, 72 ;SCANCODE_CURSORUP push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne rotateCounterClockwise mov rdi, 95 ;SCANCODE_CURSORBLOCKUP push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne rotateCounterClockwise mov rdi, 76 ;SCANCODE_KEYPAD5 push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne rotateClockwise mov rdi, 1 ;SCANCODE_ESCAPE push rcx call keyboard_keypressed pop rcx cmp rax, 0 jne endOfGame jmp waitForKey noInput: xor rax, rax ret downKey: inc word[score] call moveOneDown xor rax, rax ret ;//////////////////////////////////////////////////////////// generateNextPieceNumber: mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth mov rcx, nextPieceFrameHeight mov rbx, nextPieceFrameWidth mov rdi, boardColor call drawRect ; Random for next piece call rand xor DX, DX mov CX, 7 div CX mov byte[nextPieceType], DL mov AH, DL ; DOS Code expects next piece type in AH... genFirstPiece: ;I cmp AH, 0 jne genSecondPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + 4 mov rcx, pieceSize mov rbx, 4 * pieceSize mov rdi, 52 call drawRect ret genSecondPiece: ;J cmp AH, 1 jne genThirdPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, 3 * pieceSize mov rdi, 32 call drawRect mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + 3 * pieceSize mov rcx, pieceSize mov rbx, pieceSize mov rdi, 32 call drawRect ret genThirdPiece: ;L cmp AH, 2 jne genForthPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, 3 * pieceSize mov rdi, 43 call drawRect mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, pieceSize mov rdi, 43 call drawRect ret genForthPiece: ;O cmp AH, 3 jne genFifthPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize + 4 mov rcx, 2 * pieceSize mov rbx, 2 * pieceSize mov rdi, 45 call drawRect ret genFifthPiece: ;S cmp AH, 4 jne genSixthPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + 2 * pieceSize mov rcx, pieceSize mov rbx, 2 * pieceSize mov rdi, 48 call drawRect mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, 2 * pieceSize mov rdi, 48 call drawRect ret genSixthPiece: ;T cmp AH, 5 jne genSeventhPiece mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, 3 * pieceSize mov rdi, 34 call drawRect mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + 2 * pieceSize mov rcx, pieceSize mov rbx, pieceSize mov rdi, 34 call drawRect ret genSeventhPiece: ;Z mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + pieceSize mov rcx, pieceSize mov rbx, 2 * pieceSize mov rdi, 40 call drawRect mov rax, (nextPieceFrameBeginningY + nextPieceFrameBorderWidth + 2 * pieceSize + 4) * 320 + nextPieceFrameBeginningX + nextPieceFrameBorderWidth + 2 * pieceSize mov rcx, pieceSize mov rbx, 2 * pieceSize mov rdi, 40 call drawRect ret ;--------------------- generateNextPiece: mov AH, byte[nextPieceType] mov byte[pieceType], AH mov byte[piecePivotPos], 3 firstPiece: ;I cmp AH, 0 jne secondPiece mov byte[piecePos], 13 mov byte[piecePos + 1], 14 mov byte[piecePos + 2], 15 mov byte[piecePos + 3], 16 mov byte[pieceCol], 52 ret secondPiece: ;J cmp AH, 1 jne thirdPiece mov byte[piecePos], 13 mov byte[piecePos + 1], 14 mov byte[piecePos + 2], 15 mov byte[piecePos + 3], 25 mov byte[pieceCol], 32 ret thirdPiece: ;L cmp AH, 2 jne forthPiece mov byte[piecePos], 13 mov byte[piecePos + 1], 14 mov byte[piecePos + 2], 15 mov byte[piecePos + 3], 23 mov byte[pieceCol], 43 ret forthPiece: ;O cmp AH, 3 jne fifthPiece mov byte[piecePos], 14 mov byte[piecePos + 1], 15 mov byte[piecePos + 2], 24 mov byte[piecePos + 3], 25 mov byte[pieceCol], 45 ret fifthPiece: ;S cmp AH, 4 jne sixthPiece mov byte[piecePos], 14 mov byte[piecePos + 1], 15 mov byte[piecePos + 2], 23 mov byte[piecePos + 3], 24 mov byte[pieceCol], 48 ret sixthPiece: ;T cmp AH, 5 jne seventhPiece mov byte[piecePos], 13 mov byte[piecePos + 1], 14 mov byte[piecePos + 2], 15 mov byte[piecePos + 3], 24 mov byte[pieceCol], 34 ret seventhPiece: ;Z mov byte[piecePos], 13 mov byte[piecePos + 1], 14 mov byte[piecePos + 2], 24 mov byte[piecePos + 3], 25 mov byte[pieceCol], 40 ret ;/////////////////////////////////////////////////////////// solidifyPiece: movzx rbx, byte[piecePos] mov AL, byte[pieceCol] mov byte[boardState + rbx], AL movzx rbx, byte[piecePos + 1] mov byte[boardState + rbx], AL movzx rbx, byte[piecePos + 2] mov byte[boardState + rbx], AL movzx rbx, byte[piecePos + 3] mov byte[boardState + rbx], AL ret ;///////////////// - TO DO updateBoard: mov DL, 20 updateBoardLoop: dec DL call clearOneRow cmp DL, 0 jne updateBoardLoop ret clearOneRow: ;DL - row To clear mov BL, 10 mov AL, DL mul BL xor rbx, rbx mov BX, AX mov CX, 10 clearOneRowLoop1: cmp byte[boardState + rbx], boardColor je notclearOneRow inc BX loop clearOneRowLoop1 add word[score], 100 cmp DL, 0 je notclearOneRow push rdx clearOneRowLoop2: dec DL call moveRowDown cmp DL, 1 jne clearOneRowLoop2 pop rdx jmp clearOneRow notclearOneRow: ret moveRowDown: ;DL - beginRow mov BL, 10 mov AL, DL mul BL xor rbx, rbx mov BX, AX mov CX, 10 moveRowDownLoop: mov AL, byte[boardState + rbx] mov byte[boardState + rbx + 10], AL mov byte[boardState + rbx], boardColor inc BX loop moveRowDownLoop ret ;///////////////// - TO DO moveOneDown: xor rax, rax mov rbx, 10 xor DL, DL ;Check Frame Collision cmp byte[piecePos], 19 * 10 jae cantMoveOneDown cmp byte[piecePos + 1], 19 * 10 jae cantMoveOneDown cmp byte[piecePos + 2], 19 * 10 jae cantMoveOneDown cmp byte[piecePos + 3], 19 * 10 jae cantMoveOneDown ;Check Space Collsion xor rbx, rbx mov BL, byte[piecePos] add BL, 10 cmp byte[boardState + rbx], boardColor jne cantMoveOneDown mov BL, byte[piecePos + 1] add BL, 10 cmp byte[boardState + rbx], boardColor jne cantMoveOneDown mov BL, byte[piecePos + 2] add BL, 10 cmp byte[boardState + rbx], boardColor jne cantMoveOneDown mov BL, byte[piecePos + 3] add BL, 10 cmp byte[boardState + rbx], boardColor jne cantMoveOneDown add byte[piecePos], 10 add byte[piecePos + 1], 10 add byte[piecePos + 2], 10 add byte[piecePos + 3], 10 add byte[piecePivotPos], 10 xor rax, rax ret cantMoveOneDown: call solidifyPiece mov rax, 0xFFFF ret ;----------------------------------- moveOneLeft: mov BL, 10 ;Check Frame Collision xor AX, AX mov AL, byte[piecePos] div BL cmp AH, 0 je cantMoveOneLeft xor AX, AX mov AL, byte[piecePos + 1] div BL cmp AH, 0 je cantMoveOneLeft xor AX, AX mov AL, byte[piecePos + 2] div BL cmp AH, 0 je cantMoveOneLeft xor AX, AX mov AL, byte[piecePos + 3] div BL cmp AH, 0 je cantMoveOneLeft ;Check Space Collsion xor rbx, rbx mov BL, byte[piecePos] dec BL cmp byte[boardState + rbx], boardColor jne cantMoveOneLeft mov BL, byte[piecePos + 1] dec BL cmp byte[boardState + rbx], boardColor jne cantMoveOneLeft mov BL, byte[piecePos + 2] dec BL cmp byte[boardState + rbx], boardColor jne cantMoveOneLeft mov BL, byte[piecePos + 3] dec BL cmp byte[boardState + rbx], boardColor jne cantMoveOneLeft dec byte[piecePos] dec byte[piecePos + 1] dec byte[piecePos + 2] dec byte[piecePos + 3] dec byte[piecePivotPos] cantMoveOneLeft: xor AX, AX ret ;----------------------------------- moveOneRight: mov BL, 10 ;Check Frame Collision xor AX, AX mov AL, byte[piecePos] div BL cmp AH, 9 je cantMoveOneRight xor AX, AX mov AL, byte[piecePos + 1] div BL cmp AH, 9 je cantMoveOneRight xor AX, AX mov AL, byte[piecePos + 2] div BL cmp AH, 9 je cantMoveOneRight xor AX, AX mov AL, byte[piecePos + 3] div BL cmp AH, 9 je cantMoveOneRight ;Check Space Collsion xor rbx, rbx mov BL, byte[piecePos] inc BL cmp byte[boardState + rbx], boardColor jne cantMoveOneRight mov BL, byte[piecePos + 1] inc BL cmp byte[boardState + rbx], boardColor jne cantMoveOneRight mov BL, byte[piecePos + 2] inc BL cmp byte[boardState + rbx], boardColor jne cantMoveOneRight mov BL, byte[piecePos + 3] inc BL cmp byte[boardState + rbx], boardColor jne cantMoveOneRight inc byte[piecePos] inc byte[piecePos + 1] inc byte[piecePos + 2] inc byte[piecePos + 3] inc byte[piecePivotPos] cantMoveOneRight: ret rotateClockwise: ;CheckBoard mov rbx, 4 rotateClockwiseLoop1: dec BX push rbx xor AX, AX mov BL, 10 mov AL, byte[piecePivotPos] div BL pop rbx cmp AH, 0 jb cantRotateClockwise cmp AH, 6 ja cantRotateClockwise cmp AL, 16 ja cantRotateClockwise mov CX, AX xor AX, AX mov AL, byte[piecePos + rbx] push rbx mov BL, 10 sub AL, byte[piecePivotPos] div BL mov DX, AX ;AH - X, AL - Y mov AH, DL cmp byte[pieceType], 0 je rotateClockwiseSpc mov AL, 3 rotateClockwiseSpcBack: sub AL, DH mov DX, AX mov AL, DL mov BL, 10 mul BL add AL, DH pop rbx add AL, byte[piecePivotPos] mov byte[temporaryPiecePos + rbx], AL cmp BX, 0 jne rotateClockwiseLoop1 xor rbx, rbx mov BL, byte[temporaryPiecePos] cmp byte[boardState + rbx], boardColor jne cantRotateClockwise mov BL, byte[temporaryPiecePos + 1] cmp byte[boardState + rbx], boardColor jne cantRotateClockwise mov BL, byte[temporaryPiecePos + 2] cmp byte[boardState + rbx], boardColor jne cantRotateClockwise mov BL, byte[temporaryPiecePos + 3] cmp byte[boardState + rbx], boardColor jne cantRotateClockwise mov AL, byte[temporaryPiecePos] mov byte[piecePos], AL mov AL, byte[temporaryPiecePos + 1] mov byte[piecePos + 1], AL mov AL, byte[temporaryPiecePos + 2] mov byte[piecePos + 2], AL mov AL, byte[temporaryPiecePos + 3] mov byte[piecePos + 3], AL cantRotateClockwise: xor AX, AX ret rotateClockwiseSpc: mov AL, 4 jmp rotateClockwiseSpcBack ;///////////////// rotateCounterClockwise: ;CheckBoard mov rbx, 4 rotateCounterClockwiseLoop1: dec BX push rbx xor AX, AX mov BL, 10 mov AL, byte[piecePivotPos] div BL pop rbx cmp AH, 0 jb cantRotateCounterClockwise cmp AH, 6 ja cantRotateCounterClockwise cmp AL, 16 ja cantRotateCounterClockwise mov CX, AX xor AX, AX mov AL, byte[piecePos + rbx] push rbx mov BL, 10 sub AL, byte[piecePivotPos] div BL mov DX, AX ;AH - X, AL - Y mov AL, DH cmp byte[pieceType], 0 je rotateCounterClockwiseSpc mov AH, 3 rotateCounterClockwiseSpcBack: sub AH, DL mov DX, AX mov AL, DL mov BL, 10 mul BL add AL, DH pop rbx add AL, byte[piecePivotPos] mov byte[temporaryPiecePos + rbx], AL cmp BX, 0 jne rotateCounterClockwiseLoop1 ;xor BX, BX movzx r8, byte[temporaryPiecePos] cmp byte[boardState + r8], boardColor jne cantRotateCounterClockwise movzx r8, byte[temporaryPiecePos + 1] cmp byte[boardState + r8], boardColor jne cantRotateCounterClockwise movzx r8, byte[temporaryPiecePos + 2] cmp byte[boardState + r8], boardColor jne cantRotateCounterClockwise movzx r8, byte[temporaryPiecePos + 3] cmp byte[boardState + r8], boardColor jne cantRotateCounterClockwise mov AL, byte[temporaryPiecePos] mov byte[piecePos], AL mov AL, byte[temporaryPiecePos + 1] mov byte[piecePos + 1], AL mov AL, byte[temporaryPiecePos + 2] mov byte[piecePos + 2], AL mov AL, byte[temporaryPiecePos + 3] mov byte[piecePos + 3], AL cantRotateCounterClockwise: xor AX, AX ret rotateCounterClockwiseSpc: mov AH, 4 jmp rotateCounterClockwiseSpcBack ;///////////////// ;Delay for one/10 second (loop in input is 10 times) delayForWhile: mov rdi, usleepMS call usleep ret ;-------------------- delayForLongWhile: mov rdi, 0x000F8480 call usleep ret ;///////////////// setNewDelay: cmp byte[waitTime], 1 jb noSetNewDelat mov AX, word[score] xor DX, DX mov BX, 1000 div BX mov DX, AX mov AX, 10 cmp AX, DX jl set1Delay sub AX, DX mov byte[waitTime], AL noSetNewDelat: ret set1Delay: mov byte[waitTime], 1 ret ;///////////////// scoreToString: xor DX, DX mov AX, word[score] mov BX, 10000 div BX add AX, 48 mov byte[scoreAsString], AL mov AX, DX xor DX, DX mov BX, 1000 div BX add AX, 48 mov byte[scoreAsString + 1], AL mov AX, DX xor DX, DX mov BX, 100 div BX add AX, 48 mov byte[scoreAsString + 2], AL mov AX, DX xor DX, DX mov BX, 10 div BX add AX, 48 mov byte[scoreAsString + 3], AL add DX, 48 mov byte[scoreAsString + 4], DL mov byte[scoreAsString + 5], 0 ; 0 for C string end mov BX, 5 mov DL, 24 mov rdi, scorePosX mov rsi, scorePosY-15 mov rdx, scoreString call gl_write mov rdi, scorePosX ; x of position mov rsi, scorePosY ; y of position mov rdx, scoreAsString ; position of string (=1 character) call gl_write ret ;//////////////////////// writeScore: mov rdi, scorePosX mov rsi, scorePosY-15 mov rdx, scoreString call gl_write mov rdi, scorePosX ; x of position mov rsi, scorePosY ; y of position mov rdx, scoreAsString ; position of string (=1 character) call gl_write ret ;---------------- displayGameOver: xor rax, rax mov rcx, 200 mov rbx, 320 mov rdi, boardColor call drawRect mov rdi, gameOverPosX ; x of position mov rsi, gameOverPosY ; y of position mov rdx, gameOver ; position of string (=1 character) call gl_write ret
programs/oeis/244/A244040.asm
neoneye/loda
22
27058
<reponame>neoneye/loda ; A244040: Sum of digits of n in fractional base 3/2. ; 0,1,2,2,3,4,3,4,5,3,4,5,5,6,7,4,5,6,5,6,7,7,8,9,5,6,7,5,6,7,7,8,9,8,9,10,5,6,7,7,8,9,6,7,8,7,8,9,9,10,11,9,10,11,5,6,7,7,8,9,8,9,10,6,7,8,8,9,10,8,9,10,9,10,11,11,12,13,10,11,12,5,6,7,7,8,9,8,9,10,8,9,10,10,11,12,7,8,9,8 mov $1,$0 lpb $1 div $1,3 sub $0,$1 mul $1,2 lpe
src/test/ref/complex/borderline_pacman/pacman.asm
jbrandwood/kickc
2
246158
// Camelot Borderline Entry // Pacman made with 9 sprites in in the borders // Commodore 64 PRG executable file .plugin "se.triad.kickass.CruncherPlugins" .file [name="pacman.prg", type="prg", segments="Program", modify="B2exe", _jmpAdress=__start] .segmentdef Program [segments="Code, Data, Init"] .segmentdef Code [start=$810] .segmentdef Data [startAfter="Code"] .segmentdef Init [startAfter="Data"] /// Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f /// The offset of the sprite pointers from the screen start address .const OFFSET_SPRITE_PTRS = $3f8 /// $D011 Control Register #1 Bit#7: RST8 9th Bit for $D012 Rasterline counter .const VICII_RST8 = $80 /// $D011 Control Register #1 Bit#6: ECM Turn Extended Color Mode on/off .const VICII_ECM = $40 /// $D011 Control Register #1 Bit#5: BMM Turn Bitmap Mode on/off .const VICII_BMM = $20 /// $D011 Control Register #1 Bit#4: DEN Switch VIC-II output on/off .const VICII_DEN = $10 /// $D011 Control Register #1 Bit#3: RSEL Switch betweem 25 or 24 visible rows /// RSEL| Display window height | First line | Last line /// ----+--------------------------+-------------+---------- /// 0 | 24 text lines/192 pixels | 55 ($37) | 246 ($f6) /// 1 | 25 text lines/200 pixels | 51 ($33) | 250 ($fa) .const VICII_RSEL = 8 /// VICII IRQ Status/Enable Raster // @see #IRQ_ENABLE #IRQ_STATUS /// 0 | RST| Reaching a certain raster line. The line is specified by writing /// | | to register 0xd012 and bit 7 of $d011 and internally stored by /// | | the VIC for the raster compare. The test for reaching the /// | | interrupt raster line is done in cycle 0 of every line (for line /// | | 0, in cycle 1). .const IRQ_RASTER = 1 /// Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written .const PROCPORT_DDR_MEMORY_MASK = 7 /// RAM in all three areas 0xA000, 0xD000, 0xE000 .const PROCPORT_RAM_ALL = 0 /// RAM in 0xA000, 0xE000 I/O in 0xD000 .const PROCPORT_RAM_IO = 5 /// The colors of the C64 .const BLACK = 0 .const RED = 2 .const BLUE = 6 .const YELLOW = 7 .const EMPTY = 0 .const PILL = 1 .const POWERUP = 2 .const WALL = 4 // Address of the (decrunched) splash screen .const BOB_ROW_SIZE = $80 .const RENDER_OFFSET_CANVAS_LO = 0 .const RENDER_OFFSET_CANVAS_HI = $50 .const RENDER_OFFSET_YPOS_INC = $a0 // The number of bobs rendered .const NUM_BOBS = 5 // The size of the BOB restore structure .const SIZE_BOB_RESTORE = $12 // Size of the crunched music .const INTRO_MUSIC_CRUNCHED_SIZE = $600 // The raster line for irq_screen_top() .const IRQ_SCREEN_TOP_LINE = 5 .const STOP = 0 .const UP = 4 .const DOWN = 8 .const LEFT = $10 .const RIGHT = $20 .const CHASE = 0 .const SCATTER = 1 .const FRIGHTENED = 2 .const OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR = 2 .const OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE = $18 .const OFFSET_STRUCT_MOS6581_SID_CH1_PULSE_WIDTH = 2 .const OFFSET_STRUCT_MOS6581_SID_CH1_CONTROL = 4 .const OFFSET_STRUCT_MOS6581_SID_CH1_ATTACK_DECAY = 5 .const OFFSET_STRUCT_MOS6581_SID_CH1_SUSTAIN_RELEASE = 6 .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB = $10 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X = $1d .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 .const OFFSET_STRUCT_MOS6569_VICII_BG_COLOR = $21 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR1 = $25 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR2 = $26 .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_MC = $1c .const OFFSET_STRUCT_MOS6569_VICII_CONTROL2 = $16 .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a .const OFFSET_STRUCT_MOS6569_VICII_SPRITE0_Y = 1 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE1_Y = 3 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE2_Y = 5 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE3_Y = 7 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE4_Y = 9 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE5_Y = $b .const OFFSET_STRUCT_MOS6569_VICII_SPRITE6_Y = $d .const OFFSET_STRUCT_MOS6569_VICII_SPRITE7_Y = $f .const OFFSET_STRUCT_MOS6569_VICII_SPRITE0_COLOR = $27 .const OFFSET_STRUCT_MOS6569_VICII_SPRITE1_COLOR = $28 .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const SIZEOF_CHAR = 1 /// Sprite X position register for sprite #0 .label SPRITES_XPOS = $d000 /// Sprite Y position register for sprite #0 .label SPRITES_YPOS = $d001 /// Sprite colors register for sprite #0 .label SPRITES_COLOR = $d027 /// $D012 RASTER Raster counter .label RASTER = $d012 /// $D020 Border Color .label BORDER_COLOR = $d020 /// $D011 Control Register #1 /// - Bit#0-#2: YSCROLL Screen Soft Scroll Vertical /// - Bit#3: RSEL Switch betweem 25 or 24 visible rows /// RSEL| Display window height | First line | Last line /// ----+--------------------------+-------------+---------- /// 0 | 24 text lines/192 pixels | 55 ($37) | 246 ($f6) /// 1 | 25 text lines/200 pixels | 51 ($33) | 250 ($fa) /// - Bit#4: DEN Switch VIC-II output on/off /// - Bit#5: BMM Turn Bitmap Mode on/off /// - Bit#6: ECM Turn Extended Color Mode on/off /// - Bit#7: RST8 9th Bit for $D012 Rasterline counter /// Initial Value: %10011011 .label VICII_CONTROL1 = $d011 /// $D016 Control register 2 /// - Bit#0-#2: XSCROLL Screen Soft Scroll Horizontal /// - Bit#3: CSEL Switch betweem 40 or 38 visible columns /// CSEL| Display window width | First X coo. | Last X coo. /// ----+--------------------------+--------------+------------ /// 0 | 38 characters/304 pixels | 31 ($1f) | 334 ($14e) /// 1 | 40 characters/320 pixels | 24 ($18) | 343 ($157) /// - Bit#4: MCM Turn Multicolor Mode on/off /// - Bit#5-#7: not used /// Initial Value: %00001000 .label VICII_CONTROL2 = $d016 /// $D018 VIC-II base addresses /// - Bit#0: not used /// - Bit#1-#3: CB Address Bits 11-13 of the Character Set (*2048) /// - Bit#4-#7: VM Address Bits 10-13 of the Screen RAM (*1024) /// Initial Value: %00010100 .label VICII_MEMORY = $d018 /// VIC II IRQ Status Register .label IRQ_STATUS = $d019 /// Channel 1 Frequency High byte .label SID_CH1_FREQ_HI = $d401 /// Processor port data direction register .label PROCPORT_DDR = 0 /// Processor Port Register controlling RAM/ROM configuration and the datasette .label PROCPORT = 1 /// The SID MOS 6581/8580 .label SID = $d400 /// The VIC-II MOS 6567/6569 .label VICII = $d000 /// The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 /// The CIA#2: Serial bus, RS-232, VIC memory bank .label CIA2 = $dd00 /// CIA#1 Interrupt for reading in ASM .label CIA1_INTERRUPT = $dc0d /// The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe // Graphics Bank 1 // Address of the sprites .label BANK_1 = $4000 // Address of the sprites .label SPRITES_1 = $6000 // Use sprite pointers on all screens (0x43f8, 0x47f8, ...) .label SCREENS_1 = $4000 // Graphics Bank 2 // Address of the sprites .label BANK_2 = $c000 // Address of the sprites .label SPRITES_2 = $e000 // Use sprite pointers on all screens (0x43f8, 0x47f8, ...) .label SCREENS_2 = $c000 // The location where the logic code will be located before merging .label LOGIC_CODE_UNMERGED = $e000 // The location where the screen raster code will be located before merging .label RASTER_CODE_UNMERGED = $6000 // The location where the screen raster code will be located when running .label RASTER_CODE = $8000 // Address of the (decrunched) splash screen .label SPLASH = $4000 // Address for the victory graphics .label WIN_GFX = $a700 // Address for the gameover graphics .label GAMEOVER_GFX = $a700 // Address used by (decrunched) tiles .label LEVEL_TILES = $4800 .label TILES_LEFT = LEVEL_TILES+$a00 .label TILES_RIGHT = LEVEL_TILES+$a80 .label TILES_TYPE = LEVEL_TILES+$b00 // Address used for table containing available directions for all tiles // TABLE LEVEL_TILES_DIRECTIONS[64*37] // The level data is organized as 37 rows of 64 bytes. Each row is 50 bytes containing DIRECTION bits plus 14 unused bytes to achieve 64-byte alignment. .label LEVEL_TILES_DIRECTIONS = $3e00 .label BOB_MASK_LEFT = $5400 .label BOB_MASK_RIGT = BOB_MASK_LEFT+BOB_ROW_SIZE*6 .label BOB_PIXEL_LEFT = BOB_MASK_LEFT+BOB_ROW_SIZE*$c .label BOB_PIXEL_RIGT = BOB_MASK_LEFT+BOB_ROW_SIZE*$12 // Tables pointing to the graphics. // Each page represents one X column (1 byte wide, 4 MC pixels) // On each page: // - 0xNN00-0xNN4A : low-byte of the graphics for (X-column, Y-fine) // - 0xNN50-0xNN9A : high-byte of the graphics for (X-column, Y-fine) // - 0xNNA0-0xNNEA : index into RENDER_YPOS_INC for incrementing the y-pos. .label RENDER_INDEX = $b600 // Upper memory location used during decrunching .label INTRO_MUSIC_CRUNCHED_UPPER = $a700 // Address of the music during run-time .label INTRO_MUSIC = $3000 // Pointer to the music init routine .label musicInit = INTRO_MUSIC // Pointer to the music play routine .label musicPlay = INTRO_MUSIC+6 // Is the pacman eating sound enabled .label pacman_ch1_enabled = $6e // Index into the eating sound .label pacman_ch1_idx = $66 // Pointer to the tile to render in the logic code .label logic_tile_ptr = $1a // The x-column of the tile to render .label logic_tile_xcol = $1c // The y-fine of the tile to render .label logic_tile_yfine = $1d // The ID*4 of the left tile to render .label logic_tile_left_idx = $4d // The ID*4 of the right tile to render .label logic_tile_right_idx = $4e // Variables used by the logic-code renderer and restorer .label left_render_index_xcol = $4f .label left_canvas = $51 .label left_ypos_inc_offset = $53 .label rigt_render_index_xcol = $54 .label rigt_canvas = $56 .label rigt_ypos_inc_offset = $58 // The high-byte of the start-address of the canvas currently being rendered to .label canvas_base_hi = $20 // The offset used for bobs_restore - used to achieve double buffering .label bobs_restore_base = $21 // Sprite settings used for the top/side/bottom sprites. // Used for achieving single-color sprites on the splash and multi-color sprites in the game .label top_sprites_color = $1e .label top_sprites_mc = $3a .label side_sprites_color = $16 .label side_sprites_mc = $17 .label bottom_sprites_color = $18 .label bottom_sprites_mc = $19 // The number of pills left .label pill_count = $59 // 1 When pacman wins .label pacman_wins = $1f // The number of pacman lives left .label pacman_lives = $23 // Signal for playing th next music frame during the intro .label music_play_next = $15 // 0: intro, 1: game .label phase = $3d // The double buffer frame (0=BANK_1, 1=BANK_2) .label frame = $6d // The animation frame IDX (within the current direction) [0-3] .label anim_frame_idx = $68 // Pacman x fine position (0-99). .label pacman_xfine = $47 // Pacman y fine position (0-70). .label pacman_yfine = $48 // The pacman movement current direction .label pacman_direction = $34 // Pacman movement substep (0: on tile, 1: between tiles). .label pacman_substep = $2c // Mode determining ghost target mode. 0: chase, 1: scatter .label ghosts_mode = $67 // Counts frames to change ghost mode (7 seconds scatter, 20 seconds chase ) .label ghosts_mode_count = $2b // Ghost 1 x fine position (0-99). .label ghost1_xfine = $3b // Ghost 1 y fine position (0-70). .label ghost1_yfine = $3c // Ghost 1 movement current direction .label ghost1_direction = $35 // Ghost 1 movement substep (0: on tile, 1: between tiles). .label ghost1_substep = $2d // Ghost 1 movement should be reversed (0: normal, 1: reverse direction) .label ghost1_reverse = $69 // Ghost 1 respawn timer .label ghost1_respawn = $26 // Ghost 2 x fine position (0-99). .label ghost2_xfine = $3e // Ghost 2 y fine position (0-70). .label ghost2_yfine = $3f // Ghost 2 movement current direction .label ghost2_direction = $36 // Ghost 2 movement substep (0: on tile, 1: between tiles). .label ghost2_substep = $2e // Ghost 2 movement should be reversed (0: normal, 1: reverse direction) .label ghost2_reverse = $6a // Ghost 2 respawn timer .label ghost2_respawn = $28 // Ghost 3 x fine position (0-99). .label ghost3_xfine = $40 // Ghost 3 y fine position (0-70). .label ghost3_yfine = $42 // Ghost 3 movement current direction .label ghost3_direction = $38 // Ghost 3 movement substep (0: on tile, 1: between tiles). .label ghost3_substep = $2f // Ghost 3 movement should be reversed (0: normal, 1: reverse direction) .label ghost3_reverse = $6b // Ghost 3 respawn timer .label ghost3_respawn = $29 // Ghost 4 x fine position (0-99). .label ghost4_xfine = $43 // Ghost 4 y fine position (0-70). .label ghost4_yfine = $44 // Ghost 4 movement current direction .label ghost4_direction = $39 // Ghost 4 movement substep (0: on tile, 1: between tiles). .label ghost4_substep = $30 // Ghost 4 movement should be reversed (0: normal, 1: reverse direction) .label ghost4_reverse = $6c // Ghost 4 respawn timer .label ghost4_respawn = $2a // Game logic sub-step [0-7]. Each frame a different sub-step is animated .label game_logic_substep = $5c // 1 when the game is playable and characters should move around .label game_playable = $41 .segment Code __start: { // volatile char pacman_ch1_enabled = 0 lda #0 sta.z pacman_ch1_enabled // volatile char pacman_ch1_idx = 0 sta.z pacman_ch1_idx // volatile char* logic_tile_ptr sta.z logic_tile_ptr sta.z logic_tile_ptr+1 // volatile char logic_tile_xcol sta.z logic_tile_xcol // volatile char logic_tile_yfine sta.z logic_tile_yfine // volatile char logic_tile_left_idx sta.z logic_tile_left_idx // volatile char logic_tile_right_idx sta.z logic_tile_right_idx // char * volatile left_render_index_xcol sta.z left_render_index_xcol sta.z left_render_index_xcol+1 // char * volatile left_canvas sta.z left_canvas sta.z left_canvas+1 // volatile char left_ypos_inc_offset sta.z left_ypos_inc_offset // char * volatile rigt_render_index_xcol sta.z rigt_render_index_xcol sta.z rigt_render_index_xcol+1 // char * volatile rigt_canvas sta.z rigt_canvas sta.z rigt_canvas+1 // volatile char rigt_ypos_inc_offset sta.z rigt_ypos_inc_offset // volatile char canvas_base_hi sta.z canvas_base_hi // volatile char bobs_restore_base sta.z bobs_restore_base // volatile char top_sprites_color sta.z top_sprites_color // volatile char top_sprites_mc sta.z top_sprites_mc // volatile char side_sprites_color sta.z side_sprites_color // volatile char side_sprites_mc sta.z side_sprites_mc // volatile char bottom_sprites_color sta.z bottom_sprites_color // volatile char bottom_sprites_mc sta.z bottom_sprites_mc // volatile unsigned int pill_count sta.z pill_count sta.z pill_count+1 // volatile char pacman_wins = 0 sta.z pacman_wins // volatile char pacman_lives = 3 lda #3 sta.z pacman_lives // volatile char music_play_next = 0 lda #0 sta.z music_play_next // volatile char phase = 0 sta.z phase // volatile char frame = 0 sta.z frame // volatile char anim_frame_idx = 0 sta.z anim_frame_idx // volatile char pacman_xfine = 45 lda #$2d sta.z pacman_xfine // volatile char pacman_yfine = 35 lda #$23 sta.z pacman_yfine // volatile enum DIRECTION pacman_direction = STOP lda #STOP sta.z pacman_direction // volatile char pacman_substep = 0 lda #0 sta.z pacman_substep // volatile enum GHOSTS_MODE ghosts_mode = 1 lda #1 sta.z ghosts_mode // volatile char ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count // volatile char ghost1_xfine = 45 lda #$2d sta.z ghost1_xfine // volatile char ghost1_yfine = 35 lda #$23 sta.z ghost1_yfine // volatile enum DIRECTION ghost1_direction = STOP lda #STOP sta.z ghost1_direction // volatile char ghost1_substep = 0 lda #0 sta.z ghost1_substep // volatile char ghost1_reverse = 0 sta.z ghost1_reverse // volatile char ghost1_respawn = 0 sta.z ghost1_respawn // volatile char ghost2_xfine = 45 lda #$2d sta.z ghost2_xfine // volatile char ghost2_yfine = 35 lda #$23 sta.z ghost2_yfine // volatile enum DIRECTION ghost2_direction = STOP lda #STOP sta.z ghost2_direction // volatile char ghost2_substep = 0 lda #0 sta.z ghost2_substep // volatile char ghost2_reverse = 0 sta.z ghost2_reverse // volatile char ghost2_respawn = 0 sta.z ghost2_respawn // volatile char ghost3_xfine = 45 lda #$2d sta.z ghost3_xfine // volatile char ghost3_yfine = 35 lda #$23 sta.z ghost3_yfine // volatile enum DIRECTION ghost3_direction = STOP lda #STOP sta.z ghost3_direction // volatile char ghost3_substep = 0 lda #0 sta.z ghost3_substep // volatile char ghost3_reverse = 0 sta.z ghost3_reverse // volatile char ghost3_respawn = 0 sta.z ghost3_respawn // volatile char ghost4_xfine = 45 lda #$2d sta.z ghost4_xfine // volatile char ghost4_yfine = 35 lda #$23 sta.z ghost4_yfine // volatile enum DIRECTION ghost4_direction = STOP lda #STOP sta.z ghost4_direction // volatile char ghost4_substep = 0 lda #0 sta.z ghost4_substep // volatile char ghost4_reverse = 0 sta.z ghost4_reverse // volatile char ghost4_respawn = 0 sta.z ghost4_respawn // volatile char game_logic_substep = 0 sta.z game_logic_substep // volatile char game_playable = 0 sta.z game_playable jsr main rts } // Interrupt Routine at Screen Top irq_screen_top: { .const toDd001_return = 0 .const toDd002_return = 3^(>SCREENS_1)/$40 .const toD0181_return = 0 sta rega+1 stx regx+1 sty regy+1 // kickasm // Stabilize the raster by using the double IRQ method // Acknowledge the IRQ lda #IRQ_RASTER sta IRQ_STATUS // Set-up IRQ for the next line inc RASTER // Point IRQ to almost stable code lda #<stable sta HARDWARE_IRQ lda #>stable sta HARDWARE_IRQ+1 tsx // Save stack pointer cli // Reenable interrupts // Wait for new IRQ using NOP's to ensure minimal jitter when it hits .fill 15, NOP .align $20 stable: txs // Restore stack pointer ldx #9 // Wait till the raster has almost crossed to the next line (48 cycles) !: dex bne !- nop lda RASTER cmp RASTER bne !+ // And correct the last cycle of potential jitter !: // Raster is now completely stable! (Line 0x007 cycle 7) // asm jsr RASTER_CODE // VICII->SPRITE0_Y =7 // Move sprites back to the top lda #7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE0_Y // VICII->SPRITE1_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE1_Y // VICII->SPRITE2_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE2_Y // VICII->SPRITE3_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE3_Y // VICII->SPRITE4_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE4_Y // VICII->SPRITE5_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE5_Y // VICII->SPRITE6_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE6_Y // VICII->SPRITE7_Y =7 sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE7_Y // VICII->MEMORY = toD018(SCREENS_1, SCREENS_1) // Select first screen (graphics bank not important since layout in the banks is identical) lda #toD0181_return sta VICII+OFFSET_STRUCT_MOS6569_VICII_MEMORY // VICII->SPRITES_MC = top_sprites_mc // Set the top sprites color/MC lda.z top_sprites_mc sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MC // VICII->SPRITE0_COLOR = top_sprites_color lda.z top_sprites_color sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE0_COLOR // VICII->SPRITE1_COLOR = top_sprites_color lda.z top_sprites_color sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITE1_COLOR // frame+1 lda.z frame clc adc #1 // (frame+1) & 1 and #1 // frame = (frame+1) & 1 // Move to next frame sta.z frame // if(frame) bne __b6 // CIA2->PORT_A = toDd00(SCREENS_1) // Change graphics bank lda #toDd002_return sta CIA2 // canvas_base_hi = BYTE1(SPRITES_2) // Set the next canvas base address lda #>SPRITES_2 sta.z canvas_base_hi // bobs_restore_base = NUM_BOBS*SIZE_BOB_RESTORE lda #NUM_BOBS*SIZE_BOB_RESTORE sta.z bobs_restore_base __b1: // if(phase==0) lda.z phase beq __b2 // game_logic() // Game phase // Perform game logic jsr game_logic // pacman_sound_play() // Play sounds jsr pacman_sound_play __b3: // VICII->IRQ_STATUS = IRQ_RASTER // Acknowledge the IRQ lda #IRQ_RASTER sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS // VICII->RASTER = IRQ_SCREEN_TOP_LINE // Trigger IRQ at screen top again lda #IRQ_SCREEN_TOP_LINE sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER // *HARDWARE_IRQ = &irq_screen_top lda #<irq_screen_top sta HARDWARE_IRQ lda #>irq_screen_top sta HARDWARE_IRQ+1 // } rega: lda #0 regx: ldx #0 regy: ldy #0 rti __b2: // music_play_next = 1 // intro phase // Play intro music lda #1 sta.z music_play_next jmp __b3 __b6: // CIA2->PORT_A = toDd00(SCREENS_2) // Change graphics bank lda #toDd001_return sta CIA2 // canvas_base_hi = BYTE1(SPRITES_1) // Set the next canvas base address lda #>SPRITES_1 sta.z canvas_base_hi // bobs_restore_base = 0 lda #0 sta.z bobs_restore_base jmp __b1 } main: { // splash_run() // Show the splash screen jsr splash_run __b1: // gameplay_run() // Run the gameplay jsr gameplay_run // done_run() // Show victory or game over image jsr done_run jmp __b1 } // Perform game logic such as moving pacman and ghosts game_logic: { .label __67 = $45 .label __71 = $45 .label __210 = $5d .label ghost_frame_idx = $49 .label pacman_xtile = $5b .label ytiles = $45 .label ghost4_xtile = $5e .label ghost4_ytile = $5f .label target_ytile = $27 .label ghost3_xtile = $60 .label ghost3_ytile = $61 .label target_ytile1 = $27 .label ghost2_xtile = $62 .label ghost2_ytile = $63 .label target_ytile2 = $27 .label ghost1_xtile = $64 .label ghost1_ytile = $65 .label target_ytile3 = $27 // if(game_playable==0) lda.z game_playable bne __b1 __breturn: // } rts __b1: // game_logic_substep+1 ldx.z game_logic_substep inx // (game_logic_substep+1)&7 txa and #7 // game_logic_substep = (game_logic_substep+1)&7 // Move to next sub-step sta.z game_logic_substep // if(game_logic_substep==0) bne !__b2+ jmp __b2 !__b2: // if(game_logic_substep==1) lda #1 cmp.z game_logic_substep bne !__b3+ jmp __b3 !__b3: // if(game_logic_substep==2) lda #2 cmp.z game_logic_substep bne !__b4+ jmp __b4 !__b4: // if(game_logic_substep==4) lda #4 cmp.z game_logic_substep bne !__b5+ jmp __b5 !__b5: // if(game_logic_substep==5) lda #5 cmp.z game_logic_substep bne !__b6+ jmp __b6 !__b6: // if(game_logic_substep==6) lda #6 cmp.z game_logic_substep bne !__b7+ jmp __b7 !__b7: // if(game_logic_substep==3 || game_logic_substep==7) lda #3 cmp.z game_logic_substep beq __b14 lda #7 cmp.z game_logic_substep beq __b14 rts __b14: // anim_frame_idx+1 ldx.z anim_frame_idx inx // (anim_frame_idx+1) & 3 txa and #3 // anim_frame_idx = (anim_frame_idx+1) & 3 // Update animation and bobs sta.z anim_frame_idx // char pacman_bob_xfine = pacman_xfine-1 lda.z pacman_xfine tay dey // pacman_bob_xfine/4 tya lsr lsr // bobs_xcol[0] = pacman_bob_xfine/4 sta bobs_xcol // pacman_yfine-1 ldx.z pacman_yfine dex // bobs_yfine[0] = pacman_yfine-1 stx bobs_yfine // pacman_direction|anim_frame_idx lda.z pacman_direction ora.z anim_frame_idx tax // pacman_bob_xfine&3 tya and #3 // pacman_frames[pacman_direction|anim_frame_idx] + (pacman_bob_xfine&3) clc adc pacman_frames,x // bobs_bob_id[0] = pacman_frames[pacman_direction|anim_frame_idx] + (pacman_bob_xfine&3) sta bobs_bob_id // char ghost_frame_idx = anim_frame_idx lda.z anim_frame_idx sta.z ghost_frame_idx // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode bne __b44 // ghost_frame_idx |= 0x40 lda #$40 ora.z ghost_frame_idx sta.z ghost_frame_idx __b44: // char ghost1_bob_xfine = ghost1_xfine-1 lda.z ghost1_xfine tay dey // ghost1_bob_xfine/4 tya lsr lsr // bobs_xcol[1] = ghost1_bob_xfine/4 sta bobs_xcol+1 // ghost1_yfine-1 ldx.z ghost1_yfine dex // bobs_yfine[1] = ghost1_yfine-1 stx bobs_yfine+1 // ghost1_direction|ghost_frame_idx lda.z ghost1_direction ora.z ghost_frame_idx tax // ghost1_bob_xfine&3 tya and #3 // ghost_frames[ghost1_direction|ghost_frame_idx] + (ghost1_bob_xfine&3) clc adc ghost_frames,x // bobs_bob_id[1] = ghost_frames[ghost1_direction|ghost_frame_idx] + (ghost1_bob_xfine&3) sta bobs_bob_id+1 // char ghost2_bob_xfine = ghost2_xfine-1 lda.z ghost2_xfine tay dey // ghost2_bob_xfine/4 tya lsr lsr // bobs_xcol[2] = ghost2_bob_xfine/4 sta bobs_xcol+2 // ghost2_yfine-1 ldx.z ghost2_yfine dex // bobs_yfine[2] = ghost2_yfine-1 stx bobs_yfine+2 // ghost2_direction|ghost_frame_idx lda.z ghost2_direction ora.z ghost_frame_idx tax // ghost2_bob_xfine&3 tya and #3 // ghost_frames[ghost2_direction|ghost_frame_idx] + (ghost2_bob_xfine&3) clc adc ghost_frames,x // bobs_bob_id[2] = ghost_frames[ghost2_direction|ghost_frame_idx] + (ghost2_bob_xfine&3) sta bobs_bob_id+2 // char ghost3_bob_xfine = ghost3_xfine-1 lda.z ghost3_xfine tay dey // ghost3_bob_xfine/4 tya lsr lsr // bobs_xcol[3] = ghost3_bob_xfine/4 sta bobs_xcol+3 // ghost3_yfine-1 ldx.z ghost3_yfine dex // bobs_yfine[3] = ghost3_yfine-1 stx bobs_yfine+3 // ghost3_direction|ghost_frame_idx lda.z ghost3_direction ora.z ghost_frame_idx tax // ghost3_bob_xfine&3 tya and #3 // ghost_frames[ghost3_direction|ghost_frame_idx] + (ghost3_bob_xfine&3) clc adc ghost_frames,x // bobs_bob_id[3] = ghost_frames[ghost3_direction|ghost_frame_idx] + (ghost3_bob_xfine&3) sta bobs_bob_id+3 // char ghost4_bob_xfine = ghost4_xfine-1 lda.z ghost4_xfine tay dey // ghost4_bob_xfine/4 tya lsr lsr // bobs_xcol[4] = ghost4_bob_xfine/4 sta bobs_xcol+4 // ghost4_yfine-1 ldx.z ghost4_yfine dex // bobs_yfine[4] = ghost4_yfine-1 stx bobs_yfine+4 // ghost4_direction|ghost_frame_idx lda.z ghost4_direction ora.z ghost_frame_idx tax // ghost4_bob_xfine&3 tya and #3 // ghost_frames[ghost4_direction|ghost_frame_idx] + (ghost4_bob_xfine&3) clc adc ghost_frames,x // bobs_bob_id[4] = ghost_frames[ghost4_direction|ghost_frame_idx] + (ghost4_bob_xfine&3) sta bobs_bob_id+4 rts __b7: // ghosts_mode_count++; inc.z ghosts_mode_count // if(ghosts_mode==SCATTER) lda #SCATTER cmp.z ghosts_mode bne !__b45+ jmp __b45 !__b45: // if(ghosts_mode==CHASE) lda #CHASE cmp.z ghosts_mode bne !__b46+ jmp __b46 !__b46: // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode bne __b9 // if(ghosts_mode_count>50) lda.z ghosts_mode_count cmp #$32+1 bcc __b9 // ghosts_mode = CHASE lda #CHASE sta.z ghosts_mode // ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count __b8: lda #1 jmp __b47 __b9: lda #0 __b47: // if(do_reverse) cmp #0 beq __b48 // ghost1_reverse = 1 lda #1 sta.z ghost1_reverse // ghost2_reverse = 1 sta.z ghost2_reverse // ghost3_reverse = 1 sta.z ghost3_reverse // ghost4_reverse = 1 sta.z ghost4_reverse __b48: // char pacman_xtile = pacman_xfine/2 // Examine if pacman is on a pill tile - and handle it lda.z pacman_xfine lsr sta.z pacman_xtile // char pacman_ytile = pacman_yfine/2 lda.z pacman_yfine lsr // char* ytiles = LEVEL_TILES + LEVEL_YTILE_OFFSET[pacman_ytile] asl sta.z __210 tay clc lda #<LEVEL_TILES adc LEVEL_YTILE_OFFSET,y sta.z ytiles lda #>LEVEL_TILES adc LEVEL_YTILE_OFFSET+1,y sta.z ytiles+1 // char tile_id = ytiles[pacman_xtile] ldy.z pacman_xtile lda (ytiles),y tax // if(TILES_TYPE[tile_id]==PILL) lda TILES_TYPE,x cmp #PILL bne !__b49+ jmp __b49 !__b49: // if(TILES_TYPE[tile_id]==POWERUP) lda TILES_TYPE,x cmp #POWERUP bne __b50 // ytiles[pacman_xtile] = EMPTY // Empty the tile lda #EMPTY sta (ytiles),y // pacman_xtile/2 tya lsr // logic_tile_xcol = pacman_xtile/2 // Ask the logic code renderer to update the tile sta.z logic_tile_xcol // pacman_xtile & 0xfe lda #$fe and.z pacman_xtile // ytiles + (pacman_xtile & 0xfe) clc adc.z __67 sta.z __67 bcc !+ inc.z __67+1 !: // logic_tile_ptr = ytiles + (pacman_xtile & 0xfe) lda.z __67 sta.z logic_tile_ptr lda.z __67+1 sta.z logic_tile_ptr+1 // pacman_ytile*2 lda.z __210 // logic_tile_yfine = pacman_ytile*2 sta.z logic_tile_yfine // ghosts_mode = FRIGHTENED // Start power-up mode lda #FRIGHTENED sta.z ghosts_mode // ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count __b50: // pacman_xfine-ghost1_xfine lda.z pacman_xfine sec sbc.z ghost1_xfine tax // pacman_yfine-ghost1_yfine lda.z pacman_yfine sec sbc.z ghost1_yfine tay // if(ABS[pacman_xfine-ghost1_xfine]<2 && ABS[pacman_yfine-ghost1_yfine]<2) // Check if anyone dies lda ABS,x cmp #2 bcs __b64 lda ABS,y cmp #2 bcs !__b51+ jmp __b51 !__b51: __b64: // pacman_xfine-ghost2_xfine lda.z pacman_xfine sec sbc.z ghost2_xfine tax // pacman_yfine-ghost2_yfine lda.z pacman_yfine sec sbc.z ghost2_yfine tay // if(ABS[pacman_xfine-ghost2_xfine]<2 && ABS[pacman_yfine-ghost2_yfine]<2) lda ABS,x cmp #2 bcs __b65 lda ABS,y cmp #2 bcc __b52 __b65: // pacman_xfine-ghost3_xfine lda.z pacman_xfine sec sbc.z ghost3_xfine tax // pacman_yfine-ghost3_yfine lda.z pacman_yfine sec sbc.z ghost3_yfine tay // if(ABS[pacman_xfine-ghost3_xfine]<2 && ABS[pacman_yfine-ghost3_yfine]<2) lda ABS,x cmp #2 bcs __b66 lda ABS,y cmp #2 bcc __b53 __b66: // pacman_xfine-ghost4_xfine lda.z pacman_xfine sec sbc.z ghost4_xfine tax // pacman_yfine-ghost4_yfine lda.z pacman_yfine sec sbc.z ghost4_yfine tay // if(ABS[pacman_xfine-ghost4_xfine]<2 && ABS[pacman_yfine-ghost4_yfine]<2) lda ABS,x cmp #2 bcc !__breturn+ jmp __breturn !__breturn: lda ABS,y cmp #2 bcc __b67 rts __b67: // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b54 // pacman_lives--; dec.z pacman_lives // spawn_all() jsr spawn_all rts __b54: // ghost4_direction = STOP lda #STOP sta.z ghost4_direction // ghost4_xfine = 50 lda #$32 sta.z ghost4_xfine // ghost4_yfine = 35 lda #$23 sta.z ghost4_yfine // ghost4_substep = 0 lda #0 sta.z ghost4_substep // ghost4_respawn = 50 lda #$32 sta.z ghost4_respawn rts __b53: // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b55 // pacman_lives--; dec.z pacman_lives // spawn_all() jsr spawn_all rts __b55: // ghost3_direction = STOP lda #STOP sta.z ghost3_direction // ghost3_xfine = 50 lda #$32 sta.z ghost3_xfine // ghost3_yfine = 35 lda #$23 sta.z ghost3_yfine // ghost3_substep = 0 lda #0 sta.z ghost3_substep // ghost3_respawn = 50 lda #$32 sta.z ghost3_respawn rts __b52: // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b56 // pacman_lives--; dec.z pacman_lives // spawn_all() jsr spawn_all rts __b56: // ghost2_direction = STOP lda #STOP sta.z ghost2_direction // ghost2_xfine = 50 lda #$32 sta.z ghost2_xfine // ghost2_yfine = 35 lda #$23 sta.z ghost2_yfine // ghost2_substep = 0 lda #0 sta.z ghost2_substep // ghost2_respawn = 50 lda #$32 sta.z ghost2_respawn rts __b51: // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b57 // pacman_lives--; dec.z pacman_lives // spawn_all() jsr spawn_all rts __b57: // ghost1_direction = STOP // ghost dies lda #STOP sta.z ghost1_direction // ghost1_xfine = 50 lda #$32 sta.z ghost1_xfine // ghost1_yfine = 35 lda #$23 sta.z ghost1_yfine // ghost1_substep = 0 lda #0 sta.z ghost1_substep // ghost1_respawn = 50 lda #$32 sta.z ghost1_respawn rts __b49: // ytiles[pacman_xtile] = EMPTY // Empty the tile lda #EMPTY ldy.z pacman_xtile sta (ytiles),y // pacman_xtile/2 tya lsr // logic_tile_xcol = pacman_xtile/2 // Ask the logic code renderer to update the tile sta.z logic_tile_xcol // pacman_xtile & 0xfe lda #$fe and.z pacman_xtile // ytiles + (pacman_xtile & 0xfe) clc adc.z __71 sta.z __71 bcc !+ inc.z __71+1 !: // logic_tile_ptr = ytiles + (pacman_xtile & 0xfe) lda.z __71 sta.z logic_tile_ptr lda.z __71+1 sta.z logic_tile_ptr+1 // pacman_ytile*2 lda.z __210 // logic_tile_yfine = pacman_ytile*2 sta.z logic_tile_yfine // if(--pill_count==0) lda.z pill_count bne !+ dec.z pill_count+1 !: dec.z pill_count lda.z pill_count ora.z pill_count+1 beq !__b50+ jmp __b50 !__b50: // pacman_wins = 1 lda #1 sta.z pacman_wins jmp __b50 __b46: // if(ghosts_mode_count>150) lda.z ghosts_mode_count cmp #$96+1 bcs !__b9+ jmp __b9 !__b9: // ghosts_mode = SCATTER lda #SCATTER sta.z ghosts_mode // ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count jmp __b8 __b45: // if(ghosts_mode_count>50) lda.z ghosts_mode_count cmp #$32+1 bcs !__b9+ jmp __b9 !__b9: // ghosts_mode = CHASE lda #CHASE sta.z ghosts_mode // ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count jmp __b8 __b6: // if(ghost4_respawn) // Ghost spawn timer lda.z ghost4_respawn beq !__b72+ jmp __b72 !__b72: // if(ghost4_direction==RIGHT) // Move in the current direction (unless he is stopped) lda #RIGHT cmp.z ghost4_direction bne !__b73+ jmp __b73 !__b73: // if(ghost4_direction==DOWN) lda #DOWN cmp.z ghost4_direction bne !__b74+ jmp __b74 !__b74: // if(ghost4_direction==LEFT) lda #LEFT cmp.z ghost4_direction bne !__b75+ jmp __b75 !__b75: // if(ghost4_direction==UP) lda #UP cmp.z ghost4_direction bne __b76 // --ghost4_yfine; dec.z ghost4_yfine __b76: // ghost4_direction!=STOP ldx.z ghost4_direction // if(ghost4_substep==0 && ghost4_direction!=STOP) lda.z ghost4_substep bne __b82 cpx #STOP bne __b77 __b82: // ghost4_substep = 0 // Ghost is on a tile lda #0 sta.z ghost4_substep // if(ghost4_reverse) lda.z ghost4_reverse bne __b78 // char ghost4_xtile = ghost4_xfine/2 // Examine open directions from the new tile to determine next action lda.z ghost4_xfine lsr sta.z ghost4_xtile // char ghost4_ytile = ghost4_yfine/2 lda.z ghost4_yfine lsr sta.z ghost4_ytile // char open_directions = level_tile_directions(ghost4_xtile, ghost4_ytile) ldx.z ghost4_xtile jsr level_tile_directions // char open_directions = level_tile_directions(ghost4_xtile, ghost4_ytile) // open_directions &= DIRECTION_ELIMINATE[ghost4_direction] // Eliminate the direction ghost came from ldy.z ghost4_direction and DIRECTION_ELIMINATE,y tay // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b79 // if(ghosts_mode==SCATTER) lda #SCATTER cmp.z ghosts_mode beq __b10 // target_xtile = pacman_xfine/2 lda.z pacman_xfine lsr tax // target_ytile = pacman_yfine/2 lda.z pacman_yfine lsr sta.z target_ytile jmp __b80 __b10: lda #2 sta.z target_ytile tax __b80: // choose_direction( open_directions, ghost4_xtile, ghost4_ytile, target_xtile, target_ytile ) sty.z choose_direction.open_directions ldy.z ghost4_xtile lda.z ghost4_ytile sta.z choose_direction.ghost_ytile jsr choose_direction // choose_direction( open_directions, ghost4_xtile, ghost4_ytile, target_xtile, target_ytile ) lda.z choose_direction.return // ghost4_direction = choose_direction( open_directions, ghost4_xtile, ghost4_ytile, target_xtile, target_ytile ) sta.z ghost4_direction rts __b79: // ghost4_direction = DIRECTION_SINGLE[open_directions] // Choose a random direction between the open directions lda DIRECTION_SINGLE,y sta.z ghost4_direction rts __b78: // ghost4_direction = DIRECTION_REVERSE[ghost4_direction] // If we are changing between scatter & chase then reverse the direction ldy.z ghost4_direction lda DIRECTION_REVERSE,y sta.z ghost4_direction // ghost4_reverse = 0 lda #0 sta.z ghost4_reverse rts __b77: // ghost4_substep = 1 // Ghost was on a tile and is moving, so he is now between tiles lda #1 sta.z ghost4_substep // if(ghost4_xfine==1) // Teleport if we are in the magic positions cmp.z ghost4_xfine beq __b81 // if(ghost4_xfine==97) lda #$61 cmp.z ghost4_xfine beq !__breturn+ jmp __breturn !__breturn: // ghost4_xfine = 1 lda #1 sta.z ghost4_xfine rts __b81: // ghost4_xfine = 97 lda #$61 sta.z ghost4_xfine rts __b75: // --ghost4_xfine; dec.z ghost4_xfine jmp __b76 __b74: // ++ghost4_yfine; inc.z ghost4_yfine jmp __b76 __b73: // ++ghost4_xfine; inc.z ghost4_xfine jmp __b76 __b72: // if(--ghost4_respawn==0) dec.z ghost4_respawn lda.z ghost4_respawn beq !__breturn+ jmp __breturn !__breturn: // ghost4_direction = RIGHT // Spawn ghost lda #RIGHT sta.z ghost4_direction // ghost4_xfine = 2 lda #2 sta.z ghost4_xfine // ghost4_yfine = 2 sta.z ghost4_yfine // ghost4_substep = 0 lda #0 sta.z ghost4_substep rts __b5: // if(ghost3_respawn) // Ghost spawn timer lda.z ghost3_respawn beq !__b89+ jmp __b89 !__b89: // if(ghost3_direction==RIGHT) // Move in the current direction (unless he is stopped) lda #RIGHT cmp.z ghost3_direction bne !__b90+ jmp __b90 !__b90: // if(ghost3_direction==DOWN) lda #DOWN cmp.z ghost3_direction bne !__b91+ jmp __b91 !__b91: // if(ghost3_direction==LEFT) lda #LEFT cmp.z ghost3_direction bne !__b92+ jmp __b92 !__b92: // if(ghost3_direction==UP) lda #UP cmp.z ghost3_direction bne __b93 // --ghost3_yfine; dec.z ghost3_yfine __b93: // ghost3_direction!=STOP ldx.z ghost3_direction // if(ghost3_substep==0 && ghost3_direction!=STOP) lda.z ghost3_substep bne __b99 cpx #STOP bne __b94 __b99: // ghost3_substep = 0 // Ghost is on a tile lda #0 sta.z ghost3_substep // if(ghost3_reverse) lda.z ghost3_reverse bne __b95 // char ghost3_xtile = ghost3_xfine/2 // Examine open directions from the new tile to determine next action lda.z ghost3_xfine lsr sta.z ghost3_xtile // char ghost3_ytile = ghost3_yfine/2 lda.z ghost3_yfine lsr sta.z ghost3_ytile // char open_directions = level_tile_directions(ghost3_xtile, ghost3_ytile) ldx.z ghost3_xtile jsr level_tile_directions // char open_directions = level_tile_directions(ghost3_xtile, ghost3_ytile) // open_directions &= DIRECTION_ELIMINATE[ghost3_direction] // Eliminate the direction ghost came from ldy.z ghost3_direction and DIRECTION_ELIMINATE,y tay // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b96 // if(ghosts_mode==SCATTER) lda #SCATTER cmp.z ghosts_mode beq __b11 // target_xtile = pacman_xfine/2 lda.z pacman_xfine lsr tax // target_ytile = pacman_yfine/2 lda.z pacman_yfine lsr sta.z target_ytile1 jmp __b97 __b11: lda #2 sta.z target_ytile1 tax __b97: // choose_direction( open_directions, ghost3_xtile, ghost3_ytile, target_xtile, target_ytile ) sty.z choose_direction.open_directions ldy.z ghost3_xtile lda.z ghost3_ytile sta.z choose_direction.ghost_ytile jsr choose_direction // choose_direction( open_directions, ghost3_xtile, ghost3_ytile, target_xtile, target_ytile ) lda.z choose_direction.return // ghost3_direction = choose_direction( open_directions, ghost3_xtile, ghost3_ytile, target_xtile, target_ytile ) sta.z ghost3_direction rts __b96: // ghost3_direction = DIRECTION_SINGLE[open_directions] // Choose a random direction between the open directions lda DIRECTION_SINGLE,y sta.z ghost3_direction rts __b95: // ghost3_direction = DIRECTION_REVERSE[ghost3_direction] // If we are changing between scatter & chase then reverse the direction ldy.z ghost3_direction lda DIRECTION_REVERSE,y sta.z ghost3_direction // ghost3_reverse = 0 lda #0 sta.z ghost3_reverse rts __b94: // ghost3_substep = 1 // Ghost was on a tile and is moving, so he is now between tiles lda #1 sta.z ghost3_substep // if(ghost3_xfine==1) // Teleport if we are in the magic positions cmp.z ghost3_xfine beq __b98 // if(ghost3_xfine==97) lda #$61 cmp.z ghost3_xfine beq !__breturn+ jmp __breturn !__breturn: // ghost3_xfine = 1 lda #1 sta.z ghost3_xfine rts __b98: // ghost3_xfine = 97 lda #$61 sta.z ghost3_xfine rts __b92: // --ghost3_xfine; dec.z ghost3_xfine jmp __b93 __b91: // ++ghost3_yfine; inc.z ghost3_yfine jmp __b93 __b90: // ++ghost3_xfine; inc.z ghost3_xfine jmp __b93 __b89: // if(--ghost3_respawn==0) dec.z ghost3_respawn lda.z ghost3_respawn beq !__breturn+ jmp __breturn !__breturn: // ghost3_direction = UP // Spawn ghost lda #UP sta.z ghost3_direction // ghost3_xfine = 2 lda #2 sta.z ghost3_xfine // ghost3_yfine = 70 lda #$46 sta.z ghost3_yfine // ghost3_substep = 0 lda #0 sta.z ghost3_substep rts __b4: // if(ghost2_respawn) // Ghost spawn timer lda.z ghost2_respawn beq !__b106+ jmp __b106 !__b106: // if(ghost2_direction==RIGHT) // Move in the current direction (unless he is stopped) lda #RIGHT cmp.z ghost2_direction bne !__b107+ jmp __b107 !__b107: // if(ghost2_direction==DOWN) lda #DOWN cmp.z ghost2_direction bne !__b108+ jmp __b108 !__b108: // if(ghost2_direction==LEFT) lda #LEFT cmp.z ghost2_direction bne !__b109+ jmp __b109 !__b109: // if(ghost2_direction==UP) lda #UP cmp.z ghost2_direction bne __b110 // --ghost2_yfine; dec.z ghost2_yfine __b110: // ghost2_direction!=STOP ldx.z ghost2_direction // if(ghost2_substep==0 && ghost2_direction!=STOP) lda.z ghost2_substep bne __b116 cpx #STOP bne __b111 __b116: // ghost2_substep = 0 // Ghost is on a tile lda #0 sta.z ghost2_substep // if(ghost2_reverse) lda.z ghost2_reverse bne __b112 // char ghost2_xtile = ghost2_xfine/2 // Examine open directions from the new tile to determine next action lda.z ghost2_xfine lsr sta.z ghost2_xtile // char ghost2_ytile = ghost2_yfine/2 lda.z ghost2_yfine lsr sta.z ghost2_ytile // char open_directions = level_tile_directions(ghost2_xtile, ghost2_ytile) ldx.z ghost2_xtile jsr level_tile_directions // char open_directions = level_tile_directions(ghost2_xtile, ghost2_ytile) // open_directions &= DIRECTION_ELIMINATE[ghost2_direction] // Eliminate the direction ghost came from ldy.z ghost2_direction and DIRECTION_ELIMINATE,y tay // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b113 // if(ghosts_mode==SCATTER) lda #SCATTER cmp.z ghosts_mode beq __b12 // target_xtile = pacman_xfine/2 lda.z pacman_xfine lsr tax // target_ytile = pacman_yfine/2 lda.z pacman_yfine lsr sta.z target_ytile2 jmp __b114 __b12: lda #2 sta.z target_ytile2 tax __b114: // choose_direction( open_directions, ghost2_xtile, ghost2_ytile, target_xtile, target_ytile ) sty.z choose_direction.open_directions ldy.z ghost2_xtile lda.z ghost2_ytile sta.z choose_direction.ghost_ytile jsr choose_direction // choose_direction( open_directions, ghost2_xtile, ghost2_ytile, target_xtile, target_ytile ) lda.z choose_direction.return // ghost2_direction = choose_direction( open_directions, ghost2_xtile, ghost2_ytile, target_xtile, target_ytile ) sta.z ghost2_direction rts __b113: // ghost2_direction = DIRECTION_SINGLE[open_directions] // Choose a random direction between the open directions lda DIRECTION_SINGLE,y sta.z ghost2_direction rts __b112: // ghost2_direction = DIRECTION_REVERSE[ghost2_direction] // If we are changing between scatter & chase then reverse the direction ldy.z ghost2_direction lda DIRECTION_REVERSE,y sta.z ghost2_direction // ghost2_reverse = 0 lda #0 sta.z ghost2_reverse rts __b111: // ghost2_substep = 1 // Ghost was on a tile and is moving, so he is now between tiles lda #1 sta.z ghost2_substep // if(ghost2_xfine==1) // Teleport if we are in the magic positions cmp.z ghost2_xfine beq __b115 // if(ghost2_xfine==97) lda #$61 cmp.z ghost2_xfine beq !__breturn+ jmp __breturn !__breturn: // ghost2_xfine = 1 lda #1 sta.z ghost2_xfine rts __b115: // ghost2_xfine = 97 lda #$61 sta.z ghost2_xfine rts __b109: // --ghost2_xfine; dec.z ghost2_xfine jmp __b110 __b108: // ++ghost2_yfine; inc.z ghost2_yfine jmp __b110 __b107: // ++ghost2_xfine; inc.z ghost2_xfine jmp __b110 __b106: // if(--ghost2_respawn==0) dec.z ghost2_respawn lda.z ghost2_respawn beq !__breturn+ jmp __breturn !__breturn: // ghost2_direction = LEFT // Spawn ghost lda #LEFT sta.z ghost2_direction // ghost2_xfine = 96 lda #$60 sta.z ghost2_xfine // ghost2_yfine = 70 lda #$46 sta.z ghost2_yfine // ghost2_substep = 0 lda #0 sta.z ghost2_substep rts __b3: // if(ghost1_respawn) // Ghost spawn timer lda.z ghost1_respawn beq !__b123+ jmp __b123 !__b123: // if(ghost1_direction==RIGHT) // Ghost 1 animation // Move in the current direction (unless he is stopped) lda #RIGHT cmp.z ghost1_direction bne !__b124+ jmp __b124 !__b124: // if(ghost1_direction==DOWN) lda #DOWN cmp.z ghost1_direction bne !__b125+ jmp __b125 !__b125: // if(ghost1_direction==LEFT) lda #LEFT cmp.z ghost1_direction bne !__b126+ jmp __b126 !__b126: // if(ghost1_direction==UP) lda #UP cmp.z ghost1_direction bne __b127 // --ghost1_yfine; dec.z ghost1_yfine __b127: // ghost1_direction!=STOP ldx.z ghost1_direction // if(ghost1_substep==0 && ghost1_direction!=STOP) lda.z ghost1_substep bne __b133 cpx #STOP bne __b128 __b133: // ghost1_substep = 0 // Ghost is on a tile lda #0 sta.z ghost1_substep // if(ghost1_reverse) lda.z ghost1_reverse bne __b129 // char ghost1_xtile = ghost1_xfine/2 // Examine open directions from the new tile to determine next action lda.z ghost1_xfine lsr sta.z ghost1_xtile // char ghost1_ytile = ghost1_yfine/2 lda.z ghost1_yfine lsr sta.z ghost1_ytile // char open_directions = level_tile_directions(ghost1_xtile, ghost1_ytile) ldx.z ghost1_xtile jsr level_tile_directions // char open_directions = level_tile_directions(ghost1_xtile, ghost1_ytile) // open_directions &= DIRECTION_ELIMINATE[ghost1_direction] // Eliminate the direction ghost came from ldy.z ghost1_direction and DIRECTION_ELIMINATE,y tay // if(ghosts_mode==FRIGHTENED) lda #FRIGHTENED cmp.z ghosts_mode beq __b130 // if(ghosts_mode==SCATTER) lda #SCATTER cmp.z ghosts_mode beq __b13 // target_xtile = pacman_xfine/2 lda.z pacman_xfine lsr tax // target_ytile = pacman_yfine/2 lda.z pacman_yfine lsr sta.z target_ytile3 jmp __b131 __b13: lda #2 sta.z target_ytile3 tax __b131: // choose_direction( open_directions, ghost1_xtile, ghost1_ytile, target_xtile, target_ytile ) sty.z choose_direction.open_directions ldy.z ghost1_xtile lda.z ghost1_ytile sta.z choose_direction.ghost_ytile jsr choose_direction // choose_direction( open_directions, ghost1_xtile, ghost1_ytile, target_xtile, target_ytile ) lda.z choose_direction.return // ghost1_direction = choose_direction( open_directions, ghost1_xtile, ghost1_ytile, target_xtile, target_ytile ) sta.z ghost1_direction rts __b130: // ghost1_direction = DIRECTION_SINGLE[open_directions] // Choose a random direction between the open directions lda DIRECTION_SINGLE,y sta.z ghost1_direction rts __b129: // ghost1_direction = DIRECTION_REVERSE[ghost1_direction] // If we are changing between scatter & chase then reverse the direction ldy.z ghost1_direction lda DIRECTION_REVERSE,y sta.z ghost1_direction // ghost1_reverse = 0 lda #0 sta.z ghost1_reverse rts __b128: // ghost1_substep = 1 // Ghost was on a tile and is moving, so he is now between tiles lda #1 sta.z ghost1_substep // if(ghost1_xfine==1) // Teleport if we are in the magic positions cmp.z ghost1_xfine beq __b132 // if(ghost1_xfine==97) lda #$61 cmp.z ghost1_xfine beq !__breturn+ jmp __breturn !__breturn: // ghost1_xfine = 1 lda #1 sta.z ghost1_xfine rts __b132: // ghost1_xfine = 97 lda #$61 sta.z ghost1_xfine rts __b126: // --ghost1_xfine; dec.z ghost1_xfine jmp __b127 __b125: // ++ghost1_yfine; inc.z ghost1_yfine jmp __b127 __b124: // ++ghost1_xfine; inc.z ghost1_xfine jmp __b127 __b123: // if(--ghost1_respawn==0) dec.z ghost1_respawn lda.z ghost1_respawn beq !__breturn+ jmp __breturn !__breturn: // ghost1_direction = DOWN // Spawn ghost 1 lda #DOWN sta.z ghost1_direction // ghost1_xfine = 96 lda #$60 sta.z ghost1_xfine // ghost1_yfine = 2 lda #2 sta.z ghost1_yfine // ghost1_substep = 0 lda #0 sta.z ghost1_substep rts __b2: // if(pacman_direction==RIGHT) // Animate pacman // Move pacman in the current direction (unless he is stopped) lda #RIGHT cmp.z pacman_direction beq __b140 // if(pacman_direction==DOWN) lda #DOWN cmp.z pacman_direction beq __b141 // if(pacman_direction==LEFT) lda #LEFT cmp.z pacman_direction beq __b142 // if(pacman_direction==UP) lda #UP cmp.z pacman_direction bne __b143 // --pacman_yfine; dec.z pacman_yfine __b143: // pacman_direction!=STOP ldx.z pacman_direction // if(pacman_substep==0 && pacman_direction!=STOP) lda.z pacman_substep bne __b147 cpx #STOP bne __b144 __b147: // pacman_substep = 0 // Pacman is on a (new) tile lda #0 sta.z pacman_substep // char pacman_xtile = pacman_xfine/2 // Examine open directions from the new tile to determine next action lda.z pacman_xfine lsr tax // char pacman_ytile = pacman_yfine/2 lda.z pacman_yfine lsr // char open_directions = level_tile_directions(pacman_xtile, pacman_ytile) jsr level_tile_directions // char open_directions = level_tile_directions(pacman_xtile, pacman_ytile) tax // CIA1->PORT_A & 0x0f lda #$f and CIA1 // (CIA1->PORT_A & 0x0f)^0x0f eor #$f // char joy_directions = ((CIA1->PORT_A & 0x0f)^0x0f)*4 // Read joystick#2 - arrange bits to match DIRECTION asl asl // if(joy_directions!=0) cmp #0 beq __b145 // joy_directions&open_directions stx.z $ff and.z $ff // char new_direction = DIRECTION_SINGLE[joy_directions&open_directions] tay lda DIRECTION_SINGLE,y // if(new_direction!=0) cmp #0 beq __b145 // pacman_direction = new_direction sta.z pacman_direction __b145: // pacman_direction &= open_directions // Stop pacman if the current direction is no longer open lda.z pacman_direction sax.z pacman_direction rts __b144: // pacman_substep = 1 // Pacman was on a tile and is moving, so he is now between tiles lda #1 sta.z pacman_substep // pacman_ch1_enabled = 1 // Enable the eating sound whenever pacman is moving sta.z pacman_ch1_enabled // if(pacman_xfine==1) // Teleport if we are in the magic positions cmp.z pacman_xfine beq __b146 // if(pacman_xfine==97) lda #$61 cmp.z pacman_xfine beq !__breturn+ jmp __breturn !__breturn: // pacman_xfine = 1 lda #1 sta.z pacman_xfine rts __b146: // pacman_xfine = 97 lda #$61 sta.z pacman_xfine rts __b142: // --pacman_xfine; dec.z pacman_xfine jmp __b143 __b141: // ++pacman_yfine; inc.z pacman_yfine jmp __b143 __b140: // ++pacman_xfine; inc.z pacman_xfine jmp __b143 } pacman_sound_play: { // if(pacman_ch1_enabled) lda.z pacman_ch1_enabled beq __breturn // *SID_CH1_FREQ_HI = PACMAN_CH1_FREQ_HI[pacman_ch1_idx] // Play the entire sound - and then reset and disable it ldy.z pacman_ch1_idx lda PACMAN_CH1_FREQ_HI,y sta SID_CH1_FREQ_HI // SID->CH1_CONTROL = PACMAN_CH1_CONTROL[pacman_ch1_idx] lda PACMAN_CH1_CONTROL,y sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_CONTROL // if(++pacman_ch1_idx==sizeof(PACMAN_CH1_FREQ_HI)) inc.z pacman_ch1_idx lda #$16*SIZEOF_CHAR cmp.z pacman_ch1_idx bne __breturn // pacman_ch1_idx = 0 lda #0 sta.z pacman_ch1_idx // pacman_ch1_enabled = 0 sta.z pacman_ch1_enabled __breturn: // } rts } // Initializes all data for the splash and shows the splash. // Returns when the splash is complete and the user clicks the joystidk #2 button splash_run: { .const toDd001_return = 3^(>SCREENS_1)/$40 .const toD0181_return = 0 .label xpos = 5 .label i = $14 // asm sei // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR // Disable CIA 1 Timer IRQ lda #CIA_INTERRUPT_CLEAR sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT // *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK // Disable kernal & basic & IO lda #PROCPORT_DDR_MEMORY_MASK sta.z PROCPORT_DDR // *PROCPORT = PROCPORT_RAM_ALL lda #PROCPORT_RAM_ALL sta.z PROCPORT // memset((char*)0x4000, 0, 0xc00) // Reset memory to avoid crashes lda #<$4000 sta.z memset.str lda #>$4000 sta.z memset.str+1 lda #<$c00 sta.z memset.num lda #>$c00 sta.z memset.num+1 jsr memset // byteboozer_decrunch(RASTER_CODE_CRUNCHED) lda #<RASTER_CODE_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>RASTER_CODE_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // Decrunch raster code jsr byteboozer_decrunch // byteboozer_decrunch(LOGIC_CODE_CRUNCHED) lda #<LOGIC_CODE_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>LOGIC_CODE_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // Decrunch logic code jsr byteboozer_decrunch // merge_code(RASTER_CODE, RASTER_CODE_UNMERGED, LOGIC_CODE_UNMERGED) // Merge the raster with the logic-code jsr merge_code // memset(BANK_1+0x2000, 0x00, 0x1fff) // Clear the graphics banks lda #<BANK_1+$2000 sta.z memset.str lda #>BANK_1+$2000 sta.z memset.str+1 lda #<$1fff sta.z memset.num lda #>$1fff sta.z memset.num+1 jsr memset // memset(BANK_2, 0x00, 0x3fff) lda #<BANK_2 sta.z memset.str lda #>BANK_2 sta.z memset.str+1 lda #<$3fff sta.z memset.num lda #>$3fff sta.z memset.num+1 jsr memset // init_render_index() // Initialize the renderer tables jsr init_render_index // byteboozer_decrunch(SPLASH_CRUNCHED) lda #<SPLASH_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>SPLASH_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // decrunch splash screen jsr byteboozer_decrunch // splash_show() // Show the splash screen jsr splash_show // memset(BANK_1, 0x00, 0x1fff) // Clear the graphics bank lda #<BANK_1 sta.z memset.str lda #>BANK_1 sta.z memset.str+1 lda #<$1fff sta.z memset.num lda #>$1fff sta.z memset.num+1 jsr memset // init_bobs_restore() // Initialize bobs_restore to "safe" values jsr init_bobs_restore // byteboozer_decrunch(BOB_GRAPHICS_CRUNCHED) lda #<BOB_GRAPHICS_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>BOB_GRAPHICS_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // decrunch bobs graphics tables jsr byteboozer_decrunch // init_sprite_pointers() // Set sprite pointers on all screens (in both graphics banks) jsr init_sprite_pointers // memcpy(INTRO_MUSIC_CRUNCHED_UPPER, INTRO_MUSIC_CRUNCHED, INTRO_MUSIC_CRUNCHED_SIZE) // Move the crunched music to upper memory before decrunching it jsr memcpy // byteboozer_decrunch(INTRO_MUSIC_CRUNCHED_UPPER) lda #<INTRO_MUSIC_CRUNCHED_UPPER sta.z byteboozer_decrunch.crunched lda #>INTRO_MUSIC_CRUNCHED_UPPER sta.z byteboozer_decrunch.crunched+1 // zero-fill the entire Init segment //memset(LEVEL_TILES_CRUNCHED, 0, INTRO_MUSIC_CRUNCHED+INTRO_MUSIC_CRUNCHED_SIZE-LEVEL_TILES_CRUNCHED); // decrunch intro music jsr byteboozer_decrunch // memset(INTRO_MUSIC_CRUNCHED_UPPER, 0, INTRO_MUSIC_CRUNCHED_SIZE) // Zero-fill the upper memory lda #<INTRO_MUSIC_CRUNCHED_UPPER sta.z memset.str lda #>INTRO_MUSIC_CRUNCHED_UPPER sta.z memset.str+1 lda #<INTRO_MUSIC_CRUNCHED_SIZE sta.z memset.num lda #>INTRO_MUSIC_CRUNCHED_SIZE sta.z memset.num+1 jsr memset // *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK // Disable kernal & basic - enable IO lda #PROCPORT_DDR_MEMORY_MASK sta.z PROCPORT_DDR // *PROCPORT = PROCPORT_RAM_IO lda #PROCPORT_RAM_IO sta.z PROCPORT ldx #0 txa sta.z i __b2: // for(char i=0;i<8;i++) lda.z i cmp #8 bcs !__b3+ jmp __b3 !__b3: // CIA2->PORT_A = toDd00(SCREENS_1) // Set initial graphics bank lda #toDd001_return sta CIA2 // canvas_base_hi = BYTE1(SPRITES_2) // Set initial render/restore buffer lda #>SPRITES_2 sta.z canvas_base_hi // bobs_restore_base = NUM_BOBS*SIZE_BOB_RESTORE lda #NUM_BOBS*SIZE_BOB_RESTORE sta.z bobs_restore_base // VICII->MEMORY = toD018(SCREENS_1, SCREENS_1) // Select first screen lda #toD0181_return sta VICII+OFFSET_STRUCT_MOS6569_VICII_MEMORY // VICII->SPRITES_XMSB = msb stx VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_XMSB // VICII->SPRITES_ENABLE = 0xff lda #$ff sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE // VICII->SPRITES_EXPAND_X = 0xff sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_EXPAND_X // VICII->BORDER_COLOR = BLACK lda #BLACK sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR // VICII->BG_COLOR = BLACK sta VICII+OFFSET_STRUCT_MOS6569_VICII_BG_COLOR // VICII->SPRITES_MCOLOR1 = BLUE lda #BLUE sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR1 // VICII->SPRITES_MCOLOR2 = RED lda #RED sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR2 // top_sprites_mc = 0x03 // On the splash screen sprites all sprites are SC - except sprite #0,1 on the top/bottom of the screen lda #3 sta.z top_sprites_mc // side_sprites_mc = 0x00 lda #0 sta.z side_sprites_mc // bottom_sprites_mc = 0x03 lda #3 sta.z bottom_sprites_mc // top_sprites_color = YELLOW // On the splash top/bottom sc-sprites are yellow and side-sprites are blue lda #YELLOW sta.z top_sprites_color // side_sprites_color = BLUE lda #BLUE sta.z side_sprites_color // bottom_sprites_color = YELLOW lda #YELLOW sta.z bottom_sprites_color // VICII->SPRITES_MC = top_sprites_mc // Set the initial top colors/MC lda.z top_sprites_mc sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MC ldx #0 // Set initial Sprite Color __b6: // for(char i=0;i<8;i++) cpx #8 bcc __b7 // VICII->CONTROL2 = 0x08 // Set VICII CONTROL2 ($d016) to 8 to allow ASL, LSR to be used for opening the border lda #8 sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL2 ldx #0 // Move the bobs to the center to avoid interference while rendering the level __b9: // for(char i=0;i<4;i++) cpx #4 bcc __b10 // asm // Disable SID CH#3 lda #1 sta INTRO_MUSIC+$69 // Init music lda #0 // (*musicInit)() jsr musicInit // phase = 0 // Set phase to intro lda #0 sta.z phase // VICII->CONTROL1 = VICII_RSEL|VICII_DEN|VICII_ECM|VICII_BMM // Start a hyperscreen with no badlines and open borders // Set screen height to 25 lines (preparing for the hyperscreen), enable display // Set an illegal mode to prevent any character graphics lda #VICII_RSEL|VICII_DEN|VICII_ECM|VICII_BMM sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 // Wait for line 0xfa (lower border) __b12: // while(VICII->RASTER!=0xfa) lda #$fa cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER bne __b12 // VICII->CONTROL1 &= ~(VICII_RST8|VICII_RSEL|VICII_DEN) // Open lower/upper border using RSEL - and disable all graphics (except sprites) // Set up RASTER IRQ to start at irq_screen_top() (RST8=0) lda #(VICII_RST8|VICII_RSEL|VICII_DEN)^$ff and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 // VICII->RASTER = IRQ_SCREEN_TOP_LINE lda #IRQ_SCREEN_TOP_LINE sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER // *HARDWARE_IRQ = &irq_screen_top lda #<irq_screen_top sta HARDWARE_IRQ lda #>irq_screen_top sta HARDWARE_IRQ+1 // VICII->IRQ_ENABLE = IRQ_RASTER // Enable Raster Interrupt lda #IRQ_RASTER sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE // asm // Acknowledge any timer IRQ lda CIA1_INTERRUPT // *IRQ_STATUS = 0x0f // Acknowledge any VIC IRQ lda #$f sta IRQ_STATUS // asm cli // joyinit() // Prepare for joystick control jsr joyinit // music_play_next = 0 // Wait for fire lda #0 sta.z music_play_next __b14: // joyfire() jsr joyfire // while(!joyfire()) cmp #0 beq __b15 // } rts __b15: // if(music_play_next) lda.z music_play_next beq __b14 // (*musicPlay)() //VICII->BG_COLOR=1; jsr musicPlay // music_play_next = 0 //VICII->BG_COLOR=0; lda #0 sta.z music_play_next jmp __b14 __b10: // bobs_xcol[i] = 10 lda #$a sta bobs_xcol,x // bobs_yfine[i] = 45 lda #$2d sta bobs_yfine,x // bobs_bob_id[i] = 0 lda #0 sta bobs_bob_id,x // for(char i=0;i<4;i++) inx jmp __b9 __b7: // SPRITES_COLOR[i] = top_sprites_color lda.z top_sprites_color sta SPRITES_COLOR,x // for(char i=0;i<8;i++) inx jmp __b6 __b3: // i*2 lda.z i asl tay // SPRITES_YPOS[i*2] = 7 lda #7 sta SPRITES_YPOS,y // unsigned int xpos = sprites_xpos[i] lda sprites_xpos,y sta.z xpos lda sprites_xpos+1,y sta.z xpos+1 // SPRITES_XPOS[i*2] = (char)xpos lda.z xpos sta SPRITES_XPOS,y // msb /= 2 txa lsr tax // BYTE1(xpos) lda.z xpos+1 // if(BYTE1(xpos)) cmp #0 beq __b4 // msb |=0x80 txa ora #$80 tax __b4: // for(char i=0;i<8;i++) inc.z i jmp __b2 .segment Data // Sprite positions sprites_xpos: .word $1e7, $13f, $10f, $df, $af, $7f, $4f, $1f } .segment Code // Initialize all data for gameplay and runs the game. // Exits when the user has won or lost gameplay_run: { .label __4 = 9 // asm sei ldx #0 // Stop any sound __b1: // for(char i=0;i<0x2f;i++) cpx #$2f bcs !__b2+ jmp __b2 !__b2: // pacman_wins = 0 // Pacman has not won yet lda #0 sta.z pacman_wins // pacman_lives = 3 // Pacman has 3 lives lda #3 sta.z pacman_lives // VICII->SPRITES_MCOLOR1 = BLACK // During transition all sprites are black lda #BLACK sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR1 // VICII->SPRITES_MCOLOR2 = BLACK sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR2 ldx #0 __b4: // for(char i=0;i<8;i++) cpx #8 bcs !__b5+ jmp __b5 !__b5: // byteboozer_decrunch(LEVEL_TILES_CRUNCHED) lda #<LEVEL_TILES_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>LEVEL_TILES_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // decrunch level tiles jsr byteboozer_decrunch // init_level_tile_directions() // Initialize tile directions jsr init_level_tile_directions // init_sprite_pointers() // Set sprite pointers on all screens (in both graphics banks) jsr init_sprite_pointers // level_show() jsr level_show // level_show() // pill_count = level_show() // Show the level lda.z __4 sta.z pill_count lda.z __4+1 sta.z pill_count+1 // top_sprites_mc = 0xff // During gameplay all sprites are MC. lda #$ff sta.z top_sprites_mc // side_sprites_mc = 0xff sta.z side_sprites_mc // bottom_sprites_mc = 0xff sta.z bottom_sprites_mc // top_sprites_color = YELLOW // During gameplay all sprites are yellow lda #YELLOW sta.z top_sprites_color // side_sprites_color = YELLOW sta.z side_sprites_color // bottom_sprites_color = YELLOW sta.z bottom_sprites_color // VICII->SPRITES_MC = top_sprites_mc // Set the initial top colors/MC lda.z top_sprites_mc sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MC ldx #0 // Set initial Sprite Color __b7: // for(char i=0;i<8;i++) cpx #8 bcc __b8 // VICII->SPRITES_MCOLOR1 = BLUE // Set sprite MC-colors for the game lda #BLUE sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR1 // VICII->SPRITES_MCOLOR2 = RED lda #RED sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_MCOLOR2 // phase = 1 // Set phase to game lda #1 sta.z phase // spawn_all() // Spawn pacman and all ghosts jsr spawn_all // pacman_sound_init() // Initialize the game sound jsr pacman_sound_init // game_playable = 1 // Start the game play lda #1 sta.z game_playable // VICII->CONTROL1 = VICII_RSEL|VICII_DEN|VICII_ECM|VICII_BMM // Turn on raster after transition // Start a hyperscreen with no badlines and open borders // Set screen height to 25 lines (preparing for the hyperscreen), enable display lda #VICII_RSEL|VICII_DEN|VICII_ECM|VICII_BMM sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 // Wait at least one frames for DEN to take effect __b10: // while(VICII->RASTER!=0xfb) lda #$fb cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER bne __b10 __b11: // while(VICII->RASTER!=0xfa) lda #$fa cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER bne __b11 // VICII->CONTROL1 &= ~(VICII_RST8|VICII_RSEL|VICII_DEN) // Open lower/upper border using RSEL - and disable all graphics (except sprites) // Set up RASTER IRQ to start at irq_screen_top() (RST8=0) lda #(VICII_RST8|VICII_RSEL|VICII_DEN)^$ff and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 // VICII->RASTER = IRQ_SCREEN_TOP_LINE lda #IRQ_SCREEN_TOP_LINE sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER // *HARDWARE_IRQ = &irq_screen_top lda #<irq_screen_top sta HARDWARE_IRQ lda #>irq_screen_top sta HARDWARE_IRQ+1 // VICII->IRQ_ENABLE = IRQ_RASTER // Enable Raster Interrupt lda #IRQ_RASTER sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE // asm // Acknowledge any timer IRQ lda CIA1_INTERRUPT // *IRQ_STATUS = 0x0f // Acknowledge any VIC IRQ lda #$f sta IRQ_STATUS // asm cli __b13: // if(pacman_wins || pacman_lives==0) lda.z pacman_wins bne __breturn lda.z pacman_lives beq __breturn jmp __b13 __breturn: // } rts __b8: // SPRITES_COLOR[i] = top_sprites_color lda.z top_sprites_color sta SPRITES_COLOR,x // for(char i=0;i<8;i++) inx jmp __b7 __b5: // SPRITES_COLOR[i] = BLACK lda #BLACK sta SPRITES_COLOR,x // for(char i=0;i<8;i++) inx jmp __b4 __b2: // ((char*)SID)[i] = 0 lda #0 sta SID,x // for(char i=0;i<0x2f;i++) inx jmp __b1 } // Show Victory or Game Over Image // Returns when the user clicks the joystick button done_run: { // Show the win graphics .label gfx = 5 .label ypos = $10 .label xcol = $14 // game_playable = 0 // Stop the game play lda #0 sta.z game_playable // phase = 0 // Set phase to intro sta.z phase tax // Stop any sound __b4: // for(char i=0;i<0x2f;i++) cpx #$2f bcs !__b5+ jmp __b5 !__b5: ldx #0 // Move the bobs to the center to avoid interference while rendering the level __b6: // for(char i=0;i<4;i++) cpx #4 bcc __b7 // asm // Init music lda #0 // (*musicInit)() jsr musicInit // if(pacman_wins) lda.z pacman_wins bne __b2 // byteboozer_decrunch(GAMEOVER_GFX_CRUNCHED) lda #<GAMEOVER_GFX_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>GAMEOVER_GFX_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // decrunch game over graphics jsr byteboozer_decrunch __b1: lda #<WIN_GFX sta.z gfx lda #>WIN_GFX sta.z gfx+1 lda #0 sta.z xcol __b9: // for(char xcol=0;xcol<25;xcol++) lda.z xcol cmp #$19 bcc __b3 // music_play_next = 0 // Wait for fire lda #0 sta.z music_play_next __b14: // joyfire() jsr joyfire // while(!joyfire()) cmp #0 beq __b15 // } rts __b15: // if(music_play_next) lda.z music_play_next beq __b14 // (*musicPlay)() //VICII->BG_COLOR=1; jsr musicPlay // music_play_next = 0 //VICII->BG_COLOR=0; lda #0 sta.z music_play_next jmp __b14 __b3: lda #0 sta.z ypos __b11: // for(char ypos=0;ypos<25;ypos++) lda.z ypos cmp #$19 bcc __b12 // for(char xcol=0;xcol<25;xcol++) inc.z xcol jmp __b9 __b12: // char pixels = *gfx++ // Render 8px x 1px ldy #0 lda (gfx),y tax inc.z gfx bne !+ inc.z gfx+1 !: // render(xcol, ypos, pixels) stx.z render.pixels jsr render // for(char ypos=0;ypos<25;ypos++) inc.z ypos jmp __b11 __b2: // byteboozer_decrunch(WIN_GFX_CRUNCHED) lda #<WIN_GFX_CRUNCHED sta.z byteboozer_decrunch.crunched lda #>WIN_GFX_CRUNCHED sta.z byteboozer_decrunch.crunched+1 // decrunch win graphics jsr byteboozer_decrunch jmp __b1 __b7: // bobs_xcol[i] = 10 lda #$a sta bobs_xcol,x // bobs_yfine[i] = 45 lda #$2d sta bobs_yfine,x // bobs_bob_id[i] = 0 lda #0 sta bobs_bob_id,x // for(char i=0;i<4;i++) inx jmp __b6 __b5: // ((char*)SID)[i] = 0 lda #0 sta SID,x // for(char i=0;i<0x2f;i++) inx jmp __b4 } // Spawn pacman and all ghosts spawn_all: { // ghosts_mode_count = 0 lda #0 sta.z ghosts_mode_count // pacman_substep = 0 sta.z pacman_substep // ghost1_substep = 0 sta.z ghost1_substep // ghost2_substep = 0 sta.z ghost2_substep // ghost3_substep = 0 sta.z ghost3_substep // ghost4_substep = 0 sta.z ghost4_substep // pacman_direction = STOP lda #STOP sta.z pacman_direction // ghost1_direction = STOP sta.z ghost1_direction // ghost2_direction = STOP sta.z ghost2_direction // ghost3_direction = STOP sta.z ghost3_direction // ghost4_direction = STOP sta.z ghost4_direction // pacman_xfine = 50 lda #$32 sta.z pacman_xfine // ghost1_xfine = 50 sta.z ghost1_xfine // ghost2_xfine = 50 sta.z ghost2_xfine // ghost3_xfine = 50 sta.z ghost3_xfine // ghost4_xfine = 50 sta.z ghost4_xfine // ghost1_yfine = 35 lda #$23 sta.z ghost1_yfine // ghost2_yfine = 35 sta.z ghost2_yfine // ghost3_yfine = 35 sta.z ghost3_yfine // ghost4_yfine = 35 sta.z ghost4_yfine // pacman_yfine = 62 lda #$3e sta.z pacman_yfine // ghost1_respawn = 10 lda #$a sta.z ghost1_respawn // ghost2_respawn = 20 lda #$14 sta.z ghost2_respawn // ghost3_respawn = 30 lda #$1e sta.z ghost3_respawn // ghost4_respawn = 40 lda #$28 sta.z ghost4_respawn // } rts } // Get the open directions at a given (xtile, ytile) position // Returns the open DIRECTIONs as bits // If xtile of ytile is outside the legal range the empty tile (0) is returned // __register(A) char level_tile_directions(__register(X) char xtile, __register(A) char ytile) level_tile_directions: { .label ytiles = $31 // if(xtile>49 || ytile>36) cpx #$31+1 bcs __b1 cmp #$24+1 bcs __b1 // char* ytiles = LEVEL_TILES_DIRECTIONS + LEVEL_YTILE_OFFSET[ytile] asl tay clc lda #<LEVEL_TILES_DIRECTIONS adc LEVEL_YTILE_OFFSET,y sta.z ytiles lda #>LEVEL_TILES_DIRECTIONS adc LEVEL_YTILE_OFFSET+1,y sta.z ytiles+1 // return ytiles[xtile]; txa tay lda (ytiles),y rts __b1: lda #0 // } rts } // Choose the open direction that brings the ghost closest to the target // Uses Manhattan distance calculation // __zp($33) char choose_direction(__zp($4a) char open_directions, __register(Y) char ghost_xtile, __zp($37) char ghost_ytile, __register(X) char target_xtile, __zp($27) char target_ytile) choose_direction: { .label open_directions = $4a .label ghost_ytile = $37 .label target_ytile = $27 .label xdiff = $4c .label ydiff = $4b .label dist_left = $22 .label return = $33 .label direction = $33 .label dist_min = $22 // char xdiff = ghost_xtile-target_xtile tya stx.z $ff sec sbc.z $ff sta.z xdiff // char ydiff = ghost_ytile-target_ytile lda.z ghost_ytile sec sbc.z target_ytile sta.z ydiff // open_directions&UP lda #UP and.z open_directions // if(open_directions&UP) cmp #0 beq __b5 // char dist_up = ABS[xdiff] + ABS[ydiff-1] ldy.z xdiff lda ABS,y ldy.z ydiff clc adc ABS+-1,y tay // if(dist_up<dist_min) cpy #$ff bcs __b5 lda #UP sta.z direction jmp __b1 __b5: lda #STOP sta.z direction ldy #$ff __b1: // open_directions&DOWN lda #DOWN and.z open_directions // if(open_directions&DOWN) cmp #0 beq __b10 // char dist_down = ABS[xdiff] + ABS[ydiff+1] ldx.z xdiff lda ABS,x ldx.z ydiff clc adc ABS+1,x tax // if(dist_down<dist_min) sty.z $ff cpx.z $ff bcs __b11 lda #DOWN sta.z direction jmp __b2 __b11: tya tax __b2: // open_directions&LEFT lda #LEFT and.z open_directions // if(open_directions&LEFT) cmp #0 beq __b12 // char dist_left = ABS[xdiff-1] + ABS[ydiff] ldy.z xdiff lda ABS+-1,y ldy.z ydiff clc adc ABS,y sta.z dist_left // if(dist_left<dist_min) stx.z $ff cmp.z $ff bcs __b13 lda #LEFT sta.z direction jmp __b3 __b13: stx.z dist_min __b3: // open_directions&RIGHT lda #RIGHT and.z open_directions // if(open_directions&RIGHT) cmp #0 beq __b4 // char dist_right = ABS[xdiff+1] + ABS[ydiff] ldy.z xdiff lda ABS+1,y ldy.z ydiff clc adc ABS,y // if(dist_right<dist_min) cmp.z dist_min bcs __b4 lda #RIGHT sta.z return rts __b4: // } rts __b12: stx.z dist_min jmp __b3 __b10: tya tax jmp __b2 } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. // void * memset(__zp($6f) void *str, char c, __zp(5) unsigned int num) memset: { .label end = 5 .label dst = $b .label num = 5 .label str = $6f // if(num>0) lda.z num bne !+ lda.z num+1 beq __breturn !: // char* end = (char*)str + num clc lda.z end adc.z str sta.z end lda.z end+1 adc.z str+1 sta.z end+1 lda.z str sta.z dst lda.z str+1 sta.z dst+1 __b2: // for(char* dst = str; dst!=end; dst++) lda.z dst+1 cmp.z end+1 bne __b3 lda.z dst cmp.z end bne __b3 __breturn: // } rts __b3: // *dst = c lda #0 tay sta (dst),y // for(char* dst = str; dst!=end; dst++) inc.z dst bne !+ inc.z dst+1 !: jmp __b2 } // Decrunch crunched data using ByteBoozer // - crunched: Pointer to the start of the crunched data // void byteboozer_decrunch(__zp($24) char * volatile crunched) byteboozer_decrunch: { .label crunched = $24 // asm ldy crunched ldx crunched+1 jsr b2.Decrunch // } rts } // Merge unrolled cycle-exact logic code into an unrolled cycle-exact raster code. // The logic-code is merged into the raster code ensuring cycle-exact execution. If a logic-code block does not fit within the remaining cycle-budget of a raster-slot then NOPs/BIT $EA are used to reach the cycle-budget. // If the logic-code runs out before the raster-code ends then the remaining raster-slots are filled with NOP/BIT$EA. // If the raster-code runs out before the logic-code then the rest of the logic-code is added at the end. // An RTS is added at the very end. // // Parameters: // - dest_code: Address where the merged code is placed // - raster_code: The unrolled raster code blocks with information about cycles to be filled. Format is decribed below. // - logic_code: The unrolled logic code with information about cycles spent. Format is decribed below. // // Format of unrolled raster code. // A number of blocks that have the following structure: // <nn>* 0xff <cc> // <nn>* : some bytes of code. any number of bytes are allowed. // 0xff : signals the end of a block. // <cc> : If <cc> is 00 then this is the last block of the unrolled raster code. // If <cc> is non-zero it means that <cc> cycles must be spent here (the cycle budget of the slot). The merger merges logic code into the slot and fills with NOP's to match the number of cycles needed. // // Format of unrolled logic code. // A number of blocks that has the following structure: // <cc> <nn>* 0xff // <cc> : If <cc> is 00 then this is the last block of the unrolled logic code. No more bytes are used. // If <cc> is non-zero it holds the number of cycles used by the block of code. // <nn>* : some bytes of code. any number of bytes are allowed. This code uses exactly the number of cycles specified by <cc> // 0xff : signals the end of a block. // void merge_code(__zp(9) char *dest_code, __zp($b) char *raster_code, __zp(5) char *logic_code) merge_code: { // Cycle-count signalling the last block of the logic-code .const LOGIC_EXIT = 0 // Value signalling the end of a block of the logic-code .const LOGIC_END = $ff // Cycle-count signalling the last block of the raster-code .const RASTER_EXIT = 0 // Value signalling the end of a block of the raster-code .const RASTER_END = $ff .label dest_code = 9 .label raster_code = $b .label logic_cycles = 2 .label logic_code = 5 lda #<LOGIC_CODE_UNMERGED sta.z logic_code lda #>LOGIC_CODE_UNMERGED sta.z logic_code+1 lda #<RASTER_CODE sta.z dest_code lda #>RASTER_CODE sta.z dest_code+1 lda #<RASTER_CODE_UNMERGED sta.z raster_code lda #>RASTER_CODE_UNMERGED sta.z raster_code+1 // Output raster code until meeting RASTER_END signalling the end of a block __b1: // while(*raster_code!=RASTER_END) ldy #0 lda (raster_code),y cmp #RASTER_END beq !__b2+ jmp __b2 !__b2: // raster_code++; inc.z raster_code bne !+ inc.z raster_code+1 !: // char cycle_budget = *raster_code++ // Find the number of cycles ldy #0 lda (raster_code),y tax inc.z raster_code bne !+ inc.z raster_code+1 !: // if(cycle_budget==RASTER_EXIT) cpx #RASTER_EXIT bne __b4 __b3: // No more raster code - fill in the rest of the logic code // while(*logic_code!=LOGIC_EXIT) ldy #0 lda (logic_code),y cmp #LOGIC_EXIT bne __b15 // *dest_code++ = 0x60 // And add an RTS lda #$60 sta (dest_code),y // } rts __b15: // logic_code++; inc.z logic_code bne !+ inc.z logic_code+1 !: __b5: // Fill in the logic-code // while(*logic_code!=LOGIC_END) ldy #0 lda (logic_code),y cmp #LOGIC_END bne __b18 // logic_code++; inc.z logic_code bne !+ inc.z logic_code+1 !: jmp __b3 __b18: // *dest_code++ = *logic_code++ ldy #0 lda (logic_code),y sta (dest_code),y // *dest_code++ = *logic_code++; inc.z dest_code bne !+ inc.z dest_code+1 !: inc.z logic_code bne !+ inc.z logic_code+1 !: jmp __b5 // Fit the cycle budget with logic-code __b4: // while(cycle_budget>0) cpx #0 beq __b6 // char logic_cycles = *logic_code // Find the number of logic code cycles ldy #0 lda (logic_code),y sta.z logic_cycles // cycle_budget-1 txa tay dey // if(logic_cycles!=LOGIC_EXIT && (logic_cycles < cycle_budget-1 || logic_cycles==cycle_budget)) lda #LOGIC_EXIT cmp.z logic_cycles bne __b20 __b6: // Fit the cycle budget with NOPs __b10: // while(cycle_budget>0) cpx #0 bne __b11 jmp __b1 __b11: // if(cycle_budget==3) cpx #3 beq __b12 // *dest_code++ = 0xEA lda #$ea ldy #0 sta (dest_code),y // *dest_code++ = 0xEA; inc.z dest_code bne !+ inc.z dest_code+1 !: // cycle_budget -= 2 // NOP dex dex jmp __b6 __b12: // *dest_code++ = 0x24 lda #$24 ldy #0 sta (dest_code),y // *dest_code++ = 0x24; inc.z dest_code bne !+ inc.z dest_code+1 !: // *dest_code++ = 0xEA // BIT $EA lda #$ea ldy #0 sta (dest_code),y // *dest_code++ = 0xEA; inc.z dest_code bne !+ inc.z dest_code+1 !: // cycle_budget -= 3 txa axs #3 jmp __b6 __b20: // if(logic_cycles!=LOGIC_EXIT && (logic_cycles < cycle_budget-1 || logic_cycles==cycle_budget)) cpy.z logic_cycles beq !+ bcs __b9 !: cpx.z logic_cycles beq __b9 jmp __b10 __b9: // logic_code++; inc.z logic_code bne !+ inc.z logic_code+1 !: __b13: // Fill in the logic-code // while(*logic_code!=LOGIC_END) ldy #0 lda (logic_code),y cmp #LOGIC_END bne __b7 // logic_code++; inc.z logic_code bne !+ inc.z logic_code+1 !: // cycle_budget -= logic_cycles // Reduce the cycle budget txa sec sbc.z logic_cycles tax jmp __b4 __b7: // *dest_code++ = *logic_code++ ldy #0 lda (logic_code),y sta (dest_code),y // *dest_code++ = *logic_code++; inc.z dest_code bne !+ inc.z dest_code+1 !: inc.z logic_code bne !+ inc.z logic_code+1 !: jmp __b13 __b2: // *dest_code++ = *raster_code++ ldy #0 lda (raster_code),y sta (dest_code),y // *dest_code++ = *raster_code++; inc.z dest_code bne !+ inc.z dest_code+1 !: inc.z raster_code bne !+ inc.z raster_code+1 !: jmp __b1 } // Initialize the RENDER_INDEX table from sub-tables init_render_index: { .label __10 = $d .label __11 = $d .label render_index_xcol = 5 .label canvas_xcol = 3 .label canvas = $d .label render_index = 5 .label x_col = $14 .label render_index_xcol_1 = $b .label y_pos = $10 // Special column in sprite#9 .label render_ypos_table = 9 .label __12 = $d lda #<RENDER_INDEX sta.z render_index_xcol lda #>RENDER_INDEX sta.z render_index_xcol+1 lda #0 sta.z x_col __b1: // for(char x_col=0;x_col<26;x_col++) lda.z x_col cmp #$1a bcc __b2 // (RENDER_INDEX+24*0x100)[RENDER_OFFSET_YPOS_INC] = 0 // Fix the first entry of the inc_offset in the last column (set it to point to 0,0,6,6...) lda #0 sta RENDER_INDEX+$18*$100+RENDER_OFFSET_YPOS_INC // (RENDER_INDEX+25*0x100)[RENDER_OFFSET_YPOS_INC] = 0 sta RENDER_INDEX+$19*$100+RENDER_OFFSET_YPOS_INC // } rts __b2: // if(x_col>=24) lda.z x_col cmp #$18 bcc __b3 ldx #$b lda #<RENDER_YPOS_9TH sta.z render_ypos_table lda #>RENDER_YPOS_9TH sta.z render_ypos_table+1 jmp __b4 __b3: ldx #0 lda #<RENDER_YPOS sta.z render_ypos_table lda #>RENDER_YPOS sta.z render_ypos_table+1 __b4: // char * canvas_xcol = RENDER_XCOLS[x_col] lda.z x_col asl tay lda RENDER_XCOLS,y sta.z canvas_xcol lda RENDER_XCOLS+1,y sta.z canvas_xcol+1 lda.z render_index_xcol sta.z render_index_xcol_1 lda.z render_index_xcol+1 sta.z render_index_xcol_1+1 lda #0 sta.z y_pos __b5: // for(char y_pos=0;y_pos<148;y_pos+=2) lda.z y_pos cmp #$94 bcc __b6 // render_index += 0x100 lda.z render_index clc adc #<$100 sta.z render_index lda.z render_index+1 adc #>$100 sta.z render_index+1 // for(char x_col=0;x_col<26;x_col++) inc.z x_col jmp __b1 __b6: // char * canvas = canvas_xcol + render_ypos_table[(unsigned int)y_pos] lda.z y_pos sta.z __11 lda #0 sta.z __11+1 asl.z __10 rol.z __10+1 clc lda.z __12 adc.z render_ypos_table sta.z __12 lda.z __12+1 adc.z render_ypos_table+1 sta.z __12+1 ldy #0 clc lda (canvas),y adc.z canvas_xcol pha iny lda (canvas),y adc.z canvas_xcol+1 sta.z canvas+1 pla sta.z canvas // BYTE0(canvas) // render_index_xcol[RENDER_OFFSET_CANVAS_LO] = BYTE0(canvas) ldy #0 sta (render_index_xcol_1),y // BYTE1(canvas) lda.z canvas+1 // render_index_xcol[RENDER_OFFSET_CANVAS_HI] = BYTE1(canvas) ldy #RENDER_OFFSET_CANVAS_HI sta (render_index_xcol_1),y // render_index_xcol[RENDER_OFFSET_YPOS_INC] = ypos_inc_offset ldy #RENDER_OFFSET_YPOS_INC txa sta (render_index_xcol_1),y // ypos_inc_offset += 2 inx inx // if(ypos_inc_offset>=23) cpx #$17 bcc __b8 // ypos_inc_offset-=21 txa axs #$15 __b8: // render_index_xcol++; inc.z render_index_xcol_1 bne !+ inc.z render_index_xcol_1+1 !: // y_pos+=2 lda.z y_pos clc adc #2 sta.z y_pos jmp __b5 } // Show the splash screen splash_show: { // Show splash screen .label splash = $b .label ypos = $10 .label xcol = $14 lda #<SPLASH sta.z splash lda #>SPLASH sta.z splash+1 lda #0 sta.z xcol __b1: // for(char xcol=0;xcol<25;xcol++) lda.z xcol cmp #$19 bcc __b4 // } rts __b4: lda #0 sta.z ypos __b2: // for(char ypos=0;ypos<147;ypos++) lda.z ypos cmp #$93 bcc __b3 // for(char xcol=0;xcol<25;xcol++) inc.z xcol jmp __b1 __b3: // char pixels = *splash++ // Render 8px x 1px ldy #0 lda (splash),y tax inc.z splash bne !+ inc.z splash+1 !: // render(xcol, ypos, pixels) stx.z render.pixels jsr render // for(char ypos=0;ypos<147;ypos++) inc.z ypos jmp __b2 } // Initialize bobs_restore with data to prevent crash on the first call init_bobs_restore: { .label CANVAS_HIDDEN = $ea00 .label bob_restore = 9 lda #<bobs_restore sta.z bob_restore lda #>bobs_restore sta.z bob_restore+1 ldx #0 __b1: // for(char bob=0;bob<NUM_BOBS*2;bob++) cpx #NUM_BOBS*2 bcc __b2 // logic_tile_ptr = LEVEL_TILES + 64*18 + 12 // Also set the logic tile to something sane lda #<LEVEL_TILES+$40*$12+$c sta.z logic_tile_ptr lda #>LEVEL_TILES+$40*$12+$c sta.z logic_tile_ptr+1 // logic_tile_xcol = 12 lda #$c sta.z logic_tile_xcol // logic_tile_yfine = 35 lda #$23 sta.z logic_tile_yfine // } rts __b2: ldy #0 __b3: // for(char i=0;i<SIZE_BOB_RESTORE;i++) cpy #SIZE_BOB_RESTORE bcc __b4 // bob_restore[0] = BYTE0(CANVAS_HIDDEN) lda #0 tay sta (bob_restore),y // bob_restore[1] = BYTE1(CANVAS_HIDDEN) lda #>CANVAS_HIDDEN ldy #1 sta (bob_restore),y // bob_restore[3] = BYTE0(CANVAS_HIDDEN) lda #0 ldy #3 sta (bob_restore),y // bob_restore[4] = BYTE1(CANVAS_HIDDEN) lda #>CANVAS_HIDDEN ldy #4 sta (bob_restore),y // bob_restore += SIZE_BOB_RESTORE lda #SIZE_BOB_RESTORE clc adc.z bob_restore sta.z bob_restore bcc !+ inc.z bob_restore+1 !: // for(char bob=0;bob<NUM_BOBS*2;bob++) inx jmp __b1 __b4: // bob_restore[i] = 0 lda #0 sta (bob_restore),y // for(char i=0;i<SIZE_BOB_RESTORE;i++) iny jmp __b3 } // Initialize sprite pointers on all screens (in both graphics banks) init_sprite_pointers: { .const SPRITE_ID_0 = $ff&(SPRITES_1&$3fff)/$40 .label sprites_ptr_1 = 9 .label sprites_ptr_2 = 7 lda #<SCREENS_2+OFFSET_SPRITE_PTRS sta.z sprites_ptr_2 lda #>SCREENS_2+OFFSET_SPRITE_PTRS sta.z sprites_ptr_2+1 lda #<SCREENS_1+OFFSET_SPRITE_PTRS sta.z sprites_ptr_1 lda #>SCREENS_1+OFFSET_SPRITE_PTRS sta.z sprites_ptr_1+1 ldx #0 __b1: // for(char screen=0;screen<14;screen++) cpx #$e bcc __b4 // } rts __b4: ldy #0 __b2: // for(char sprite=0; sprite<8; sprite++) cpy #8 bcc __b3 // sprites_ptr_1 += 0x400 lda.z sprites_ptr_1 clc adc #<$400 sta.z sprites_ptr_1 lda.z sprites_ptr_1+1 adc #>$400 sta.z sprites_ptr_1+1 // sprites_ptr_2 += 0x400 lda.z sprites_ptr_2 clc adc #<$400 sta.z sprites_ptr_2 lda.z sprites_ptr_2+1 adc #>$400 sta.z sprites_ptr_2+1 // for(char screen=0;screen<14;screen++) inx jmp __b1 __b3: // SPRITE_ID_0 + screen txa clc adc #SPRITE_ID_0 // char sprite_id = SPRITE_ID_0 + screen + sprites_id[sprite] clc adc sprites_id,y // sprites_ptr_1[sprite] = sprite_id sta (sprites_ptr_1),y // sprites_ptr_2[sprite] = sprite_id sta (sprites_ptr_2),y // for(char sprite=0; sprite<8; sprite++) iny jmp __b2 .segment Data sprites_id: .byte 0, $70, $60, $50, $40, $30, $20, $10 } .segment Code // Copy block of memory (forwards) // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. // void * memcpy(void *destination, void *source, unsigned int num) memcpy: { .label destination = INTRO_MUSIC_CRUNCHED_UPPER .label source = INTRO_MUSIC_CRUNCHED .label src_end = source+INTRO_MUSIC_CRUNCHED_SIZE .label dst = 9 .label src = 7 lda #<destination sta.z dst lda #>destination sta.z dst+1 lda #<source sta.z src lda #>source sta.z src+1 __b1: // while(src!=src_end) lda.z src+1 cmp #>src_end bne __b2 lda.z src cmp #<src_end bne __b2 // } rts __b2: // *dst++ = *src++ ldy #0 lda (src),y sta (dst),y // *dst++ = *src++; inc.z dst bne !+ inc.z dst+1 !: inc.z src bne !+ inc.z src+1 !: jmp __b1 } // Prepare for joystick control joyinit: { // CIA1->PORT_A_DDR = 0x00 // Joystick Read Mode lda #0 sta CIA1+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR // } rts } // Return 1 if joy #2 fire is pressed joyfire: { // CIA1->PORT_A & 0x10 lda #$10 and CIA1 // if( (CIA1->PORT_A & 0x10) == 0 ) cmp #0 beq __b1 lda #0 rts __b1: lda #1 // } rts } // Initialize the LEVEL_TILES_DIRECTIONS table with bits representing all open (non-blocked) movement directions from a tile init_level_tile_directions: { .label directions = 9 .label ytile = $14 .label open_directions = $f .label xtile = $10 lda #<LEVEL_TILES_DIRECTIONS sta.z directions lda #>LEVEL_TILES_DIRECTIONS sta.z directions+1 lda #0 sta.z ytile __b1: // for(char ytile=0;ytile<37;ytile++) lda.z ytile cmp #$25 bcc __b4 // } rts __b4: lda #0 sta.z xtile __b2: // for(char xtile=0; xtile<50; xtile++) lda.z xtile cmp #$32 bcc __b3 // directions += 0x40 lda #$40 clc adc.z directions sta.z directions bcc !+ inc.z directions+1 !: // for(char ytile=0;ytile<37;ytile++) inc.z ytile jmp __b1 __b3: // level_tile_get(xtile-1, ytile) ldx.z xtile dex lda.z ytile jsr level_tile_get // level_tile_get(xtile-1, ytile) tax // if(TILES_TYPE[level_tile_get(xtile-1, ytile)]!=WALL) lda TILES_TYPE,x cmp #WALL beq __b9 lda #LEFT sta.z open_directions jmp __b5 __b9: lda #0 sta.z open_directions __b5: // level_tile_get(xtile+1, ytile) ldx.z xtile inx lda.z ytile jsr level_tile_get // level_tile_get(xtile+1, ytile) tax // if(TILES_TYPE[level_tile_get(xtile+1, ytile)]!=WALL) lda TILES_TYPE,x cmp #WALL beq __b6 // open_directions |= RIGHT lda #RIGHT ora.z open_directions sta.z open_directions __b6: // level_tile_get(xtile, ytile-1) lda.z ytile sec sbc #1 ldx.z xtile jsr level_tile_get // level_tile_get(xtile, ytile-1) // if(TILES_TYPE[level_tile_get(xtile, ytile-1)]!=WALL) tay lda TILES_TYPE,y cmp #WALL beq __b7 // open_directions |= UP lda #UP ora.z open_directions sta.z open_directions __b7: // level_tile_get(xtile, ytile+1) lda.z ytile clc adc #1 ldx.z xtile jsr level_tile_get // level_tile_get(xtile, ytile+1) // if(TILES_TYPE[level_tile_get(xtile, ytile+1)]!=WALL) tay lda TILES_TYPE,y cmp #WALL beq __b8 // open_directions |= DOWN lda #DOWN ora.z open_directions sta.z open_directions __b8: // directions[xtile] = open_directions lda.z open_directions ldy.z xtile sta (directions),y // for(char xtile=0; xtile<50; xtile++) inc.z xtile jmp __b2 } // Show the level by rendering all tiles // Returns the number of pills on the level level_show: { .label return = 9 .label level = 7 .label ytile = $10 .label tile_right = 2 .label xtile = $13 .label count = 9 .label xcol = $f lda #<LEVEL_TILES sta.z level lda #>LEVEL_TILES sta.z level+1 lda #<0 sta.z count sta.z count+1 sta.z ytile __b1: // for(char ytile=0;ytile<37;ytile++) lda.z ytile cmp #$25 bcc __b4 // } rts __b4: lda #0 sta.z xtile sta.z xcol __b2: // for(char xcol=0, xtile=0; xcol<25; xcol++) lda.z xcol cmp #$19 bcc __b3 // level += 0x40 lda #$40 clc adc.z level sta.z level bcc !+ inc.z level+1 !: // for(char ytile=0;ytile<37;ytile++) inc.z ytile jmp __b1 __b3: // char tile_left = level[xtile++] ldy.z xtile lda (level),y tax iny // if(TILES_TYPE[tile_left]==PILL) lda TILES_TYPE,x cmp #PILL bne __b5 // count++; inc.z count bne !+ inc.z count+1 !: __b5: // char tile_right = level[xtile++] lda (level),y sta.z tile_right iny sty.z xtile // if(TILES_TYPE[tile_right]==PILL) lda #PILL ldy.z tile_right cmp TILES_TYPE,y bne __b6 // count++; inc.z count bne !+ inc.z count+1 !: __b6: // render_tiles(xcol, ytile, tile_left, tile_right) ldy.z tile_right jsr render_tiles // for(char xcol=0, xtile=0; xcol<25; xcol++) inc.z xcol jmp __b2 } // Sound effects for pacman pacman_sound_init: { // SID->VOLUME_FILTER_MODE = 0x0f // Set master volume lda #$f sta SID+OFFSET_STRUCT_MOS6581_SID_VOLUME_FILTER_MODE // SID->CH1_FREQ = 0 // Channel 1 is Pacman eating sound lda #<0 sta SID sta SID+1 // SID->CH1_PULSE_WIDTH = 0 sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_PULSE_WIDTH sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_PULSE_WIDTH+1 // SID->CH1_CONTROL = 0 sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_CONTROL // SID->CH1_ATTACK_DECAY = 0 sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_ATTACK_DECAY // SID->CH1_SUSTAIN_RELEASE = 0xf0 lda #$f0 sta SID+OFFSET_STRUCT_MOS6581_SID_CH1_SUSTAIN_RELEASE // } rts } // Render graphic pixels into the 9 all-border sprites // - xcol: x column (0-24). The x-column represents 8 bits of data, 4 mc pixels, 16 on-screen pixels (due to x-expanded sprites) // - ypos: y position (0-145). The y-position is a line on the screen. Since every second line is black each ypos represents a 2 pixel distance. // - pixels: The pixel data to set // void render(__zp($14) char xcol, __zp($10) char ypos, __zp($13) char pixels) render: { .label render_index_xcol = $d .label canvas_offset = 9 .label canvas1 = 7 .label canvas2 = 9 .label ypix = 2 .label xcol = $14 .label ypos = $10 .label pixels = $13 // char ytile = ypos/4 lda.z ypos lsr lsr tay // BYTE1(RENDER_INDEX) + xcol lax.z xcol axs #-[>RENDER_INDEX] // ytile*2 tya asl // MAKEWORD( BYTE1(RENDER_INDEX) + xcol, ytile*2 ) stx.z render_index_xcol+1 sta.z render_index_xcol // unsigned int canvas_offset = MAKEWORD( render_index_xcol[RENDER_OFFSET_CANVAS_HI], render_index_xcol[RENDER_OFFSET_CANVAS_LO] ) ldy #RENDER_OFFSET_CANVAS_HI lda (render_index_xcol),y sta.z canvas_offset+1 ldy #0 lda (render_index_xcol),y sta.z canvas_offset // char * canvas1 = SPRITES_1 + canvas_offset clc adc #<SPRITES_1 sta.z canvas1 lda.z canvas_offset+1 adc #>SPRITES_1 sta.z canvas1+1 // char * canvas2 = SPRITES_2 + canvas_offset lda.z canvas2 clc adc #<SPRITES_2 sta.z canvas2 lda.z canvas2+1 adc #>SPRITES_2 sta.z canvas2+1 // char ypos_inc_offset = render_index_xcol[RENDER_OFFSET_YPOS_INC] ldy #RENDER_OFFSET_YPOS_INC lda (render_index_xcol),y tax // char ypix = ypos&3 // Move the last few y-pixels lda #3 and.z ypos sta.z ypix ldy #0 __b1: // for(char i=0;i<ypix;i++) cpy.z ypix bcc __b2 // *canvas1 = pixels // Render the pixels lda.z pixels ldy #0 sta (canvas1),y // *canvas2 = pixels sta (canvas2),y // } rts __b2: // canvas1 += RENDER_YPOS_INC[ypos_inc_offset] lda RENDER_YPOS_INC,x clc adc.z canvas1 sta.z canvas1 bcc !+ inc.z canvas1+1 !: // canvas2 += RENDER_YPOS_INC[ypos_inc_offset] lda RENDER_YPOS_INC,x clc adc.z canvas2 sta.z canvas2 bcc !+ inc.z canvas2+1 !: // ypos_inc_offset++; inx // for(char i=0;i<ypix;i++) iny jmp __b1 } // Get the level tile at a given (xtile, ytile) position // Returns the TILE ID // If xtile of ytile is outside the legal range the empty tile (0) is returned // __register(A) char level_tile_get(__register(X) char xtile, __register(A) char ytile) level_tile_get: { .label ytiles = $d // if(xtile>49 || ytile>36) cpx #$31+1 bcs __b1 cmp #$24+1 bcs __b1 // char* ytiles = LEVEL_TILES + LEVEL_YTILE_OFFSET[ytile] asl tay clc lda #<LEVEL_TILES adc LEVEL_YTILE_OFFSET,y sta.z ytiles lda #>LEVEL_TILES adc LEVEL_YTILE_OFFSET+1,y sta.z ytiles+1 // return ytiles[xtile]; txa tay lda (ytiles),y rts __b1: lda #0 // } rts } // Renders 2x1 tiles on the canvas. // Tiles are 4x4 px. This renders 8px x 4px. // - xcol: The x column position (0-24) (a column is 8 pixels) // - ytile: The y tile position (0-37). Tile y position 0 is a special half-tile at the top of the screen. // - tile_left: The left tile ID. // - tile_right: The right tile ID. // void render_tiles(__zp($f) char xcol, __zp($10) char ytile, __register(X) char tile_left, __register(Y) char tile_right) render_tiles: { .label tile_left_pixels = $d .label tile_right_pixels = $b .label render_index_xcol = $11 .label canvas_offset = 3 .label canvas1 = 5 .label canvas2 = 3 .label y = 2 .label xcol = $f .label ytile = $10 // tile_left*4 txa asl asl // char * tile_left_pixels = TILES_LEFT + tile_left*4 clc adc #<TILES_LEFT sta.z tile_left_pixels lda #>TILES_LEFT adc #0 sta.z tile_left_pixels+1 // tile_right*4 tya asl asl // char * tile_right_pixels = TILES_RIGHT + tile_right*4 clc adc #<TILES_RIGHT sta.z tile_right_pixels lda #>TILES_RIGHT adc #0 sta.z tile_right_pixels+1 // BYTE1(RENDER_INDEX) + xcol lax.z xcol axs #-[>RENDER_INDEX] // ytile*2 lda.z ytile asl // MAKEWORD( BYTE1(RENDER_INDEX) + xcol, ytile*2 ) stx.z render_index_xcol+1 sta.z render_index_xcol // unsigned int canvas_offset = MAKEWORD( render_index_xcol[RENDER_OFFSET_CANVAS_HI], render_index_xcol[RENDER_OFFSET_CANVAS_LO] ) ldy #RENDER_OFFSET_CANVAS_HI lda (render_index_xcol),y sta.z canvas_offset+1 ldy #0 lda (render_index_xcol),y sta.z canvas_offset // char * canvas1 = SPRITES_1 + canvas_offset clc adc #<SPRITES_1 sta.z canvas1 lda.z canvas_offset+1 adc #>SPRITES_1 sta.z canvas1+1 // char * canvas2 = SPRITES_2 + canvas_offset lda.z canvas2 clc adc #<SPRITES_2 sta.z canvas2 lda.z canvas2+1 adc #>SPRITES_2 sta.z canvas2+1 // char ypos_inc_offset = render_index_xcol[RENDER_OFFSET_YPOS_INC] ldy #RENDER_OFFSET_YPOS_INC lda (render_index_xcol),y tax lda #0 sta.z y __b1: // for(char y=0;y<4;y++) lda.z y cmp #4 bcc __b2 // } rts __b2: // char pixels = tile_left_pixels[y] | tile_right_pixels[y] ldy.z y lda (tile_left_pixels),y ora (tile_right_pixels),y // *canvas1 = pixels ldy #0 sta (canvas1),y // *canvas2 = pixels sta (canvas2),y // canvas1 += RENDER_YPOS_INC[ypos_inc_offset] lda RENDER_YPOS_INC,x clc adc.z canvas1 sta.z canvas1 bcc !+ inc.z canvas1+1 !: // canvas2 += RENDER_YPOS_INC[ypos_inc_offset] lda RENDER_YPOS_INC,x clc adc.z canvas2 sta.z canvas2 bcc !+ inc.z canvas2+1 !: // ypos_inc_offset++; inx // for(char y=0;y<4;y++) inc.z y jmp __b1 } .segment Data // The byteboozer decruncher BYTEBOOZER: .const B2_ZP_BASE = $fc #import "byteboozer_decrunch.asm" // Pacman eating sound PACMAN_CH1_FREQ_HI: .byte $23, $1d, $1a, $17, $15, $12, 0, 0, 0, 0, 0, $19, $1a, $1c, $1d, $20, $23, 0, 0, 0, 0, 0 PACMAN_CH1_CONTROL: .byte $21, $21, $21, $21, $21, $21, 0, 0, 0, 0, 0, $21, $21, $21, $21, $21, $21, 0, 0, 0, 0, 0 // Address of the first pixel each x column RENDER_XCOLS: .word 0, 1, 2, $400, $401, $402, $800, $801, $802, $c00, $c01, $c02, $1000, $1001, $1002, $1400, $1401, $1402, $1800, $1801, $1802, $1c00, $1c01, $1c02, 0, 0 // Offset for each y-position from the first pixel of an X column RENDER_YPOS: .word 0, 0, 0, 6, $c, $12, $18, $1e, $24, $2a, $30, $36, $3c, $40+3, $40+9, $40+$f, $40+$15, $40+$1b, $40+$21, $40+$27, $40+$2d, $40+$33, $40+$39, $80, $80+6, $80+$c, $80+$12, $80+$18, $80+$1e, $80+$24, $80+$2a, $80+$30, $80+$36, $80+$3c, $c0+3, $c0+9, $c0+$f, $c0+$15, $c0+$1b, $c0+$21, $c0+$27, $c0+$2d, $c0+$33, $c0+$39, $100, $100+6, $100+$c, $100+$12, $100+$18, $100+$1e, $100+$24, $100+$2a, $100+$30, $100+$36, $100+$3c, $140+3, $140+9, $140+$f, $140+$15, $140+$1b, $140+$21, $140+$27, $140+$2d, $140+$33, $140+$39, $180, $180+6, $180+$c, $180+$12, $180+$18, $180+$1e, $180+$24, $180+$2a, $180+$30, $180+$36, $180+$3c, $1c0+3, $1c0+9, $1c0+$f, $1c0+$15, $1c0+$1b, $1c0+$21, $1c0+$27, $1c0+$2d, $1c0+$33, $1c0+$39, $200, $200+6, $200+$c, $200+$12, $200+$18, $200+$1e, $200+$24, $200+$2a, $200+$30, $200+$36, $200+$3c, $240+3, $240+9, $240+$f, $240+$15, $240+$1b, $240+$21, $240+$27, $240+$2d, $240+$33, $240+$39, $280, $280+6, $280+$c, $280+$12, $280+$18, $280+$1e, $280+$24, $280+$2a, $280+$30, $280+$36, $280+$3c, $2c0+3, $2c0+9, $2c0+$f, $2c0+$15, $2c0+$1b, $2c0+$21, $2c0+$27, $2c0+$2d, $2c0+$33, $2c0+$39, $300, $300+6, $300+$c, $300+$12, $300+$18, $300+$1e, $300+$24, $300+$2a, $300+$30, $300+$36, $300+$3c, $340+3, $340+9, $340+$f, $340+$15, $340+$1b, $340+$21, $340+$27, $340+$2d, $340+$33, $340+$39 // Offset for each y-position from the first pixel of an X column in sprite#9 RENDER_YPOS_9TH: .word 3, 3, 3, 9, $f, $15, $1b, $21, $27, $2d, $33, $39, $40, $40+6, $40+$c, $40+$12, $40+$18, $40+$1e, $40+$24, $40+$2a, $40+$30, $40+$36, $40+$3c, $80+3, $80+9, $80+$f, $80+$15, $80+$1b, $80+$21, $80+$27, $80+$2d, $80+$33, $80+$39, $c0, $c0+6, $c0+$c, $c0+$12, $c0+$18, $c0+$1e, $c0+$24, $c0+$2a, $c0+$30, $c0+$36, $c0+$3c, $100+3, $100+9, $100+$f, $100+$15, $100+$1b, $100+$21, $100+$27, $100+$2d, $100+$33, $100+$39, $140, $140+6, $140+$c, $140+$12, $140+$18, $140+$1e, $140+$24, $140+$2a, $140+$30, $140+$36, $140+$3c, $180+3, $180+9, $180+$f, $180+$15, $180+$1b, $180+$21, $180+$27, $180+$2d, $180+$33, $180+$39, $1c0, $1c0+6, $1c0+$c, $1c0+$12, $1c0+$18, $1c0+$1e, $1c0+$24, $1c0+$2a, $1c0+$30, $1c0+$36, $1c0+$3c, $200+3, $200+9, $200+$f, $200+$15, $200+$1b, $200+$21, $200+$27, $200+$2d, $200+$33, $200+$39, $240, $240+6, $240+$c, $240+$12, $240+$18, $240+$1e, $240+$24, $240+$2a, $240+$30, $240+$36, $240+$3c, $280+3, $280+9, $280+$f, $280+$15, $280+$1b, $280+$21, $280+$27, $280+$2d, $280+$33, $280+$39, $2c0, $2c0+6, $2c0+$c, $2c0+$12, $2c0+$18, $2c0+$1e, $2c0+$24, $2c0+$2a, $2c0+$30, $2c0+$36, $2c0+$3c, $300+3, $300+9, $300+$f, $300+$15, $300+$1b, $300+$21, $300+$27, $300+$2d, $300+$33, $300+$39, $340, $340+6, $340+$c, $340+$12, $340+$18, $340+$1e, $340+$24, $340+$2a, $340+$30, $340+$36, $340+$3c // Increment for each y-position from the first pixel of an X column .align $20 RENDER_YPOS_INC: .byte 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7 // The BOB x column position (0-24) (a column is 8 pixels) bobs_xcol: .byte $a, $a, $a, $a, $a // The BOB y fine position (0-99). The y-position is a line on the screen. Since every second line is black each ypos represents a 2 pixel distance. bobs_yfine: .byte $2d, $2d, $2d, $2d, $2d // The BOB ID in the BOB data tables bobs_bob_id: .byte 0, 0, 0, 0, 0 // The BOB restore data: 18 bytes per BOB. Doubled for double-buffering. // char * left_canvas; // char left_ypos_inc_offset; // char * right_canvas; // char right_ypos_inc_offset; // char[12] restore_pixels; .align $100 bobs_restore: .fill NUM_BOBS*SIZE_BOB_RESTORE*2, 0 .segment Init // The level represented as 4x4 px tiles. Each byte is the ID of a tile from the tile set. // The level is 50 tiles * 37 tiles. The first tile line are special half-tiles (where only the last 2 pixel rows are shown). // The level data is organized as 37 rows of 50 tile IDs. LEVEL_TILES_CRUNCHED: .modify B2() { .pc = LEVEL_TILES "LEVEL TILE GRAPHICS" .var pic_level = LoadPicture("pacman-tiled.png", List().add($000000, $352879, $bfce72, $883932)) // Maps the tile pixels (a 16 bit number) to the tile ID .var TILESET = Hashtable() // Maps the tile ID to the pixels (a 16 bit number) .var TILESET_BY_ID = Hashtable() // Tile ID 0 is empty .eval TILESET.put(0, 0) .eval TILESET_BY_ID.put(0, 0) .align $100 // TABLE LEVEL_TILES[64*37] // The level is 50 tiles * 37 tiles. The first tile line are special half-tiles (where only the last 2 pixel rows are shown). // The level data is organized as 37 rows of 64 bytes containing tile IDs. (the last 14 are unused to achieve 64-byte alignment) .for(var ytile=0; ytile<37; ytile++) { .for(var xtile=0; xtile<50; xtile++) { // Find the tile pixels (4x4 px - 16 bits) .var pixels = 0; .for(var i=0; i<4; i++) { .var pix = pic_level.getMulticolorByte(xtile/2,ytile*4+i) .if((xtile&1)==0) { // left nibble .eval pix = floor(pix / $10) } else { // right nibble .eval pix = pix & $0f } .eval pixels = pixels*$10 + pix } .var tile_id = 0 .if(TILESET.containsKey(pixels)) { .eval tile_id = TILESET.get(pixels) } else { .eval tile_id = TILESET.keys().size() .eval TILESET.put(pixels, tile_id) .eval TILESET_BY_ID.put(tile_id, pixels) // .print "tile "+tile_id+" : "+toHexString(pixels,4) } // Output the tile ID .byte tile_id } .fill 14, 0 } .align $100 // TABLE char TILES_LEFT[0x80] // The left tile graphics. A tile is 4x4 px. The left tiles contain tile graphics for the 4 left bits of a char. Each tile is 4 bytes. .for(var tile_id=0;tile_id<TILESET_BY_ID.keys().size();tile_id++) { .var pixels = TILESET_BY_ID.get(tile_id) .for(var i=0; i<4; i++) { .var pix = (pixels & $f000) >> 12 .byte pix<<4 .eval pixels = pixels << 4 } } .align $80 // TABLE char TILES_RIGHT[0x80] // The right tile graphics. A tile is 4x4 px. The right tiles contain tile graphics for the 4 right bits of a char. Each tile is 4 bytes. .for(var tile_id=0;tile_id<TILESET_BY_ID.keys().size();tile_id++) { .var pixels = TILESET_BY_ID.get(tile_id) .for(var i=0; i<4; i++) { .var pix = (pixels & $f000) >> 12 .byte pix .eval pixels = pixels << 4 } } .align $80 // TABLE char TILES_TYPE[0x20] // 0: empty (all black), 1:pill, 2:powerup, 4: wall (contains blue pixels) .for(var tile_id=0;tile_id<TILESET_BY_ID.keys().size();tile_id++) { .var pixels = TILESET_BY_ID.get(tile_id) .var tile_type = 0 .if(pixels==$0220) .eval tile_type=1 // 1:pill .if(pixels==$aaaa) .eval tile_type=2 // 2:powerup .for(var i=0; i<4; i++) { .var pix = (pixels & $f000) >> 12 // Detect wall - any blue pixels (%01) .if( (pix&%0100)==%0100) .eval tile_type = 4; // 4:wall .if( (pix&%0001)==%0001) .eval tile_type = 4; // 4:wall .eval pixels = pixels << 4 } .byte tile_type //.print "tile "+tile_id+" gfx "+toHexString(TILESET_BY_ID.get(tile_id),4) + " type "+tile_type } } // BOB data: One table per bob byte (left/right, mask/pixels = 4 tables). The index into the table is the bob_id + row*BOB_ROW_SIZE. BOB_GRAPHICS_CRUNCHED: .modify B2() { .pc = BOB_MASK_LEFT "BOB GRAPHICS TABLES" .var bobs_pic = LoadPicture("pacman-bobs.png", List().add($000000, $352879, $bfce72, $883932)) // TABLE char BOB_MASK_LEFT[BOB_ROW_SIZE*6] .for(var row=0; row<6;row++) { .align BOB_ROW_SIZE .for(var pac=0; pac<9;pac++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(0,scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(0,24+scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(0,48+scroll*6+row) } // TABLE char BOB_MASK_RIGT[BOB_ROW_SIZE*6] .for(var row=0; row<6;row++) { .align BOB_ROW_SIZE .for(var pac=0; pac<9;pac++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(1,scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(1,24+scroll*6+row) .for(var blue=0; blue<8;blue++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(1,48+scroll*6+row) } // TABLE char BOB_PIXEL_LEFT[BOB_ROW_SIZE*6] .for(var row=0; row<6;row++) { .align BOB_ROW_SIZE .for(var pac=0; pac<9;pac++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(2+pac*2,scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(2+ghost*2,24+scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(2+ghost*2,48+scroll*6+row) } // TABLE char BOB_PIXEL_RIGT[BOB_ROW_SIZE*6] .for(var row=0; row<6;row++) { .align BOB_ROW_SIZE .for(var pac=0; pac<9;pac++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(3+pac*2,scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(3+ghost*2,24+scroll*6+row) .for(var ghost=0; ghost<8;ghost++) .for(var scroll=0; scroll<4;scroll++) .byte bobs_pic.getMulticolorByte(3+ghost*2,48+scroll*6+row) } } // Splash screen 25 xcol * 147 ypos bytes SPLASH_CRUNCHED: .modify B2() { .pc = SPLASH "SPLASH SCREEN" // 00:BLACK, 01:BLUE, 10:YELLOW, 11:RED .var pic_splash_mc = LoadPicture("pacman-splash.png", List().add($000000, $352879, $bfce72, $883932)) // 0:BLACK, 1:YELLOW .var pic_splash_yellow = LoadPicture("pacman-splash.png", List().add($000000, $bfce72)) // 0:BLACK, 1:BLUE .var pic_splash_blue = LoadPicture("pacman-splash.png", List().add($000000, $352879)) .for(var xcol=0; xcol<25; xcol++) { .for(var ypos=0; ypos<147; ypos++) { .if(ypos>25 && ypos<123) { // Sprites in the sides are in single color blue on splash screen .byte pic_splash_blue.getSinglecolorByte(xcol,ypos) } else .if(xcol>2 && xcol<21) { // Sprites 2-7 are in single color yellow on splash screen .byte pic_splash_yellow.getSinglecolorByte(xcol,ypos) } else { // Sprites 0&1 are in multi color on splash screen .byte pic_splash_mc.getMulticolorByte(xcol,ypos) } } } } // Victory graphics 25 xcol * 25 ypos bytes WIN_GFX_CRUNCHED: .modify B2() { .pc = WIN_GFX "WIN GRAPHICS" // 00:BLACK, 01:BLUE, 10:YELLOW, 11:RED .var pic_win = LoadPicture("pacman-win.png", List().add($000000, $352879, $bfce72, $883932)) .for(var xcol=0; xcol<25; xcol++) { .for(var ypos=0; ypos<25; ypos++) { .byte pic_win.getMulticolorByte(xcol,ypos) } } } // Game Over graphics 25 xcol * 25 ypos bytes GAMEOVER_GFX_CRUNCHED: .modify B2() { .pc = GAMEOVER_GFX "GAMEOVER GRAPHICS" // 00:BLACK, 01:BLUE, 10:YELLOW, 11:RED .var pic_gameover = LoadPicture("pacman-gameover.png", List().add($000000, $352879, $bfce72, $883932)) .for(var xcol=0; xcol<25; xcol++) { .for(var ypos=0; ypos<25; ypos++) { .byte pic_gameover.getMulticolorByte(xcol,ypos) } } } // Renders the BOBs at the given positions // The bob logic code will be merged with raster code using code-merger.c // First restores the canvas from previously rendered bobs, and then renders the bobs at the given positions. // BOBs are 16px*6px graphics (2 x-columns * 6px) with masks and pixels // Uses the bobs_xcol, bobs_yfine, bobs_bob_id and bob_restore for data about the bobs // Implemented in inline kick assembler LOGIC_CODE_CRUNCHED: .macro LOGIC_BEGIN(cycles) { .byte cycles } .macro LOGIC_END() { .byte $ff } .modify B2() { .pc = LOGIC_CODE_UNMERGED "LOGIC CODE UNMERGED" LOGIC_BEGIN(2) clc LOGIC_END() // ****************************************** // Restores the canvas under the rendered bobs // ****************************************** .for(var bob=NUM_BOBS-1;bob>=0; bob--) { //LOGIC_BEGIN(6) //inc $d021 //LOGIC_END() LOGIC_BEGIN(3) ldx bobs_restore_base LOGIC_END() // char * volatile left_canvas = *((char**)&bob_restore[0]); LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+0,x sta.z left_canvas LOGIC_END() LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+1,x sta.z left_canvas+1 LOGIC_END() // char left_ypos_inc_offset = bob_restore[2]; LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+2,x sta.z left_ypos_inc_offset LOGIC_END() // char * volatile rigt_canvas = *((char**)&bob_restore[3]); LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+3,x sta.z rigt_canvas LOGIC_END() LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+4,x sta.z rigt_canvas+1 LOGIC_END() // char rigt_ypos_inc_offset = bob_restore[5]; LOGIC_BEGIN(7) lda bobs_restore+SIZE_BOB_RESTORE*bob+5,x sta.z rigt_ypos_inc_offset LOGIC_END() // Restore Bob Rows LOGIC_BEGIN(2) ldy #0 LOGIC_END() .for(var row=0;row<6;row++) { //left_canvas += RENDER_YPOS_INC[left_ypos_inc_offset++]; LOGIC_BEGIN(3) ldx.z left_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(5) inc.z left_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(18) lda RENDER_YPOS_INC,x adc.z left_canvas sta.z left_canvas lda.z left_canvas+1 adc #0 sta.z left_canvas+1 LOGIC_END() //rigt_canvas += RENDER_YPOS_INC[rigt_ypos_inc_offset++]; LOGIC_BEGIN(3) ldx.z rigt_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(5) inc.z rigt_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(18) lda RENDER_YPOS_INC,x adc.z rigt_canvas sta.z rigt_canvas lda.z rigt_canvas+1 adc #0 sta.z rigt_canvas+1 LOGIC_END() LOGIC_BEGIN(3) ldx bobs_restore_base LOGIC_END() // *left_canvas = bob_restore[6] ; LOGIC_BEGIN(10) lda bobs_restore+SIZE_BOB_RESTORE*bob+6+row,x sta (left_canvas),y LOGIC_END() // *rigt_canvas = bob_restore[7]; LOGIC_BEGIN(10) lda bobs_restore+SIZE_BOB_RESTORE*bob+12+row,x sta (rigt_canvas),y LOGIC_END() } } // ****************************************** // Render two tiles on the canvas // ****************************************** // y==0 from bob restore LOGIC_BEGIN(12) // char tile_left_idx = 4 * logic_tile_ptr[0]; lda (logic_tile_ptr),y asl asl sta logic_tile_left_idx LOGIC_END() // char logic_tile_right_idx = 4 * logic_tile_ptr[1]; LOGIC_BEGIN(2) iny LOGIC_END() LOGIC_BEGIN(12) lda (logic_tile_ptr),y asl asl sta logic_tile_right_idx LOGIC_END() // char * render_index_xcol = (char*){ (>RENDER_INDEX) + xcol, ytile*2 }; LOGIC_BEGIN(8) lda #>RENDER_INDEX adc logic_tile_xcol sta.z left_render_index_xcol+1 LOGIC_END() LOGIC_BEGIN(6) lda logic_tile_yfine sta.z left_render_index_xcol LOGIC_END() // unsigned int canvas_offset = {render_index_xcol[RENDER_OFFSET_CANVAS_HI], render_index_xcol[RENDER_OFFSET_CANVAS_LO] }; // char * left_canvas = canvas_base_hi*$100 + canvas_offset; LOGIC_BEGIN(2) ldy #RENDER_OFFSET_CANVAS_LO LOGIC_END() LOGIC_BEGIN(8) lda (left_render_index_xcol),y sta.z left_canvas LOGIC_END() LOGIC_BEGIN(2) ldy #RENDER_OFFSET_CANVAS_HI LOGIC_END() LOGIC_BEGIN(11) lda (left_render_index_xcol),y adc canvas_base_hi sta.z left_canvas+1 LOGIC_END() // char left_ypos_inc_offset = render_index_xcol[RENDER_OFFSET_YPOS_INC]; LOGIC_BEGIN(2) ldy #RENDER_OFFSET_YPOS_INC LOGIC_END() LOGIC_BEGIN(8) lda (left_render_index_xcol),y sta.z left_ypos_inc_offset LOGIC_END() // Render Tile Rows LOGIC_BEGIN(2) ldy #0 LOGIC_END() .for(var row=0;row<4;row++) { // *left_canvas = tile_left_pixels[y] | tile_right_pixels[y]; LOGIC_BEGIN(3) ldx logic_tile_left_idx LOGIC_END() LOGIC_BEGIN(17) lda TILES_LEFT+row,x ldx logic_tile_right_idx ora TILES_RIGHT+row,x sta (left_canvas),y LOGIC_END() //left_canvas += RENDER_YPOS_INC[left_ypos_inc_offset++]; LOGIC_BEGIN(3) ldx.z left_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(18) lda RENDER_YPOS_INC,x adc.z left_canvas sta.z left_canvas lda.z left_canvas+1 adc #0 sta.z left_canvas+1 LOGIC_END() LOGIC_BEGIN(5) inc.z left_ypos_inc_offset LOGIC_END() } // ****************************************** // Renders the BOBs at the given positions // ****************************************** .for(var bob=0;bob<NUM_BOBS; bob++) { // char * left_render_index_xcol = (char*){ (>RENDER_INDEX) + xcol, yfine }; // char * rigt_render_index_xcol = (char*){ (>RENDER_INDEX) + xcol+1, yfine }; //LOGIC_BEGIN(6) //inc $d021 //LOGIC_END() LOGIC_BEGIN(14) lda #>RENDER_INDEX adc bobs_xcol+bob sta.z left_render_index_xcol+1 adc #1 sta.z rigt_render_index_xcol+1 LOGIC_END() LOGIC_BEGIN(10) lda bobs_yfine+bob sta.z left_render_index_xcol sta.z rigt_render_index_xcol LOGIC_END() // char * left_canvas = (char*){ left_render_index_xcol[85], left_render_index_xcol[0] }; // bob_restore[0] = <left_canvas; bob_restore[1] = >left_canvas; // char * rigt_canvas = (char*){ rigt_render_index_xcol[85], rigt_render_index_xcol[0] }; // bob_restore[3] = <rigt_canvas; bob_restore[4] = >rigt_canvas; LOGIC_BEGIN(3) ldx bobs_restore_base LOGIC_END() LOGIC_BEGIN(2) ldy #RENDER_OFFSET_CANVAS_LO LOGIC_END() LOGIC_BEGIN(13) lda (left_render_index_xcol),y sta.z left_canvas sta bobs_restore+SIZE_BOB_RESTORE*bob+0,x LOGIC_END() LOGIC_BEGIN(13) lda (rigt_render_index_xcol),y sta.z rigt_canvas sta bobs_restore+SIZE_BOB_RESTORE*bob+3,x LOGIC_END() LOGIC_BEGIN(2) ldy #RENDER_OFFSET_CANVAS_HI LOGIC_END() LOGIC_BEGIN(16) lda (left_render_index_xcol),y adc canvas_base_hi sta.z left_canvas+1 sta bobs_restore+SIZE_BOB_RESTORE*bob+1,x LOGIC_END() LOGIC_BEGIN(16) lda (rigt_render_index_xcol),y adc canvas_base_hi sta.z rigt_canvas+1 sta bobs_restore+SIZE_BOB_RESTORE*bob+4,x LOGIC_END() // char left_ypos_inc_offset = left_render_index_xcol[170]; // bob_restore[2] = left_ypos_inc_offset; // char rigt_ypos_inc_offset = rigt_render_index_xcol[170]; // bob_restore[5] = rigt_ypos_inc_offset; LOGIC_BEGIN(2) ldy #RENDER_OFFSET_YPOS_INC LOGIC_END() LOGIC_BEGIN(13) lda (left_render_index_xcol),y sta.z left_ypos_inc_offset sta bobs_restore+SIZE_BOB_RESTORE*bob+2,x LOGIC_END() LOGIC_BEGIN(13) lda (rigt_render_index_xcol),y sta.z rigt_ypos_inc_offset sta bobs_restore+SIZE_BOB_RESTORE*bob+5,x LOGIC_END() // Render Bob Rows LOGIC_BEGIN(2) ldy #0 LOGIC_END() .for(var row=0;row<6;row++) { //left_canvas += RENDER_YPOS_INC[left_ypos_inc_offset++]; LOGIC_BEGIN(3) ldx.z left_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(18) lda RENDER_YPOS_INC,x adc.z left_canvas sta.z left_canvas lda.z left_canvas+1 adc #0 sta.z left_canvas+1 LOGIC_END() LOGIC_BEGIN(5) inc.z left_ypos_inc_offset LOGIC_END() //rigt_canvas += RENDER_YPOS_INC[rigt_ypos_inc_offset++]; LOGIC_BEGIN(3) ldx.z rigt_ypos_inc_offset LOGIC_END() LOGIC_BEGIN(18) lda RENDER_YPOS_INC,x adc.z rigt_canvas sta.z rigt_canvas lda.z rigt_canvas+1 adc #0 sta.z rigt_canvas+1 LOGIC_END() LOGIC_BEGIN(5) inc.z rigt_ypos_inc_offset LOGIC_END() // bob_restore[6] = *left_canvas; // *left_canvas = *left_canvas & BOB_MASK_LEFT_0[bob_id] | BOB_PIXEL_LEFT_0[bob_id]; LOGIC_BEGIN(3) ldx bobs_restore_base LOGIC_END() LOGIC_BEGIN(10) lda (left_canvas),y sta bobs_restore+SIZE_BOB_RESTORE*bob+6+row,x LOGIC_END() LOGIC_BEGIN(10) lda (rigt_canvas),y sta bobs_restore+SIZE_BOB_RESTORE*bob+12+row,x LOGIC_END() LOGIC_BEGIN(4) ldx bobs_bob_id+bob LOGIC_END() LOGIC_BEGIN(19) lda (left_canvas),y and BOB_MASK_LEFT+row*BOB_ROW_SIZE,x ora BOB_PIXEL_LEFT+row*BOB_ROW_SIZE,x sta (left_canvas),y LOGIC_END() // bob_restore[7] = *rigt_canvas; // *rigt_canvas = *rigt_canvas & BOB_MASK_RIGT_0[bob_id] | BOB_PIXEL_RIGT_0[bob_id]; LOGIC_BEGIN(19) lda (rigt_canvas),y and BOB_MASK_RIGT+row*BOB_ROW_SIZE,x ora BOB_PIXEL_RIGT+row*BOB_ROW_SIZE,x sta (rigt_canvas),y LOGIC_END() } } //LOGIC_BEGIN(6) //lda #0 //sta $d021 //LOGIC_END() LOGIC_BEGIN(0) // end of logic code } // Raster-code for displaying 9 sprites on the entire screen - with open side borders // The uncrunched code will be merged with logic code using code-merger.c // The unmerged raster-code is identical for both buffers! RASTER_CODE_CRUNCHED: .macro RASTER_CYCLES(cycles) { .byte $ff, cycles } .modify B2() { .pc = RASTER_CODE_UNMERGED "RASTER CODE UNMERGED" RASTER_CYCLES(29) // Line 7 cycle 44 // Raster Line .var raster_line = 7 // Line in the sprite .var sprite_line = 20 // Current sprite ypos .var sprite_ypos = 7 // Current sprite screen (graphics bank not important since sprite layout in the banks is identical) .var sprite_screen = SCREENS_1 .var available_cycles = 0; .for(var i=0;i<293;i++) { // Line cycle count .var line_cycles = 46 .if(raster_line>=70 && raster_line<238) { // Only 2 sprites on these lines - so more cycles available .eval line_cycles = 58 } // Create 9th sprite by moving sprite 0 .if(mod(raster_line,2)==0) { lda #$6f sta $d000 } else { lda #$e7 sta $d000 } .eval line_cycles -= 6; lda #$8 // Cycle 50. LSR abs is a 6 cycle RWM instruction. lsr VICII_CONTROL2 sta VICII_CONTROL2 .eval line_cycles -= 12; .eval raster_line++ .eval sprite_line++ .if(sprite_line==21) { .eval sprite_line = 0 .eval sprite_ypos += 21 } // Set sprite single-color mode on splash .if(raster_line==53) { lda side_sprites_mc sta $d01c lda side_sprites_color sta $d027 sta $d028 .eval line_cycles -= 18 } // Set sprite multi-color mode on splash .if(raster_line==248) { lda bottom_sprites_mc sta $d01c lda bottom_sprites_color sta $d027 sta $d028 .eval line_cycles -= 18 //.print "raster:"+raster_line+" multi-color" } // Open top border .if(raster_line==55) { lda #VICII_RSEL|VICII_ECM|VICII_BMM|7 sta VICII_CONTROL1 .eval line_cycles -= 6 //.print "raster:"+raster_line+" top border rsel=1" } // Open bottom border .if(raster_line==250) { lda #VICII_ECM|VICII_BMM|7 // DEN=0, RSEL=0 sta VICII_CONTROL1 .eval line_cycles -= 6 //.print "raster:"+raster_line+" bottom border rsel=0" } // Move sprites down .if(sprite_line>=2 && sprite_line<=9) { .if(sprite_ypos<300) { .var sprite_id = sprite_line-2 .if(sprite_id==0 || sprite_id==1 || sprite_ypos<=55 || sprite_ypos>=(246-21)) { lda #sprite_ypos sta SPRITES_YPOS+2*sprite_id .eval line_cycles -= 6; //.print "raster:"+raster_line+" sprite:"+sprite_id+" ypos:"+sprite_ypos } } } // Change sprite data .if(sprite_line==20) { .eval sprite_screen += $400 lda #sprite_screen/$40 sta VICII_MEMORY .eval line_cycles -= 6 //.print "raster:"+raster_line+" sprite data $"+toHexString(sprite_screen) } // Spend the rest of the cycles on NOPS .if(line_cycles<0 || line_cycles==1) .error "Too many cycles spent on line "+raster_line .if(line_cycles>0) { //.print "raster:"+raster_line+" cycles $"+toHexString(line_cycles) RASTER_CYCLES(line_cycles) .eval line_cycles -= line_cycles .eval available_cycles += line_cycles } } //.print "Available cycles: "+available_cycles lda #$6f sta $d000 lda #$8 // Cycle 50. LSR abs is a 6 cycle RWM instruction. lsr VICII_CONTROL2 sta VICII_CONTROL2 RASTER_CYCLES(00) // End of raster code } // SID tune // Pacman 2 channel music by Metal/Camelot INTRO_MUSIC_CRUNCHED: .modify B2() { .pc = INTRO_MUSIC "INTRO MUSIC" .const music = LoadBinary("pacman-2chn-simpler.prg", BF_C64FILE) .fill music.getSize(), music.get(i) } .segment Data // Offset of the LEVEL_TILE data within the LEVEL_TILE data (each row is 64 bytes of data) LEVEL_YTILE_OFFSET: .word 0, $40, $80, $c0, $100, $140, $180, $1c0, $200, $240, $280, $2c0, $300, $340, $380, $3c0, $400, $440, $480, $4c0, $500, $540, $580, $5c0, $600, $640, $680, $6c0, $700, $740, $780, $7c0, $800, $840, $880, $8c0, $900 // Used to choose a single direction when presented with multiple potential directions. // Used to eliminate diagonal joy directions and convert them to a single direction // Priority: (4)up, (8)down, (16)left, (32)right .align $40 DIRECTION_SINGLE: .byte 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 4, $10, $10, $10, $10, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 4, $20, $20, $20, $20, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 4, $10, $10, $10, $10, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 4 // Used to eliminate a single direction (the one that the ghost came from) // The value DIRECTION_ELIMINATE[current_direction] is ANDed onto the open directions to remove the current direction .align $40 DIRECTION_ELIMINATE: .byte $ff, 0, 0, 0, $f7, 0, 0, 0, $fb, 0, 0, 0, 0, 0, 0, 0, $df, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, $ef // Used to reverse direction direction (when a ghost changes between chase and scatter) .align $40 DIRECTION_REVERSE: .byte 0, 0, 0, 0, 8, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, $20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, $10 // The animation frames for pacman. The index into this is DIRECTION + anim_frame_idx. .align $40 pacman_frames: .byte 8, 8, 8, 8, 8, $18, $14, $18, 8, $20, $1c, $20, 0, 0, 0, 0, 8, 4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, $c, $10, $c // The animation frames for ghost. The index into thos is DIRECTION + anim_frame_idx. .align $80 ghost_frames: .byte 0, 0, 0, 0, $3c, $40, $3c, $40, $34, $38, $34, $38, 0, 0, 0, 0, $2c, $30, $2c, $30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $24, $28, $24, $28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $5c, $60, $5c, $60, $54, $58, $54, $58, 0, 0, 0, 0, $4c, $50, $4c, $50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, $44, $48, $44, $48 // Lookup the absolute value of a signed number // PRE_ and POST_ are used to ensure lookup of ABS-1,y works for y=0 and ABS+1,y works for y=0xff .align $100 ABS_PRE: .byte 1 ABS: .for(var i=0;i<$100;i++) { .var x = (i<$80)?i:($100-i); .byte abs(x) } ABS_POST: .byte 0
oeis/216/A216130.asm
neoneye/loda-programs
11
9195
; A216130: 7^n mod 10000. ; Submitted by <NAME>(s2) ; 7,49,343,2401,6807,7649,3543,4801,3607,5249,6743,7201,407,2849,9943,9601,7207,449,3143,2001,4007,8049,6343,4401,807,5649,9543,6801,7607,3249,2743,9201,4407,849,5943,1601,1207,8449,9143,4001,8007,6049,2343,6401,4807,3649,5543,8801,1607,1249,8743,1201,8407,8849,1943,3601,5207,6449,5143,6001,2007,4049,8343,8401,8807,1649,1543,801,5607,9249,4743,3201,2407,6849,7943,5601,9207,4449,1143,8001,6007,2049,4343,401,2807,9649,7543,2801,9607,7249,743,5201,6407,4849,3943,7601,3207,2449,7143,1 add $0,1 mov $1,7 pow $1,$0 mod $1,10000 mov $0,$1
oeis/158/A158329.asm
neoneye/loda-programs
11
164336
<reponame>neoneye/loda-programs ; A158329: 484n^2 - 2n. ; 482,1932,4350,7736,12090,17412,23702,30960,39186,48380,58542,69672,81770,94836,108870,123872,139842,156780,174686,193560,213402,234212,255990,278736,302450,327132,352782,379400,406986,435540,465062,495552,527010,559436,592830,627192,662522,698820,736086,774320,813522,853692,894830,936936,980010,1024052,1069062,1115040,1161986,1209900,1258782,1308632,1359450,1411236,1463990,1517712,1572402,1628060,1684686,1742280,1800842,1860372,1920870,1982336,2044770,2108172,2172542,2237880,2304186,2371460 add $0,1 mul $0,242 bin $0,2 div $0,121 mul $0,2
oeis/061/A061190.asm
neoneye/loda-programs
11
10127
<gh_stars>10-100 ; A061190: a(n) = n^n - n. ; 1,0,2,24,252,3120,46650,823536,16777208,387420480,9999999990,285311670600,8916100448244,302875106592240,11112006825558002,437893890380859360,18446744073709551600,827240261886336764160,39346408075296537575406,1978419655660313589123960,104857599999999999999999980,5842587018385982521381124400,341427877364219557396646723562,20880467999847912034355032910544,1333735776850284124449081472843752,88817841970012523233890533447265600,6156119580207157310796674288400203750 mov $1,$0 pow $0,$0 sub $0,$1
examples/ucd_normalization.adb
ytomino/drake
33
3138
<reponame>ytomino/drake<filename>examples/ucd_normalization.adb<gh_stars>10-100 -- convert UCD/UnicodeData.txt, UCD/CompositionExclusions.txt -- bin/ucd_normalization -r $UCD/UnicodeData.txt $UCD/CompositionExclusions.txt > ../source/strings/a-ucdnor.ads -- bin/ucd_normalization -u $UCD/UnicodeData.txt $UCD/CompositionExclusions.txt > ../source/strings/a-ucnoun.ads with Ada.Command_Line; use Ada.Command_Line; with Ada.Containers.Ordered_Maps; with Ada.Containers.Ordered_Sets; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; with Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Wide_Wide_Unbounded; with Ada.Text_IO; use Ada.Text_IO; procedure ucd_normalization is function Value (S : String) return Wide_Wide_Character is Img : constant String := "Hex_" & (1 .. 8 - S'Length => '0') & S; begin return Wide_Wide_Character'Value (Img); end Value; procedure Put_16 (Item : Integer) is begin if Item >= 16#10000# then Put (Item, Width => 1, Base => 16); else declare S : String (1 .. 8); -- "16#XXXX#" begin Put (S, Item, Base => 16); S (1) := '1'; S (2) := '6'; S (3) := '#'; for I in reverse 4 .. 6 loop if S (I) = '#' then S (4 .. I) := (others => '0'); exit; end if; end loop; Put (S); end; end if; end Put_16; function NFS_Exclusion (C : Wide_Wide_Character) return Boolean is begin case Wide_Wide_Character'Pos (C) is when 16#2000# .. 16#2FFF# | 16#F900# .. 16#FAFF# | 16#2F800# .. 16#2FAFF# => return True; when others => return False; end case; end NFS_Exclusion; package Decomposite_Maps is new Ada.Containers.Ordered_Maps ( Wide_Wide_Character, Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String); use Decomposite_Maps; package WWC_Sets is new Ada.Containers.Ordered_Sets ( Wide_Wide_Character); use WWC_Sets; NFD : Decomposite_Maps.Map; Exclusions : WWC_Sets.Set; type Kind_Type is (Decomposition, Excluded, Singleton); type Bit is (In_16, In_32); function Get_Bit (C : Wide_Wide_Character) return Bit is begin if C > Wide_Wide_Character'Val (16#FFFF#) then return In_32; else return In_16; end if; end Get_Bit; function Get_Bit (S : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String) return Bit is begin for I in 1 .. Length (S) loop if Get_Bit (Element (S, I)) = In_32 then return In_32; end if; end loop; return In_16; end Get_Bit; type Normalization is (D, C); Total_Num : array (Boolean, Normalization) of Natural; Num : array (Boolean, Kind_Type, Bit) of Natural; type Output_Kind is (Reversible, Unreversible); Output : Output_Kind; begin if Argument (1) = "-r" then Output := Reversible; elsif Argument (1) = "-u" then Output := Unreversible; else raise Data_Error with "-r or -u"; end if; declare File : Ada.Text_IO.File_Type; begin Open (File, In_File, Argument (2)); while not End_Of_File (File) loop declare Line : constant String := Get_Line (File); type Range_Type is record First : Positive; Last : Natural; end record; Fields : array (1 .. 14) of Range_Type; P : Positive := Line'First; N : Natural; Token_First : Positive; Token_Last : Natural; Code : Wide_Wide_Character; Alt : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String; begin for I in Fields'Range loop N := P; while N <= Line'Last and then Line (N) /= ';' loop N := N + 1; end loop; if (N <= Line'Last) /= (I < Field'Last) then raise Data_Error with Line & " -- 2A"; end if; Fields (I).First := P; Fields (I).Last := N - 1; P := N + 1; -- skip ';' end loop; Code := Value (Line (Fields (1).First .. Fields (1).Last)); if Fields (6).First <= Fields (6).Last then -- normalization if Line (Fields (6).First) = '<' then null; -- skip NFKD else -- NFD Alt := Null_Unbounded_Wide_Wide_String; P := Fields (6).First; while P <= Fields (6).Last loop Find_Token ( Line (P .. Fields (6).Last), Hexadecimal_Digit_Set, Inside, Token_First, Token_Last); if Token_First /= P then raise Data_Error with Line & " -- 2B"; end if; Append (Alt, Value (Line (Token_First .. Token_Last))); P := Token_Last + 1; exit when P > Fields (6).Last; N := Index_Non_Blank (Line (P .. Fields (6).Last)); if N = 0 then raise Data_Error with Line & " -- 2C"; end if; P := N; end loop; Insert (NFD, Code, Alt); end if; end if; end; end loop; Close (File); end; declare I : Decomposite_Maps.Cursor := First (NFD); begin while Has_Element (I) loop if not NFS_Exclusion (Key (I)) then declare J : Decomposite_Maps.Cursor := Next (I); begin while Has_Element (J) loop if Element (I) = Element (J) then raise Data_Error with "dup"; end if; J := Next (J); end loop; end; end if; I := Next (I); end loop; end; declare File : Ada.Text_IO.File_Type; begin Open (File, In_File, Argument (3)); while not End_Of_File (File) loop declare Line : constant String := Get_Line (File); P : Positive := Line'First; Token_First : Positive; Token_Last : Natural; First : Wide_Wide_Character; begin if Line'Length = 0 or else Line (P) = '#' then null; -- comment else Find_Token ( Line (P .. Line'Last), Hexadecimal_Digit_Set, Inside, Token_First, Token_Last); if Token_First /= P then raise Data_Error with Line & " -- 3A"; end if; First := Value (Line (Token_First .. Token_Last)); P := Token_Last + 1; if Line (P) = '.' then raise Data_Error with Line & " -- 3B"; end if; if not Contains (NFD, First) then raise Data_Error with Line & " -- 3C"; end if; Insert (Exclusions, First); end if; end; end loop; Close (File); end; -- # (4) Non-Starter Decompositions -- # 0344 COMBINING GREEK DIALYTIKA TONOS -- # 0F73 TIBETAN VOWEL SIGN II -- # 0F75 TIBETAN VOWEL SIGN UU -- # 0F81 TIBETAN VOWEL SIGN REVERSED II Insert (Exclusions, Wide_Wide_Character'Val (16#0344#)); Insert (Exclusions, Wide_Wide_Character'Val (16#0F73#)); Insert (Exclusions, Wide_Wide_Character'Val (16#0F75#)); Insert (Exclusions, Wide_Wide_Character'Val (16#0F81#)); -- count for NFSE in Boolean loop for K in Kind_Type loop for B in Bit loop Num (NFSE, K, B) := 0; end loop; end loop; for N in Normalization loop Total_Num (NFSE, N) := 0; end loop; end loop; declare I : Decomposite_Maps.Cursor := First (NFD); begin while Has_Element (I) loop declare NFSE : Boolean := NFS_Exclusion (Key (I)); B : Bit := Bit'Max (Get_Bit (Key (I)), Get_Bit (Element (I))); K : Kind_Type; begin if Contains (Exclusions, Key (I)) then K := Excluded; elsif Length (Element (I)) > 1 then K := Decomposition; Total_Num (NFSE, C) := Total_Num (NFSE, C) + 1; else K := Singleton; end if; Num (NFSE, K, B) := Num (NFSE, K, B) + 1; Total_Num (NFSE, D) := Total_Num (NFSE, D) + 1; end; I := Next (I); end loop; end; -- output the Ada spec case Output is when Reversible => Put_Line ("pragma License (Unrestricted);"); Put_Line ("-- implementation unit,"); Put_Line ("-- translated from UnicodeData.txt (6), CompositionExclusions.txt"); Put_Line ("package Ada.UCD.Normalization is"); Put_Line (" pragma Pure;"); New_Line; Put_Line (" -- excluding U+2000..U+2FFF, U+F900..U+FAFF, and U+2F800..U+2FAFF"); New_Line; Put (" NFD_Total : constant := "); Put (Total_Num (False, D), Width => 1); Put (";"); New_Line; Put (" NFC_Total : constant := "); Put (Total_Num (False, C), Width => 1); Put (";"); New_Line; New_Line; when Unreversible => Put_Line ("pragma License (Unrestricted);"); Put_Line ("-- implementation unit,"); Put_Line ("-- translated from UnicodeData.txt (6), CompositionExclusions.txt"); Put_Line ("package Ada.UCD.Normalization.Unreversible is"); Put_Line (" pragma Pure;"); New_Line; Put_Line (" -- including U+2000..U+2FFF, U+F900..U+FAFF, and U+2F800..U+2FAFF"); New_Line; Put (" NFD_Unreversible_Total : constant := "); Put (Total_Num (True, D), Width => 1); Put (";"); New_Line; Put (" NFC_Unreversible_Total : constant := "); Put (Total_Num (True, C), Width => 1); Put (";"); New_Line; New_Line; end case; declare NFSE : constant Boolean := Output = Unreversible; begin for K in Kind_Type loop for B in Bit loop if Num (NFSE, K, B) /= 0 then Put (" NFD_"); if NFSE then Put ("Unreversible_"); end if; case K is when Decomposition => Put ("D_"); when Excluded => Put ("E_"); when Singleton => Put ("S_"); end case; Put ("Table_"); case B is when In_16 => Put ("XXXX"); when In_32 => Put ("XXXXXXXX"); end case; Put (" : constant Map_"); case B is when In_16 => Put ("16"); when In_32 => Put ("32"); end case; Put ("x"); case K is when Decomposition | Excluded => Put ("2"); when Singleton => Put ("1"); end case; Put ("_Type (1 .. "); Put (Num (NFSE, K, B), Width => 1); Put (") := ("); New_Line; declare I : Decomposite_Maps.Cursor := First (NFD); Second : Boolean := False; begin while Has_Element (I) loop declare Item_NFSE : Boolean := NFS_Exclusion (Key (I)); Item_B : Bit := Bit'Max (Get_Bit (Key (I)), Get_Bit (Element (I))); Item_K : Kind_Type; begin if Contains (Exclusions, Key (I)) then Item_K := Excluded; elsif Length (Element (I)) > 1 then Item_K := Decomposition; else Item_K := Singleton; end if; if Item_NFSE = NFSE and then Item_K = K and then Item_B = B then if Second then Put (","); New_Line; end if; Put (" "); if Num (NFSE, K, B) = 1 then Put ("1 => "); end if; Put ("("); Put_16 (Wide_Wide_Character'Pos (Key (I))); Put (", "); if K = Singleton then Put_16 ( Wide_Wide_Character'Pos ( Element (Element (I), 1))); else declare E : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String renames Element (I); begin Put ("("); for EI in 1 .. Length (E) loop if EI > 1 then Put (", "); end if; Put_16 ( Wide_Wide_Character'Pos ( Element (E, EI))); end loop; Put (")"); end; end if; Put (")"); Second := True; end if; end; I := Next (I); end loop; Put (");"); New_Line; end; New_Line; end if; end loop; end loop; end; case Output is when Reversible => Put_Line ("end Ada.UCD.Normalization;"); when Unreversible => Put_Line ("end Ada.UCD.Normalization.Unreversible;"); end case; end ucd_normalization;
oeis/157/A157877.asm
neoneye/loda-programs
11
10484
<gh_stars>10-100 ; A157877: Expansion of (1-x)*x/(x^2-30*x+1). ; Submitted by <NAME>(s1) ; 1,29,869,26041,780361,23384789,700763309,20999514481,629284671121,18857540619149,565096933903349,16934050476481321,507456417360536281,15206758470339607109,455695297692827676989,13655652172314490702561,409213869871741893399841,12262760443979942311292669,367473599449526527445380229,11011945223041815881050114201,329990883091804949904058045801,9888714547531106681240691259829,296331445542841395487316679749069,8880054651737710757938259701212241,266105308106588481342660474356618161 lpb $0 sub $0,1 mov $1,$3 mul $1,28 add $2,1 add $2,$1 add $3,$2 lpe mov $0,$3 mul $0,28 add $0,1
applescript/setSpace.applescript
dolox/mac-space-maker
10
2560
(** * * Set the active space on the desktop. * * @author <NAME> <<EMAIL>> * @method setSpace * @param {number} inputDelay The delay between opening Mission Control and switching desktops. * @param {number} inputIndex The desktop space to change to. * @returns {undefined} Nothing is returned. * **) on setSpace(inputDelay, inputIndex) -- Launch the Mission Control Application. do shell script "/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control" -- Set a slight delay for Mission Control to finish loading. delay inputDelay -- Catch any errors. try -- Attempt to set the active space. setSpaceIndex(inputIndex, 1, 1) end try end setSpace
memsim-master/src/variance.adb
strenkml/EE368
0
3957
package body Variance is procedure Reset(v : in out Variance_Type) is begin v.sample_count := 0; v.sum := 0.0; v.sum_squares := 0.0; end Reset; procedure Update(v : in out Variance_Type; value : in T) is begin v.sample_count := v.sample_count + 1; v.sum := v.sum + value; v.sum_squares := v.sum_squares + value * value; end Update; function Get_Variance(v : Variance_Type) return T is count : constant T := T(v.sample_count); mean : constant T := v.sum / count; begin if v.sample_count > 0 then return v.sum_squares / count - mean * mean; else return 0.0; end if; end Get_Variance; end Variance;
Scripts Pack Source Items/Scripts Pack/Dock/Dock Show Running Apps Only.applescript
Phorofor/ScriptsPack.macOS
1
2903
# Scripts Pack - Tweak various preference variables in macOS # <Phorofor, https://github.com/Phorofor/> -- Show only running applications in the Dock, if used improperly your current settings will be overwritten. -- Show Running Applications Only -- Version compatible: -- -- Preference Identifier: com.apple.dock -- Preference Key: static-only -- Default value (boolean): NO -- Preference location: ~/Library/Preferences/com.apple.dock.plist try set prValue to do shell script "defaults read com.apple.dock static-only -boolean" if prValue = "1" then set prValue to "[ ! WARNING ! ]: The Dock will only show running applications. Modifying it will cause the normal preferences to be overwritten, please don't drag anything in the Dock or you can lock the Dock so you cannot drag any files across." as string else set prValue to "The Dock is at its default setting." as string end if on error set prValue to "Unknown setting. The Dock lets you modify it with your customized items by default." as string end try display alert "Would you like to use the 3D Glass Dock or the 2D Glass Dock?" message "When the 2D Dock is chosen it will switch to it, the Dock is similiar to OS X Tiger's Dock." & return & return & prValue buttons {"Cancel", "Show Only Running Applications", "Return to Default"} default button 3 cancel button 1 if the button returned of the result is "Show Only Running Applications" then do shell script "defaults write com.apple.dock static-only -boolean YES" display alert "Watch out when choosing this!" message "If this feature is enabled, this will only show applications that are running. Dragging an item on the Dock while this feature is enabled will mess up your setting for the Dock. Should you take the risk of losing your setting or proceed anyway?" buttons ["Flee to the Exit", "Proceed Anyway"] as warning cancel button 1 default button 1 set bT to "You've decided to make the Dock to show only the currently running applications. This feature may mess up your 'default' Dock when modifying it with this setting enabled." else do shell script "defaults write com.apple.dock static-only -boolean NO" set bT to "You've decided to return the normal setting for the Dock." end if (* tell application "System Events" to (name of every process) if the result contains "Dock" then *) tell application "System Events" display alert "Dock - Changes Applied!" message bT & " In order to see your changes the Dock will need to be restarted. Would you like to do that now?" buttons {"Don't restart", "Restart Dock"} cancel button 1 default button 2 do shell script "killall Dock" (* delay 3 display alert "The Dock has been restarted. You should be able to see the changes you've made." *) end tell (* else display dialog "You'll be able to see the changes the next time the Dock is running" end *) end
oeis/343/A343230.asm
neoneye/loda-programs
11
87247
; A343230: A binary encoding of the digits "0" in balanced ternary representation of n. ; Submitted by <NAME> ; 0,0,0,1,0,0,1,0,2,3,2,0,1,0,0,1,0,2,3,2,0,1,0,4,5,4,6,7,6,4,5,4,0,1,0,2,3,2,0,1,0,0,1,0,2,3,2,0,1,0,4,5,4,6,7,6,4,5,4,0,1,0,2,3,2,0,1,0,8,9,8,10,11,10,8,9,8,12,13,12,14,15,14,12,13,12,8,9,8,10,11,10,8,9,8,0,1,0,2,3 mov $2,1 lpb $0 add $0,1 mov $3,$0 div $0,3 add $3,$0 mod $3,2 mul $3,$2 add $1,$3 mul $2,2 lpe mov $0,$1
bootloader.asm
Ninespin/bloader_game_test
0
19981
[org 0x7C00] [BITS 16] start: xor ax, ax mov ds, ax mov ss, ax ; Setup stack [0x9c00; 0] mov sp, 0x9c00 setup_screen: mov ah, 0xb8 mov es, ax xor ah, ah mov al, 0x03 int 0x10 mov ah, 1 mov ch, 0x26 int 0x10 make_blue: mov cx, 0x07d0 ; 80x25 mov ax, 0x0020 ; empty, blue-background char xor di, di rep stosw mainloop: ; infinite loop xor ax, ax mov ah, 0x01 ; read keyboard buffer int 0x16 ; keyboard interrupt cmp al, 0x77 ; if up arrow NOT WORKING je uparrow mov bx, 1 jmp print_buffer uparrow: mov bx, 158 print_buffer: mov di, [DATA.pos] ; position rdtsc ; timestamp to ax mov ah, 0x07 ; set color ; print to screen, increments di stosw ; add to position +1 vertical, increments of two bytes add di, bx mov word [DATA.pos], di ; wait 1 sec mov cx, 0x00f mov dx, 0x4240 mov ah, 0x86 int 0x15 jmp mainloop DATA: .pos: dw 0x0 TIMES 510 - ($ - $$) db 0 DW 0xAA55
oeis/242/A242124.asm
neoneye/loda-programs
11
145
<gh_stars>10-100 ; A242124: Primes modulo 26. ; Submitted by Jon Maiga ; 2,3,5,7,11,13,17,19,23,3,5,11,15,17,21,1,7,9,15,19,21,1,5,11,19,23,25,3,5,9,23,1,7,9,19,21,1,7,11,17,23,25,9,11,15,17,3,15,19,21,25,5,7,17,23,3,9,11,17,21,23,7,21,25,1,5,19,25,9,11,15,21,3,9,15,19,25,7,11,19,3,5,15,17,23,1,7,15,19,21,25,11,19,23,5,9,15,1,3,21 mul $0,2 max $0,1 seq $0,173919 ; Numbers that are prime or one less than a prime. mod $0,26
source/network-managers.adb
reznikmm/network
1
15396
-- SPDX-FileCopyrightText: 2021 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package body Network.Managers is ------------- -- Connect -- ------------- procedure Connect (Self : in out Manager'Class; Address : Network.Addresses.Address; Error : out League.Strings.Universal_String; Promise : out Connection_Promises.Promise; Options : League.String_Vectors.Universal_String_Vector := League.String_Vectors.Empty_Universal_String_Vector) is begin for Proto of Self.Proto (1 .. Self.Last) loop if Proto.Can_Connect (Address) then Proto.Connect (Address, Self.Poll, Error, Promise, Options); return; end if; end loop; Error.Append ("Unknown protocol"); end Connect; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Manager'Class) is begin Self.Poll.Initialize; end Initialize; ------------ -- Listen -- ------------ procedure Listen (Self : in out Manager'Class; List : Network.Addresses.Address_Array; Listener : Connection_Listener_Access; Error : out League.Strings.Universal_String; Options : League.String_Vectors.Universal_String_Vector := League.String_Vectors.Empty_Universal_String_Vector) is Done : array (List'Range) of Boolean := (List'Range => False); begin for Proto of Self.Proto (1 .. Self.Last) loop declare Ok : League.Strings.Universal_String; Slice : Network.Addresses.Address_Array (List'Range); Last : Natural := Slice'First - 1; begin for J in List'Range loop if not Done (J) and then Proto.Can_Listen (List (J)) then Done (J) := True; Last := Last + 1; Slice (Last) := List (J); end if; end loop; if Last >= Slice'First then Proto.Listen (Slice (Slice'First .. Last), Listener, Self.Poll, Ok, Options); Error.Append (Ok); end if; end; end loop; if Done /= (List'Range => True) then for J in Done'Range loop Error.Append ("Unknown protocol for "); Error.Append (Network.Addresses.To_String (List (J))); Error.Append (". "); end loop; end if; end Listen; -------------- -- Register -- -------------- procedure Register (Self : in out Manager; Protocol : not null Protocol_Access) is begin Self.Last := Self.Last + 1; Self.Proto (Self.Last) := Protocol; end Register; ---------- -- Wait -- ---------- procedure Wait (Self : in out Manager'Class; Timeout : Duration) is begin Self.Poll.Wait (Timeout); end Wait; end Network.Managers;
test/Succeed/Issue760.agda
shlevy/agda
2
13012
<reponame>shlevy/agda module Issue760 where module M where A : Set₂ A = Set₁ abstract B : Set₁ B = Set open M public -- Not abstract. C : Set₁ C = F where F = Set -- where clauses declare an anonymous open public module -- but we should not see any error here InScope : A InScope = Set private D : Set₁ D = Set open M public -- Private & public?! E : Set₁ E = F where F = Set -- where clauses declare an anonymous open public module -- but we should not see any error here
programs/oeis/047/A047426.asm
neoneye/loda
22
2753
<filename>programs/oeis/047/A047426.asm<gh_stars>10-100 ; A047426: Numbers that are congruent to {0, 3, 4, 5, 6} mod 8. ; 0,3,4,5,6,8,11,12,13,14,16,19,20,21,22,24,27,28,29,30,32,35,36,37,38,40,43,44,45,46,48,51,52,53,54,56,59,60,61,62,64,67,68,69,70,72,75,76,77,78,80,83,84,85,86,88,91,92,93,94,96,99,100,101,102 mov $1,$0 lpb $1 trn $1,4 add $0,$1 trn $1,1 sub $0,$1 add $0,2 lpe
include/bits_byteswap_h.ads
docandrew/troodon
5
7394
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package bits_byteswap_h is -- Macros and inline functions to swap the order of bytes in integer values. -- Copyright (C) 1997-2021 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library 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. -- The GNU C Library 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 the GNU C Library; if not, see -- <https://www.gnu.org/licenses/>. -- Swap bytes in 16-bit value. -- skipped func __bswap_16 -- Swap bytes in 32-bit value. -- skipped func __bswap_32 -- Swap bytes in 64-bit value. -- skipped func __bswap_64 end bits_byteswap_h;
test/interaction/Issue2210.agda
cruhland/agda
1,989
17287
<filename>test/interaction/Issue2210.agda module _ where record R : Set₁ where field Type : Set postulate A : Set module M (x : A) (r₁ : R) (y : A) where open R r₁ r₂ : R r₂ = record { Type = A } foo : R.Type r₂ foo = {!!} -- R.Type r₂ bar : R.Type r₁ bar = {!!} -- Type
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr14_pkg.ads
best08618/asylo
7
4221
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr14_pkg.ads package Aggr14_Pkg is type A is array (Integer range 1 .. 3) of Short_Short_Integer; X : A := (1, 2, 3); procedure Proc; end Aggr14_Pkg;
test/Succeed/Issue2223/Setoids.agda
shlevy/agda
1,989
7536
-- Andreas, 2016-10-09, re issue #2223 module Issue2223.Setoids where open import Common.Level record Setoid c ℓ : Set (lsuc (c ⊔ ℓ)) where infix 4 _≈_ field Carrier : Set c _≈_ : (x y : Carrier) → Set ℓ _⟨_⟩_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → A → (A → B → C) → B → C x ⟨ f ⟩ y = f x y
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/lto18.ads
best08618/asylo
7
27558
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/lto18.ads with Lto18_Pkg; use Lto18_Pkg; package Lto18 is procedure Proc (Driver : Rec); end Lto18;
tools-src/gnu/gcc/gcc/ada/prj-strt.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
20473
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . S T R T -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 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 Errout; use Errout; with Prj.Attr; use Prj.Attr; with Prj.Tree; use Prj.Tree; with Scans; use Scans; with Sinfo; use Sinfo; with Stringt; use Stringt; with Table; with Types; use Types; package body Prj.Strt is Initial_Size : constant := 8; type Name_Location is record Name : Name_Id := No_Name; Location : Source_Ptr := No_Location; end record; -- Store the identifier and the location of a simple name type Name_Range is range 0 .. 3; subtype Name_Index is Name_Range range 1 .. Name_Range'Last; -- A Name may contain up to 3 simple names type Names is array (Name_Index) of Name_Location; -- Used to store 1 to 3 simple_names. 2 simple names are for -- <project>.<package>, <project>.<variable> or <package>.<variable>. -- 3 simple names are for <project>.<package>.<variable>. type Choice_String is record The_String : String_Id; Already_Used : Boolean := False; end record; -- The string of a case label, and an indication that it has already -- been used (to avoid duplicate case labels). Choices_Initial : constant := 10; Choices_Increment : constant := 10; Choice_Node_Low_Bound : constant := 0; Choice_Node_High_Bound : constant := 099_999_999; -- In practice, infinite type Choice_Node_Id is range Choice_Node_Low_Bound .. Choice_Node_High_Bound; First_Choice_Node_Id : constant Choice_Node_Id := Choice_Node_Low_Bound; Empty_Choice : constant Choice_Node_Id := Choice_Node_Low_Bound; First_Choice_Id : constant Choice_Node_Id := First_Choice_Node_Id + 1; package Choices is new Table.Table (Table_Component_Type => Choice_String, Table_Index_Type => Choice_Node_Id, Table_Low_Bound => First_Choice_Node_Id, Table_Initial => Choices_Initial, Table_Increment => Choices_Increment, Table_Name => "Prj.Strt.Choices"); -- Used to store the case labels and check that there is no duplicate. package Choice_Lasts is new Table.Table (Table_Component_Type => Choice_Node_Id, Table_Index_Type => Nat, Table_Low_Bound => 1, Table_Initial => 3, Table_Increment => 3, Table_Name => "Prj.Strt.Choice_Lasts"); -- Used to store the indices of the choices in table Choices, -- to distinguish nested case constructions. Choice_First : Choice_Node_Id := 0; -- Index in table Choices of the first case label of the current -- case construction. -- 0 means no current case construction. procedure Add (This_String : String_Id); -- Add a string to the case label list, indicating that it has not -- yet been used. procedure External_Reference (External_Value : out Project_Node_Id); -- Parse an external reference. Current token is "external". procedure Attribute_Reference (Reference : out Project_Node_Id; First_Attribute : Attribute_Node_Id; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id); -- Parse an attribute reference. Current token is an apostrophe. procedure Terms (Term : out Project_Node_Id; Expr_Kind : in out Variable_Kind; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id); -- Recursive procedure to parse one term or several terms concatenated -- using "&". --------- -- Add -- --------- procedure Add (This_String : String_Id) is begin Choices.Increment_Last; Choices.Table (Choices.Last) := (The_String => This_String, Already_Used => False); end Add; ------------------------- -- Attribute_Reference -- ------------------------- procedure Attribute_Reference (Reference : out Project_Node_Id; First_Attribute : Attribute_Node_Id; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is Current_Attribute : Attribute_Node_Id := First_Attribute; begin Reference := Default_Project_Node (Of_Kind => N_Attribute_Reference); Set_Location_Of (Reference, To => Token_Ptr); Scan; -- past apostrophe Expect (Tok_Identifier, "Identifier"); if Token = Tok_Identifier then Set_Name_Of (Reference, To => Token_Name); while Current_Attribute /= Empty_Attribute and then Attributes.Table (Current_Attribute).Name /= Token_Name loop Current_Attribute := Attributes.Table (Current_Attribute).Next; end loop; if Current_Attribute = Empty_Attribute then Error_Msg ("unknown attribute", Token_Ptr); Reference := Empty_Node; elsif Attributes.Table (Current_Attribute).Kind_2 = Associative_Array then Error_Msg ("associative array attribute cannot be referenced", Token_Ptr); Reference := Empty_Node; else Set_Project_Node_Of (Reference, To => Current_Project); Set_Package_Node_Of (Reference, To => Current_Package); Set_Expression_Kind_Of (Reference, To => Attributes.Table (Current_Attribute).Kind_1); Scan; end if; end if; end Attribute_Reference; --------------------------- -- End_Case_Construction -- --------------------------- procedure End_Case_Construction is begin if Choice_Lasts.Last = 1 then Choice_Lasts.Set_Last (0); Choices.Set_Last (First_Choice_Node_Id); Choice_First := 0; elsif Choice_Lasts.Last = 2 then Choice_Lasts.Set_Last (1); Choices.Set_Last (Choice_Lasts.Table (1)); Choice_First := 1; else Choice_Lasts.Decrement_Last; Choices.Set_Last (Choice_Lasts.Table (Choice_Lasts.Last)); Choice_First := Choice_Lasts.Table (Choice_Lasts.Last - 1) + 1; end if; end End_Case_Construction; ------------------------ -- External_Reference -- ------------------------ procedure External_Reference (External_Value : out Project_Node_Id) is Field_Id : Project_Node_Id := Empty_Node; begin External_Value := Default_Project_Node (Of_Kind => N_External_Value, And_Expr_Kind => Single); Set_Location_Of (External_Value, To => Token_Ptr); -- The current token is External -- Get the left parenthesis Scan; Expect (Tok_Left_Paren, "("); -- Scan past the left parenthesis if Token = Tok_Left_Paren then Scan; end if; -- Get the name of the external reference Expect (Tok_String_Literal, "literal string"); if Token = Tok_String_Literal then Field_Id := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Set_String_Value_Of (Field_Id, To => Strval (Token_Node)); Set_External_Reference_Of (External_Value, To => Field_Id); -- Scan past the first argument Scan; case Token is when Tok_Right_Paren => -- Scan past the right parenthesis Scan; when Tok_Comma => -- Scan past the comma Scan; Expect (Tok_String_Literal, "literal string"); -- Get the default if Token = Tok_String_Literal then Field_Id := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Set_String_Value_Of (Field_Id, To => Strval (Token_Node)); Set_External_Default_Of (External_Value, To => Field_Id); Scan; Expect (Tok_Right_Paren, ")"); end if; -- Scan past the right parenthesis if Token = Tok_Right_Paren then Scan; end if; when others => Error_Msg ("',' or ')' expected", Token_Ptr); end case; end if; end External_Reference; ----------------------- -- Parse_Choice_List -- ----------------------- procedure Parse_Choice_List (First_Choice : out Project_Node_Id) is Current_Choice : Project_Node_Id := Empty_Node; Next_Choice : Project_Node_Id := Empty_Node; Choice_String : String_Id := No_String; Found : Boolean := False; begin First_Choice := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Current_Choice := First_Choice; loop Expect (Tok_String_Literal, "literal string"); exit when Token /= Tok_String_Literal; Set_Location_Of (Current_Choice, To => Token_Ptr); Choice_String := Strval (Token_Node); Set_String_Value_Of (Current_Choice, To => Choice_String); Found := False; for Choice in Choice_First .. Choices.Last loop if String_Equal (Choices.Table (Choice).The_String, Choice_String) then Found := True; if Choices.Table (Choice).Already_Used then Error_Msg ("duplicate case label", Token_Ptr); else Choices.Table (Choice).Already_Used := True; end if; exit; end if; end loop; if not Found then Error_Msg ("illegal case label", Token_Ptr); end if; Scan; if Token = Tok_Vertical_Bar then Next_Choice := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Set_Next_Literal_String (Current_Choice, To => Next_Choice); Current_Choice := Next_Choice; Scan; else exit; end if; end loop; end Parse_Choice_List; ---------------------- -- Parse_Expression -- ---------------------- procedure Parse_Expression (Expression : out Project_Node_Id; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is First_Term : Project_Node_Id := Empty_Node; Expression_Kind : Variable_Kind := Undefined; begin Expression := Default_Project_Node (Of_Kind => N_Expression); Set_Location_Of (Expression, To => Token_Ptr); Terms (Term => First_Term, Expr_Kind => Expression_Kind, Current_Project => Current_Project, Current_Package => Current_Package); Set_First_Term (Expression, To => First_Term); Set_Expression_Kind_Of (Expression, To => Expression_Kind); end Parse_Expression; ---------------------------- -- Parse_String_Type_List -- ---------------------------- procedure Parse_String_Type_List (First_String : out Project_Node_Id) is Last_String : Project_Node_Id := Empty_Node; Next_String : Project_Node_Id := Empty_Node; String_Value : String_Id := No_String; begin First_String := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Last_String := First_String; loop Expect (Tok_String_Literal, "literal string"); exit when Token /= Tok_String_Literal; String_Value := Strval (Token_Node); Set_String_Value_Of (Last_String, To => String_Value); Set_Location_Of (Last_String, To => Token_Ptr); declare Current : Project_Node_Id := First_String; begin while Current /= Last_String loop if String_Equal (String_Value_Of (Current), String_Value) then Error_Msg ("duplicate value in type", Token_Ptr); exit; end if; Current := Next_Literal_String (Current); end loop; end; Scan; if Token /= Tok_Comma then exit; else Next_String := Default_Project_Node (Of_Kind => N_Literal_String, And_Expr_Kind => Single); Set_Next_Literal_String (Last_String, To => Next_String); Last_String := Next_String; Scan; end if; end loop; end Parse_String_Type_List; ------------------------------ -- Parse_Variable_Reference -- ------------------------------ procedure Parse_Variable_Reference (Variable : out Project_Node_Id; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is The_Names : Names; Last_Name : Name_Range := 0; Current_Variable : Project_Node_Id := Empty_Node; The_Package : Project_Node_Id := Current_Package; The_Project : Project_Node_Id := Current_Project; Specified_Project : Project_Node_Id := Empty_Node; Specified_Package : Project_Node_Id := Empty_Node; Look_For_Variable : Boolean := True; First_Attribute : Attribute_Node_Id := Empty_Attribute; Variable_Name : Name_Id; begin for Index in The_Names'Range loop Expect (Tok_Identifier, "identifier"); if Token /= Tok_Identifier then Look_For_Variable := False; exit; end if; Last_Name := Last_Name + 1; The_Names (Last_Name) := (Name => Token_Name, Location => Token_Ptr); Scan; exit when Token /= Tok_Dot; Scan; end loop; if Look_For_Variable then if Token = Tok_Apostrophe then -- Attribute reference case Last_Name is when 0 => -- Cannot happen null; when 1 => for Index in Package_First .. Package_Attributes.Last loop if Package_Attributes.Table (Index).Name = The_Names (1).Name then First_Attribute := Package_Attributes.Table (Index).First_Attribute; exit; end if; end loop; if First_Attribute /= Empty_Attribute then The_Package := First_Package_Of (Current_Project); while The_Package /= Empty_Node and then Name_Of (The_Package) /= The_Names (1).Name loop The_Package := Next_Package_In_Project (The_Package); end loop; if The_Package = Empty_Node then Error_Msg ("package not yet defined", The_Names (1).Location); end if; else First_Attribute := Attribute_First; The_Package := Empty_Node; declare The_Project_Name_And_Node : constant Tree_Private_Part.Project_Name_And_Node := Tree_Private_Part.Projects_Htable.Get (The_Names (1).Name); use Tree_Private_Part; begin if The_Project_Name_And_Node = Tree_Private_Part.No_Project_Name_And_Node then Error_Msg ("unknown project", The_Names (1).Location); else The_Project := The_Project_Name_And_Node.Node; end if; end; end if; when 2 => declare With_Clause : Project_Node_Id := First_With_Clause_Of (Current_Project); begin while With_Clause /= Empty_Node loop The_Project := Project_Node_Of (With_Clause); exit when Name_Of (The_Project) = The_Names (1).Name; With_Clause := Next_With_Clause_Of (With_Clause); end loop; if With_Clause = Empty_Node then Error_Msg ("unknown project", The_Names (1).Location); The_Project := Empty_Node; The_Package := Empty_Node; First_Attribute := Attribute_First; else The_Package := First_Package_Of (The_Project); while The_Package /= Empty_Node and then Name_Of (The_Package) /= The_Names (2).Name loop The_Package := Next_Package_In_Project (The_Package); end loop; if The_Package = Empty_Node then Error_Msg ("package not declared in project", The_Names (2).Location); First_Attribute := Attribute_First; else First_Attribute := Package_Attributes.Table (Package_Id_Of (The_Package)).First_Attribute; end if; end if; end; when 3 => Error_Msg ("too many single names for an attribute reference", The_Names (1).Location); Scan; Variable := Empty_Node; return; end case; Attribute_Reference (Variable, Current_Project => The_Project, Current_Package => The_Package, First_Attribute => First_Attribute); return; end if; end if; Variable := Default_Project_Node (Of_Kind => N_Variable_Reference); if Look_For_Variable then case Last_Name is when 0 => -- Cannot happen null; when 1 => Set_Name_Of (Variable, To => The_Names (1).Name); -- Header comment needed ??? when 2 => Set_Name_Of (Variable, To => The_Names (2).Name); The_Package := First_Package_Of (Current_Project); while The_Package /= Empty_Node and then Name_Of (The_Package) /= The_Names (1).Name loop The_Package := Next_Package_In_Project (The_Package); end loop; if The_Package /= Empty_Node then Specified_Package := The_Package; The_Project := Empty_Node; else declare With_Clause : Project_Node_Id := First_With_Clause_Of (Current_Project); begin while With_Clause /= Empty_Node loop The_Project := Project_Node_Of (With_Clause); exit when Name_Of (The_Project) = The_Names (1).Name; With_Clause := Next_With_Clause_Of (With_Clause); end loop; if With_Clause = Empty_Node then The_Project := Modified_Project_Of (Project_Declaration_Of (Current_Project)); if The_Project /= Empty_Node and then Name_Of (The_Project) /= The_Names (1).Name then The_Project := Empty_Node; end if; end if; if The_Project = Empty_Node then Error_Msg ("unknown package or project", The_Names (1).Location); Look_For_Variable := False; else Specified_Project := The_Project; end if; end; end if; -- Header comment needed ??? when 3 => Set_Name_Of (Variable, To => The_Names (3).Name); declare With_Clause : Project_Node_Id := First_With_Clause_Of (Current_Project); begin while With_Clause /= Empty_Node loop The_Project := Project_Node_Of (With_Clause); exit when Name_Of (The_Project) = The_Names (1).Name; With_Clause := Next_With_Clause_Of (With_Clause); end loop; if With_Clause = Empty_Node then The_Project := Modified_Project_Of (Project_Declaration_Of (Current_Project)); if The_Project /= Empty_Node and then Name_Of (The_Project) /= The_Names (1).Name then The_Project := Empty_Node; end if; end if; if The_Project = Empty_Node then Error_Msg ("unknown package or project", The_Names (1).Location); Look_For_Variable := False; else Specified_Project := The_Project; The_Package := First_Package_Of (The_Project); while The_Package /= Empty_Node and then Name_Of (The_Package) /= The_Names (2).Name loop The_Package := Next_Package_In_Project (The_Package); end loop; if The_Package = Empty_Node then Error_Msg ("unknown package", The_Names (2).Location); Look_For_Variable := False; else Specified_Package := The_Package; The_Project := Empty_Node; end if; end if; end; end case; end if; if Look_For_Variable then Variable_Name := Name_Of (Variable); Set_Project_Node_Of (Variable, To => Specified_Project); Set_Package_Node_Of (Variable, To => Specified_Package); if The_Package /= Empty_Node then Current_Variable := First_Variable_Of (The_Package); while Current_Variable /= Empty_Node and then Name_Of (Current_Variable) /= Variable_Name loop Current_Variable := Next_Variable (Current_Variable); end loop; end if; if Current_Variable = Empty_Node and then The_Project /= Empty_Node then Current_Variable := First_Variable_Of (The_Project); while Current_Variable /= Empty_Node and then Name_Of (Current_Variable) /= Variable_Name loop Current_Variable := Next_Variable (Current_Variable); end loop; end if; if Current_Variable = Empty_Node then Error_Msg ("unknown variable", The_Names (Last_Name).Location); end if; end if; if Current_Variable /= Empty_Node then Set_Expression_Kind_Of (Variable, To => Expression_Kind_Of (Current_Variable)); if Kind_Of (Current_Variable) = N_Typed_Variable_Declaration then Set_String_Type_Of (Variable, To => String_Type_Of (Current_Variable)); end if; end if; end Parse_Variable_Reference; --------------------------------- -- Start_New_Case_Construction -- --------------------------------- procedure Start_New_Case_Construction (String_Type : Project_Node_Id) is Current_String : Project_Node_Id; begin if Choice_First = 0 then Choice_First := 1; Choices.Set_Last (First_Choice_Node_Id); else Choice_First := Choices.Last + 1; end if; if String_Type /= Empty_Node then Current_String := First_Literal_String (String_Type); while Current_String /= Empty_Node loop Add (This_String => String_Value_Of (Current_String)); Current_String := Next_Literal_String (Current_String); end loop; end if; Choice_Lasts.Increment_Last; Choice_Lasts.Table (Choice_Lasts.Last) := Choices.Last; end Start_New_Case_Construction; ----------- -- Terms -- ----------- procedure Terms (Term : out Project_Node_Id; Expr_Kind : in out Variable_Kind; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is Next_Term : Project_Node_Id := Empty_Node; Term_Id : Project_Node_Id := Empty_Node; Current_Expression : Project_Node_Id := Empty_Node; Next_Expression : Project_Node_Id := Empty_Node; Current_Location : Source_Ptr := No_Location; Reference : Project_Node_Id := Empty_Node; begin Term := Default_Project_Node (Of_Kind => N_Term); Set_Location_Of (Term, To => Token_Ptr); case Token is when Tok_Left_Paren => case Expr_Kind is when Undefined => Expr_Kind := List; when List => null; when Single => Expr_Kind := List; Error_Msg ("literal string list cannot appear in a string", Token_Ptr); end case; Term_Id := Default_Project_Node (Of_Kind => N_Literal_String_List, And_Expr_Kind => List); Set_Current_Term (Term, To => Term_Id); Set_Location_Of (Term, To => Token_Ptr); Scan; if Token = Tok_Right_Paren then Scan; else loop Current_Location := Token_Ptr; Parse_Expression (Expression => Next_Expression, Current_Project => Current_Project, Current_Package => Current_Package); if Expression_Kind_Of (Next_Expression) = List then Error_Msg ("single expression expected", Current_Location); end if; if Current_Expression = Empty_Node then Set_First_Expression_In_List (Term_Id, To => Next_Expression); else Set_Next_Expression_In_List (Current_Expression, To => Next_Expression); end if; Current_Expression := Next_Expression; exit when Token /= Tok_Comma; Scan; -- past the comma end loop; Expect (Tok_Right_Paren, "("); if Token = Tok_Right_Paren then Scan; end if; end if; when Tok_String_Literal => if Expr_Kind = Undefined then Expr_Kind := Single; end if; Term_Id := Default_Project_Node (Of_Kind => N_Literal_String); Set_Current_Term (Term, To => Term_Id); Set_String_Value_Of (Term_Id, To => Strval (Token_Node)); Scan; when Tok_Identifier => Current_Location := Token_Ptr; Parse_Variable_Reference (Variable => Reference, Current_Project => Current_Project, Current_Package => Current_Package); Set_Current_Term (Term, To => Reference); if Reference /= Empty_Node then if Expr_Kind = Undefined then Expr_Kind := Expression_Kind_Of (Reference); elsif Expr_Kind = Single and then Expression_Kind_Of (Reference) = List then Expr_Kind := List; Error_Msg ("list variable cannot appear in single string expression", Current_Location); end if; end if; when Tok_Project => Current_Location := Token_Ptr; Scan; Expect (Tok_Apostrophe, "'"); if Token = Tok_Apostrophe then Attribute_Reference (Reference => Reference, First_Attribute => Prj.Attr.Attribute_First, Current_Project => Current_Project, Current_Package => Empty_Node); Set_Current_Term (Term, To => Reference); end if; if Reference /= Empty_Node then if Expr_Kind = Undefined then Expr_Kind := Expression_Kind_Of (Reference); elsif Expr_Kind = Single and then Expression_Kind_Of (Reference) = List then Error_Msg ("lists cannot appear in single string expression", Current_Location); end if; end if; when Tok_External => if Expr_Kind = Undefined then Expr_Kind := Single; end if; External_Reference (External_Value => Reference); Set_Current_Term (Term, To => Reference); when others => Error_Msg ("cannot be part of an expression", Token_Ptr); Term := Empty_Node; return; end case; if Token = Tok_Ampersand then Scan; Terms (Term => Next_Term, Expr_Kind => Expr_Kind, Current_Project => Current_Project, Current_Package => Current_Package); Set_Next_Term (Term, To => Next_Term); end if; end Terms; end Prj.Strt;
3-mid/impact/source/3d/collision/narrowphase/impact-d3-collision-convex_penetration_depth_solver.ads
charlie5/lace
20
19936
<reponame>charlie5/lace with impact.d3.Shape.convex, impact.d3.collision.simplex_Solver; package impact.d3.collision.convex_penetration_depth_Solver -- -- ConvexPenetrationDepthSolver provides an interface for penetration depth calculation. -- is use Math; type Item is abstract tagged null record; procedure destruct (Self : in out Item) is null; function calcPenDepth (Self : access Item; simplexSolver : access impact.d3.collision.simplex_Solver.Item'Class; convexA, convexB : in impact.d3.Shape.convex.view; transA, transB : in Transform_3d; v : access math.Vector_3; pa, pb : access math.Vector_3) return Boolean is abstract; end impact.d3.collision.convex_penetration_depth_Solver;
3-mid/physics/implement/bullet/source/thin/bullet_c-ray_collision.ads
charlie5/lace
20
5470
<gh_stars>10-100 -- This file is generated by SWIG. Please do *not* modify by hand. -- with c_math_c; with c_math_c.Vector_3; with Interfaces.C; package bullet_c.ray_Collision is -- Item -- type Item is record near_Object : access bullet_c.Object; hit_Fraction : aliased c_math_c.Real; Normal_world : aliased c_math_c.Vector_3.Item; Site_world : aliased c_math_c.Vector_3.Item; end record; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased bullet_c.ray_Collision.Item; -- Pointer -- type Pointer is access all bullet_c.ray_Collision.Item; -- Pointers -- type Pointers is array (Interfaces.C .size_t range <>) of aliased bullet_c.ray_Collision.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all bullet_c.ray_Collision.Pointer; function construct return bullet_c.ray_Collision.Item; private pragma Import (C, construct, "Ada_new_ray_Collision"); end bullet_c.ray_Collision;
programs/oeis/059/A059536.asm
jmorken/loda
1
89896
; A059536: Beatty sequence for zeta(2)/(zeta(2)-1). ; 2,5,7,10,12,15,17,20,22,25,28,30,33,35,38,40,43,45,48,51,53,56,58,61,63,66,68,71,73,76,79,81,84,86,89,91,94,96,99,102,104,107,109,112,114,117,119,122,124,127,130,132,135,137,140,142,145,147,150,153,155,158,160,163,165,168,170,173,175,178,181,183,186,188,191,193,196,198,201,204,206,209,211,214,216,219,221,224,226,229,232,234,237,239,242,244,247,249,252,255,257,260,262,265,267,270,272,275,278,280,283,285,288,290,293,295,298,300,303,306,308,311,313,316,318,321,323,326,329,331,334,336,339,341,344,346,349,351,354,357,359,362,364,367,369,372,374,377,380,382,385,387,390,392,395,397,400,402,405,408,410,413,415,418,420,423,425,428,431,433,436,438,441,443,446,448,451,453,456,459,461,464,466,469,471,474,476,479,482,484,487,489,492,494,497,499,502,505,507,510,512,515,517,520,522,525,527,530,533,535,538,540,543,545,548,550,553,556,558,561,563,566,568,571,573,576,578,581,584,586,589,591,594,596,599,601,604,607,609,612,614,617,619,622,624,627,629,632,635,637 mov $27,$0 mov $29,$0 add $29,1 lpb $29 clr $0,27 mov $0,$27 sub $29,1 sub $0,$29 add $4,$0 mov $26,$0 cmp $26,0 add $0,$26 div $4,$0 sub $4,3 cal $0,276856 ; First differences of the Beatty sequence A022840 for sqrt(6). mul $0,3 mov $1,$0 mul $4,2 sub $4,2 add $1,$4 mov $26,$1 cmp $26,0 mov $1,$26 add $1,2 add $28,$1 lpe mov $1,$28
oeis/214/A214281.asm
neoneye/loda-programs
11
22683
; A214281: Triangle by rows, row n contains the ConvOffs transform of the first n terms of 1, 1, 3, 2, 5, 3, 7,... (A026741 without leading zero). ; Submitted by <NAME> ; 1,1,1,1,1,1,1,3,3,1,1,2,6,2,1,1,5,10,10,5,1,1,3,15,10,15,3,1,1,7,21,35,35,21,7,1,1,4,28,28,70,28,28,4,1,1,9,36,84,126,126,84,36,9,1,1,5,45,60,210,126,210,60,45,5,1,1,11,55,165,330,462,462,330,165,55,11,1 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe bin $1,$0 mul $2,$0 mov $0,2 gcd $2,2 add $2,6 pow $0,$2 mul $1,$0 mov $0,$1 div $0,256
tests/data_simple/26.asm
NullMember/customasm
414
7288
#d0 0x0 ; error: unknown directive
libsrc/ctype/toascii.asm
andydansby/z88dk-mk2
1
179158
; ; Small C+ Library ; ; ctype/toascii(char c) ; returns c&127 ; ; djm 1/3/99 ; ; $Id: toascii.asm,v 1.3 2006/12/31 21:44:58 aralbrec Exp $ ; XLIB toascii ; FASTCALL .toascii res 7,l ld h,0 ret
Vec.agda
pigworker/InteriorDesign
6
5032
module Vec where open import Basics open import Ix open import All open import Cutting open import Tensor data Vec (X : Set) : Nat -> Set where [] : Vec X zero _,-_ : forall {n} -> X -> Vec X n -> Vec X (suc n) _+V_ : forall {X n m} -> Vec X n -> Vec X m -> Vec X (n +N m) [] +V ys = ys (x ,- xs) +V ys = x ,- (xs +V ys) record Applicative (F : Set -> Set) : Set1 where field pure : {X : Set} -> X -> F X _<*>_ : {S T : Set} -> F (S -> T) -> F S -> F T infixl 2 _<*>_ VecAppl : (n : Nat) -> Applicative \ X -> Vec X n Applicative.pure (VecAppl zero) x = [] Applicative.pure (VecAppl (suc n)) x = x ,- Applicative.pure (VecAppl n) x Applicative._<*>_ (VecAppl .zero) [] [] = [] Applicative._<*>_ (VecAppl .(suc _)) (f ,- fs) (s ,- ss) = f s ,- Applicative._<*>_ (VecAppl _) fs ss module VTRAVERSE {F}(A : Applicative F) where open Applicative A vtraverse : forall {n S T} -> (S -> F T) -> Vec S n -> F (Vec T n) vtraverse f [] = pure [] vtraverse f (s ,- ss) = pure _,-_ <*> f s <*> vtraverse f ss Matrix : Set -> Nat * Nat -> Set Matrix X (i , j) = Vec (Vec X i) j xpose : forall {X ij} -> Matrix X ij -> Matrix X (swap ij) xpose = vtraverse id where open VTRAVERSE (VecAppl _) module VECALL {I : Set}{P : I -> Set}{n : Nat}where open Applicative (VecAppl n) vecAll : {is : List I} -> All (\ i -> Vec (P i) n) is -> Vec (All P is) n vecAll {[]} pss = pure <> vecAll {i ,- is} (ps , pss) = pure _,_ <*> ps <*> vecAll pss VecLiftAlg : (C : I |> I) -> Algebra (Cutting C) P -> Algebra (Cutting C) (\ i -> Vec (P i) n) VecLiftAlg C alg i (c 8>< pss) = pure (alg i << (c 8><_)) <*> vecAll pss open VECALL NatCutVecAlg : {X : Set} -> Algebra (Cutting NatCut) (Vec X) NatCutVecAlg {X} .(m +N n) (m , n , refl .(m +N n) 8>< xm , xn , <>) = xm +V xn open RECTANGLE NatCut2DMatAlg : {X : Set} -> Algebra (Cutting RectCut) (Matrix X) NatCut2DMatAlg _ (inl c 8>< ms) = VecLiftAlg NatCut NatCutVecAlg _ (c 8>< ms) NatCut2DMatAlg _ (inr c 8>< ms) = NatCutVecAlg _ (c 8>< ms)
examples/exception_save.adb
ytomino/drake
33
29321
<filename>examples/exception_save.adb with Ada.Exceptions; procedure exception_save is S : Ada.Exceptions.Exception_Occurrence; begin -- Save_Exception Ada.Exceptions.Save_Exception (S, Constraint_Error'Identity, Message => "save!"); Ada.Debug.Put ("(1)"); begin Ada.Exceptions.Reraise_Occurrence (S); raise Program_Error; exception when X : Constraint_Error => Ada.Debug.Put (Ada.Exceptions.Exception_Information (X)); pragma Assert (Ada.Exceptions.Exception_Message (X) = "save!"); null; end; -- Save_Exception_From_Here Ada.Exceptions.Save_Exception_From_Here (S, Tasking_Error'Identity); -- line 18 Ada.Debug.Put ("(2)"); begin Ada.Exceptions.Reraise_Occurrence (S); raise Program_Error; exception when X : Tasking_Error => Ada.Debug.Put (Ada.Exceptions.Exception_Information (X)); pragma Assert (Ada.Exceptions.Exception_Message (X) = "exception_save.adb:18 explicit raise"); null; end; pragma Debug (Ada.Debug.Put ("OK")); end exception_save;
softwares/TEST2.asm
FerrisChi/minisys-3
0
163284
<gh_stars>0 .DATA 0x0000 LED: .word 0XAAAAAAAA LED2: .word 0XC33C0000 .TEXT 0x0000 start: lui $28, 0xFFFF ori $28,$28,0XF000 lw $3, LED($zero) lw $4, LED2($zero) srl $4,$4,16 sw $3,0XC60($28) sw $4,0XC62($28) j start
video/VideoBlock.asm
puzzud/puzl6502
0
167493
<filename>video/VideoBlock.asm ;------------------------------------------------------------------ !zone DrawBlock DrawBlock lda #BLOCK_STANDARD_NW sta PARAM1 lda #(COLOR_LIGHT_GREEN | $f0) jsr PrintChar lda #BLOCK_STANDARD_NE sta PARAM1 lda #(COLOR_LIGHT_GREEN | $f0) inx jsr PrintChar lda #BLOCK_STANDARD_SE sta PARAM1 lda #(COLOR_LIGHT_GREEN | $f0) iny jsr PrintChar lda #BLOCK_STANDARD_SW sta PARAM1 lda #(COLOR_LIGHT_GREEN | $f0) dex jsr PrintChar dey rts
Confuser.Core/ObfAttrLexer.g4
lysep-corp/ConfuserEx-LSREMAKE
9
2355
<gh_stars>1-10 lexer grammar ObfAttrLexer; fragment A : ( 'a' | 'A' ); fragment B : ( 'b' | 'B' ); fragment C : ( 'c' | 'C' ); fragment D : ( 'd' | 'D' ); fragment E : ( 'e' | 'E' ); fragment F : ( 'f' | 'F' ); fragment G : ( 'g' | 'G' ); fragment H : ( 'h' | 'H' ); fragment I : ( 'i' | 'I' ); fragment J : ( 'j' | 'J' ); fragment K : ( 'k' | 'K' ); fragment L : ( 'l' | 'L' ); fragment M : ( 'm' | 'M' ); fragment N : ( 'n' | 'N' ); fragment O : ( 'o' | 'O' ); fragment P : ( 'p' | 'P' ); fragment Q : ( 'q' | 'Q' ); fragment R : ( 'r' | 'R' ); fragment S : ( 's' | 'S' ); fragment T : ( 't' | 'T' ); fragment U : ( 'u' | 'U' ); fragment V : ( 'v' | 'V' ); fragment W : ( 'w' | 'W' ); fragment X : ( 'x' | 'X' ); fragment Y : ( 'y' | 'Y' ); fragment Z : ( 'z' | 'Z' ); fragment F_PLUS : '+'; fragment F_MINUS : '-'; fragment F_EQUAL : '='; fragment F_PAREN_OPEN : '('; fragment F_PAREN_CLOSE : ')'; fragment F_COMMA : ','; fragment F_SEMICOLON : ';'; fragment F_SINGLE_QUOTE : '\''; fragment F_ESCAPE_CHAR : '\\'; // This looks ugly, but it's due to this bug: https://github.com/antlr/antlr4/issues/70 fragment F_NO_CONTROL_CHAR : ~( '+' | '-' | '=' | '(' | ')' | ',' | ';' ); fragment F_NO_QUOTE_CONTROL_CHAR : ~( '+' | '-' | '=' | '(' | ')' | ',' | ';' | '\'' ); fragment F_ID_STRING : F_NO_QUOTE_CONTROL_CHAR F_NO_CONTROL_CHAR*; fragment F_ESCAPED_STRING : F_SINGLE_QUOTE ( ( F_ESCAPE_CHAR F_SINGLE_QUOTE ) | ~'\'' )* F_SINGLE_QUOTE; PLUS : F_PLUS; MINUS : F_MINUS; EQUAL : F_EQUAL; PAREN_OPEN : F_PAREN_OPEN; PAREN_CLOSE : F_PAREN_CLOSE; PRESET : P R E S E T; IDENTIFIER : F_ID_STRING | F_ESCAPED_STRING; SEP : ( F_SEMICOLON | F_COMMA ); WS : ( ' ' | '\t' ) -> skip; EOL : ( '\r\n' | '\r' | '\n' ) -> skip;
firmware/coreboot/3rdparty/blobs/cpu/amd/geode_lx/gplvsa_ii/sysmgr/init.asm
fabiojna02/OpenCellular
1
18112
<gh_stars>1-10 ; ; Copyright (c) 2006-2008 Advanced Micro Devices,Inc. ("AMD"). ; ; This library 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. ; ; This code 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 this library; if not, write to the ; Free Software Foundation, Inc., 59 Temple Place, Suite 330, ; Boston, MA 02111-1307 USA ; ;******************************************************************************* ;* This file contains the installation code for VSA II. ;* ;* BIOS Usage: ;* CALL far ptr [VSA_Entry] ;* where VSA_Entry: dw 0020h, <segment> ;* ;******************************************************************************* include vsa2.inc include sysmgr.inc include init.inc include smimac.mac include chipset.inc ;include vpci.inc DESCRIPTOR struc DescrType BYTE ? ; Type of MSR Flag BYTE ? ; See definitions below Link BYTE ? ; Link to next MSR Split BYTE ? ; Index of descriptor that was split Owner WORD ? ; PCI Address this descriptor belongs to Mbiu BYTE ? ; MBUI on which this descriptor is located Port BYTE ? ; Port this descriptor routes to MsrAddr DWORD ? ; Routing address of MSR (descriptor/LBAR/RCONF) MsrData0 DWORD ? ; MSR data low MsrData1 DWORD ? ; MSR data high Physical DWORD ? ; Physical memory assigned (00000000 if none) Range DWORD ? ; Actual I/O range for IOD_SC Address WORD ? ; Address of I/O Trap or Timeout DESCRIPTOR ENDS .model small,c .586 .CODE VERIFY_VSM_COPY equ 1 ; 0=skip verify SW_SMI equ 0D0h ; VSA loader debug codes: VSA_ENTERED equ 10h ; VSA installation has been entered VSA_INIT1 equ 11h ; Returned from Setup VSA_SYSMGR equ 12h ; Image of SysMgr was found VSA_VSM_FOUND equ 13h ; A VSM has been found (followed by VSM type) VSA_COPY_START equ 14h ; Start of module copy VSA_COPY_END equ 15h ; End of module copy VSA_VRFY_START equ 1Ch ; Start of verifying module copy VSA_VRFY_END equ 1Dh ; End of verifying module copy VSA_FILL_START equ 1Eh ; Start of filling BSS VSA_FILL_END equ 1Fh ; End of filling BSS VSA_INIT2 equ 16h ; Returned from copying VSA image VSA_INIT3 equ 17h ; Performing VSA initialization SMI VSA_INIT4 equ 18h ; Returned from s/w SMI VSA_INIT5 equ 19h ; Returned from initializing statistics VSA_INIT6 equ 1Ah ; Returning to BIOS VSA_ERROR equ 0EEh ; Installation error. EBX contains error mask ; NOTES: ; 1) A VSM's CS segment must be writeable since the message queue is ; stored there and the VSM must be able to update the pointers. ; 2) The nested flag must be set so when the System Manager RSMs ; to a VSM, the processor remains in SMM. VSM_FLAGS equ SMI_FLAGS_CS_WRITABLE + SMI_FLAGS_NESTED + SMI_FLAGS_CS_READABLE POST macro Code mov al, Code out 80h, al endm public Device_ID public Chipset_Base public Errors public BIOS_ECX public BIOS_EDX externdef Software_SMI: proc externdef Get_Sbridge_Info: proc externdef Get_IRQ_Base: proc externdef Get_SMI_Base: proc externdef Get_CPU_Info: proc externdef Clear_SMIs: proc externdef Get_SMM_Region: proc externdef Init_SMM_Region: proc externdef Enable_SMIs: proc externdef Enable_SMM_Instr: proc externdef Disable_A20: proc externdef Get_Memory_Size: proc externdef Set_CPU_Fields: proc externdef VSA_Image: byte ORG 0000h ;*********************************************************************** ; Entry Point for DOS installer ;*********************************************************************** VSA_Installation: mov dx, offset Msg_Not_DOS_BUILD push cs ; DS <= CS pop ds mov ah, 9 ; Call DOS PrintString int 21h ReturnToDOS: sti mov ah, 4Ch ; Return to DOS int 21h org 001Eh ; Used by INFO to skip over init code dw offset VSA_Image ;*********************************************************************** ; Entry point for BIOS installer ;*********************************************************************** org 0020h VSA_Install proc far POST VSA_ENTERED pushf push cs ; DS <- CS pop ds ASSUME DS:_TEXT mov [BIOS_ECX], ecx ; MSR address of SMM memory descriptor (P2D_BMO) mov [BIOS_EDX], edx ; MSR address of system memory descriptor (P2D_R) ; ; Make sure VSM's SmiHeader is DWORD aligned ; mov si, VSM_Header.SysStuff.State test si, 3 jz AlignmentOK mov bx, [Errors] or bx, ERR_INTERNAL jmp DisplayErrors AlignmentOK: ; Set up for SMM call Setup jc DisplayErrors ; Load System Manager and VSMs into memory POST VSA_INIT1 call ProcessModules POST VSA_INIT2 push cs pop ds mov bx, [Errors] ; Any errors detected ? test bx, bx jz Init_VSA DisplayErrors: POST VSA_ERROR jmp Exit Init_VSA: cli ; Set SMM MSRs mov ebx, [SysMgrEntry] call Init_SMM_Region ; Generate s/w SMI to initialize VSA POST VSA_INIT3 ; POST 17h call Enable_SMIs ; Enable SMIs movzx eax, [SysCall_Code] mov ebx, [InitParam1] mov ecx, [InitParam2] call Software_SMI POST VSA_INIT4 ; POST 18h call InitStatistics ; Initialize VSA statistics POST VSA_INIT5 ; POST 19h Exit: POST VSA_INIT6 ; POST 1Ah popf ret VSA_Install endp ASSUME DS:NOTHING ;*********************************************************************** ;*********************************************************************** ;*********************************************************************** ;*********************************************************************** ;*********************************************************************** ; ; Some of the time in SMM cannot be recorded by VSA. ; This unaccounted time consists of: ; 1) the cycles used to write the SMM header. ; 2) the cycles for the SMM entry code before RDTSC is executed. ; 3) the cycles between the exit RDTSC through the RSM instruction. ; ; The following code calculates how many clocks this time consists ; of and stores it in a VSA structure. It is used as an adjustment ; to the statistics calculations. ; ;*********************************************************************** InitStatistics proc in al, 92h ; Save A20 mask push ax mov si, 0 ; Don't toggle A20 (no SMI) call DeltaSMI mov edi, eax ; EDI = overhead of DeltaSMI() mov ebx, [SysMgrEntry] ; Get ptr to SysMgr's header add ebx, VSM_Header.SysStuff mov es:(System PTR [ebx]).Clocks, 0 mov si, 2 ; Generate an SMI by toggling A20 call DeltaSMI mov ecx, es:(System PTR [ebx]).Clocks sub eax, ecx ; Subtract clocks VSA determined sub eax, edi ; Subtract DeltaSMI() overhead mov es:(System PTR [ebx]).Adjustment, eax pop ax ; Restore A20 mask out 92h, al ; Initialize statistics structure RDTSC ; Record VSA start time mov es:(System PTR [ebx+0]).StartClocks, eax mov es:(System PTR [ebx+4]).StartClocks, edx xor eax, eax mov es:(System PTR [ebx+0]).Clocks, eax mov es:(System PTR [ebx+4]).Clocks, eax mov es:(System PTR [ebx+0]).NumSMIs, eax mov es:(System PTR [ebx+4]).NumSMIs, eax ret InitStatistics endp ;*********************************************************************** ; Helper routine for InitStatistics() ; Input: SI = XOR mask for port 92h ;*********************************************************************** DeltaSMI proc RDTSC ; Record VSA start time mov ecx, eax in al, 92h ; Generate an SMI by toggling A20 mask xor ax, si out 92h, al RDTSC ; Compute actual delta clocks sub eax, ecx jnc Exit neg eax ; TSC rolled over Exit: ret DeltaSMI endp ;*********************************************************************** ; Setup for VSA installation: ; - Gets information about the system: CPU, Southbridge, memory, PCI ; - Sets ES to be 4 GB descriptor ; - Clears pending SMIs ;*********************************************************************** Setup proc near ASSUME DS:_TEXT cli call Get_CPU_Info ; Get information about the CPU mov [Cpu_Revision], ax mov [Cpu_ID], si mov [PCI_MHz], bx mov [CPU_MHz], cx mov [DRAM_MHz], dx call Get_Sbridge_Info ; Get information about the Southbridge jc short SetupExit mov [Chipset_Base], ebx mov [Device_ID], dx mov [Chipset_Rev], cl call Get_SMM_Region ; Get SMM entry point mov [ModuleBase], eax mov [SysMgr_Location], eax mov [VSA_Size], bx movzx ebx, bx ; Get end of VSA memory shl ebx, 10 add eax, ebx mov [VSA_End], eax call Enable_SMM_Instr ; Enable SMM instructions rsdc es, [Flat_Descriptor] ; Setup ES as a 4 GB flat descriptor call Disable_A20 ; Turn off A20 masking call Get_Memory_Size ; Get physical memory size mov [TotalMemory], eax call Clear_SMIs ; Clear all pending SMIs SetupExit: mov [SetupComplete], 0FFh clc ret ASSUME DS: NOTHING Setup endp ;***************************************************************************** ; ; Loads the VSA II image into memory ; NOTE: The System Manager must be the first module of the VSA image. ; ;***************************************************************************** ProcessModules proc ; Point DS:ESI to loaded VSA image lea bx, [VSA_Image] ; Point DS to start of file image movzx esi, bx and si, 000Fh shr bx, 4 mov ax, cs add ax, bx mov ds, ax ; Point EDI to where System Manager will be loaded mov edi, cs:[ModuleBase] ; Get last ptr value call AlignVSM mov cs:[SysMgrEntry], edi ; Record entry point of System Manager ; Ensure the System Manager is the first module unless loading from DOS mov ax, ERR_NO_SYS_MGR cmp (VSM_Header PTR [si]).Signature, VSM_SIGNATURE jne ErrExit cmp (VSM_Header PTR [si]).VSM_Type, VSM_SYS_MGR je LoadSysMgr LoadSysMgr: POST VSA_SYSMGR call PatchSysMgr ; Apply patches to the System Manager ; EDI = flat ptr of System Manager base ; DS:SI = near ptr to System Manager image call CopyModule ; Install System Manager jc ErrExit ; Sequence through each VSM and install it. VSM_Loop: mov eax, VSM_SIGNATURE ; Check for a VSM signature cmp eax, (VSM_Header PTR [si]).Signature jne short Return call Load_VSM ; Load the VSM jnc VSM_Loop ErrExit:or cs:[Errors], ax Return: ret ProcessModules endp ;***************************************************************************** ; Copies INT vector table to VSA. If installing VSA from DOS, copies the ; INT_Vector[] from current System Manager to the VSA image being installed. ;***************************************************************************** SnagInterruptVectors proc Exit: ret SnagInterruptVectors endp ;******************************************************************* ; ; Aligns a VSM ptr according to requirements flag ; Input: ; EDI = ptr to be aligned ; Output: ; EDI = aligned ptr ; ;******************************************************************* AlignVSM proc uses eax mov cx, cs:[Requirments] ; Compute alignment and cl, MASK Alignment@@tag_i0 ; Compute mask from 2^(n+4) add cl, 4 xor eax, eax mov al, 1 shl eax, cl dec eax add edi, eax ; Align the next VSM load address not eax ; to requested boundary and edi, eax ret AlignVSM endp ;******************************************************************* ; Patches various fields within System Manager ; INPUT: ; SI = ptr to System Manager ; EDI = ptr to where System Manager will reside ;******************************************************************* PatchSysMgr proc pushad ; ; Patch "jmp <EntryPoint>" over System Manager's VSM signature ; mov ax, (VSM_Header PTR [si]).EntryPoint sub ax, 3 shl eax, 8 mov al, 0E9h ; JMP opcode mov (VSM_Header PTR [si]).Signature, eax ; ; Patch SysMgr's Hardware structure ; lea bx, [si+SPECIAL_LOC] mov bx, (InfoStuff PTR [bx]).HardwareInfo ASSUME BX: PTR Hardware mov ax, cs:[Device_ID] mov [bx].Chipset_ID, ax mov ax, cs:[PCI_MHz] mov [bx].PCI_MHz, ax movzx ax, cs:[Chipset_Rev] mov [bx].Chipset_Rev, ax mov eax, cs:[Chipset_Base] mov [bx].Chipset_Base, eax mov ax, cs:[Cpu_ID] mov [bx].CPU_ID, ax mov ax, cs:[Cpu_Revision] mov [bx].CPU_Revision, ax mov ax, cs:[CPU_MHz] mov [bx].CPU_MHz, ax mov ax, cs:[DRAM_MHz] mov [bx].DRAM_MHz, ax mov eax, cs:[TotalMemory] mov [bx].SystemMemory, eax mov eax, cs:[SysMgr_Location] mov [bx].VSA_Location, eax mov [si].SysStuff.SysMgr_Ptr, eax mov ax, cs:[VSA_Size] mov [bx].VSA_Size, ax ASSUME BX:NOTHING ; ; Patch SysMgr's descriptors ; mov eax, (VSM_Header PTR [si]).DS_Limit mov [SysMgrSize], ax lea bx, (VSM_Header PTR [si])._DS call Init_Descr mov eax, SYSMGRS_STACK + VSM_STACK_FRAME lea bx, (VSM_Header PTR [si])._SS call Init_Descr ; ; Initialize the SysMgr's message queue ; call Init_Msg_Q ; ; Patch variables in SysMgr ; mov eax, cs:[Chipset_Base] mov [si].SysStuff.Southbridge, eax mov bx, si add si, SPECIAL_LOC ASSUME SI: PTR InfoStuff movzx eax, [si].SysMgr_Stack mov (VSM_Header PTR [bx]).SysStuff.SavedESP, eax mov [si].SysMgr_VSM, edi lea eax, (VSM_Header PTR [edi]).SysStuff.State + sizeof(SmiHeader) add bx, [si].Header_Addr mov [bx], eax call Get_SMI_Base mov [si].SMI_Base, eax call Get_IRQ_Base mov [si].IRQ_Base, eax Exit: call SnagInterruptVectors ; Snapshot INT vectors from current VSA popad ret PatchSysMgr endp ;******************************************************************* ; ; Loads a VSM into memory ; Input: ; DS:SI = ptr to VSM to load ; ;******************************************************************* Load_VSM proc POST VSA_VSM_FOUND ; Initialize the VSM's Header ASSUME si:PTR VSM_Header mov ax, [si].Flag mov cs:[Requirments], ax test ax, MASK SkipMe@@tag_i0 jz LoadIt Skip_VSM: add esi, [si].VSM_Length ; Point to end of this VSM call Flat_ESI jmp Next_VSM LoadIt: ; Initialize CPU dependent fields in the VSM's SMM header call Set_CPU_Fields ; Initialize EIP to VSM's entry point movzx ecx, [si].EntryPoint mov [si].SysStuff.State.Next_EIP, ecx or [si].SysStuff.State.SMI_Flags, VSM_FLAGS ; Store ptrs to certain System Manager structures for fast access mov eax, cs:[SysMgrEntry] add eax, SPECIAL_LOC mov [si].SysStuff.SysMgr_Ptr, eax mov eax, cs:[Chipset_Base] mov al, SW_SMI mov [si].SysStuff.Southbridge, eax ; Initialize the VSM's resume header ; Get size of DS segment mov eax, [si].DS_Limit ; _DS.limit_15_0 inc eax ; Round to WORD boundary and al, NOT 1 mov ecx, eax ; Initialize the CS descriptor fields ; NOTE: CS descriptor fields in SMM header are in "linear" format. mov [si].SysStuff.State._CS.limit, ecx mov [si].SysStuff.State._CS.attr, CODE_ATTR mov [si].SysStuff.State.EFLAGS, VSM_EFLAGS mov ecx, CR0 ; Preserve the CD & NW bit and ecx, 60000000h or ecx, VSM_CR0 mov [si].SysStuff.State.r_CR0, ecx mov [si].SysStuff.State.r_DR7, VSM_DR7 ; Determine size of VSM's stack movzx ecx, [si]._SS.limit_15_0 ; Get SS limit or cx, cx ; Did VSM specify a stack size ? jnz CheckMemSize mov cx, VSM_STACK_SIZE ; No, use default stack size ;******************************************************************* ; SI = ptr to VSM image to be loaded ; EAX = DS limit ; ECX = stack size ;******************************************************************* CheckMemSize: add eax, ecx ; Compute descriptor limits add ax, 15 ; Round up to next paragraph and al, NOT 15 mov [si].DS_Limit,eax ; Update for use by BIOS scan lea ebx, [edi+eax] ; If not enough memory, skip this VSM cmp ebx, [VSA_End] jae Skip_VSM call AlignVSM mov cs:[ModuleBase], edi ; Save the VSM module pointer in EDI ;******************************************************************* ; ; Initialize VSM's descriptors ; ; SI = ptr to VSM image to be loaded ; EAX = DS limit ; EDI = Runtime address for this VSM ; ;******************************************************************* ; Set VSM's CS selector to <load address> & 0xFFFFF mov ecx, edi and ecx, 000FFFFFh shr ecx, 4 mov [si].SysStuff.State._CS.selector, cx mov [si].SysStuff.State._CS.base, edi ; Initialize the VSM's stack ptr mov ebx, eax and bl, 0FCh ; Round DOWN to nearest DWORD sub bx, VSM_STACK_FRAME mov [si].SysStuff.SavedESP, ebx lea bx, [si]._DS ; Init DS call Init_Descr lea bx, [si]._ES ; Init ES call Init_Descr lea bx, [si]._SS ; Init SS call Init_Descr ; Initialize the VSM's message queue call Init_Msg_Q ; Update the doubly linked list of VSMs mov ebx, edi xchg ebx, cs:[Blink] or ebx, ebx ; 1st VSM other than System Manager ? jnz SetFlink ; Store ptr to 1st VSM in the System Manager mov eax, cs:[SysMgrEntry] mov es:(VSM_Header PTR [eax]).SysStuff.Flink, edi jmp Setlinks ; EBX points to previous VSM SetFlink: mov (VSM_Header PTR es:[ebx]).SysStuff.Flink, edi Setlinks: mov [si].SysStuff.Blink, ebx mov eax, cs:[Flink] mov [si].SysStuff.Flink, eax call CopyModule ret Load_VSM endp END_MSG_QUEUE equ (MAX_MSG_CNT)*sizeof(Message) Init_Msg_Q proc mov bx, offset VSM_Header.SysStuff.MsgQueue mov [si].SysStuff.Qhead, bx ; Store queue head ptr mov [si].SysStuff.Qtail, bx ; Store queue tail ptr add bx, END_MSG_QUEUE ; End of queue mov [si].SysStuff.EndMsgQ, bx ret Init_Msg_Q endp ;******************************************************************* ; ; Initializes a descriptor ; On entry: ; BX = ptr to descriptor ; EAX = limit ; EDI = base ; ;******************************************************************* Init_Descr proc ASSUME bx: PTR Descriptor push eax push edi mov [bx].limit_15_0, ax ; limit shr eax, 16 mov [bx].limit_19_16, al mov [bx].base_15_0, di ; base[15:00] shr edi, 16 mov ax, di mov [bx].base_23_16, al ; base[31:16] mov [bx].base_31_24, ah mov [bx].attr, DATA_ATTR ; attribute pop edi pop eax ret ASSUME bx: NOTHING Init_Descr endp ;******************************************************************* ; ; Copies a module to its runtime location. ; On Entry: ; DS:SI - ptr to source ; ES:EDI - ptr to destination ; On Exit: ; CF - set if error. AX = error code ;******************************************************************* CopyModule proc ; Get length of segment & compute size of BSS mov ecx, [si].VSM_Length movzx edx, [si]._DS.limit_15_0 sub edx, ecx call Flat_ESI ; ; Copy the VSM image to its runtime location ; if VERIFY_VSM_COPY push ecx ; Save byte count & ptrs push esi push edi endif POST VSA_COPY_START ; 14h mov ah, cl shr ecx, 2 ; Convert BYTE count to DWORD count cld rep movsd [edi], es:[esi] and ah, 3 ; Copy remaining bytes mov cl, ah rep movsb [edi], es:[esi] POST VSA_COPY_END ; 15h if VERIFY_VSM_COPY pop edi ; Restore original ptrs and byte count pop esi pop ecx ; ; Verify the VSM image copy ; mov ebx, edi ; Save ptr to start of VSM shr ecx, 2 ; Convert byte count to dword count POST VSA_VRFY_START ; 1Ch repe cmpsd es:[esi], [edi] jne VerifyError mov cl, ah ; Compare leftover byte(s) repe cmpsb es:[esi], [edi] je Verify_Passed VerifyError: mov ax, ERR_VERIFY stc jmp Exit Verify_Passed: POST VSA_VRFY_END ; 1Dh endif ; VERIFY_VSM_COPY POST VSA_FILL_START ; ; Clear the uninitialized data space ; mov ecx, edx ; Fill BSS with zeros shr ecx, 2 xor eax, eax rep stosd [edi] mov cl, dl and cl, 3 je BSS_Cleared rep stosb [edi] BSS_Cleared: POST VSA_FILL_END ; Search the image for the next VSM. ; Some VSMs lie about their size. Search a byte at a time ; for 'VSM ', first backward, then forward. Next_VSM:: mov edx, -1 ; Start search backwards MAX_SEARCH equ 16 Search: mov cx, MAX_SEARCH ; Range in bytes to scan for VSM SearchNext: cmp dword ptr es:[esi], VSM_SIGNATURE je NextVSMfound add esi, edx loop SearchNext add esi, MAX_SEARCH neg edx ; Look the other direction cmp dl, 1 ; Have we already looked in that direction ? je Search jmp OK_Exit ; No more VSMs found NextVSMfound: ; Convert ESI into DS:SI format mov edx, esi shr edx, 4 mov ds, dx and esi, 0000000Fh OK_Exit: clc Exit: ret CopyModule endp ;******************************************************************* ; Converts DS:SI to a flat ptr in ESI. ;******************************************************************* Flat_ESI proc push eax mov ax, ds ; Convert DS:SI to a flat ptr movzx eax, ax shl eax, 4 movzx esi, si add esi, eax pop eax ret Flat_ESI endp BIOS_ECX dd 0 BIOS_EDX dd 0 TotalMemory dd 0 SysMgr_Location dd 0 VSA_End dd 0 Chipset_Base dd 0 SysMgrEntry dd 00000000h ModuleBase dd 00000000h Blink dd 00000000h Flink dd 00000000h InitParam1 dd 0 InitParam2 dd 0 SysMgrSize dw 0 VSA_Size dw 0 Errors dw 0 Device_ID dw 0 Cpu_ID dw 0 Cpu_Revision dw 0 SysCall_Code dw SYS_BIOS_INIT Requirments dw 0 CPU_MHz dw 0 PCI_MHz dw 0 DRAM_MHz dw 0 Chipset_Rev db 0 SetupComplete db 0 LoadFlag db 0 Flat_Descriptor Descriptor {0FFFFh, 0000h, 00h, DATA_ATTR, 8Fh, 00h, 0} Msg_CompareError db "...compare error at 0x$" Msg_Not_DOS_BUILD db CR,LF, "This version of INIT doesn't support DOS install.$" END VSA_Installation
programs/oeis/232/A232970.asm
jmorken/loda
1
86220
<reponame>jmorken/loda<gh_stars>1-10 ; A232970: Expansion of (1-3*x)/(1-5*x+3*x^2+x^3). ; 1,2,7,28,117,494,2091,8856,37513,158906,673135,2851444,12078909,51167078,216747219,918155952,3889371025,16475640050,69791931223,295643364940,1252365390981,5305104928862,22472785106427,95196245354568,403257766524697,1708227311453354,7236167012338111,30652895360805796 mov $1,1 lpb $0 sub $0,1 add $2,1 add $1,$2 add $1,$2 mov $3,$1 sub $1,1 sub $3,$2 mov $2,$1 add $2,$3 sub $2,2 lpe
compiler/ti-cgt-arm_18.12.4.LTS/lib/src/aeabi_ctype.asm
JosiahCraw/TI-Arm-Docker
0
1042
;/****************************************************************************/ ;/* aeabi_ctype.asm */ ;* ;* Copyright (c) 2006 Texas Instruments Incorporated ;* http://www.ti.com/ ;* ;* 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 Texas Instruments Incorporated nor the names ;* of its contributors may be used to endorse or promote products ;* derived from this software without specific prior written ;* permission. ;* ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ;* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ;* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ;* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;* ;/****************************************************************************/ ;/****************************************************************************/ ;/* ARM's CLIB ABI (GENC-003539) requires that a conforming toolset to */ ;/* supply the following ctype table. */ ;/****************************************************************************/ .if !__TI_ARM_V7M__ & !__TI_ARM_V6M0__ .arm .else .thumb .endif .global __aeabi_ctype_table_ .global __aeabi_ctype_table_C .sect ".const:__aeabi_ctype_table" .align 4 __aeabi_ctype_table_: __aeabi_ctype_table_C: .field 0,8 ; -1 EOF : 0 .field 128,8 ; 0x00 NUL : _ABI_C .field 128,8 ; 0x01 SOH : _ABI_C .field 128,8 ; 0x02 STX : _ABI_C .field 128,8 ; 0x03 ETX : _ABI_C .field 128,8 ; 0x04 EOT : _ABI_C .field 128,8 ; 0x05 ENQ : _ABI_C .field 128,8 ; 0x06 ACK : _ABI_C .field 128,8 ; 0x07 BEL : _ABI_C .field 128,8 ; 0x08 BS : _ABI_C .field 144,8 ; 0x09 HT : _ABI_C | _ABI_S .field 144,8 ; 0x0A LF : _ABI_C | _ABI_S .field 144,8 ; 0x0B VT : _ABI_C | _ABI_S .field 144,8 ; 0x0C FF : _ABI_C | _ABI_S .field 144,8 ; 0x0D CR : _ABI_C | _ABI_S .field 128,8 ; 0x0E SO : _ABI_C .field 128,8 ; 0x0F SI : _ABI_C .field 128,8 ; 0x10 DLE : _ABI_C .field 128,8 ; 0x11 DC1 : _ABI_C .field 128,8 ; 0x12 DC2 : _ABI_C .field 128,8 ; 0x13 DC3 : _ABI_C .field 128,8 ; 0x14 DC4 : _ABI_C .field 128,8 ; 0x15 NAK : _ABI_C .field 128,8 ; 0x16 SYN : _ABI_C .field 128,8 ; 0x17 ETB : _ABI_C .field 128,8 ; 0x18 CAN : _ABI_C .field 128,8 ; 0x19 EM : _ABI_C .field 128,8 ; 0x1A SUB : _ABI_C .field 128,8 ; 0x1B ESC : _ABI_C .field 128,8 ; 0x1C FS : _ABI_C .field 128,8 ; 0x1D GS : _ABI_C .field 128,8 ; 0x1E RS : _ABI_C .field 128,8 ; 0x1F US : _ABI_C .field 24,8 ; 0x20 ' ' : _ABI_S | _ABI_B .field 4,8 ; 0x21 '!' : _ABI_P .field 4,8 ; 0x22 '"' : _ABI_P .field 4,8 ; 0x23 '#' : _ABI_P .field 4,8 ; 0x24 '$' : _ABI_P .field 4,8 ; 0x25 '%' : _ABI_P .field 4,8 ; 0x26 '&' : _ABI_P .field 4,8 ; 0x27 ''' : _ABI_P .field 4,8 ; 0x28 '(' : _ABI_P .field 4,8 ; 0x29 ')' : _ABI_P .field 4,8 ; 0x2A '*' : _ABI_P .field 4,8 ; 0x2B '+' : _ABI_P .field 4,8 ; 0x2C ',' : _ABI_P .field 4,8 ; 0x2D '-' : _ABI_P .field 4,8 ; 0x2E '.' : _ABI_P .field 4,8 ; 0x2F '/' : _ABI_P .field 2,8 ; 0x30 '0' : _ABI_X .field 2,8 ; 0x31 '1' : _ABI_X .field 2,8 ; 0x32 '2' : _ABI_X .field 2,8 ; 0x33 '3' : _ABI_X .field 2,8 ; 0x34 '4' : _ABI_X .field 2,8 ; 0x35 '5' : _ABI_X .field 2,8 ; 0x36 '6' : _ABI_X .field 2,8 ; 0x37 '7' : _ABI_X .field 2,8 ; 0x38 '8' : _ABI_X .field 2,8 ; 0x39 '9' : _ABI_X .field 4,8 ; 0x3A ':' : _ABI_P .field 4,8 ; 0x3B ';' : _ABI_P .field 4,8 ; 0x3C '<' : _ABI_P .field 4,8 ; 0x3D '=' : _ABI_P .field 4,8 ; 0x3E '>' : _ABI_P .field 4,8 ; 0x3F '?' : _ABI_P .field 4,8 ; 0x40 '@' : _ABI_P .field 67,8 ; 0x41 'A' : _ABI_U | _ABI_X .field 67,8 ; 0x42 'B' : _ABI_U | _ABI_X .field 67,8 ; 0x43 'C' : _ABI_U | _ABI_X .field 67,8 ; 0x44 'D' : _ABI_U | _ABI_X .field 67,8 ; 0x45 'E' : _ABI_U | _ABI_X .field 67,8 ; 0x46 'F' : _ABI_U | _ABI_X .field 65,8 ; 0x47 'G' : _ABI_U .field 65,8 ; 0x48 'H' : _ABI_U .field 65,8 ; 0x49 'I' : _ABI_U .field 65,8 ; 0x4A 'J' : _ABI_U .field 65,8 ; 0x4B 'K' : _ABI_U .field 65,8 ; 0x4C 'L' : _ABI_U .field 65,8 ; 0x4D 'M' : _ABI_U .field 65,8 ; 0x4E 'N' : _ABI_U .field 65,8 ; 0x4F 'O' : _ABI_U .field 65,8 ; 0x50 'P' : _ABI_U .field 65,8 ; 0x51 'Q' : _ABI_U .field 65,8 ; 0x52 'R' : _ABI_U .field 65,8 ; 0x53 'S' : _ABI_U .field 65,8 ; 0x54 'T' : _ABI_U .field 65,8 ; 0x55 'U' : _ABI_U .field 65,8 ; 0x56 'V' : _ABI_U .field 65,8 ; 0x57 'W' : _ABI_U .field 65,8 ; 0x58 'X' : _ABI_U .field 65,8 ; 0x59 'Y' : _ABI_U .field 65,8 ; 0x5A 'Z' : _ABI_U .field 4,8 ; 0x5B '[' : _ABI_P .field 4,8 ; 0x5C '\' : _ABI_P .field 4,8 ; 0x5D ']' : _ABI_P .field 4,8 ; 0x5E '^' : _ABI_P .field 4,8 ; 0x5F '_' : _ABI_P .field 4,8 ; 0x60 '`' : _ABI_P .field 35,8 ; 0x61 'a' : _ABI_L | _ABI_X .field 35,8 ; 0x62 'b' : _ABI_L | _ABI_X .field 35,8 ; 0x63 'c' : _ABI_L | _ABI_X .field 35,8 ; 0x64 'd' : _ABI_L | _ABI_X .field 35,8 ; 0x65 'e' : _ABI_L | _ABI_X .field 35,8 ; 0x66 'f' : _ABI_L | _ABI_X .field 33,8 ; 0x67 'g' : _ABI_L .field 33,8 ; 0x68 'h' : _ABI_L .field 33,8 ; 0x69 'i' : _ABI_L .field 33,8 ; 0x6A 'j' : _ABI_L .field 33,8 ; 0x6B 'k' : _ABI_L .field 33,8 ; 0x6C 'l' : _ABI_L .field 33,8 ; 0x6D 'm' : _ABI_L .field 33,8 ; 0x6E 'n' : _ABI_L .field 33,8 ; 0x6F 'o' : _ABI_L .field 33,8 ; 0x70 'p' : _ABI_L .field 33,8 ; 0x71 'q' : _ABI_L .field 33,8 ; 0x72 'r' : _ABI_L .field 33,8 ; 0x73 's' : _ABI_L .field 33,8 ; 0x74 't' : _ABI_L .field 33,8 ; 0x75 'u' : _ABI_L .field 33,8 ; 0x76 'v' : _ABI_L .field 33,8 ; 0x77 'w' : _ABI_L .field 33,8 ; 0x78 'x' : _ABI_L .field 33,8 ; 0x79 'y' : _ABI_L .field 33,8 ; 0x7A 'z' : _ABI_L .field 4,8 ; 0x7B '{' : _ABI_P .field 4,8 ; 0x7C '|' : _ABI_P .field 4,8 ; 0x7D '}' : _ABI_P .field 4,8 ; 0x7E '~' : _ABI_P .field 128,8 ; 0x7F DEL : _ABI_C .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ; .field 0,8 ;
tlsf/src/old/tlsf-mem_block_size.ads
vasil-sd/ada-tlsf
3
30149
<reponame>vasil-sd/ada-tlsf<gh_stars>1-10 with TLSF.Config; use TLSF.Config; private package TLSF.Mem_Block_Size with SPARK_Mode is type Size is mod 2 ** Max_Block_Size_Log2 with Size => Max_Block_Size_Log2; use type SSE.Storage_Count; use type SSE.Integer_Address; function Align ( Sz : Size) return Size with Pre => Sz <= Size'Last - Align_Size, Post => Sz <= Align'Result and Align'Result mod Align_Size = 0; function Align ( Sz : SSE.Storage_Count ) return Size with Pre => Sz <= SSE.Storage_Count (Size'Last - Align_Size), Post => (Sz <= SSE.Storage_Count (Align'Result) and Align'Result mod Align_Size = 0); function Align ( Addr : System.Address) return System.Address with Pre => SSE.To_Integer (Addr) <= SSE.Integer_Address'Last - Align_Size, Post => (SSE.To_Integer (Addr) <= SSE.To_Integer (Align'Result) and SSE.To_Integer (Align'Result) mod Align_Size = 0); function Align ( Sc : SSE.Storage_Count) return SSE.Storage_Count with Pre => Sc <= SSE.Storage_Count'Last - Align_Size, Post => Sc <= Align'Result and Align'Result mod Align_Size = 0; function "+" (A : System.Address; B : Size) return System.Address; function "-" (A : System.Address; B : Size) return System.Address; end TLSF.Mem_Block_Size;
packages/query/src/loader/sql/grammar/SQLLexer.g4
danvk/pgtyped
0
5042
<filename>packages/query/src/loader/sql/grammar/SQLLexer.g4 /* -- @name GetAllUsers -- @param userNames -> (...) -- @param user -> (name,age) -- @param users -> ((name,age)...) select * from $userNames; select * from $books $filterById; */ lexer grammar SQLLexer; tokens { ID } fragment QUOT: '\''; fragment ID: [a-zA-Z_][a-zA-Z_0-9]*; LINE_COMMENT: '--' ~[\r\n]* '\r'? '\n'; OPEN_COMMENT: '/*' -> mode(COMMENT); SID: ID -> type(ID); S_REQUIRED_MARK: '!'; WORD: [a-zA-Z_0-9]+; SPECIAL: [\-+*/<>=~@#%^&|`?$(){},.[\]"]+ -> type(WORD); EOF_STATEMENT: ';'; WSL : [ \t\r\n]+ -> skip; // parse strings and recognize escaped quotes STRING: QUOT (QUOT | .*? ~([\\]) QUOT); PARAM_MARK: ':'; CAST: '::' -> type(WORD); mode COMMENT; CID: ID -> type(ID); WS : [ \t\r\n]+ -> skip; TRANSFORM_ARROW: '->'; SPREAD: '...'; NAME_TAG : '@name'; TYPE_TAG : '@param'; OB: '('; CB: ')'; COMMA: ','; C_REQUIRED_MARK: '!'; ANY: .+?; CLOSE_COMMENT: '*/' -> mode(DEFAULT_MODE);
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2873.asm
ljhsiun2/medusa
9
85311
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0x15208, %rsi lea addresses_WT_ht+0x10e88, %rdi clflush (%rdi) nop nop dec %r14 mov $46, %rcx rep movsq nop nop nop nop add %r15, %r15 lea addresses_UC_ht+0x1e208, %rax xor $7800, %r13 movw $0x6162, (%rax) nop nop nop nop xor $15490, %rdi lea addresses_normal_ht+0x1d108, %rsi lea addresses_UC_ht+0x19be8, %rdi nop nop cmp %r14, %r14 mov $51, %rcx rep movsq nop xor $23396, %r13 pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r8 push %r9 push %rbx // Faulty Load lea addresses_PSE+0x1ec08, %r10 nop nop nop nop sub $8837, %r9 mov (%r10), %r14 lea oracles, %r8 and $0xff, %r14 shlq $12, %r14 mov (%r8,%r14,1), %r14 pop %rbx pop %r9 pop %r8 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
wof/lcs/base/190.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
26265
<reponame>zengfr/arcade_game_romhacking_sourcecode_top_secret_data copyright zengfr site:http://github.com/zengfr/romhack 005EB4 bne $5fe2 005EC2 bne $66da 005F4A bne $5fe2 006086 bne $66da 006150 bne $66da 006170 bne $5fe2 0062F2 bne $5fe2 006302 bne $66da 006324 bne $5fe2 006688 bne $5fe2 01A610 dbra D1, $1a60e 04C7D8 beq $4c802 058F62 beq $58f78 05905C beq $59064 0590D2 beq $590fa 0597FE beq $59838 05E186 beq $5e450 05E7F6 bpl $5e80a 05E868 bpl $5e87c 05E8BA beq $5e8c4 copyright zengfr site:http://github.com/zengfr/romhack
programs/oeis/026/A026581.asm
neoneye/loda
22
86427
<reponame>neoneye/loda ; A026581: Expansion of (1 + 2*x) / (1 - x - 4*x^2). ; 1,3,7,19,47,123,311,803,2047,5259,13447,34483,88271,226203,579287,1484099,3801247,9737643,24942631,63893203,163663727,419236539,1073891447,2750837603,7046403391,18049753803,46235367367,118434382579,303375852047,777113382363,1990616790551,5099070320003,13061537482207,33457818762219,85703968691047,219535243739923,562351118504111,1440492093463803,3689896567480247,9451864941335459,24211451211256447,62018910976598283,158864715821624071,406940359728017203,1042399223014513487,2670160661926582299,6839757553984636247,17520400201690965443,44879430417629510431,114961031224393372203,294478752894911413927,754322877792484902739,1932237889372130558447,4949529400542070169403,12678480958030592403191,32476598560198873080803,83190522392321242693567,213096916633116735016779,545859006202401705791047,1398246672734868645858163,3581682697544475469022351,9174669388483950052455003,23501400178661851928544407,60200077732597652138364419,154205678447245059852542047,395005989377635668405999723,1011828703166615907816167911,2591852660677158581440166803,6639167473343622212704838447,17006578116052256538465505659,43563248009426745389284859447,111589560473635771543146882083,285842552511342753100286319871,732200794405885839272873848203,1875571004451256851674019127687,4804374182074800208765514520499,12306658199879827615461591031247,31524154928179028450523649113243,80750787727698338912370013238231,206847407440414452714464609691203,529850558351207808363944662644127,1357240188112865619221803101408939,3476642421517696852677581751985447,8905603173969159329564794157621203,22812172860039946740275121165562991,58434585555916584058534297796047803,149683276996076371019634782458299767,383421619219742707253771973642490979,982154727204048191332311103475690047 add $0,1 seq $0,26597 ; Expansion of (1+x)/(1-x-4*x^2). div $0,2
assembly/EasyCode20200033Eng/EasyCode/EasyCode/Macros/ECSolar32.asm
Sanardi/bored
0
80215
#ifndef LOCALE_USER_DEFAULT LOCALE_USER_DEFAULT equ 0400H #endif #ifndef LOCALE_NOUSEROVERRIDE LOCALE_NOUSEROVERRIDE equ 080000000H #endif macro Return marg dwValue mov eax, dwValue ret endm macro HiByte marg wWord mov ax, wWord shr ax, 8 endm macro LoByte marg wWord mov ax, wWord and ax, 00FFh endm macro HiWord marg dwDWord mov eax, dwDWord shr eax, 16 endm macro LoWord marg dwDWord mov eax, dwDWord and eax, 0000FFFFH endm macro MakeWord marg byteLow, byteHigh mov ah, byteHigh mov al, byteLow endm macro MakeLong marg wordLow, wordHigh mov ax, wordHigh shl eax, 16 or ax, wordLow endm macro Color marg byteRed, byteGreen, byteBlue xor eax, eax mov ah, byteBlue mov al, byteGreen shl eax, 8 mov al, byteRed endm macro Move marg dwValue1, dwValue2 push dwValue2 pop dwValue1 endm macro TextA marg Name, quoted_text jmp @L1 Name db quoted_text,0,0 @L1: endm macro TextW marg Name, quoted_text jmp @L1 Name du quoted_text,0,0 @L1: endm macro Text marg Name, quoted_text #ifdef APP_UNICODE TextW Name, quoted_text #else TextA Name, quoted_text #endif endm macro TextAddrA marg quoted_text .data @ECvname db quoted_text,0 .code exitm @ECvname endm macro TextAddrW marg quoted_text .data @ECvname du quoted_text,0 .code exitm @ECvname endm macro TextAddr marg quoted_text #ifdef APP_UNICODE TextAddrW quoted_text #else TextAddrA quoted_text #endif endm macro TextStrA marg quoted_text TextAddrA quoted_text endm macro TextStrW marg quoted_text TextAddrW quoted_text endm macro TextStr marg quoted_text #ifdef APP_UNICODE TextAddrW quoted_text #else TextAddrA quoted_text #endif endm macro Date marg lpszStrPtr push esi push edi invoke GlobalAlloc, GPTR, MAX_PATH mov esi, eax invoke GetSystemTime, esi mov edi, esi add edi, 64 invoke GetDateFormat, LOCALE_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, esi, NULL, edi, MAX_PATH - 65 invoke lstrcpy, lpszStrPtr, edi invoke GlobalFree, esi pop edi pop esi endm macro Now marg lpszStrPtr push esi push edi invoke GlobalAlloc, GPTR, MAX_PATH mov esi, eax invoke GetSystemTime, esi mov edi, esi add edi, 64 invoke GetDateFormat, LOCALE_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, esi, NULL, edi, MAX_PATH - 65 invoke lstrcpy, lpszStrPtr, edi invoke lstrcat, lpszStrPtr, " - " invoke GetTimeFormat, LOCALE_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, esi, NULL, edi, MAX_PATH - 65 invoke lstrcat, lpszStrPtr, edi invoke GlobalFree, esi pop edi pop esi endm macro Time marg lpszStrPtr push esi push edi invoke GlobalAlloc, GPTR, MAX_PATH mov esi, eax invoke GetSystemTime, esi mov edi, esi add edi, 64 invoke GetTimeFormat, LOCALE_USER_DEFAULT, LOCALE_NOUSEROVERRIDE, esi, NULL, edi, MAX_PATH - 65 invoke lstrcpy, lpszStrPtr, edi invoke GlobalFree, esi pop edi pop esi endm macro Swap marg dwValue1, dwValue2 push dwValue1 push dwValue2 pop dwValue1 pop dwValue2 endm
bsp/freedom_e310-G000/pwm.adb
yannickmoy/SPARKZumo
6
11299
<reponame>yannickmoy/SPARKZumo pragma SPARK_Mode; with Interfaces.C; use Interfaces.C; with Sparkduino; use Sparkduino; package body Pwm is Pwm_Resolution : constant := 8; procedure Configure_Timers is begin null; end Configure_Timers; procedure SetRate (Index : Pwm_Index; Value : Word) is Scaled : unsigned; begin Scaled := (unsigned (Value) * ((2 ** Pwm_Resolution) - 1)) / PWM_Max; case Index is when Left => AnalogWrite (Pin => 10, Val => Scaled); when Right => AnalogWrite (Pin => 9, Val => Scaled); end case; end SetRate; end Pwm;
regge.adb
leo-brewin/Regge
0
4513
-- Copyright (c) 2017, <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. with Ada.Numerics; use Ada.Numerics; with Ada.Numerics.Generic_Elementary_Functions; package body regge is package Maths is new Ada.Numerics.Generic_Elementary_Functions (Real); use Maths; function "*" (Left : Integer; Right : Real) return Real is begin return Real(Left) * Right; end "*"; function "*" (Left : Real; Right : Integer) return Real is begin return Left * Real(Right); end "*"; function sign (x : Real) return Integer is begin if x = 0.0 then return 0; else if x < 0.0 then return -1; else return +1; end if; end if; end sign; function inv_angle (n1_dot_m2 : Real; m1_dot_m2 : Real; sig_m1 : Integer) return Real is phi : Real; rho : Real; begin case bone_signature is when timelike => phi := arccos (m1_dot_m2); when spacelike => if abs (m1_dot_m2) < abs (n1_dot_m2) then rho := sign (n1_dot_m2) * m1_dot_m2; else rho := sign (m1_dot_m2) * n1_dot_m2; end if; phi := sig_m1 * arcsinh (rho); end case; return phi; end inv_angle; procedure gauss_system (solution : out Array2dReal; the_matrix : in Array2dReal; the_rhs : in Array2dReal; num_row : in Integer; num_rhs : in Integer; cond : out Real; failed : out Boolean) is singular_pivot : constant := 1.0e-20; -- Solves a set of linear equations by Gaussian elimination. ------------ det : Real; pivoting : Boolean; size : Integer := num_row; col, row, pivot_row : Integer; sum, pivot, factor, maximum, temporary : Real; min_pivot, max_pivot : Real; rhs : Array2dReal := the_rhs; matrix : Array2dReal := the_matrix; begin col := 1; row := 1; det := 1.0e0; min_pivot := 1.0e20; max_pivot := 0.0e0; failed := False; pivoting := True; while pivoting loop -- search for pivot row maximum := abs (matrix (col, col)); pivot_row := col; for row in col + 1 .. size loop if maximum < abs (matrix (row, col)) then maximum := abs (matrix (row, col)); pivot_row := row; end if; end loop; -- swap diagonal row with pivot row if pivot_row /= col then for i in col .. size loop temporary := matrix (pivot_row, i); matrix (pivot_row, i) := matrix (col, i); matrix (col, i) := temporary; end loop; for i in 1 .. num_rhs loop temporary := rhs (pivot_row, i); rhs (pivot_row, i) := rhs (col, i); rhs (col, i) := temporary; end loop; det := -det; end if; -- set diagonal element to one pivot := matrix (col, col); if abs (pivot) < min_pivot then min_pivot := abs (pivot); end if; if abs (pivot) > max_pivot then max_pivot := abs (pivot); end if; if abs (pivot / max_pivot) < singular_pivot then pivoting := False; failed := True; det := 0.0e0; else matrix (col, col) := 1.0e0; for i in col + 1 .. size loop matrix (col, i) := matrix (col, i) / pivot; end loop; for i in 1 .. num_rhs loop rhs (col, i) := rhs (col, i) / pivot; end loop; -- eliminate elements below diagonal for row in col + 1 .. size loop factor := matrix (row, col); for i in col .. size loop matrix (row, i) := matrix (row, i) - factor * matrix (col, i); end loop; for i in 1 .. num_rhs loop rhs (row, i) := rhs (row, i) - factor * rhs (col, i); end loop; end loop; col := col + 1; pivoting := (not failed) and (col <= size); det := det * pivot; end if; end loop; -- form the back-substitution if not failed then for i in 1 .. num_rhs loop solution (size, i) := rhs (size, i); for row in reverse 1 .. size - 1 loop sum := 0.0e0; for col in row + 1 .. size loop sum := sum + matrix (row, col) * solution (col, i); end loop; solution (row, i) := rhs (row, i) - sum; end loop; end loop; else for i in 1 .. size loop for j in 1 .. num_rhs loop solution (i, j) := 0.0e0; end loop; end loop; end if; if not failed then cond := min_pivot / max_pivot; else cond := 0.0e0; end if; end gauss_system; function inverse (matrix : Array2dReal) return Array2dReal is cond : Real; failed : Boolean; sol : Array2dReal (matrix'first(1)..matrix'last(1),matrix'first(1)..matrix'last(1)); identity : Array2dReal (matrix'first(1)..matrix'last(1),matrix'first(1)..matrix'last(1)); begin if matrix'length(1) /= matrix'length (2) then raise Constraint_Error with " matrix must be square"; else for i in identity'range(1) loop identity (i,i) := 1.0; for j in i+1 .. identity'last(2) loop identity (i,j) := 0.0; identity (j,i) := 0.0; end loop; end loop; gauss_system (sol,matrix,identity,matrix'length(1),matrix'length(2),cond,failed); if not failed then return sol; else raise Constraint_Error with " matrix may be singular"; end if; end if; end inverse; procedure set_normal (n : out Array1dReal; m : out Array1dReal; sig_n : out Integer; sig_m : out Integer; c : Integer; d : Integer; inv_metric : Array2dReal) is tmp : Real; begin -- compute the outward pointing unit normal, n if inv_metric (c, c) > 0.0 then sig_n := +1; tmp := +Sqrt (abs (inv_metric (c, c))); for a in 1 .. 4 loop n (a) := -inv_metric (a, c) / tmp; -- minus sign for outward normal end loop; else sig_n := -1; tmp := -Sqrt (abs (inv_metric (c, c))); for a in 1 .. 4 loop n (a) := -inv_metric (a, c) / tmp; -- minus sign for outward normal end loop; end if; -- compute the unit tangent vector, m tmp := inv_metric (c, d) / inv_metric (c, c); for a in 1 .. 4 loop m (a) := inv_metric (a, d) - tmp * inv_metric (a, c); end loop; if m (d) > 0.0 then sig_m := +1; tmp := +Sqrt (abs (m (d))); for a in 1 .. 4 loop m (a) := m (a) / tmp; end loop; else sig_m := -1; tmp := -Sqrt (abs (m (d))); for a in 1 .. 4 loop m (a) := m (a) / tmp; end loop; end if; end set_normal; function get_signature (bone : Integer) return bone_type is leg_ij, leg_ik, leg_jk : Integer; lsq_ij, lsq_ik, lsq_jk : Real; g11, g22, g12 : Real; begin leg_ij := simp12 (bone)(1); leg_ik := simp12 (bone)(2); leg_jk := simp12 (bone)(3); lsq_ij := lsq (leg_ij); lsq_ik := lsq (leg_ik); lsq_jk := lsq (leg_jk); g11 := lsq_ij; g22 := lsq_ik; g12 := (g11 + g22 - lsq_jk) / 2.0; if g11*g22-g12*g12 > 0.0 then return spacelike; else return timelike; end if; end get_signature; procedure set_metric (metric : out Array2dReal; bone : Integer; index : Integer) is offset : Integer; leg_ab : Integer; leg_ij, leg_ik, leg_jk : Integer; leg_ai, leg_aj, leg_ak : Integer; leg_bi, leg_bj, leg_bk : Integer; lsq_ab : Real; lsq_ij, lsq_ik, lsq_jk : Real; lsq_ia, lsq_ja, lsq_ka : Real; lsq_ib, lsq_jb, lsq_kb : Real; begin offset := 4*index - 4; leg_ij := simp12 (bone)(1); leg_ik := simp12 (bone)(2); leg_jk := simp12 (bone)(3); leg_ai := simp12 (bone)(offset+4); leg_aj := simp12 (bone)(offset+5); leg_ak := simp12 (bone)(offset+6); leg_ab := simp12 (bone)(offset+7); leg_bi := simp12 (bone)(offset+8); leg_bj := simp12 (bone)(offset+9); leg_bk := simp12 (bone)(offset+10); lsq_ij := lsq (leg_ij); lsq_ik := lsq (leg_ik); lsq_jk := lsq (leg_jk); lsq_ia := lsq (leg_ai); lsq_ja := lsq (leg_aj); lsq_ka := lsq (leg_ak); lsq_ib := lsq (leg_bi); lsq_jb := lsq (leg_bj); lsq_kb := lsq (leg_bk); lsq_ab := lsq (leg_ab); metric (1, 1) := lsq_ij; metric (2, 2) := lsq_ik; metric (3, 3) := lsq_ia; metric (4, 4) := lsq_ib; metric (1, 2) := (metric (1, 1) + metric (2, 2) - lsq_jk) / 2.0; metric (1, 3) := (metric (1, 1) + metric (3, 3) - lsq_ja) / 2.0; metric (1, 4) := (metric (1, 1) + metric (4, 4) - lsq_jb) / 2.0; metric (2, 3) := (metric (2, 2) + metric (3, 3) - lsq_ka) / 2.0; metric (2, 4) := (metric (2, 2) + metric (4, 4) - lsq_kb) / 2.0; metric (3, 4) := (metric (3, 3) + metric (4, 4) - lsq_ab) / 2.0; metric (2, 1) := metric (1, 2); metric (3, 1) := metric (1, 3); metric (4, 1) := metric (1, 4); metric (3, 2) := metric (2, 3); metric (4, 2) := metric (2, 4); metric (4, 3) := metric (3, 4); end set_metric; procedure get_defect (defect : out Real; bone : Integer; n_vertex : Integer) is phi : Real; procedure take_one_step (phi : in out Real; index : Integer) is n1_dot_m2 : Real; m1_dot_m2 : Real; tmp_a : Real; tmp_b : Real; tmp_c : Real; sig_m1 : Integer; metric : Array2dReal (1..4,1..4); inv_metric : Array2dReal (1..4,1..4); begin set_metric (metric, bone, index); -- standard metric for (i,j,k,a,b); inv_metric := inverse (metric); -- update phi, the defect tmp_a := inv_metric (3, 3) * inv_metric (4, 4); tmp_b := inv_metric (3, 4) * inv_metric (3, 4); tmp_c := 1.0 - (tmp_b / tmp_a); sig_m1 := sign (tmp_c * inv_metric (3, 3)); n1_dot_m2 := -sign (inv_metric (4, 4)) * Sqrt (abs (tmp_c)); m1_dot_m2 := -sign (tmp_a - tmp_b) * inv_metric (3, 4) / Sqrt (abs (tmp_a)); phi := phi + inv_angle (n1_dot_m2, m1_dot_m2, sig_m1); end take_one_step; begin phi := 0.0; -- compute the defect -- take a tour around the bone, visiting each 4-simplex in turn for a in 1 .. n_vertex loop take_one_step (phi, a); end loop; case bone_signature is when timelike => defect := 2.0 * Pi - phi; when spacelike => defect := -phi; end case; end get_defect; procedure get_defect_deriv (deriv : out Real; bone : Integer; n_vertex : Integer; leg_pq : Integer) is rho : Real; deriv_metric : Array2dReal (1 .. 4, 1 .. 4); procedure set_metric_deriv (bone : Integer; index : Integer) is the_delta : Real; save_lsq : Real; metric_p : Array2dReal (1 .. 4, 1 .. 4); metric_m : Array2dReal (1 .. 4, 1 .. 4); begin -- compute derivative of the metric -- since the metric is linear in the lsq, a simple finite difference -- method will give the exact answer save_lsq := lsq (leg_pq); the_delta := save_lsq / 10.0; lsq (leg_pq) := save_lsq + the_delta; set_metric (metric_p, bone, index); lsq (leg_pq) := save_lsq - the_delta; set_metric (metric_m, bone, index); for a in 1 .. 4 loop for b in 1 .. 4 loop deriv_metric (a, b) := (metric_p (a, b) - metric_m (a, b)) / (2.0 * the_delta); end loop; end loop; -- reset lsq to its original value lsq (leg_pq) := save_lsq; end set_metric_deriv; procedure take_one_step (rho : in out Real; index : Integer) is sum : Real; sig_n1, sig_m1 : Integer; sig_n2, sig_m2 : Integer; n1, m1 : Array1dReal (1 .. 4); n2, m2 : Array1dReal (1 .. 4); metric : Array2dReal (1..4,1..4); inv_metric : Array2dReal (1..4,1..4); begin set_metric (metric, bone, index); -- standard metric for (i,j,k,a,b); inv_metric := inverse (metric); set_normal (n1, m1, sig_n1, sig_m1, 4, 3, inv_metric); -- outward normal & tangent vector to (i,j,k,a) set_normal (n2, m2, sig_n2, sig_m2, 3, 4, inv_metric); -- outward normal & tangent vector to (i,j,k,b) set_metric_deriv (bone, index); -- update rho, the derivative of the defect sum := 0.0; for a in 1 .. 4 loop for b in 1 .. 4 loop sum := sum + (n1 (a) * m1 (b) + n2 (a) * m2 (b)) * deriv_metric (a, b); end loop; end loop; rho := rho + sum; end take_one_step; begin rho := 0.0; for a in 1 .. n_vertex loop take_one_step (rho, a); end loop; case bone_signature is when timelike => deriv := -rho / 2.0; when spacelike => deriv := rho / 2.0; end case; end get_defect_deriv; procedure get_defect_and_deriv (defect : out Real; deriv : out Real; bone : Integer; n_vertex : Integer; leg_pq : Integer) is phi : Real; rho : Real; deriv_metric : Array2dReal (1 .. 4, 1 .. 4); procedure set_metric_deriv (bone : Integer; index : Integer) is the_delta : Real; save_lsq : Real; metric_p : Array2dReal (1 .. 4, 1 .. 4); metric_m : Array2dReal (1 .. 4, 1 .. 4); begin -- compute derivative of the metric -- since the metric is linear in the lsq, a simple finite difference -- method will give the exact answer save_lsq := lsq (leg_pq); the_delta := save_lsq / 10.0; lsq (leg_pq) := save_lsq + the_delta; set_metric (metric_p, bone, index); lsq (leg_pq) := save_lsq - the_delta; set_metric (metric_m, bone, index); for a in 1 .. 4 loop for b in 1 .. 4 loop deriv_metric (a, b) := (metric_p (a, b) - metric_m (a, b)) / (2.0 * the_delta); end loop; end loop; -- reset lsq to its original value lsq (leg_pq) := save_lsq; end set_metric_deriv; procedure take_one_step (phi : in out Real; rho : in out Real; index : Integer) is sum : Real; n1_dot_m2 : Real; m1_dot_m2 : Real; tmp_a : Real; tmp_b : Real; tmp_c : Real; sig_n1, sig_m1 : Integer; sig_n2, sig_m2 : Integer; n1, m1 : Array1dReal (1 .. 4); n2, m2 : Array1dReal (1 .. 4); metric : Array2dReal (1..4,1..4); inv_metric : Array2dReal (1..4,1..4); begin set_metric (metric, bone, index); -- standard metric for (i,j,k,a,b); inv_metric := inverse (metric); set_normal (n1, m1, sig_n1, sig_m1, 4, 3, inv_metric); -- outward normal & tangent vector to (i,j,k,a) set_normal (n2, m2, sig_n2, sig_m2, 3, 4, inv_metric); -- outward normal & tangent vector to (i,j,k,b) set_metric_deriv (bone, index); -- update phi, the defect tmp_a := inv_metric (3, 3) * inv_metric (4, 4); tmp_b := inv_metric (3, 4) * inv_metric (3, 4); tmp_c := 1.0 - (tmp_b / tmp_a); sig_m1 := sign (tmp_c * inv_metric (3, 3)); n1_dot_m2 := -sign (inv_metric (4, 4)) * Sqrt (abs (tmp_c)); m1_dot_m2 := -sign (tmp_a - tmp_b) * inv_metric (3, 4) / Sqrt (abs (tmp_a)); phi := phi + inv_angle (n1_dot_m2, m1_dot_m2, sig_m1); -- update rho, the derivative of the defect sum := 0.0; for a in 1 .. 4 loop for b in 1 .. 4 loop sum := sum + (n1 (a) * m1 (b) + n2 (a) * m2 (b)) * deriv_metric (a, b); end loop; end loop; rho := rho + sum; end take_one_step; begin phi := 0.0; rho := 0.0; for a in 1 .. n_vertex loop take_one_step (phi, rho, a); end loop; case bone_signature is when timelike => defect := 2.0 * Pi - phi; when spacelike => defect := -phi; end case; case bone_signature is when timelike => deriv := -rho / 2.0; when spacelike => deriv := rho / 2.0; end case; end get_defect_and_deriv; end regge;
programs/oeis/080/A080063.asm
neoneye/loda
22
243814
<reponame>neoneye/loda ; A080063: n mod (spf(n)+1), where spf(n) is the smallest prime dividing n (A020639). ; 1,2,3,1,5,0,7,2,1,1,11,0,13,2,3,1,17,0,19,2,1,1,23,0,1,2,3,1,29,0,31,2,1,1,5,0,37,2,3,1,41,0,43,2,1,1,47,0,1,2,3,1,53,0,1,2,1,1,59,0,61,2,3,1,5,0,67,2,1,1,71,0,73,2,3,1,5,0,79,2,1,1,83,0,1,2,3,1,89,0,3,2,1,1,5,0 add $0,1 mov $1,$0 mov $2,2 mov $3,$0 lpb $3 mov $5,$0 lpb $5 mov $3,$4 mov $6,$1 div $1,$2 mod $6,$2 cmp $6,0 sub $5,$6 lpe add $2,1 mov $6,$1 lpb $3 cmp $6,1 cmp $6,0 sub $3,$6 lpe lpe mod $0,$2
oeis/290/A290000.asm
neoneye/loda-programs
11
163716
; A290000: a(n) = Product_{k=1..n-1} (3^k + 1). ; Submitted by <NAME> ; 1,1,4,40,1120,91840,22408960,16358540800,35792487270400,234870301468364800,4623187014103292723200,272999193182799435304960000,48361261073946554365403054080000,25701205307660304745058529866383360000,40976048450930207702360695570691784048640000,195987210459345655534160136093751682351123660800000,2812202452057788551459354650076722264901497105442406400000,121056097161449951709453533921259942008425103281783955311820800000,15633204240629581241550909720971071997598507219526518201537209250611200000 sub $0,1 mov $1,1 mov $2,1 lpb $0 sub $0,1 mul $2,3 add $2,1 mul $1,$2 sub $2,1 lpe mov $0,$1
Task/Abstract-type/Ada/abstract-type-1.ada
mullikine/RosettaCodeData
1
8392
type Queue is limited interface; procedure Enqueue (Lounge : in out Queue; Item : in out Element) is abstract; procedure Dequeue (Lounge : in out Queue; Item : in out Element) is abstract;
Tests/Test6/3.asm
5ayam5/COL216-A5
0
105302
<reponame>5ayam5/COL216-A5<gh_stars>0 addi $t0, $0, 100 sw $t0, 1000 addi $t2, $0, 20 addi $t0, $0, 1 loop: addi $t0, $t0, 1 addi $t2, $t2, -1 bne $t2, $0, loop lw $t0, 1000 addi $t2, $t0, -50