text stringlengths 1 1.05M |
|---|
;/*!
; @file
;
; @ingroup fapi
;
; @brief DosQFHandState DOS wrapper
;
; (c) osFree Project 2022, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
INCLUDE dos.inc
INCLUDE bseerr.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOSQFHANDSTATE
@START DOSQFHANDSTATE
XOR AX,AX
EXIT:
@EPILOG DOSQFHANDSTATE
_TEXT ENDS
END
|
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Burgwar" project
// For conditions of distribution and use, see copyright notice in LICENSE
#include <ClientLib/OptionWidget.hpp>
namespace bw
{
}
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; SetMem32.asm
;
; Abstract:
;
; SetMem32 function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat,C
.xmm
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; InternalMemSetMem32 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT32 Value
; );
;------------------------------------------------------------------------------
InternalMemSetMem32 PROC USES edi
mov edx, [esp + 12]
mov edi, [esp + 8]
xor ecx, ecx
sub ecx, edi
and ecx, 15 ; ecx + edi aligns on 16-byte boundary
mov eax, [esp + 16]
jz @F
shr ecx, 2
cmp ecx, edx
cmova ecx, edx
sub edx, ecx
rep stosd
@@:
mov ecx, edx
and edx, 3
shr ecx, 2
jz @SetDwords
movd xmm0, eax
pshufd xmm0, xmm0, 0
@@:
movntdq [edi], xmm0
add edi, 16
loop @B
mfence
@SetDwords:
mov ecx, edx
rep stosd
mov eax, [esp + 8]
ret
InternalMemSetMem32 ENDP
END
|
; size_t bv_priority_queue_max_size(bv_priority_queue_t *q)
SECTION code_clib
SECTION code_adt_bv_priority_queue
PUBLIC bv_priority_queue_max_size
EXTERN asm_bv_priority_queue_max_size
defc bv_priority_queue_max_size = asm_bv_priority_queue_max_size
|
; A140431: 2*A094555(n).
; Submitted by Stefano Spezia
; 0,2,2,12,22,92,222,772,2102,6732,19342,59732,175782,534172,1588862,4793892,14327062,43090412,129052782,387595252,1161911942,3487483452,10458955102,31383855812,94137586422,282440721292,847266239822
mov $1,$0
min $0,1
sub $0,3
pow $0,$1
sub $0,1
mov $2,3
pow $2,$1
sub $2,$0
div $2,3
mov $0,$2
|
;12、试编写一程序,要求比较两个字符串 STRING1 和 STRING2 所含字符是否完全相同,若相同则显示 MATCH,若不相同则显示 NO MATCH。
.model small
.data
STRING1 db 'hello world!',0
STRING2 db 'hello china!',0
matchString db 'MATCH$'
nomatchString db 'NO MATCH$'
.code
start:
mov ax,@data
mov ds,ax
call compare
mov ah,4ch
int 21h
compare proc
push ax
push bx
push dx
push si
mov si,0
comstart:
mov bx,offset STRING1
mov dl,[bx][si]
mov bx,offset STRING2
cmp dl, [bx][si]
jne nomatch
cmp dl, 0
je match
inc si
jmp comstart
nomatch:
mov dx,offset nomatchString
mov ah,09h
int 21h
jmp funcreturn
match:
mov dx,offset matchString
mov ah,09h
int 21h
jmp funcreturn
funcreturn:
pop si
pop dx
pop bx
pop ax
ret
compare endp
end start |
; void sp1_PrintAtInv(uchar row, uchar col, uchar colour, uint tile)
SECTION code_clib
SECTION code_temp_sp1
PUBLIC _sp1_PrintAtInv
EXTERN asm_sp1_PrintAtInv
_sp1_PrintAtInv:
ld hl,2
add hl,sp
ld d,(hl)
inc hl
inc hl
ld e,(hl)
inc hl
inc hl
ld a,(hl)
inc hl
inc hl
ld c,(hl)
inc hl
ld b,(hl)
jp asm_sp1_PrintAtInv
|
#include <mbgl/style/conversion.hpp>
#include <mbgl/style/rapidjson_conversion.hpp>
#include <string>
#include <sstream>
namespace mbgl {
namespace style {
namespace conversion {
template <class T, class...Args>
optional<T> convertJSON(const std::string& json, Error& error, Args&&...args) {
JSDocument document;
document.Parse<0>(json.c_str());
if (document.HasParseError()) {
std::stringstream message;
message << document.GetErrorOffset() << " - " << rapidjson::GetParseError_En(document.GetParseError());
error = { message.str() };
return {};
}
return convert<T, JSValue>(document, error, std::forward<Args>(args)...);
}
} // namespace conversion
} // namespace style
} // namespace mbgl
|
; A256534: Number of ON cells at n-th stage in simple 2-dimensional cellular automaton (see Comments lines for definition).
; 0,4,16,28,64,76,112,172,256,268,304,364,448,556,688,844,1024,1036,1072,1132,1216,1324,1456,1612,1792,1996,2224,2476,2752,3052,3376,3724,4096,4108,4144,4204,4288,4396,4528,4684,4864,5068,5296,5548,5824,6124,6448,6796,7168,7564,7984,8428,8896,9388,9904,10444,11008
mov $10,$0
mov $12,$0
lpb $12,1
mov $0,$10
sub $12,1
sub $0,$12
mov $6,$0
mov $8,2
lpb $8,1
clr $0,6
mov $0,$6
sub $8,1
add $0,$8
sub $0,1
lpb $0,1
sub $0,1
mov $1,$0
cal $1,236305 ; The number of P-positions in the game of Nim with up to 3 piles, allowing for piles of zero, such that the number of objects in each pile does not exceed n.
mov $0,0
lpe
mov $9,$8
lpb $9,1
mov $7,$1
sub $9,1
lpe
lpe
lpb $6,1
mov $6,0
sub $7,$1
lpe
mov $1,$7
mul $1,4
add $11,$1
lpe
mov $1,$11
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x106f3, %r14
and %r13, %r13
mov (%r14), %r9d
inc %r9
lea addresses_WT_ht+0x10ddd, %rsi
lea addresses_UC_ht+0x1998d, %rdi
xor $27191, %r12
mov $108, %rcx
rep movsl
inc %rcx
lea addresses_WC_ht+0x182a3, %rsi
lea addresses_A_ht+0x1b8a3, %rdi
nop
nop
nop
nop
xor %r9, %r9
mov $76, %rcx
rep movsb
nop
nop
nop
nop
and $30049, %r14
lea addresses_normal_ht+0xb0a3, %r13
nop
nop
nop
nop
nop
sub %r12, %r12
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
and $0xffffffffffffffc0, %r13
movntdq %xmm4, (%r13)
nop
nop
xor $9802, %rsi
lea addresses_A_ht+0xbca3, %r13
clflush (%r13)
sub $8901, %r9
movb $0x61, (%r13)
nop
nop
nop
and $16457, %r14
lea addresses_A_ht+0x6ca3, %r14
nop
nop
nop
nop
inc %rdi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
movups %xmm2, (%r14)
nop
nop
nop
nop
nop
cmp $59728, %rdi
lea addresses_UC_ht+0x130a3, %rsi
nop
nop
nop
nop
sub $44608, %r14
mov $0x6162636465666768, %r13
movq %r13, (%rsi)
nop
nop
nop
nop
nop
and %r12, %r12
lea addresses_D_ht+0x19f6b, %rsi
lea addresses_A_ht+0x170a3, %rdi
clflush (%rsi)
nop
nop
nop
sub %rax, %rax
mov $101, %rcx
rep movsq
nop
nop
nop
add %r9, %r9
lea addresses_WT_ht+0x80a3, %rax
clflush (%rax)
sub $27564, %rcx
movups (%rax), %xmm0
vpextrq $0, %xmm0, %rsi
nop
nop
nop
nop
nop
cmp %r9, %r9
lea addresses_A_ht+0x68a3, %r14
nop
add $55850, %r13
movb $0x61, (%r14)
and $33632, %rcx
lea addresses_WC_ht+0xfca3, %rsi
lea addresses_normal_ht+0x81bb, %rdi
clflush (%rdi)
nop
cmp $2996, %r9
mov $48, %rcx
rep movsq
nop
nop
and %rsi, %rsi
lea addresses_A_ht+0xeea3, %rsi
nop
nop
xor $51298, %r13
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
and $0xffffffffffffffc0, %rsi
movaps %xmm4, (%rsi)
nop
nop
nop
nop
nop
sub $49246, %r13
lea addresses_normal_ht+0x1e8a3, %r12
nop
nop
nop
nop
nop
cmp %r14, %r14
movl $0x61626364, (%r12)
nop
nop
nop
nop
and $7905, %rsi
lea addresses_D_ht+0x40a3, %r12
add $23781, %r13
mov $0x6162636465666768, %rax
movq %rax, (%r12)
nop
nop
nop
nop
nop
add $35746, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r8
push %rax
push %rbx
push %rcx
// Store
lea addresses_A+0x1b223, %r12
nop
nop
nop
nop
add %rcx, %rcx
mov $0x5152535455565758, %rax
movq %rax, %xmm2
vmovups %ymm2, (%r12)
nop
nop
nop
nop
and $27148, %rbx
// Store
mov $0xca3, %r10
sub %r13, %r13
movw $0x5152, (%r10)
nop
nop
nop
xor %r13, %r13
// Load
lea addresses_D+0x1e0a3, %r12
nop
add $51255, %r8
vmovups (%r12), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %r13
nop
nop
nop
nop
nop
xor $16023, %r8
// Store
mov $0xe38, %rcx
nop
nop
nop
nop
nop
xor $54758, %r8
movl $0x51525354, (%rcx)
nop
xor %r13, %r13
// Faulty Load
lea addresses_D+0x1e0a3, %rbx
nop
and $28685, %rcx
movb (%rbx), %r8b
lea oracles, %r10
and $0xff, %r8
shlq $12, %r8
mov (%r10,%r8,1), %r8
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 4, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 10, 'same': False}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
# Return (2^x - 1)
# Test to find maximum XOR-value of at-most k-elements from 1 to n
.data
nStr: .asciiz "Enter n: "
n: .word 0
kStr: .asciiz "Enter k: "
k: .word 0
retVal: .word 0
str: .asciiz "Maximum XOR-value: "
x: .word 0
result: .word 0
.text
runtime:
addi $sp, $sp, -4
sw $ra, 0($sp)
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
.end runtime
.globl main
.ent main
main:
li $2, 4
la $4, nStr
syscall
li $2, 5
syscall
move $3, $2
li $2, 4
la $4, kStr
syscall
li $2, 5
syscall
sw $3, n # spilled n, freed $3
move $3, $2
sw $3, k
jal maxXOR
lw $3, k
move $3, $2
li $2, 4
la $4, str
syscall
li $2, 1
move $4, $3
syscall
# Store dirty variables back into memory
sw $3, retVal
li $2, 10
syscall
.end main
maxXOR:
addi $sp, $sp, -4
sw $ra, 0($sp)
# x = log2(n) + 1
li $3, 0 # x -> $3
# Store dirty variables back into memory
sw $3, x
while:
lw $3, n # n -> $3
srl $3, $3, 1
lw $5, x # x -> $5
addi $5, $5, 1
# Store dirty variables back into memory
sw $3, n
sw $5, x
bgt $3, 0, while
li $3, 1 # result -> $3
lw $5, x # x -> $5
sll $3, $3, $5
sub $3, $3, 1
move $2, $3
# Store dirty variables back into memory
sw $3, result
lw $ra, 0($sp)
addi $sp, $sp, 4
jr $ra
.end maxXOR
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/task/single_thread_task_executor.h"
#include "base/message_loop/message_pump.h"
#include "base/message_loop/message_pump_type.h"
#include "base/task/sequence_manager/sequence_manager.h"
#include "base/task/sequence_manager/sequence_manager_impl.h"
#include "build/build_config.h"
namespace base {
SingleThreadTaskExecutor::SingleThreadTaskExecutor(MessagePumpType type)
: SingleThreadTaskExecutor(type, MessagePump::Create(type)) {
DCHECK_NE(type, MessagePumpType::CUSTOM);
}
SingleThreadTaskExecutor::SingleThreadTaskExecutor(
std::unique_ptr<MessagePump> pump)
: SingleThreadTaskExecutor(MessagePumpType::CUSTOM, std::move(pump)) {}
SingleThreadTaskExecutor::SingleThreadTaskExecutor(
MessagePumpType type,
std::unique_ptr<MessagePump> pump)
: sequence_manager_(sequence_manager::CreateUnboundSequenceManager(
sequence_manager::SequenceManager::Settings::Builder()
.SetMessagePumpType(type)
.Build())),
default_task_queue_(sequence_manager_->CreateTaskQueue(
sequence_manager::TaskQueue::Spec("default_tq"))),
type_(type),
simple_task_executor_(task_runner()) {
sequence_manager_->SetDefaultTaskRunner(default_task_queue_->task_runner());
sequence_manager_->BindToMessagePump(std::move(pump));
}
SingleThreadTaskExecutor::~SingleThreadTaskExecutor() = default;
scoped_refptr<SingleThreadTaskRunner> SingleThreadTaskExecutor::task_runner()
const {
return default_task_queue_->task_runner();
}
void SingleThreadTaskExecutor::SetWorkBatchSize(size_t work_batch_size) {
sequence_manager_->SetWorkBatchSize(work_batch_size);
}
} // namespace base
|
BITS 64
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
;TEST_BEGIN_RECORDING
lea rdi, [rsp-08]
mov dword [rdi], 0
FNSTCW [rdi]
mov eax, dword [rdi]
mov edi, 0
;TEST_END_RECORDING
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r8
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x1a877, %r10
nop
nop
nop
nop
nop
add $24496, %r14
movb $0x61, (%r10)
nop
nop
sub $40025, %r8
lea addresses_A_ht+0xe7f7, %rax
nop
nop
nop
nop
inc %rcx
movl $0x61626364, (%rax)
nop
nop
nop
nop
xor $25035, %rcx
lea addresses_D_ht+0x8c0d, %rsi
lea addresses_WC_ht+0x5457, %rdi
dec %r14
mov $32, %rcx
rep movsb
nop
nop
nop
add %r8, %r8
lea addresses_WT_ht+0x7f7, %rsi
nop
nop
xor %rdi, %rdi
movb $0x61, (%rsi)
nop
nop
add $63496, %rdi
lea addresses_WT_ht+0x9bf7, %rsi
lea addresses_A_ht+0xb7b7, %rdi
nop
nop
nop
nop
inc %r14
mov $44, %rcx
rep movsl
nop
nop
nop
nop
add $7351, %r11
lea addresses_A_ht+0x6e26, %rsi
lea addresses_UC_ht+0x11aad, %rdi
and $55382, %r10
mov $5, %rcx
rep movsl
nop
nop
nop
nop
nop
sub %rdi, %rdi
lea addresses_UC_ht+0x115f7, %rdi
clflush (%rdi)
nop
nop
nop
nop
sub %r11, %r11
mov $0x6162636465666768, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%rdi)
nop
nop
nop
sub %rdi, %rdi
lea addresses_WC_ht+0x2bf7, %r10
nop
nop
nop
and %rcx, %rcx
movw $0x6162, (%r10)
nop
inc %r8
lea addresses_normal_ht+0xcf68, %r8
cmp $34096, %rdx
mov (%r8), %r14d
nop
nop
nop
nop
nop
sub $24607, %r14
lea addresses_WC_ht+0x157f7, %rsi
lea addresses_normal_ht+0xcef7, %rdi
clflush (%rsi)
nop
nop
add %r14, %r14
mov $58, %rcx
rep movsl
nop
nop
nop
add $47513, %rdi
lea addresses_WC_ht+0xb3f7, %r10
nop
nop
nop
nop
nop
inc %rdi
vmovups (%r10), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r11
nop
add $26169, %rax
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %rbp
push %rbx
push %rsi
// Faulty Load
lea addresses_WT+0x1a3f7, %rsi
clflush (%rsi)
nop
nop
add %rbp, %rbp
movntdqa (%rsi), %xmm7
vpextrq $0, %xmm7, %r13
lea oracles, %r12
and $0xff, %r13
shlq $12, %r13
mov (%r12,%r13,1), %r13
pop %rsi
pop %rbx
pop %rbp
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 11, 'type': 'addresses_WT_ht'}, 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_A_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 9, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
// Copyright 2019 Mobilinkd LLC <rob@mobilinkd.com>
// All rights reserved.
#pragma once
#include <ap_axi_sdata.h>
#include <hls_stream.h>
#include <stdint.h>
using idata_type = ap_axiu<1,0,0,0>;
using odata_type = ap_axiu<3,0,0,0>;
using istream_type = hls::stream<idata_type>;
using ostream_type = hls::stream<odata_type>;
using locked_type = ap_int<1>;
void demodulate_top(istream_type& input, ostream_type& output, locked_type& locked);
|
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
EXTERN OPENSSL_ia32cap_P
global asm_RC4
ALIGN 16
asm_RC4:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_asm_RC4:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
or rsi,rsi
jne NEAR $L$entry
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$entry:
push rbx
push r12
push r13
$L$prologue:
mov r11,rsi
mov r12,rdx
mov r13,rcx
xor r10,r10
xor rcx,rcx
lea rdi,[8+rdi]
mov r10b,BYTE[((-8))+rdi]
mov cl,BYTE[((-4))+rdi]
cmp DWORD[256+rdi],-1
je NEAR $L$RC4_CHAR
mov r8d,DWORD[OPENSSL_ia32cap_P]
xor rbx,rbx
inc r10b
sub rbx,r10
sub r13,r12
mov eax,DWORD[r10*4+rdi]
test r11,-16
jz NEAR $L$loop1
bt r8d,30
jc NEAR $L$intel
and rbx,7
lea rsi,[1+r10]
jz NEAR $L$oop8
sub r11,rbx
$L$oop8_warmup:
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov DWORD[r10*4+rdi],edx
add al,dl
inc r10b
mov edx,DWORD[rax*4+rdi]
mov eax,DWORD[r10*4+rdi]
xor dl,BYTE[r12]
mov BYTE[r13*1+r12],dl
lea r12,[1+r12]
dec rbx
jnz NEAR $L$oop8_warmup
lea rsi,[1+r10]
jmp NEAR $L$oop8
ALIGN 16
$L$oop8:
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov ebx,DWORD[rsi*4+rdi]
ror r8,8
mov DWORD[r10*4+rdi],edx
add dl,al
mov r8b,BYTE[rdx*4+rdi]
add cl,bl
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
mov eax,DWORD[4+rsi*4+rdi]
ror r8,8
mov DWORD[4+r10*4+rdi],edx
add dl,bl
mov r8b,BYTE[rdx*4+rdi]
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov ebx,DWORD[8+rsi*4+rdi]
ror r8,8
mov DWORD[8+r10*4+rdi],edx
add dl,al
mov r8b,BYTE[rdx*4+rdi]
add cl,bl
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
mov eax,DWORD[12+rsi*4+rdi]
ror r8,8
mov DWORD[12+r10*4+rdi],edx
add dl,bl
mov r8b,BYTE[rdx*4+rdi]
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov ebx,DWORD[16+rsi*4+rdi]
ror r8,8
mov DWORD[16+r10*4+rdi],edx
add dl,al
mov r8b,BYTE[rdx*4+rdi]
add cl,bl
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
mov eax,DWORD[20+rsi*4+rdi]
ror r8,8
mov DWORD[20+r10*4+rdi],edx
add dl,bl
mov r8b,BYTE[rdx*4+rdi]
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov ebx,DWORD[24+rsi*4+rdi]
ror r8,8
mov DWORD[24+r10*4+rdi],edx
add dl,al
mov r8b,BYTE[rdx*4+rdi]
add sil,8
add cl,bl
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
mov eax,DWORD[((-4))+rsi*4+rdi]
ror r8,8
mov DWORD[28+r10*4+rdi],edx
add dl,bl
mov r8b,BYTE[rdx*4+rdi]
add r10b,8
ror r8,8
sub r11,8
xor r8,QWORD[r12]
mov QWORD[r13*1+r12],r8
lea r12,[8+r12]
test r11,-8
jnz NEAR $L$oop8
cmp r11,0
jne NEAR $L$loop1
jmp NEAR $L$exit
ALIGN 16
$L$intel:
test r11,-32
jz NEAR $L$loop1
and rbx,15
jz NEAR $L$oop16_is_hot
sub r11,rbx
$L$oop16_warmup:
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov DWORD[r10*4+rdi],edx
add al,dl
inc r10b
mov edx,DWORD[rax*4+rdi]
mov eax,DWORD[r10*4+rdi]
xor dl,BYTE[r12]
mov BYTE[r13*1+r12],dl
lea r12,[1+r12]
dec rbx
jnz NEAR $L$oop16_warmup
mov rbx,rcx
xor rcx,rcx
mov cl,bl
$L$oop16_is_hot:
lea rsi,[r10*4+rdi]
add cl,al
mov edx,DWORD[rcx*4+rdi]
pxor xmm0,xmm0
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[4+rsi]
movzx eax,al
mov DWORD[rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],0
jmp NEAR $L$oop16_enter
ALIGN 16
$L$oop16:
add cl,al
mov edx,DWORD[rcx*4+rdi]
pxor xmm2,xmm0
psllq xmm1,8
pxor xmm0,xmm0
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[4+rsi]
movzx eax,al
mov DWORD[rsi],edx
pxor xmm2,xmm1
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],0
movdqu XMMWORD[r13*1+r12],xmm2
lea r12,[16+r12]
$L$oop16_enter:
mov edx,DWORD[rcx*4+rdi]
pxor xmm1,xmm1
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[8+rsi]
movzx ebx,bl
mov DWORD[4+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],0
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[12+rsi]
movzx eax,al
mov DWORD[8+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],1
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[16+rsi]
movzx ebx,bl
mov DWORD[12+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],1
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[20+rsi]
movzx eax,al
mov DWORD[16+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],2
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[24+rsi]
movzx ebx,bl
mov DWORD[20+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],2
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[28+rsi]
movzx eax,al
mov DWORD[24+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],3
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[32+rsi]
movzx ebx,bl
mov DWORD[28+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],3
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[36+rsi]
movzx eax,al
mov DWORD[32+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],4
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[40+rsi]
movzx ebx,bl
mov DWORD[36+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],4
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[44+rsi]
movzx eax,al
mov DWORD[40+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],5
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[48+rsi]
movzx ebx,bl
mov DWORD[44+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],5
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[52+rsi]
movzx eax,al
mov DWORD[48+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],6
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
mov eax,DWORD[56+rsi]
movzx ebx,bl
mov DWORD[52+rsi],edx
add cl,al
pinsrw xmm1,WORD[rbx*4+rdi],6
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
add al,dl
mov ebx,DWORD[60+rsi]
movzx eax,al
mov DWORD[56+rsi],edx
add cl,bl
pinsrw xmm0,WORD[rax*4+rdi],7
add r10b,16
movdqu xmm2,XMMWORD[r12]
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],ebx
add bl,dl
movzx ebx,bl
mov DWORD[60+rsi],edx
lea rsi,[r10*4+rdi]
pinsrw xmm1,WORD[rbx*4+rdi],7
mov eax,DWORD[rsi]
mov rbx,rcx
xor rcx,rcx
sub r11,16
mov cl,bl
test r11,-16
jnz NEAR $L$oop16
psllq xmm1,8
pxor xmm2,xmm0
pxor xmm2,xmm1
movdqu XMMWORD[r13*1+r12],xmm2
lea r12,[16+r12]
cmp r11,0
jne NEAR $L$loop1
jmp NEAR $L$exit
ALIGN 16
$L$loop1:
add cl,al
mov edx,DWORD[rcx*4+rdi]
mov DWORD[rcx*4+rdi],eax
mov DWORD[r10*4+rdi],edx
add al,dl
inc r10b
mov edx,DWORD[rax*4+rdi]
mov eax,DWORD[r10*4+rdi]
xor dl,BYTE[r12]
mov BYTE[r13*1+r12],dl
lea r12,[1+r12]
dec r11
jnz NEAR $L$loop1
jmp NEAR $L$exit
ALIGN 16
$L$RC4_CHAR:
add r10b,1
movzx eax,BYTE[r10*1+rdi]
test r11,-8
jz NEAR $L$cloop1
jmp NEAR $L$cloop8
ALIGN 16
$L$cloop8:
mov r8d,DWORD[r12]
mov r9d,DWORD[4+r12]
add cl,al
lea rsi,[1+r10]
movzx edx,BYTE[rcx*1+rdi]
movzx esi,sil
movzx ebx,BYTE[rsi*1+rdi]
mov BYTE[rcx*1+rdi],al
cmp rcx,rsi
mov BYTE[r10*1+rdi],dl
jne NEAR $L$cmov0
mov rbx,rax
$L$cmov0:
add dl,al
xor r8b,BYTE[rdx*1+rdi]
ror r8d,8
add cl,bl
lea r10,[1+rsi]
movzx edx,BYTE[rcx*1+rdi]
movzx r10d,r10b
movzx eax,BYTE[r10*1+rdi]
mov BYTE[rcx*1+rdi],bl
cmp rcx,r10
mov BYTE[rsi*1+rdi],dl
jne NEAR $L$cmov1
mov rax,rbx
$L$cmov1:
add dl,bl
xor r8b,BYTE[rdx*1+rdi]
ror r8d,8
add cl,al
lea rsi,[1+r10]
movzx edx,BYTE[rcx*1+rdi]
movzx esi,sil
movzx ebx,BYTE[rsi*1+rdi]
mov BYTE[rcx*1+rdi],al
cmp rcx,rsi
mov BYTE[r10*1+rdi],dl
jne NEAR $L$cmov2
mov rbx,rax
$L$cmov2:
add dl,al
xor r8b,BYTE[rdx*1+rdi]
ror r8d,8
add cl,bl
lea r10,[1+rsi]
movzx edx,BYTE[rcx*1+rdi]
movzx r10d,r10b
movzx eax,BYTE[r10*1+rdi]
mov BYTE[rcx*1+rdi],bl
cmp rcx,r10
mov BYTE[rsi*1+rdi],dl
jne NEAR $L$cmov3
mov rax,rbx
$L$cmov3:
add dl,bl
xor r8b,BYTE[rdx*1+rdi]
ror r8d,8
add cl,al
lea rsi,[1+r10]
movzx edx,BYTE[rcx*1+rdi]
movzx esi,sil
movzx ebx,BYTE[rsi*1+rdi]
mov BYTE[rcx*1+rdi],al
cmp rcx,rsi
mov BYTE[r10*1+rdi],dl
jne NEAR $L$cmov4
mov rbx,rax
$L$cmov4:
add dl,al
xor r9b,BYTE[rdx*1+rdi]
ror r9d,8
add cl,bl
lea r10,[1+rsi]
movzx edx,BYTE[rcx*1+rdi]
movzx r10d,r10b
movzx eax,BYTE[r10*1+rdi]
mov BYTE[rcx*1+rdi],bl
cmp rcx,r10
mov BYTE[rsi*1+rdi],dl
jne NEAR $L$cmov5
mov rax,rbx
$L$cmov5:
add dl,bl
xor r9b,BYTE[rdx*1+rdi]
ror r9d,8
add cl,al
lea rsi,[1+r10]
movzx edx,BYTE[rcx*1+rdi]
movzx esi,sil
movzx ebx,BYTE[rsi*1+rdi]
mov BYTE[rcx*1+rdi],al
cmp rcx,rsi
mov BYTE[r10*1+rdi],dl
jne NEAR $L$cmov6
mov rbx,rax
$L$cmov6:
add dl,al
xor r9b,BYTE[rdx*1+rdi]
ror r9d,8
add cl,bl
lea r10,[1+rsi]
movzx edx,BYTE[rcx*1+rdi]
movzx r10d,r10b
movzx eax,BYTE[r10*1+rdi]
mov BYTE[rcx*1+rdi],bl
cmp rcx,r10
mov BYTE[rsi*1+rdi],dl
jne NEAR $L$cmov7
mov rax,rbx
$L$cmov7:
add dl,bl
xor r9b,BYTE[rdx*1+rdi]
ror r9d,8
lea r11,[((-8))+r11]
mov DWORD[r13],r8d
lea r12,[8+r12]
mov DWORD[4+r13],r9d
lea r13,[8+r13]
test r11,-8
jnz NEAR $L$cloop8
cmp r11,0
jne NEAR $L$cloop1
jmp NEAR $L$exit
ALIGN 16
$L$cloop1:
add cl,al
movzx ecx,cl
movzx edx,BYTE[rcx*1+rdi]
mov BYTE[rcx*1+rdi],al
mov BYTE[r10*1+rdi],dl
add dl,al
add r10b,1
movzx edx,dl
movzx r10d,r10b
movzx edx,BYTE[rdx*1+rdi]
movzx eax,BYTE[r10*1+rdi]
xor dl,BYTE[r12]
lea r12,[1+r12]
mov BYTE[r13],dl
lea r13,[1+r13]
sub r11,1
jnz NEAR $L$cloop1
jmp NEAR $L$exit
ALIGN 16
$L$exit:
sub r10b,1
mov DWORD[((-8))+rdi],r10d
mov DWORD[((-4))+rdi],ecx
mov r13,QWORD[rsp]
mov r12,QWORD[8+rsp]
mov rbx,QWORD[16+rsp]
add rsp,24
$L$epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_asm_RC4:
global asm_RC4_set_key
ALIGN 16
asm_RC4_set_key:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_asm_RC4_set_key:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
lea rdi,[8+rdi]
lea rdx,[rsi*1+rdx]
neg rsi
mov rcx,rsi
xor eax,eax
xor r9,r9
xor r10,r10
xor r11,r11
mov r8d,DWORD[OPENSSL_ia32cap_P]
bt r8d,20
jc NEAR $L$c1stloop
jmp NEAR $L$w1stloop
ALIGN 16
$L$w1stloop:
mov DWORD[rax*4+rdi],eax
add al,1
jnc NEAR $L$w1stloop
xor r9,r9
xor r8,r8
ALIGN 16
$L$w2ndloop:
mov r10d,DWORD[r9*4+rdi]
add r8b,BYTE[rsi*1+rdx]
add r8b,r10b
add rsi,1
mov r11d,DWORD[r8*4+rdi]
cmovz rsi,rcx
mov DWORD[r8*4+rdi],r10d
mov DWORD[r9*4+rdi],r11d
add r9b,1
jnc NEAR $L$w2ndloop
jmp NEAR $L$exit_key
ALIGN 16
$L$c1stloop:
mov BYTE[rax*1+rdi],al
add al,1
jnc NEAR $L$c1stloop
xor r9,r9
xor r8,r8
ALIGN 16
$L$c2ndloop:
mov r10b,BYTE[r9*1+rdi]
add r8b,BYTE[rsi*1+rdx]
add r8b,r10b
add rsi,1
mov r11b,BYTE[r8*1+rdi]
jnz NEAR $L$cnowrap
mov rsi,rcx
$L$cnowrap:
mov BYTE[r8*1+rdi],r10b
mov BYTE[r9*1+rdi],r11b
add r9b,1
jnc NEAR $L$c2ndloop
mov DWORD[256+rdi],-1
ALIGN 16
$L$exit_key:
xor eax,eax
mov DWORD[((-8))+rdi],eax
mov DWORD[((-4))+rdi],eax
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_asm_RC4_set_key:
global RC4_options
ALIGN 16
RC4_options:
lea rax,[$L$opts]
mov rdx,QWORD[OPENSSL_ia32cap_P]
mov edx,DWORD[rdx]
bt edx,20
jc NEAR $L$8xchar
bt edx,30
jnc NEAR $L$done
add rax,25
DB 0F3h,0C3h ;repret
$L$8xchar:
add rax,12
$L$done:
DB 0F3h,0C3h ;repret
ALIGN 64
$L$opts:
DB 114,99,52,40,56,120,44,105,110,116,41,0
DB 114,99,52,40,56,120,44,99,104,97,114,41,0
DB 114,99,52,40,49,54,120,44,105,110,116,41,0
DB 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32
DB 67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97
DB 112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103
DB 62,0
ALIGN 64
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
stream_se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
lea r10,[$L$prologue]
cmp rbx,r10
jb NEAR $L$in_prologue
mov rax,QWORD[152+r8]
lea r10,[$L$epilogue]
cmp rbx,r10
jae NEAR $L$in_prologue
lea rax,[24+rax]
mov rbx,QWORD[((-8))+rax]
mov r12,QWORD[((-16))+rax]
mov r13,QWORD[((-24))+rax]
mov QWORD[144+r8],rbx
mov QWORD[216+r8],r12
mov QWORD[224+r8],r13
$L$in_prologue:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
jmp NEAR $L$common_seh_exit
ALIGN 16
key_se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[152+r8]
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
$L$common_seh_exit:
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_asm_RC4 wrt ..imagebase
DD $L$SEH_end_asm_RC4 wrt ..imagebase
DD $L$SEH_info_asm_RC4 wrt ..imagebase
DD $L$SEH_begin_asm_RC4_set_key wrt ..imagebase
DD $L$SEH_end_asm_RC4_set_key wrt ..imagebase
DD $L$SEH_info_asm_RC4_set_key wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_asm_RC4:
DB 9,0,0,0
DD stream_se_handler wrt ..imagebase
$L$SEH_info_asm_RC4_set_key:
DB 9,0,0,0
DD key_se_handler wrt ..imagebase
|
copyright zengfr site:http://github.com/zengfr/romhack
0389A8 move.b #$0, ($2f,A6)
0389AE cmpi.b #$a, ($14,A6)
copyright zengfr site:http://github.com/zengfr/romhack
|
; %include './syscall.asm'
;------------------------------------------
; int strlen(String message)
; String length calculation function
;
; rdi - 1st arg with string address
; rax - return value
slen:
mov rax, rdi
nextchar:
cmp byte [rax], 0
jz finished
inc rax
jmp nextchar
finished:
sub rax, rdi
ret
;------------------------------------------
; void sprint(String message)
; String printing function
sprint:
call slen
mov rdx, rax ; arg #3, length of string
mov rsi, rdi ; arg #2, address of string
mov rdi, 1h ; arg #1, stdout
mov rax, SYS_WRITE ; write()
syscall
ret
;------------------------------------------
; void sprint(String message)
; String printing function with defined length
; rdi - address of string
; rsi - length
print:
mov rdx, rsi ; arg #3, length of string
mov rsi, rdi ; arg #2, address of string
mov rdi, 1h ; arg #1, stdout
mov rax, SYS_WRITE ; write()
syscall
ret
;------------------------------------------
; void printChar(Char char)
; String printing with single char by its' code
printChar:
push rdi
mov rdi, rsp
mov rsi, 1h
call print
pop rdi
ret
;------------------------------------------
; void sprintLF(String message)
; String printing with line feed function
sprintLF:
call sprint
mov rdi, 0Ah
call printChar
ret
;------------------------------------------
; void input(char *buf, size_t count)
; Read data from console
sinput:
mov rax, SYS_READ
mov rdx, rsi ; 3rd, size
mov rsi, rdi ; 2nd, address to put input
mov rdi, 0x0 ; 1st, fd for input
syscall
ret
;------------------------------------------
; void iprint(Integer number)
; Integer printing (itoa)
; num in rdi - 1st argument
iprint:
mov rcx, 0 ; num counter
mov rax, rdi
; if positive
cmp rax, 0x0
jnl .divideLoop
; else
neg rax
mov rdi, 45
push rax
push rcx
call printChar
pop rcx
pop rax
.divideLoop:
inc rcx
mov rdx, 0 ; empty remainder
mov rsi, 0Ah
div rsi
add rdx, 30h ; 48 or 30h or '0'
push rdx
cmp rax, 0
jnz .divideLoop
.printLoop:
dec rcx
mov rdi, rsp
push rcx
call sprint
pop rcx
pop rdi
cmp rcx, 0
jnz .printLoop
ret
;------------------------------------------
; int atoi(Integer number)
; Ascii to integer function (atoi)
;
; atoi:
; in rdi - 1st argument
; return rax
atoi:
push rbx
mov rcx, 0 ; init counter
; check first char
xor rbx, rbx ; set 0
mov bl, [rdi + rcx] ; current char in rbx
; if char is minus
mov rax, 1
cmp bl, 45 ; '-'
jne .begin
mov rax, -1
inc rcx
.begin:
push rax
mov rax, 0 ; initialise rax with decimal value 0
.multiplyLoop:
xor rbx, rbx ; set 0
mov bl, [rdi + rcx] ; current char in rbx
; if char is minus
cmp bl, 45 ; '-' code is 45
jne .notNegative
; mov rax, 0xa
inc rcx
jmp .multiplyLoop
.notNegative:
; if end of string
cmp bl, 10 ; compare ebx register's lower half value against ascii value 10 (linefeed character)
je .finished ; jump if equal to label finished
cmp bl, 0 ; compare ebx register's lower half value against decimal value 0 (end of string)
jz .finished ; jump if zero to label finished
; if char is number
cmp bl, 48 ; ascii value 48 (char value 0)
jge .processNumber ; jump if less than to label finished
cmp bl, 57 ; compare ebx register's lower half value against ascii value 57 (char value 9)
jle .processNumber ; jump if greater than to label finished
.processNumber:
sub bl, 48
add rax, rbx
mov rbx, 10
mul rbx
inc rcx
jmp .multiplyLoop
.finished:
xor rdx, rdx ; otherwise wrong result in linux
mov rbx, 10
div rbx ; rax/rbx
pop rbx
mul rbx ; 1 or -1
pop rbx ; restore initial value
ret
;------------------------------------------
; void exit()
; Exit program and restore resources
;
; rdi - 1st argument, exit code
exit:
mov rax, SYS_EXIT
syscall
ret
|
Name: zel_enmy00.asm
Type: file
Size: 534138
Last-Modified: '2016-05-13T04:36:32Z'
SHA-1: CC70CC43DDF19B7FA4E6E68D97705E51FA75EFAA
Description: null
|
/*
* Copyright (c) 2012, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project 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 PETER THORSON 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.
*
*/
//#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE message_buffer_alloc
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
#include <websocketpp/message_buffer/alloc.hpp>
template <template <class> class con_msg_manager>
struct stub {
typedef websocketpp::lib::shared_ptr<stub> ptr;
typedef con_msg_manager<stub> con_msg_man_type;
typedef typename con_msg_man_type::ptr con_msg_man_ptr;
typedef typename con_msg_man_type::weak_ptr con_msg_man_weak_ptr;
stub(con_msg_man_ptr manager, websocketpp::frame::opcode::value op, size_t size = 128)
: m_opcode(op)
, m_manager(manager)
, m_size(size) {}
bool recycle() {
con_msg_man_ptr shared = m_manager.lock();
if (shared) {
return shared->recycle(this);
} else {
return false;
}
}
websocketpp::frame::opcode::value m_opcode;
con_msg_man_weak_ptr m_manager;
size_t m_size;
};
BOOST_AUTO_TEST_CASE( basic_get_message ) {
typedef stub<websocketpp::message_buffer::alloc::con_msg_manager>
message_type;
typedef websocketpp::message_buffer::alloc::con_msg_manager<message_type>
con_msg_man_type;
con_msg_man_type::ptr manager(new con_msg_man_type());
message_type::ptr msg = manager->get_message(websocketpp::frame::opcode::TEXT,512);
BOOST_CHECK(msg);
BOOST_CHECK(msg->m_opcode == websocketpp::frame::opcode::TEXT);
BOOST_CHECK(msg->m_manager.lock() == manager);
BOOST_CHECK(msg->m_size == 512);
}
BOOST_AUTO_TEST_CASE( basic_get_manager ) {
typedef stub<websocketpp::message_buffer::alloc::con_msg_manager>
message_type;
typedef websocketpp::message_buffer::alloc::con_msg_manager<message_type>
con_msg_man_type;
typedef websocketpp::message_buffer::alloc::endpoint_msg_manager
<con_msg_man_type> endpoint_manager_type;
endpoint_manager_type em;
con_msg_man_type::ptr manager = em.get_manager();
message_type::ptr msg = manager->get_message(websocketpp::frame::opcode::TEXT,512);
BOOST_CHECK(msg);
BOOST_CHECK(msg->m_opcode == websocketpp::frame::opcode::TEXT);
BOOST_CHECK(msg->m_manager.lock() == manager);
BOOST_CHECK(msg->m_size == 512);
}
|
// This is a generated file, modify: generate/templates/struct_content.cc.
#include <nan.h>
#include <string.h>
#include <chrono>
#include <thread>
extern "C" {
#include <git2.h>
}
#include <iostream>
#include "../include/functions/copy.h"
#include "../include/repository_init_options.h"
using namespace v8;
using namespace node;
using namespace std;
// generated from struct_content.cc
GitRepositoryInitOptions::GitRepositoryInitOptions() {
git_repository_init_options wrappedValue = GIT_REPOSITORY_INIT_OPTIONS_INIT;
this->raw = (git_repository_init_options*) malloc(sizeof(git_repository_init_options));
memcpy(this->raw, &wrappedValue, sizeof(git_repository_init_options));
this->ConstructFields();
this->selfFreeing = true;
}
GitRepositoryInitOptions::GitRepositoryInitOptions(git_repository_init_options* raw, bool selfFreeing) {
this->raw = raw;
this->ConstructFields();
this->selfFreeing = selfFreeing;
}
GitRepositoryInitOptions::~GitRepositoryInitOptions() {
if (this->selfFreeing) {
free(this->raw);
}
}
void GitRepositoryInitOptions::ConstructFields() {
}
void GitRepositoryInitOptions::InitializeComponent(Handle<v8::Object> target) {
NanScope();
Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(JSNewFunction);
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->SetClassName(NanNew<String>("RepositoryInitOptions"));
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("version"), GetVersion, SetVersion);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("flags"), GetFlags, SetFlags);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("mode"), GetMode, SetMode);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("workdirPath"), GetWorkdirPath, SetWorkdirPath);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("description"), GetDescription, SetDescription);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("templatePath"), GetTemplatePath, SetTemplatePath);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("initialHead"), GetInitialHead, SetInitialHead);
tpl->InstanceTemplate()->SetAccessor(NanNew<String>("originUrl"), GetOriginUrl, SetOriginUrl);
Local<Function> _constructor_template = tpl->GetFunction();
NanAssignPersistent(constructor_template, _constructor_template);
target->Set(NanNew<String>("RepositoryInitOptions"), _constructor_template);
}
NAN_METHOD(GitRepositoryInitOptions::JSNewFunction) {
NanScope();
GitRepositoryInitOptions* instance;
if (args.Length() == 0 || !args[0]->IsExternal()) {
instance = new GitRepositoryInitOptions();
}
else {
instance = new GitRepositoryInitOptions(static_cast<git_repository_init_options*>(Handle<External>::Cast(args[0])->Value()), args[1]->BooleanValue());
}
instance->Wrap(args.This());
NanReturnValue(args.This());
}
Handle<v8::Value> GitRepositoryInitOptions::New(void* raw, bool selfFreeing) {
NanEscapableScope();
Handle<v8::Value> argv[2] = { NanNew<External>((void *)raw), NanNew<Boolean>(selfFreeing) };
return NanEscapeScope(NanNew<Function>(GitRepositoryInitOptions::constructor_template)->NewInstance(2, argv));
}
git_repository_init_options *GitRepositoryInitOptions::GetValue() {
return this->raw;
}
git_repository_init_options **GitRepositoryInitOptions::GetRefValue() {
return this->raw == NULL ? NULL : &this->raw;
}
void GitRepositoryInitOptions::ClearValue() {
this->raw = NULL;
}
NAN_GETTER(GitRepositoryInitOptions::GetVersion) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
NanReturnValue(NanNew<Number>(wrapper->GetValue()->version));
}
NAN_SETTER(GitRepositoryInitOptions::SetVersion) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (value->IsNumber()) {
wrapper->GetValue()->version = (unsigned int) value->Int32Value();
}
}
NAN_GETTER(GitRepositoryInitOptions::GetFlags) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
NanReturnValue(NanNew<Number>(wrapper->GetValue()->flags));
}
NAN_SETTER(GitRepositoryInitOptions::SetFlags) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (value->IsNumber()) {
wrapper->GetValue()->flags = (uint32_t) value->Int32Value();
}
}
NAN_GETTER(GitRepositoryInitOptions::GetMode) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
NanReturnValue(NanNew<Number>(wrapper->GetValue()->mode));
}
NAN_SETTER(GitRepositoryInitOptions::SetMode) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (value->IsNumber()) {
wrapper->GetValue()->mode = (uint32_t) value->Int32Value();
}
}
NAN_GETTER(GitRepositoryInitOptions::GetWorkdirPath) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->workdir_path) {
NanReturnValue(NanNew<String>(wrapper->GetValue()->workdir_path));
}
else {
NanReturnUndefined();
}
}
NAN_SETTER(GitRepositoryInitOptions::SetWorkdirPath) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->workdir_path) {
}
String::Utf8Value str(value);
wrapper->GetValue()->workdir_path = strdup(*str);
}
NAN_GETTER(GitRepositoryInitOptions::GetDescription) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->description) {
NanReturnValue(NanNew<String>(wrapper->GetValue()->description));
}
else {
NanReturnUndefined();
}
}
NAN_SETTER(GitRepositoryInitOptions::SetDescription) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->description) {
}
String::Utf8Value str(value);
wrapper->GetValue()->description = strdup(*str);
}
NAN_GETTER(GitRepositoryInitOptions::GetTemplatePath) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->template_path) {
NanReturnValue(NanNew<String>(wrapper->GetValue()->template_path));
}
else {
NanReturnUndefined();
}
}
NAN_SETTER(GitRepositoryInitOptions::SetTemplatePath) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->template_path) {
}
String::Utf8Value str(value);
wrapper->GetValue()->template_path = strdup(*str);
}
NAN_GETTER(GitRepositoryInitOptions::GetInitialHead) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->initial_head) {
NanReturnValue(NanNew<String>(wrapper->GetValue()->initial_head));
}
else {
NanReturnUndefined();
}
}
NAN_SETTER(GitRepositoryInitOptions::SetInitialHead) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->initial_head) {
}
String::Utf8Value str(value);
wrapper->GetValue()->initial_head = strdup(*str);
}
NAN_GETTER(GitRepositoryInitOptions::GetOriginUrl) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->origin_url) {
NanReturnValue(NanNew<String>(wrapper->GetValue()->origin_url));
}
else {
NanReturnUndefined();
}
}
NAN_SETTER(GitRepositoryInitOptions::SetOriginUrl) {
NanScope();
GitRepositoryInitOptions *wrapper = ObjectWrap::Unwrap<GitRepositoryInitOptions>(args.This());
if (wrapper->GetValue()->origin_url) {
}
String::Utf8Value str(value);
wrapper->GetValue()->origin_url = strdup(*str);
}
Persistent<Function> GitRepositoryInitOptions::constructor_template;
|
.586
.XMM
.MODEL FLAT, C
.STACK
.DATA
dispatchLabel dword Opcode_Move ; done
dword Opcode_LoadK ; done
dword Opcode_LoadBool
dword Opcode_LoadNil
dword Opcode_GetUpVal
dword Opcode_GetGlobal ; done
dword Opcode_GetTable
dword Opcode_SetGlobal ; done
dword Opcode_SetUpVal
dword Opcode_SetTable
dword Opcode_NewTable ; done
dword Opcode_Self
dword Opcode_Add
dword Opcode_Sub
dword Opcode_Mul
dword Opcode_Div
dword Opcode_Mod
dword Opcode_Pow
dword Opcode_Unm
dword Opcode_Not
dword Opcode_Len
dword Opcode_Concat
dword Opcode_Jmp
dword Opcode_Eq
dword Opcode_Lt
dword Opcode_Le
dword Opcode_Test
dword Opcode_TestSet
dword Opcode_Call ; done
dword Opcode_TailCall
dword Opcode_Return ; done (sort of)
dword Opcode_ForLoop
dword Opcode_ForPrep
dword Opcode_TForLoop
dword Opcode_SetList
dword Opcode_Close
dword Opcode_Closure
dword Opcode_VarArg
.CODE
offsetof_lua_State_stackBase = 4
offsetof_LClosure_prototype = 0
offsetof_Prototype_code = 32
offsetof_Prototype_constant = 40
offsetof_Prototype_numUpValues = 44
offsetof_Prototype_prototype = 52
sizeof_Value = 8
tag_Nil = 0FFFFFFFFh
tag_Function = 0FFFFFFF9h
tag_Table = 0FFFFFFFAh
EXTRN Vm_GetGlobal:NEAR
EXTRN Vm_SetGlobal:NEAR
EXTRN Vm_Call:NEAR
EXTRN Table_Create:NEAR
EXTRN Vm_SetTable:NEAR
EXTRN Vm_GetTable:NEAR
EXTRN Closure_Create:NEAR
GET_INST macro inst, opcode
mov inst, DWORD PTR [ ebx ]
add ebx, 4
mov opcode, inst ; get opcode
and opcode, 3Fh
endm
; ebx should contain the current IP
; after executing:
; ecx = packed instruction
DISPATCH macro
GET_INST ecx, eax
jmp DWORD PTR [dispatchLabel + eax * 4]
endm
; Parser_EmitABC
; Parser_EmitAB
; Parser_EmitABx
; Parser_EmitAsBx
; Unpacks an instruction encoded as A
; ecx should contain the instruction
; Result:
; ecx = 'a'
UNPACK_A macro
shr ecx, 6
and ecx, 0FFh
endm
; Unpacks an instruction encoded as A
; ecx should contain the instruction
; Result:
; ecx = 'a'
; edx = 'b'
UNPACK_AB macro
mov edx, ecx ; get 'b'
shr edx, 23
and edx, 1FFh
shr ecx, 6 ; get 'a'
and ecx, 0FFh
endm
; Unpacks an instruction encoded as A Bx
; ecx should contain the instruction
; Result:
; ecx = 'a'
; edx = 'b'
UNPACK_ABx macro
mov edx, ecx ; get 'bx'
shr edx, 14
and edx, 3FFFFh
shr ecx, 6 ; get 'a'
and ecx, 0FFh
endm
; Unpacks an instruction encoded as A B C
; ecx should contain the instruction
; Result:
; ecx = 'a'
; edx = 'b'
; eax = 'c'
UNPACK_ABC macro
mov edx, ecx ; get 'b'
shr edx, 23
and edx, 1FFh
mov eax, ecx ; get 'c'
shr eax, 14
and eax, 1FFh
shr ecx, 6 ; get 'a'
and ecx, 0FFh
endm
UNPACK_sBx macro
shr ecx, 14
;and ecx, 3FFFFh
sub ecx, 131071
endm
; Pushes a VM stack location or a constant location onto the x86 stack
; based on the encoded value of src
PUSH_RK macro src
LOCAL Const
LOCAL Done
test src, 100h
jne Const
lea src, DWORD PTR [ esi + src * sizeof_Value ]
jmp Done
Const:
and src, 0FFh
lea src, DWORD PTR [ edi + src * sizeof_Value ]
Done:
push src
endm
; Parameters:
; lua_State*
; LClosure*
;
Vm_Execute PROC USES esi edi ebx L:DWORD, closure:DWORD
LOCAL prototype : DWORD
; esi = stack base
mov eax, L
mov esi, DWORD PTR [ eax + offsetof_lua_State_stackBase ]
; Save prototype
mov eax, closure
mov eax, DWORD PTR [ eax + offsetof_LClosure_prototype ]
mov prototype, eax
; ebx = code
; edi = constants
mov eax, prototype
mov ebx, DWORD PTR [ eax + offsetof_Prototype_code ]
mov edi, DWORD PTR [ eax + offsetof_Prototype_constant ]
DISPATCH
;-------------------------------------------------------------------------------
Opcode_Move::
UNPACK_AB
movsd xmm0, QWORD PTR [ esi + edx * sizeof_Value ]
movsd QWORD PTR [ esi + ecx * sizeof_Value ], xmm0
DISPATCH
;-------------------------------------------------------------------------------
Opcode_LoadK::
UNPACK_ABx
movsd xmm0, QWORD PTR [ edi + edx * sizeof_Value ]
movsd QWORD PTR [ esi + ecx * sizeof_Value ], xmm0
DISPATCH
;-------------------------------------------------------------------------------
Opcode_LoadBool::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_LoadNil::
UNPACK_AB
; eax = &stackBase[a]
lea eax, DWORD PTR [ esi + ecx * sizeof_Value ]
; ecx = b - a
sub edx, ecx
mov ecx, edx
LoadNil_Loop:
mov DWORD PTR [ eax + ecx * sizeof_Value ], tag_Nil
loopnz LoadNil_Loop
DISPATCH
;-------------------------------------------------------------------------------
Opcode_GetUpVal::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_GetGlobal::
UNPACK_ABx
push ecx
lea eax, DWORD PTR [ esi + ecx * sizeof_Value ]
push eax
lea edx, DWORD PTR [ edi + edx * sizeof_Value ]
push edx
push DWORD PTR [ ebp + 8 ] ; L
call Vm_GetGlobal
add esp, 3 * 4
pop ecx
DISPATCH
;-------------------------------------------------------------------------------
Opcode_GetTable::
UNPACK_ABC
; Call the Vm_GetTable
push ecx
PUSH_RK eax
lea edx, DWORD PTR [ esi + edx * sizeof_Value ]
push edx
push DWORD PTR [ ebp + 8 ] ; L
call Vm_GetTable
add esp, 3 * 4
pop ecx
; Check for Vm_GetTable returning a NULL value
cmp eax, 0
je SetTable_Nil
movsd xmm0, QWORD PTR [eax]
movsd QWORD PTR [ esi + ecx * sizeof_Value ], xmm0
DISPATCH
SetTable_Nil:
mov DWORD PTR [ esi + ecx * sizeof_Value ], tag_Nil
DISPATCH
;-------------------------------------------------------------------------------
Opcode_SetGlobal::
UNPACK_ABx
; &stackBase[a]
lea ecx, DWORD PTR [ esi + ecx * sizeof_Value ]
push ecx
; &constant[bx]
lea edx, DWORD PTR [ edi + edx * sizeof_Value ]
push edx
push DWORD PTR [ ebp + 8 ] ; L
call Vm_SetGlobal
add esp, 3 * 4
DISPATCH
;-------------------------------------------------------------------------------
Opcode_SetUpVal::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_SetTable::
UNPACK_ABC
PUSH_RK eax ; value
PUSH_RK edx ; key
; table
lea ecx, DWORD PTR [ esi + ecx * sizeof_Value ]
push ecx
push DWORD PTR [ ebp + 8 ] ; L
call Vm_SetTable
add esp, 4 * 4
DISPATCH
;-------------------------------------------------------------------------------
Opcode_NewTable::
push ecx
push DWORD PTR [ ebp + 8 ] ; L
call Table_Create
add esp, 1 * 4
pop ecx
UNPACK_A
; stackBase[a] = { tag_Table, table }
mov DWORD PTR [ esi + ecx * sizeof_Value ], tag_Table
mov DWORD PTR [ esi + ecx * sizeof_Value + 4 ], eax
DISPATCH
;-------------------------------------------------------------------------------
Opcode_Self::
DISPATCH
Opcode_Add::
DISPATCH
Opcode_Sub::
DISPATCH
Opcode_Mul::
DISPATCH
Opcode_Div::
DISPATCH
Opcode_Mod::
DISPATCH
Opcode_Pow::
DISPATCH
Opcode_Unm::
DISPATCH
Opcode_Not::
DISPATCH
Opcode_Len::
DISPATCH
Opcode_Concat::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_Jmp::
UNPACK_sBx
add ebx, ecx
DISPATCH
;-------------------------------------------------------------------------------
Opcode_Eq::
DISPATCH
Opcode_Lt::
DISPATCH
Opcode_Le::
DISPATCH
Opcode_Test::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_TestSet::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_Call::
UNPACK_ABC
dec eax ; numResults
push eax
dec edx ; numArgs
push edx
; &stackBase[a]
lea ecx, DWORD PTR [ esi + ecx * sizeof_Value ]
push ecx
push DWORD PTR [ ebp + 8 ] ; L
call Vm_Call
add esp, 4 * 4
DISPATCH
Opcode_TailCall::
DISPATCH
Opcode_Return::
jmp Done
Opcode_ForLoop::
DISPATCH
Opcode_ForPrep::
DISPATCH
Opcode_TForLoop::
DISPATCH
;-------------------------------------------------------------------------------
Opcode_SetList::
UNPACK_ABC
; TODO
DISPATCH
Opcode_Close::
DISPATCH
Opcode_Closure::
UNPACK_ABx
; a = ecx
; bx = edx
push ecx ; store a for later
mov eax, DWORD PTR [ prototype ]
; Get the new prototype
mov eax, DWORD PTR [ eax + offsetof_Prototype_prototype ]
mov eax, DWORD PTR [ eax + edx * 4 ]
push eax ; Store for later
; Create the closure
push eax
push L
call Closure_Create
add esp, 2 * 4
; Handle the up-values
pop ecx ; new prototype
mov ecx, DWORD PTR [ ecx + offsetof_Prototype_numUpValues ]
Closure_Loop:
GET_INST eax, edx
Closure_Loop_End:
loop Closure_Loop
; TODO!!!!!!!!
; stackBase[a] = { tag_Function, closure }
pop ecx ; a
mov DWORD PTR [ esi + ecx * sizeof_Value ], tag_Function
mov DWORD PTR [ esi + ecx * sizeof_Value + 4 ], eax
DISPATCH
Opcode_VarArg::
DISPATCH
Done:
; Return value
mov eax, 0
ret
Vm_Execute ENDP
END |
DOSSEG
.MODEL SMALL
.STACK 100h
.DATA
hobptr dw 0
hob dw 32605 dup(0) ; allocate hob
; error messages
oomstr db 10,13,'Out of memory! Can not allocate another class.','$',0,0
.CODE
jmp START
; ------------ STANDARD FUNCTIONS BEGIN ----------:
new PROC
mov ax, hobptr ; get hop size
push ax ; save pos. of class in stack
add ax, cx ; add size of obj
cmp ax, 32605
jg OutOfMem ; if ax < HOBSIZE jump to OutOfMemory
mov hobptr, ax ; save hop size
pop ax ; ax = pos. of class in hob
ret
OutOfMem:
mov dx, OFFSET oomstr; write out of mem string to screen
mov ah, 9h
int 21h
jmp SystemExit
new ENDP
SystemOutPrint PROC
mov bp, sp
sub bp, 2
mov bx, [bp+4] ; get adr of str obj
mov cx, hob[bx] ; strlen
mov si, bx ; source-print ptr
add si, 2 ; get past length field
printloop:
mov dx, hob[si]
add si, 2 ; next char
mov ah, 2h ; print char
int 21h
loop printloop
ret
SystemOutPrint ENDP
SystemInRead PROC
mov ah, 1h ; read with screen echo
int 21h
mov ah, 0 ; clear AH as only AL contains userinput
ret
SystemInRead ENDP
SystemExit PROC
mov ah, 4ch
int 21h
ret
SystemExit ENDP
Integer_toString PROC
mov bp, sp
sub bp, 2
mov ax, [bp+4] ; get number (first argument)
xor cx, cx ; cx counts size of str
xor di, di ; flag for negative numbers
cmp ax, 0 ; is negative?
jge nonneg
inc di ; di == 1 == number is negative
inc cx
neg ax ; make the number positive
nonneg:
mov si, 10 ; div with reg SI as many times as possible
getDigits:
xor dx, dx
div si
add dx, 48 ; conv digit to ASCII
push dx
inc cx
cmp ax, 0 ; are we done?
jg getDigits
push cx ; store cx
shl cx, 1 ; calc str size = (2*strlen)+2
add cx, 2
call new ; alloc new str
pop cx ; get original strlen
mov si, ax ; ptr to str in hob
mov hob[si], cx ; store size of str
cmp di, 0 ; is no negative?
je toStr
add si, 2 ; next pos
mov hob[si], '-' ; write '-' sign
dec cx
toStr:
add si, 2 ; next pos
pop dx ; get digit
mov hob[si], dx ; store size of str
loop toStr
ret
Integer_toString ENDP
String_charAt PROC
mov bp, sp
sub bp, 2
mov si, bx ; pos in hob where obj begins
mov ax, [bp+4] ; get (first) argument telling pos to get
shl ax, 1 ; ax = ax * 2 every char is 2 elems
add si, ax ; pos in hob to fetch character
mov ax, hob[si+2] ; +2 as first field contains str_len
ret
String_charAt ENDP
String_concat PROC
mov bp, sp
sub bp, 2
mov cx, hob[bx] ; size of caller str
mov si, [bp+4] ; pos in hob of 2nd str len
add cx, hob[si] ; add 2nd str len
add cx, 2 ; add space for sizefield
push cx
call new ; alloc new String object
pop cx ; total strsize
mov si, ax ; can't just use the AX
mov hob[si], cx ; set concat'ed String size
mov cx, hob[bx] ; size of str1
add bx, 4 ; start in 2nd pos (but why +4 instead of +2 ??)
mov di, ax ; destination ptr = adr of new String obj
add di, 2 ; start in 2nd pos
strcat1:
mov si, [bx] ; we can't just use [bx]
mov hob[di], si
add bx, 2
add di, 2
loop strcat1
mov si, [bp+4] ; pos in hob of 2nd str len
mov cx, hob[si] ; size of 2nd str len
mov bx, [bp+4] ; point at start of 2nd string
add bx, 4 ; start in 2nd pos (but why +4??)
strcat2:
mov si, [bx] ; we can't just use [bx]
mov hob[di], si
add bx, 2
add di, 2
loop strcat2
ret
String_concat ENDP
String_length PROC ; str_len length()
mov ax, hob[bx] ; first field in string
ret
String_length ENDP
; ------------ STANDARD FUNCTIONS END ----------:
A_f PROC
mov bp, sp ; adjust bp to point at functions local variable
sub bp, 2
; fnccallGen
push bp
push bx
; fnccallGen
push bp
push bx
mov ax, [bp+4] ; get argument variable i
push ax
call Integer_toString
pop cx ; de-stack arguments
pop bx
pop bp
push ax ; store generated String
call SystemOutPrint
pop cx ; de-stack argument
pop bx
pop bp
; fnccallGen
push bp
push bx
mov ax, hob[bx+2] ; get class variable space
push ax
call SystemOutPrint
pop cx ; de-stack argument
pop bx
pop bp
A_f_end:
ret
A_f ENDP
START:
mov ax, @data ; setup DOS program
mov ds, ax
; allocate object main resides in
mov cx, 4
call new
mov bp, sp ; adjust bp to point at functions local variable
sub bp, 2 ;
mov bx, ax ; store main's 'this'
; execute mains contents
push 0 ; push local variables to stack
; assign
mov ax, 0
push ax
pop ax ; get value (assign)
mov [bp-0], ax ; set local variable i
; assign
; string - allocate class and return pointer on stack
mov cx, 4 ; length of 2*str + 2
call new
mov si, ax ; mov (adr of obj in hob) to si
mov hob[si], 1 ; insert strlength
mov hob[si+2], '*'
push ax
pop ax ; get value (assign)
mov hob[bx+0], ax ; set class variable a
; assign
; string - allocate class and return pointer on stack
mov cx, 4 ; length of 2*str + 2
call new
mov si, ax ; mov (adr of obj in hob) to si
mov hob[si], 1 ; insert strlength
mov hob[si+2], ' '
push ax
pop ax ; get value (assign)
mov hob[bx+2], ax ; set class variable space
start_while1:
; condition code
mov ax, [bp-0] ; get local variable i
push ax
;
mov ax, 5000
push ax
pop dx
pop ax
cmp ax, dx
jl less_2
xor ax, ax ; is not <
jmp less_end2
less_2:
mov ax, 65535 ; is <
less_end2:
push ax
pop ax ; compare condition code
cmp ax, 0
je end_while1 ; condition is false
; fnccallGen
push bp
mov ax, [bp-0] ; get local variable i
push ax
call A_f
pop cx ; de-stack arguments
pop bp
; assign
mov ax, [bp-0] ; get local variable i
push ax
;
mov ax, 1
push ax
pop dx
pop ax
add ax, dx
push ax
pop ax ; get value (assign)
mov [bp-0], ax ; set local variable i
jmp start_while1 ; loop once more
end_while1:
jmp SystemExit
END
|
; A169424: Number of reduced words of length n in Coxeter group on 27 generators S_i with relations (S_i)^2 = (S_i S_j)^32 = I.
; 1,27,702,18252,474552,12338352,320797152,8340725952,216858874752,5638330743552,146596599332352,3811511582641152,99099301148669952,2576581829865418752,66991127576500887552,1741769316989023076352
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,26
lpe
mov $0,$2
div $0,26
|
; A034871: Odd-numbered rows of Pascal's triangle.
; 1,1,1,3,3,1,1,5,10,10,5,1,1,7,21,35,35,21,7,1,1,9,36,84,126,126,84,36,9,1,1,11,55,165,330,462,462,330,165,55,11,1,1,13,78,286,715,1287,1716,1716,1287,715,286,78,13,1,1,15,105,455,1365,3003,5005
mov $1,1
lpb $0
sub $2,2
add $0,$2
add $1,2
lpe
bin $1,$0
mov $0,$1
|
IFDEF RAX
fix_and_swapcontext PROTO STDCALL :QWORD
.code
swapcontext PROC
push r8
push r9
push rdi
push rsi
push rbp
push rdx ; other
push rcx ; current
lea r8, gotback
mov r9, rsp
; without some stack padding someone overrides our values, no idea why?
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
push rax
call fix_and_swapcontext
gotback:
pop rcx
pop rdx
pop rbp
pop rsi
pop rdi
pop r9
pop r8
ret
swapcontext ENDP
ENDIF
end |
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <vector>
#include <map>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int main() {
std::ios::sync_with_stdio(false);
int n;
int a[1000010];
cin >> n;
long long ans = 0;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
if (i != 1)
ans += max (0, a[i - 1] - a[i]);
a[i] = max (a[i], a[i - 1]);
}
cout << ans << endl;
return 0;
} |
; A006234: a(n) = n*3^(n-4).
; 1,4,15,54,189,648,2187,7290,24057,78732,255879,826686,2657205,8503056,27103491,86093442,272629233,860934420,2711943423,8523250758,26732013741,83682825624,261508830075,815907549834,2541865828329,7908027021468,24571369673847,76255974849870,236393522034597,732057358558752,2264802453041139,7000298491218066,21618568869938145,66708726798666276,205685240962554351,633732904587329622,1951230258860988573,6003785411879964840,18461640141530891883,56735772142265667738,174259871579815979481
mov $1,3
pow $1,$0
add $0,3
mul $1,$0
div $1,3
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x136b8, %rsi
lea addresses_WC_ht+0x1cae, %rdi
nop
cmp %r8, %r8
mov $59, %rcx
rep movsw
inc %r9
lea addresses_A_ht+0x11dae, %r14
nop
nop
nop
inc %rbx
movb (%r14), %r9b
sub %r8, %r8
lea addresses_D_ht+0xf1ae, %rbx
nop
nop
inc %rsi
movb (%rbx), %r8b
nop
nop
sub %rbx, %rbx
lea addresses_UC_ht+0x1c574, %r8
clflush (%r8)
add $48813, %rbx
mov $0x6162636465666768, %rsi
movq %rsi, %xmm3
vmovups %ymm3, (%r8)
sub %r14, %r14
lea addresses_WC_ht+0xa28e, %rsi
lea addresses_WC_ht+0x7cae, %rdi
nop
nop
nop
nop
xor $34031, %r11
mov $96, %rcx
rep movsw
nop
nop
xor %rcx, %rcx
lea addresses_UC_ht+0x182e, %rsi
lea addresses_normal_ht+0x306e, %rdi
clflush (%rsi)
nop
nop
sub %r8, %r8
mov $9, %rcx
rep movsl
nop
nop
nop
sub $42746, %rsi
lea addresses_UC_ht+0x282e, %r11
nop
cmp %r14, %r14
movups (%r11), %xmm6
vpextrq $1, %xmm6, %r9
cmp $7974, %r8
lea addresses_D_ht+0x46d4, %rbx
clflush (%rbx)
add %r8, %r8
mov (%rbx), %ecx
nop
sub %rsi, %rsi
lea addresses_normal_ht+0xaf16, %r9
nop
nop
nop
nop
xor %r11, %r11
movups (%r9), %xmm6
vpextrq $1, %xmm6, %r8
nop
nop
nop
nop
nop
dec %rsi
lea addresses_D_ht+0xceae, %r11
nop
nop
nop
cmp %rdi, %rdi
movb $0x61, (%r11)
nop
nop
nop
nop
sub $652, %r8
lea addresses_WT_ht+0x1a7ae, %rbx
nop
nop
nop
nop
nop
add $57265, %r9
mov $0x6162636465666768, %rsi
movq %rsi, %xmm6
movups %xmm6, (%rbx)
nop
nop
nop
nop
add %rsi, %rsi
lea addresses_D_ht+0x3e36, %rsi
lea addresses_D_ht+0xf06c, %rdi
nop
nop
nop
dec %rbx
mov $15, %rcx
rep movsl
nop
sub $65047, %rsi
lea addresses_A_ht+0xdaae, %rsi
lea addresses_D_ht+0x119f6, %rdi
clflush (%rdi)
cmp $41662, %rbx
mov $105, %rcx
rep movsl
inc %r8
lea addresses_WC_ht+0x19b2e, %r11
nop
nop
nop
nop
sub $48750, %r9
vmovups (%r11), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $0, %xmm7, %r14
nop
nop
nop
nop
nop
dec %rbx
lea addresses_A_ht+0x14a2e, %r9
nop
dec %r11
mov (%r9), %r14w
dec %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Faulty Load
lea addresses_UC+0x1c6ae, %rcx
xor $35856, %rax
vmovups (%rcx), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %rsi
lea oracles, %rcx
and $0xff, %rsi
shlq $12, %rsi
mov (%rcx,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_UC', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': True, 'congruent': 1}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': True, 'AVXalign': False, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'45': 1236, '00': 784, '48': 19809}
48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 00 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 00 45 48 48 48 48 48 48 48 00 48 48 48 48 00 48 48 48 48 48 48 48 45 00 48 48 48 48 48 48 48 48 48 48 45 45 45 00 48 48 45 48 45 48 48 45 45 48 48 48 45 00 45 48 48 48 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 45 45 45 45 00 48 48 48 48 48 48 48 00 48 48 48 48 48 00 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 45 45 45 45 48 48 48 48 48 45 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 45 45 45 45 45 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 45 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 45 45 45 45 48 48 48 48 48 48 48 48 48 48 45 00 48 48 48 48 48 00 48 48 45 45 45 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 45 48 48 00 48 48 48 48 48 48 48 48 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 45 45 45 45 45 45 45 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 45 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 45 48 48 48 48 48 48 48 48 48 45 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 45 45 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 45 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 45 45 45 45 45 45 45 45 48 48 48 48 48 48 48 00 48 48 48 48 48 48 45 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
*/
|
SECTION code_threads_mutex
PUBLIC asm_spinlock_acquire
EXTERN __thread_context_switch
asm_spinlock_acquire:
; enter : hl = & spinlock
;
; exit : hl = & spinlock
; carry reset
;
; spinlock acquired
;
; uses : f
scf
rr (hl) ; atomic operation
ret nc ; if acquisition succeeded
acquisition_failed:
call __thread_context_switch
jr asm_spinlock_acquire
|
//
// Copyright (c) 2011-2012, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php
//
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
//
#include <AsmMacroIoLib.h>
#include <Base.h>
#include <Library/ArmPlatformSecLib.h>
#include <ArmPlatform.h>
#include <AutoGen.h>
INCLUDE AsmMacroIoLib.inc
EXPORT ArmPlatformSecBootAction
EXPORT ArmPlatformSecBootMemoryInit
PRESERVE8
AREA ArmRealviewEbBootMode, CODE, READONLY
/**
Call at the beginning of the platform boot up
This function allows the firmware platform to do extra actions at the early
stage of the platform power up.
Note: This function must be implemented in assembler as there is no stack set up yet
**/
ArmPlatformSecBootAction
LoadConstantToReg (ARM_EB_SYS_FLAGS_NV_REG, r0)
ldr r0, [r0]
cmp r0, #0
bxeq lr
bxne r0
/**
Initialize the memory where the initial stacks will reside
This memory can contain the initial stacks (Secure and Secure Monitor stacks).
In some platform, this region is already initialized and the implementation of this function can
do nothing. This memory can also represent the Secure RAM.
This function is called before the satck has been set up. Its implementation must ensure the stack
pointer is not used (probably required to use assembly language)
**/
ArmPlatformSecBootMemoryInit
// The SMC does not need to be initialized for RTSM
bx lr
END
|
; A096320: a(n) = (n^2+n+4)/2, modulo 10.
; Submitted by Christian Krause
; 2,3,5,8,2,7,3,0,8,7,7,8,0,3,7,2,8,5,3,2,2,3,5,8,2,7,3,0,8,7,7,8,0,3,7,2,8,5,3,2,2,3,5,8,2,7,3,0,8,7,7,8,0,3,7,2,8,5,3,2,2,3,5,8,2,7,3,0,8,7,7,8,0,3,7,2,8,5,3,2,2,3,5,8,2,7,3,0,8,7,7,8,0,3,7,2,8,5,3,2
add $0,11
bin $0,2
sub $0,53
mod $0,10
|
; A103488: a(n) = 2^(n^2-1).
; 1,8,256,32768,16777216,34359738368,281474976710656,9223372036854775808,1208925819614629174706176,633825300114114700748351602688,1329227995784915872903807060280344576,11150372599265311570767859136324180752990208,374144419156711147060143317175368453031918731001856,50216813883093446110686315385661331328818843555712276103168,26959946667150639794667015087019630673637144422540572481103610249216,57896044618658097711785492504343953926634992332820282019728792003956564819968
mov $1,2
pow $1,$0
add $0,2
pow $1,$0
mov $0,$1
|
#include "main.h"
#include <FreeRTOS.h>
#include <task.h>
#include <timers.h>
#if defined STM32H7
#include <stm32h7xx_hal.h>
// STM32H743ZI blue LED
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_7
#define LED_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
#elif defined STM32F4
#include <stm32f4xx_hal.h>
// STM32F4-Discovery green led - PD12
#define LED_PORT GPIOD
#define LED_PIN GPIO_PIN_12
#define LED_PORT_CLK_ENABLE __HAL_RCC_GPIOD_CLK_ENABLE
#elif defined STM32L5
#include <stm32l5xx_hal.h>
// NUCLEO-L552ZE-Q blue led - PB7
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_7
#define LED_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
#endif
static void blinky::blinkTask(void *arg)
{
for(;;)
{
vTaskDelay(500);
HAL_GPIO_TogglePin(LED_PORT, LED_PIN);
}
}
void blinky::init()
{
GPIO_InitTypeDef GPIO_Config;
GPIO_Config.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_Config.Pull = GPIO_NOPULL;
GPIO_Config.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_Config.Pin = LED_PIN;
LED_PORT_CLK_ENABLE();
HAL_GPIO_Init(LED_PORT, &GPIO_Config);
}
int main(void)
{
SystemInit();
blinky::init();
xTaskCreate(blinky::blinkTask, "blinky", configMINIMAL_STACK_SIZE * 4, NULL, tskIDLE_PRIORITY + 1, NULL);
vTaskStartScheduler();
for (;;);
return 0;
}
extern "C" void vApplicationTickHook(void)
{
}
extern "C" void vApplicationIdleHook(void)
{
}
extern "C" void vApplicationMallocFailedHook(void)
{
taskDISABLE_INTERRUPTS();
for(;;);
}
extern "C" void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName)
{
(void) pcTaskName;
(void) pxTask;
taskDISABLE_INTERRUPTS();
for(;;);
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xa987, %rsi
lea addresses_D_ht+0x4c86, %rdi
nop
nop
nop
nop
dec %rbx
mov $60, %rcx
rep movsw
inc %r9
lea addresses_WC_ht+0xd06, %r8
nop
and %r14, %r14
movl $0x61626364, (%r8)
nop
nop
nop
cmp $44594, %r14
lea addresses_WT_ht+0x1df86, %rsi
lea addresses_UC_ht+0x1242a, %rdi
nop
nop
nop
nop
and $51770, %r14
mov $25, %rcx
rep movsq
nop
cmp %rbx, %rbx
lea addresses_A_ht+0x19f86, %r9
nop
nop
dec %r8
mov (%r9), %di
nop
nop
nop
xor $18285, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rcx
push %rdx
push %rsi
// Faulty Load
lea addresses_A+0x1f086, %rdx
nop
nop
nop
cmp $43552, %rcx
vmovaps (%rdx), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %r13
lea oracles, %rcx
and $0xff, %r13
shlq $12, %r13
mov (%rcx,%r13,1), %r13
pop %rsi
pop %rdx
pop %rcx
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': True}, 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'00': 12823}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
// The following example builds a CodeDom source graph for a simple
// class that represents document properties. The source for the
// graph is generated, saved to a file, compiled into an executable,
// and run.
#using <System.dll>
using namespace System;
using namespace System::CodeDom;
using namespace System::CodeDom::Compiler;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::IO;
using namespace System::Diagnostics;
//<Snippet2>
// Build the source graph using System.CodeDom types.
CodeCompileUnit^ DocumentPropertyGraphBase()
{
// Create a new CodeCompileUnit for the source graph.
CodeCompileUnit^ docPropUnit = gcnew CodeCompileUnit;
// Declare a new namespace called DocumentSamples.
CodeNamespace^ sampleSpace = gcnew CodeNamespace( "DocumentSamples" );
// Add the new namespace to the compile unit.
docPropUnit->Namespaces->Add( sampleSpace );
// Add an import statement for the System namespace.
sampleSpace->Imports->Add( gcnew CodeNamespaceImport( "System" ) );
// Declare a new class called DocumentProperties.
// <Snippet3>
CodeTypeDeclaration^ baseClass = gcnew CodeTypeDeclaration( "DocumentProperties" );
baseClass->IsPartial = true;
baseClass->IsClass = true;
baseClass->Attributes = MemberAttributes::Public;
baseClass->BaseTypes->Add( gcnew CodeTypeReference( System::Object::typeid ) );
// Add the DocumentProperties class to the namespace.
sampleSpace->Types->Add( baseClass );
// </Snippet3>
// ------Build the DocumentProperty.Main method------
// Declare the Main method of the class.
CodeEntryPointMethod^ mainMethod = gcnew CodeEntryPointMethod;
mainMethod->Comments->Add( gcnew CodeCommentStatement( " Perform a simple test of the class methods." ) );
// Add the code entry point method to the Members
// collection of the type.
baseClass->Members->Add( mainMethod );
mainMethod->Statements->Add( gcnew CodeCommentStatement( "Initialize a class instance and display it." ) );
// <Snippet4>
// Initialize a local DocumentProperty instance, named myDoc.
// Use the DocumentProperty constructor to set the author,
// title, and date. Set the publish date to DateTime.Now.
CodePrimitiveExpression^ docTitlePrimitive = gcnew CodePrimitiveExpression( "Cubicle Survival Strategies" );
CodePrimitiveExpression^ docAuthorPrimitive = gcnew CodePrimitiveExpression( "John Smith" );
// Store the value of DateTime.Now in a local variable, to re-use
// the same value later.
CodeTypeReferenceExpression^ docDateClass = gcnew CodeTypeReferenceExpression( "DateTime" );
CodePropertyReferenceExpression^ docDateNow = gcnew CodePropertyReferenceExpression( docDateClass,"Now" );
CodeVariableDeclarationStatement^ publishNow = gcnew CodeVariableDeclarationStatement( DateTime::typeid,"publishNow",docDateNow );
mainMethod->Statements->Add( publishNow );
CodeVariableReferenceExpression^ publishNowRef = gcnew CodeVariableReferenceExpression( "publishNow" );
array<CodeExpression^>^ctorParams = {docTitlePrimitive,docAuthorPrimitive,publishNowRef};
CodeObjectCreateExpression^ initDocConstruct = gcnew CodeObjectCreateExpression( "DocumentProperties",ctorParams );
CodeVariableDeclarationStatement^ myDocDeclare = gcnew CodeVariableDeclarationStatement( "DocumentProperties","myDoc",initDocConstruct );
mainMethod->Statements->Add( myDocDeclare );
// </Snippet4>
// Create a variable reference for the myDoc instance.
CodeVariableReferenceExpression^ myDocInstance = gcnew CodeVariableReferenceExpression( "myDoc" );
// Create a type reference for the System.Console class.
CodeTypeReferenceExpression^ csSystemConsoleType = gcnew CodeTypeReferenceExpression( "System.Console" );
// Build Console.WriteLine statement.
CodeMethodInvokeExpression^ consoleWriteLine0 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "** Document properties test **" ) );
// Add the WriteLine call to the statement collection.
mainMethod->Statements->Add( consoleWriteLine0 );
// Build Console.WriteLine("First document:").
CodeMethodInvokeExpression^ consoleWriteLine1 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "First document:" ) );
// Add the WriteLine call to the statement collection.
mainMethod->Statements->Add( consoleWriteLine1 );
// Add a statement to display the myDoc instance properties.
CodeMethodInvokeExpression^ myDocToString = gcnew CodeMethodInvokeExpression( myDocInstance,"ToString" );
CodeMethodInvokeExpression^ consoleWriteLine2 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",myDocToString );
mainMethod->Statements->Add( consoleWriteLine2 );
// Add a statement to display the myDoc instance hashcode property.
CodeMethodInvokeExpression^ myDocHashCode = gcnew CodeMethodInvokeExpression( myDocInstance,"GetHashCode" );
array<CodeExpression^>^writeHashCodeParams = {gcnew CodePrimitiveExpression( " Hash code: {0}" ),myDocHashCode};
CodeMethodInvokeExpression^ consoleWriteLine3 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",writeHashCodeParams );
mainMethod->Statements->Add( consoleWriteLine3 );
// Add statements to create another instance.
mainMethod->Statements->Add( gcnew CodeCommentStatement( "Create another instance." ) );
CodeVariableDeclarationStatement^ myNewDocDeclare = gcnew CodeVariableDeclarationStatement( "DocumentProperties","myNewDoc",initDocConstruct );
mainMethod->Statements->Add( myNewDocDeclare );
// Create a variable reference for the myNewDoc instance.
CodeVariableReferenceExpression^ myNewDocInstance = gcnew CodeVariableReferenceExpression( "myNewDoc" );
// Build Console.WriteLine("Second document:").
CodeMethodInvokeExpression^ consoleWriteLine5 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Second document:" ) );
// Add the WriteLine call to the statement collection.
mainMethod->Statements->Add( consoleWriteLine5 );
// Add a statement to display the myNewDoc instance properties.
CodeMethodInvokeExpression^ myNewDocToString = gcnew CodeMethodInvokeExpression( myNewDocInstance,"ToString" );
CodeMethodInvokeExpression^ consoleWriteLine6 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",myNewDocToString );
mainMethod->Statements->Add( consoleWriteLine6 );
// Add a statement to display the myNewDoc instance hashcode property.
CodeMethodInvokeExpression^ myNewDocHashCode = gcnew CodeMethodInvokeExpression( myNewDocInstance,"GetHashCode" );
array<CodeExpression^>^writeNewHashCodeParams = {gcnew CodePrimitiveExpression( " Hash code: {0}" ),myNewDocHashCode};
CodeMethodInvokeExpression^ consoleWriteLine7 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",writeNewHashCodeParams );
mainMethod->Statements->Add( consoleWriteLine7 );
// <Snippet5>
// Build a compound statement to compare the two instances.
mainMethod->Statements->Add( gcnew CodeCommentStatement( "Compare the two instances." ) );
CodeMethodInvokeExpression^ myDocEquals = gcnew CodeMethodInvokeExpression( myDocInstance,"Equals",myNewDocInstance );
CodePrimitiveExpression^ equalLine = gcnew CodePrimitiveExpression( "Second document is equal to the first." );
CodePrimitiveExpression^ notEqualLine = gcnew CodePrimitiveExpression( "Second document is not equal to the first." );
CodeMethodInvokeExpression^ equalWriteLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",equalLine );
CodeMethodInvokeExpression^ notEqualWriteLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",notEqualLine );
array<CodeStatement^>^equalStatements = {gcnew CodeExpressionStatement( equalWriteLine )};
array<CodeStatement^>^notEqualStatements = {gcnew CodeExpressionStatement( notEqualWriteLine )};
CodeConditionStatement^ docCompare = gcnew CodeConditionStatement( myDocEquals,equalStatements,notEqualStatements );
mainMethod->Statements->Add( docCompare );
// </Snippet5>
// <Snippet6>
// Add a statement to change the myDoc.Author property:
mainMethod->Statements->Add( gcnew CodeCommentStatement( "Change the author of the original instance." ) );
CodePropertyReferenceExpression^ myDocAuthor = gcnew CodePropertyReferenceExpression( myDocInstance,"Author" );
CodePrimitiveExpression^ newDocAuthor = gcnew CodePrimitiveExpression( "Jane Doe" );
CodeAssignStatement^ myDocAuthorAssign = gcnew CodeAssignStatement( myDocAuthor,newDocAuthor );
mainMethod->Statements->Add( myDocAuthorAssign );
// </Snippet6>
// Add a statement to display the modified instance.
CodeMethodInvokeExpression^ consoleWriteLine8 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Modified original document:" ) );
mainMethod->Statements->Add( consoleWriteLine8 );
// Reuse the myDoc.ToString statement built earlier.
mainMethod->Statements->Add( consoleWriteLine2 );
// Reuse the comparison block built earlier.
mainMethod->Statements->Add( gcnew CodeCommentStatement( "Compare the two instances again." ) );
mainMethod->Statements->Add( docCompare );
// Add a statement to prompt the user to hit a key.
// Build another call to System.WriteLine.
// Add string parameter to the WriteLine method.
CodeMethodInvokeExpression^ consoleWriteLine9 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Press the Enter key to continue." ) );
mainMethod->Statements->Add( consoleWriteLine9 );
// Build a call to System.ReadLine.
CodeMethodInvokeExpression^ consoleReadLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"ReadLine" );
mainMethod->Statements->Add( consoleReadLine );
// Define a few common expressions for the class methods.
CodePropertyReferenceExpression^ thisTitle = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" );
CodePropertyReferenceExpression^ thisAuthor = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" );
CodePropertyReferenceExpression^ thisDate = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" );
CodeTypeReferenceExpression^ stringType = gcnew CodeTypeReferenceExpression( String::typeid );
CodePrimitiveExpression^ trueConst = gcnew CodePrimitiveExpression( true );
CodePrimitiveExpression^ falseConst = gcnew CodePrimitiveExpression( false );
// ------Build the DocumentProperty.Equals method------
CodeMemberMethod^ baseEquals = gcnew CodeMemberMethod;
baseEquals->Attributes = static_cast<MemberAttributes>(MemberAttributes::Public | MemberAttributes::Override | MemberAttributes::Overloaded);
baseEquals->ReturnType = gcnew CodeTypeReference( bool::typeid );
baseEquals->Name = "Equals";
baseEquals->Parameters->Add( gcnew CodeParameterDeclarationExpression( Object::typeid,"obj" ) );
baseEquals->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.Equals method." ) );
CodeVariableReferenceExpression^ objVar = gcnew CodeVariableReferenceExpression( "obj" );
CodeCastExpression^ objCast = gcnew CodeCastExpression( "DocumentProperties",objVar );
CodePropertyReferenceExpression^ objTitle = gcnew CodePropertyReferenceExpression( objCast,"Title" );
CodePropertyReferenceExpression^ objAuthor = gcnew CodePropertyReferenceExpression( objCast,"Author" );
CodePropertyReferenceExpression^ objDate = gcnew CodePropertyReferenceExpression( objCast,"PublishDate" );
CodeMethodInvokeExpression^ objTitleEquals = gcnew CodeMethodInvokeExpression( objTitle,"Equals",thisTitle );
CodeMethodInvokeExpression^ objAuthorEquals = gcnew CodeMethodInvokeExpression( objAuthor,"Equals",thisAuthor );
CodeMethodInvokeExpression^ objDateEquals = gcnew CodeMethodInvokeExpression( objDate,"Equals",thisDate );
CodeBinaryOperatorExpression^ andEquals1 = gcnew CodeBinaryOperatorExpression( objTitleEquals,CodeBinaryOperatorType::BooleanAnd,objAuthorEquals );
CodeBinaryOperatorExpression^ andEquals2 = gcnew CodeBinaryOperatorExpression( andEquals1,CodeBinaryOperatorType::BooleanAnd,objDateEquals );
array<CodeStatement^>^returnTrueStatements = {gcnew CodeMethodReturnStatement( trueConst )};
array<CodeStatement^>^returnFalseStatements = {gcnew CodeMethodReturnStatement( falseConst )};
CodeConditionStatement^ objEquals = gcnew CodeConditionStatement( andEquals2,returnTrueStatements,returnFalseStatements );
baseEquals->Statements->Add( objEquals );
baseClass->Members->Add( baseEquals );
// ------Build the DocumentProperty.GetHashCode method------
CodeMemberMethod^ baseHash = gcnew CodeMemberMethod;
baseHash->Attributes = static_cast<MemberAttributes>(MemberAttributes::Public | MemberAttributes::Override);
baseHash->ReturnType = gcnew CodeTypeReference( int::typeid );
baseHash->Name = "GetHashCode";
baseHash->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.GetHashCode method." ) );
CodeMethodInvokeExpression^ hashTitle = gcnew CodeMethodInvokeExpression( thisTitle,"GetHashCode" );
CodeMethodInvokeExpression^ hashAuthor = gcnew CodeMethodInvokeExpression( thisAuthor,"GetHashCode" );
CodeMethodInvokeExpression^ hashDate = gcnew CodeMethodInvokeExpression( thisDate,"GetHashCode" );
CodeBinaryOperatorExpression^ orHash1 = gcnew CodeBinaryOperatorExpression( hashTitle,CodeBinaryOperatorType::BitwiseOr,hashAuthor );
CodeBinaryOperatorExpression^ andHash = gcnew CodeBinaryOperatorExpression( orHash1,CodeBinaryOperatorType::BitwiseAnd,hashDate );
baseHash->Statements->Add( gcnew CodeMethodReturnStatement( andHash ) );
baseClass->Members->Add( baseHash );
// ------Build the DocumentProperty.ToString method------
CodeMemberMethod^ docToString = gcnew CodeMemberMethod;
docToString->Attributes = static_cast<MemberAttributes>(MemberAttributes::Public | MemberAttributes::Override);
docToString->ReturnType = gcnew CodeTypeReference( String::typeid );
docToString->Name = "ToString";
docToString->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.ToString method." ) );
CodeMethodInvokeExpression^ baseToString = gcnew CodeMethodInvokeExpression( gcnew CodeBaseReferenceExpression,"ToString" );
CodePrimitiveExpression^ formatString = gcnew CodePrimitiveExpression( "{0} ({1} by {2}, {3})" );
array<CodeExpression^>^formatParams = {formatString,baseToString,thisTitle,thisAuthor,thisDate};
CodeMethodInvokeExpression^ stringFormat = gcnew CodeMethodInvokeExpression( stringType,"Format",formatParams );
docToString->Statements->Add( gcnew CodeMethodReturnStatement( stringFormat ) );
baseClass->Members->Add( docToString );
return docPropUnit;
}
//</Snippet2>
void DocumentPropertyGraphExpand( interior_ptr<CodeCompileUnit^> docPropUnit )
{
// Expand on the DocumentProperties class,
// adding the constructor and property implementation.
// <Snippet7>
CodeTypeDeclaration^ baseClass = gcnew CodeTypeDeclaration( "DocumentProperties" );
baseClass->IsPartial = true;
baseClass->IsClass = true;
baseClass->Attributes = MemberAttributes::Public;
// Extend the DocumentProperties class in the unit namespace.
( *docPropUnit)->Namespaces[ 0 ]->Types->Add( baseClass );
// </Snippet7>
// ------Declare the internal class fields------
baseClass->Members->Add( gcnew CodeMemberField( "String","docTitle" ) );
baseClass->Members->Add( gcnew CodeMemberField( "String","docAuthor" ) );
baseClass->Members->Add( gcnew CodeMemberField( "DateTime","docDate" ) );
// ------Build the DocumentProperty constructor------
CodeConstructor^ docPropCtor = gcnew CodeConstructor;
docPropCtor->Attributes = MemberAttributes::Public;
docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","title" ) );
docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","author" ) );
docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "DateTime","publishDate" ) );
CodeFieldReferenceExpression^ myTitle = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" );
CodeVariableReferenceExpression^ inTitle = gcnew CodeVariableReferenceExpression( "title" );
CodeAssignStatement^ myDocTitleAssign = gcnew CodeAssignStatement( myTitle,inTitle );
docPropCtor->Statements->Add( myDocTitleAssign );
CodeFieldReferenceExpression^ myAuthor = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" );
CodeVariableReferenceExpression^ inAuthor = gcnew CodeVariableReferenceExpression( "author" );
CodeAssignStatement^ myDocAuthorAssign = gcnew CodeAssignStatement( myAuthor,inAuthor );
docPropCtor->Statements->Add( myDocAuthorAssign );
CodeFieldReferenceExpression^ myDate = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" );
CodeVariableReferenceExpression^ inDate = gcnew CodeVariableReferenceExpression( "publishDate" );
CodeAssignStatement^ myDocDateAssign = gcnew CodeAssignStatement( myDate,inDate );
docPropCtor->Statements->Add( myDocDateAssign );
baseClass->Members->Add( docPropCtor );
// ------Build the DocumentProperty properties------
CodeMemberProperty^ docTitleProp = gcnew CodeMemberProperty;
docTitleProp->HasGet = true;
docTitleProp->HasSet = true;
docTitleProp->Name = "Title";
docTitleProp->Type = gcnew CodeTypeReference( "String" );
docTitleProp->Attributes = MemberAttributes::Public;
docTitleProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ) ) );
docTitleProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ),gcnew CodePropertySetValueReferenceExpression ) );
baseClass->Members->Add( docTitleProp );
CodeMemberProperty^ docAuthorProp = gcnew CodeMemberProperty;
docAuthorProp->HasGet = true;
docAuthorProp->HasSet = true;
docAuthorProp->Name = "Author";
docAuthorProp->Type = gcnew CodeTypeReference( "String" );
docAuthorProp->Attributes = MemberAttributes::Public;
docAuthorProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ) ) );
docAuthorProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ),gcnew CodePropertySetValueReferenceExpression ) );
baseClass->Members->Add( docAuthorProp );
CodeMemberProperty^ docDateProp = gcnew CodeMemberProperty;
docDateProp->HasGet = true;
docDateProp->HasSet = true;
docDateProp->Name = "PublishDate";
docDateProp->Type = gcnew CodeTypeReference( "DateTime" );
docDateProp->Attributes = MemberAttributes::Public;
docDateProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ) ) );
docDateProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ),gcnew CodePropertySetValueReferenceExpression ) );
baseClass->Members->Add( docDateProp );
}
String^ GenerateCode( CodeDomProvider^ provider, CodeCompileUnit^ compileUnit )
{
// Build the source file name with the language
// extension (vb, cs, js).
String^ sourceFile = "";
// Write the source out in the selected language if
// the code generator supports partial type declarations.
if ( provider->Supports( GeneratorSupport::PartialTypes ) )
{
if ( provider->FileExtension[ 0 ] == '.' )
{
sourceFile = String::Format( "DocProp{0}", provider->FileExtension );
}
else
{
sourceFile = String::Format( "DocProp.{0}", provider->FileExtension );
}
// Create a TextWriter to a StreamWriter to an output file.
IndentedTextWriter^ outWriter = gcnew IndentedTextWriter( gcnew StreamWriter( sourceFile,false )," " );
// Generate source code using the code generator.
provider->GenerateCodeFromCompileUnit( compileUnit, outWriter, nullptr );
// Close the output file.
outWriter->Close();
}
return sourceFile;
}
//<Snippet1>
bool CompileCode( CodeDomProvider^ provider, String^ sourceFile, String^ exeFile )
{
CompilerParameters^ cp = gcnew CompilerParameters;
// Generate an executable instead of
// a class library.
cp->GenerateExecutable = true;
// Set the assembly file name to generate.
cp->OutputAssembly = exeFile;
// Save the assembly as a physical file.
cp->GenerateInMemory = false;
// Generate debug information.
cp->IncludeDebugInformation = true;
// Add an assembly reference.
cp->ReferencedAssemblies->Add( "System.dll" );
// Set the warning level at which
// the compiler should abort compilation
// if a warning of this level occurs.
cp->WarningLevel = 3;
// Set whether to treat all warnings as errors.
cp->TreatWarningsAsErrors = false;
if ( provider->Supports( GeneratorSupport::EntryPointMethod ) )
{
// Specify the class that contains
// the main method of the executable.
cp->MainClass = "DocumentSamples.DocumentProperties";
}
// Invoke compilation.
CompilerResults^ cr = provider->CompileAssemblyFromFile( cp, sourceFile );
if ( cr->Errors->Count > 0 )
{
// Display compilation errors.
Console::WriteLine( "Errors building {0} into {1}", sourceFile, cr->PathToAssembly );
IEnumerator^ myEnum = cr->Errors->GetEnumerator();
while ( myEnum->MoveNext() )
{
CompilerError^ ce = safe_cast<CompilerError^>(myEnum->Current);
Console::WriteLine( " {0}", ce );
Console::WriteLine();
}
}
else
{
Console::WriteLine( "Source {0} built into {1} successfully.", sourceFile, cr->PathToAssembly );
}
// Return the results of compilation.
if ( cr->Errors->Count > 0 )
{
return false;
}
else
{
return true;
}
}
//</Snippet1>
[STAThread]
int main()
{
CodeDomProvider^ provider = nullptr;
String^ exeName = "DocProp.exe";
Console::WriteLine( "Enter the source language for DocumentProperties class (cs, vb, etc):" );
String^ inputLang = Console::ReadLine();
Console::WriteLine();
if ( CodeDomProvider::IsDefinedLanguage( inputLang ) )
{
provider = CodeDomProvider::CreateProvider( inputLang );
}
if ( provider == nullptr )
{
Console::WriteLine( "There is no CodeDomProvider for the input language." );
}
else
{
CodeCompileUnit^ docPropertyUnit = DocumentPropertyGraphBase();
DocumentPropertyGraphExpand( &docPropertyUnit );
String^ sourceFile = GenerateCode( provider, docPropertyUnit );
if ( !String::IsNullOrEmpty( sourceFile ) )
{
Console::WriteLine( "Document property class code generated." );
if ( CompileCode( provider, sourceFile, exeName ) )
{
Console::WriteLine( "Starting DocProp executable." );
Process::Start( exeName );
}
}
else
{
Console::WriteLine( "Could not generate source file." );
Console::WriteLine( "Target language code generator might not support partial type declarations." );
}
}
}
|
; A178936: Floor((2*3^n+3*2^n)/5).
; 1,2,6,15,42,116,330,951,2778,8180,24234,72087,215034,642644,1923018,5759223,17258010,51734708,155125482,465219159,1395342906,4185399572,12554940426,37662304695,112981880922,338935576436,1016786596650,3050319524631,9150878043258,27452473068500,82357097082954,247070647003767,741210652521114,2223629380582964,6670882987788138
cal $0,94125 ; a(n) = 3*2^n + 2*3^n.
div $0,5
add $0,1
mov $1,$0
sub $1,1
|
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021, 2022 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "ShaderState.h"
/* Needed only for Emscripten+pthread- / Windows+Intel-specific workarounds,
but I won't bother crafting the preprocessor logic for this. */
#include <Corrade/Containers/StringView.h>
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Shader.h"
namespace Magnum { namespace GL { namespace Implementation {
using namespace Containers::Literals;
ShaderState::ShaderState(Context& context, Containers::StaticArrayView<Implementation::ExtensionCount, const char*>):
maxVertexOutputComponents{}, maxFragmentInputComponents{},
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
maxTessellationControlInputComponents{}, maxTessellationControlOutputComponents{}, maxTessellationControlTotalOutputComponents{}, maxTessellationEvaluationInputComponents{}, maxTessellationEvaluationOutputComponents{}, maxGeometryInputComponents{}, maxGeometryOutputComponents{}, maxGeometryTotalOutputComponents{}, maxAtomicCounterBuffers{}, maxCombinedAtomicCounterBuffers{}, maxAtomicCounters{}, maxCombinedAtomicCounters{}, maxImageUniforms{}, maxCombinedImageUniforms{}, maxShaderStorageBlocks{}, maxCombinedShaderStorageBlocks{},
#endif
maxTextureImageUnits{}, maxTextureImageUnitsCombined{},
#ifndef MAGNUM_TARGET_GLES2
maxUniformBlocks{}, maxCombinedUniformBlocks{},
#endif
maxUniformComponents{}, maxUniformComponentsCombined{}
#ifndef MAGNUM_TARGET_GLES2
, maxCombinedUniformComponents{}
#endif
{
#if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__)
if(!context.isDriverWorkaroundDisabled("emscripten-pthreads-broken-unicode-shader-sources"_s)) {
addSourceImplementation = &Shader::addSourceImplementationEmscriptenPthread;
} else
#endif
{
addSourceImplementation = &Shader::addSourceImplementationDefault;
}
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES)
if((context.detectedDriver() & Context::DetectedDriver::IntelWindows) && !context.isDriverWorkaroundDisabled("intel-windows-chatty-shader-compiler"_s)) {
cleanLogImplementation = &Shader::cleanLogImplementationIntelWindows;
} else
#endif
{
cleanLogImplementation = &Shader::cleanLogImplementationNoOp;
}
/* Needed only if neither of these ifdefs above hits, but I won't bother
crafting the preprocessor logic for this. */
static_cast<void>(context);
}
}}}
|
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
%ifdef __YASM_VERSION_ID__
%if __YASM_VERSION_ID__ < 01010000h
%error yasm version 1.1.0 or later needed.
%endif
; Yasm automatically includes .00 and complains about redefining it.
; https://www.tortall.net/projects/yasm/manual/html/objfmt-win32-safeseh.html
%else
$@feat.00 equ 1
%endif
section .text code align=64
%else
section .text code
%endif
global _GFp_gcm_init_clmul
align 16
_GFp_gcm_init_clmul:
L$_GFp_gcm_init_clmul_begin:
mov edx,DWORD [4+esp]
mov eax,DWORD [8+esp]
call L$000pic
L$000pic:
pop ecx
lea ecx,[(L$bswap-L$000pic)+ecx]
movdqu xmm2,[eax]
pshufd xmm2,xmm2,78
pshufd xmm4,xmm2,255
movdqa xmm3,xmm2
psllq xmm2,1
pxor xmm5,xmm5
psrlq xmm3,63
pcmpgtd xmm5,xmm4
pslldq xmm3,8
por xmm2,xmm3
pand xmm5,[16+ecx]
pxor xmm2,xmm5
movdqa xmm0,xmm2
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pshufd xmm4,xmm2,78
pxor xmm3,xmm0
pxor xmm4,xmm2
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
pshufd xmm3,xmm2,78
pshufd xmm4,xmm0,78
pxor xmm3,xmm2
movdqu [edx],xmm2
pxor xmm4,xmm0
movdqu [16+edx],xmm0
db 102,15,58,15,227,8
movdqu [32+edx],xmm4
ret
global _GFp_gcm_gmult_clmul
align 16
_GFp_gcm_gmult_clmul:
L$_GFp_gcm_gmult_clmul_begin:
mov eax,DWORD [4+esp]
mov edx,DWORD [8+esp]
call L$001pic
L$001pic:
pop ecx
lea ecx,[(L$bswap-L$001pic)+ecx]
movdqu xmm0,[eax]
movdqa xmm5,[ecx]
movups xmm2,[edx]
db 102,15,56,0,197
movups xmm4,[32+edx]
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pxor xmm3,xmm0
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
db 102,15,56,0,197
movdqu [eax],xmm0
ret
global _GFp_gcm_ghash_clmul
align 16
_GFp_gcm_ghash_clmul:
L$_GFp_gcm_ghash_clmul_begin:
push ebp
push ebx
push esi
push edi
mov eax,DWORD [20+esp]
mov edx,DWORD [24+esp]
mov esi,DWORD [28+esp]
mov ebx,DWORD [32+esp]
call L$002pic
L$002pic:
pop ecx
lea ecx,[(L$bswap-L$002pic)+ecx]
movdqu xmm0,[eax]
movdqa xmm5,[ecx]
movdqu xmm2,[edx]
db 102,15,56,0,197
sub ebx,16
jz NEAR L$003odd_tail
movdqu xmm3,[esi]
movdqu xmm6,[16+esi]
db 102,15,56,0,221
db 102,15,56,0,245
movdqu xmm5,[32+edx]
pxor xmm0,xmm3
pshufd xmm3,xmm6,78
movdqa xmm7,xmm6
pxor xmm3,xmm6
lea esi,[32+esi]
db 102,15,58,68,242,0
db 102,15,58,68,250,17
db 102,15,58,68,221,0
movups xmm2,[16+edx]
nop
sub ebx,32
jbe NEAR L$004even_tail
jmp NEAR L$005mod_loop
align 32
L$005mod_loop:
pshufd xmm4,xmm0,78
movdqa xmm1,xmm0
pxor xmm4,xmm0
nop
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,229,16
movups xmm2,[edx]
xorps xmm0,xmm6
movdqa xmm5,[ecx]
xorps xmm1,xmm7
movdqu xmm7,[esi]
pxor xmm3,xmm0
movdqu xmm6,[16+esi]
pxor xmm3,xmm1
db 102,15,56,0,253
pxor xmm4,xmm3
movdqa xmm3,xmm4
psrldq xmm4,8
pslldq xmm3,8
pxor xmm1,xmm4
pxor xmm0,xmm3
db 102,15,56,0,245
pxor xmm1,xmm7
movdqa xmm7,xmm6
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
db 102,15,58,68,242,0
movups xmm5,[32+edx]
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
pshufd xmm3,xmm7,78
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm3,xmm7
pxor xmm1,xmm4
db 102,15,58,68,250,17
movups xmm2,[16+edx]
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
db 102,15,58,68,221,0
lea esi,[32+esi]
sub ebx,32
ja NEAR L$005mod_loop
L$004even_tail:
pshufd xmm4,xmm0,78
movdqa xmm1,xmm0
pxor xmm4,xmm0
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,229,16
movdqa xmm5,[ecx]
xorps xmm0,xmm6
xorps xmm1,xmm7
pxor xmm3,xmm0
pxor xmm3,xmm1
pxor xmm4,xmm3
movdqa xmm3,xmm4
psrldq xmm4,8
pslldq xmm3,8
pxor xmm1,xmm4
pxor xmm0,xmm3
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
test ebx,ebx
jnz NEAR L$006done
movups xmm2,[edx]
L$003odd_tail:
movdqu xmm3,[esi]
db 102,15,56,0,221
pxor xmm0,xmm3
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pshufd xmm4,xmm2,78
pxor xmm3,xmm0
pxor xmm4,xmm2
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
L$006done:
db 102,15,56,0,197
movdqu [eax],xmm0
pop edi
pop esi
pop ebx
pop ebp
ret
align 64
L$bswap:
db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194
align 64
L$007rem_8bit:
dw 0,450,900,582,1800,1738,1164,1358
dw 3600,4050,3476,3158,2328,2266,2716,2910
dw 7200,7650,8100,7782,6952,6890,6316,6510
dw 4656,5106,4532,4214,5432,5370,5820,6014
dw 14400,14722,15300,14854,16200,16010,15564,15630
dw 13904,14226,13780,13334,12632,12442,13020,13086
dw 9312,9634,10212,9766,9064,8874,8428,8494
dw 10864,11186,10740,10294,11640,11450,12028,12094
dw 28800,28994,29444,29382,30600,30282,29708,30158
dw 32400,32594,32020,31958,31128,30810,31260,31710
dw 27808,28002,28452,28390,27560,27242,26668,27118
dw 25264,25458,24884,24822,26040,25722,26172,26622
dw 18624,18690,19268,19078,20424,19978,19532,19854
dw 18128,18194,17748,17558,16856,16410,16988,17310
dw 21728,21794,22372,22182,21480,21034,20588,20910
dw 23280,23346,22900,22710,24056,23610,24188,24510
dw 57600,57538,57988,58182,58888,59338,58764,58446
dw 61200,61138,60564,60758,59416,59866,60316,59998
dw 64800,64738,65188,65382,64040,64490,63916,63598
dw 62256,62194,61620,61814,62520,62970,63420,63102
dw 55616,55426,56004,56070,56904,57226,56780,56334
dw 55120,54930,54484,54550,53336,53658,54236,53790
dw 50528,50338,50916,50982,49768,50090,49644,49198
dw 52080,51890,51444,51510,52344,52666,53244,52798
dw 37248,36930,37380,37830,38536,38730,38156,38094
dw 40848,40530,39956,40406,39064,39258,39708,39646
dw 36256,35938,36388,36838,35496,35690,35116,35054
dw 33712,33394,32820,33270,33976,34170,34620,34558
dw 43456,43010,43588,43910,44744,44810,44364,44174
dw 42960,42514,42068,42390,41176,41242,41820,41630
dw 46560,46114,46692,47014,45800,45866,45420,45230
dw 48112,47666,47220,47542,48376,48442,49020,48830
db 71,72,65,83,72,32,102,111,114,32,120,56,54,44,32,67
db 82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112
db 112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62
db 0
|
// Copyright (c) 2001-2008 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_ACTION_MAR_07_2007_0851AM)
#define BOOST_SPIRIT_KARMA_ACTION_MAR_07_2007_0851AM
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once // MS compatible compilers support #pragma once
#endif
#include <boost/spirit/home/support/component.hpp>
#include <boost/spirit/home/support/detail/values.hpp>
#include <boost/spirit/home/support/attribute_of.hpp>
#include <boost/spirit/home/support/detail/action_dispatch.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <vector>
namespace boost { namespace spirit { namespace karma
{
///////////////////////////////////////////////////////////////////////////
struct sequence; // forward declaration only
///////////////////////////////////////////////////////////////////////////
struct action
{
template <typename Component, typename Context, typename Unused>
struct attribute
: traits::attribute_of<
karma::domain,
typename result_of::left<Component>::type,
Context
>
{
};
template <typename Component, typename OutputIterator,
typename Context, typename Delimiter, typename Parameter>
static bool
generate(Component const& component, OutputIterator& sink,
Context& ctx, Delimiter const& d, Parameter const& param)
{
typedef typename
result_of::left<Component>::type::director
director;
typedef typename is_same<director, sequence>::type is_sequence;
typedef typename
attribute<Component, Context, unused_type>::type
param_type;
// create a parameter if one is not supplied
// this creates a _copy_ of the parameter because the semantic
// action likely will change parts of this
typename mpl::if_<
is_same<typename remove_const<Parameter>::type, unused_type>,
param_type,
Parameter
>::type p = spirit::detail::make_value<param_type>::call(param);
// call the function, passing the parameter, the context
// and a bool flag that the client can set to false to
// fail generating.
// The client can return false to fail parsing.
bool pass = spirit::detail::action_dispatch(
spirit::right(component), p, ctx, is_sequence());
return pass &&
director::generate(spirit::left(component), sink, ctx, d, p);
}
template <typename Component, typename Context>
static std::string what(Component const& component, Context const& ctx)
{
typedef typename
spirit::result_of::left<Component>::type::director
director;
return director::what(spirit::left(component), ctx);
}
};
}}}
#endif
|
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/sysman/frequency/linux/os_frequency_imp_prelim.h"
#include "igfxfmid.h"
#include "sysman/linux/os_sysman_imp.h"
namespace L0 {
const bool LinuxFrequencyImp::canControl = true; // canControl is true on i915 (GEN9 Hardcode)
ze_result_t LinuxFrequencyImp::osFrequencyGetProperties(zes_freq_properties_t &properties) {
properties.pNext = nullptr;
properties.canControl = canControl;
properties.type = frequencyDomainNumber;
ze_result_t result1 = getMinVal(properties.min);
ze_result_t result2 = getMaxVal(properties.max);
// If can't figure out the valid range, then can't control it.
if (ZE_RESULT_SUCCESS != result1 || ZE_RESULT_SUCCESS != result2) {
properties.canControl = false;
properties.min = 0.0;
properties.max = 0.0;
}
properties.isThrottleEventSupported = false;
properties.onSubdevice = isSubdevice;
properties.subdeviceId = subdeviceId;
return ZE_RESULT_SUCCESS;
}
double LinuxFrequencyImp::osFrequencyGetStepSize() {
auto productFamily = pDevice->getNEODevice()->getHardwareInfo().platform.eProductFamily;
double stepSize;
if (productFamily >= IGFX_XE_HP_SDV) {
stepSize = 50.0;
} else {
stepSize = 50.0 / 3; // Step of 16.6666667 Mhz (GEN9 Hardcode)
}
return stepSize;
}
ze_result_t LinuxFrequencyImp::osFrequencyGetRange(zes_freq_range_t *pLimits) {
ze_result_t result = getMax(pLimits->max);
if (ZE_RESULT_SUCCESS != result) {
pLimits->max = -1;
}
result = getMin(pLimits->min);
if (ZE_RESULT_SUCCESS != result) {
pLimits->min = -1;
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::osFrequencySetRange(const zes_freq_range_t *pLimits) {
double newMin = round(pLimits->min);
double newMax = round(pLimits->max);
if (newMax == -1 && newMin == -1) {
double MaxDefault = 0, MinDefault = 0;
ze_result_t result1, result2, result;
result1 = pSysfsAccess->read(maxDefaultFreqFile, MaxDefault);
result2 = pSysfsAccess->read(minDefaultFreqFile, MinDefault);
if (result1 == ZE_RESULT_SUCCESS && result2 == ZE_RESULT_SUCCESS) {
result = setMax(MaxDefault);
if (ZE_RESULT_SUCCESS != result) {
return result;
}
return setMin(MinDefault);
}
}
double currentMax = 0.0;
ze_result_t result = getMax(currentMax);
if (ZE_RESULT_SUCCESS != result) {
return result;
}
if (newMin > currentMax) {
// set the max first
ze_result_t result = setMax(newMax);
if (ZE_RESULT_SUCCESS != result) {
return result;
}
return setMin(newMin);
}
// set the min first
result = setMin(newMin);
if (ZE_RESULT_SUCCESS != result) {
return result;
}
return setMax(newMax);
}
bool LinuxFrequencyImp::getThrottleReasonStatus(void) {
uint32_t val = 0;
auto result = pSysfsAccess->read(throttleReasonStatusFile, val);
if (ZE_RESULT_SUCCESS == result) {
return (val == 0 ? false : true);
} else {
return false;
}
}
ze_result_t LinuxFrequencyImp::osFrequencyGetState(zes_freq_state_t *pState) {
ze_result_t result;
result = getRequest(pState->request);
if (ZE_RESULT_SUCCESS != result) {
pState->request = -1;
}
result = getTdp(pState->tdp);
if (ZE_RESULT_SUCCESS != result) {
pState->tdp = -1;
}
result = getEfficient(pState->efficient);
if (ZE_RESULT_SUCCESS != result) {
pState->efficient = -1;
}
result = getActual(pState->actual);
if (ZE_RESULT_SUCCESS != result) {
pState->actual = -1;
}
pState->pNext = nullptr;
pState->currentVoltage = -1.0;
pState->throttleReasons = 0u;
if (getThrottleReasonStatus()) {
uint32_t val = 0;
ze_result_t result;
result = pSysfsAccess->read(throttleReasonPL1File, val);
if (val && (result == ZE_RESULT_SUCCESS)) {
pState->throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_AVE_PWR_CAP;
}
result = pSysfsAccess->read(throttleReasonPL2File, val);
if (val && (result == ZE_RESULT_SUCCESS)) {
pState->throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_BURST_PWR_CAP;
}
result = pSysfsAccess->read(throttleReasonPL4File, val);
if (val && (result == ZE_RESULT_SUCCESS)) {
pState->throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_CURRENT_LIMIT;
}
result = pSysfsAccess->read(throttleReasonThermalFile, val);
if (val && (result == ZE_RESULT_SUCCESS)) {
pState->throttleReasons |= ZES_FREQ_THROTTLE_REASON_FLAG_THERMAL_LIMIT;
}
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::osFrequencyGetThrottleTime(zes_freq_throttle_time_t *pThrottleTime) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcCapabilities(zes_oc_capabilities_t *pOcCapabilities) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcFrequencyTarget(double *pCurrentOcFrequency) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::setOcFrequencyTarget(double currentOcFrequency) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcVoltageTarget(double *pCurrentVoltageTarget, double *pCurrentVoltageOffset) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::setOcVoltageTarget(double currentVoltageTarget, double currentVoltageOffset) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcMode(zes_oc_mode_t *pCurrentOcMode) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::setOcMode(zes_oc_mode_t currentOcMode) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcIccMax(double *pOcIccMax) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::setOcIccMax(double ocIccMax) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getOcTjMax(double *pOcTjMax) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::setOcTjMax(double ocTjMax) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
ze_result_t LinuxFrequencyImp::getMin(double &min) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(minFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
min = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::setMin(double min) {
ze_result_t result = pSysfsAccess->write(minFreqFile, min);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getMax(double &max) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(maxFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
max = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::setMax(double max) {
ze_result_t result = pSysfsAccess->write(maxFreqFile, max);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getRequest(double &request) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(requestFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
request = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getTdp(double &tdp) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(tdpFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
tdp = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getActual(double &actual) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(actualFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
actual = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getEfficient(double &efficient) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(efficientFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
efficient = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getMaxVal(double &maxVal) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(maxValFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
maxVal = intval;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxFrequencyImp::getMinVal(double &minVal) {
double intval = 0;
ze_result_t result = pSysfsAccess->read(minValFreqFile, intval);
if (ZE_RESULT_SUCCESS != result) {
if (result == ZE_RESULT_ERROR_NOT_AVAILABLE) {
result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
return result;
}
minVal = intval;
return ZE_RESULT_SUCCESS;
}
void LinuxFrequencyImp::init() {
const std::string baseDir = "gt/gt" + std::to_string(subdeviceId) + "/";
if (pSysfsAccess->directoryExists(baseDir)) {
minFreqFile = baseDir + "rps_min_freq_mhz";
minDefaultFreqFile = baseDir + ".defaults/rps_min_freq_mhz";
maxFreqFile = baseDir + "rps_max_freq_mhz";
maxDefaultFreqFile = baseDir + ".defaults/rps_max_freq_mhz";
requestFreqFile = baseDir + "punit_req_freq_mhz";
tdpFreqFile = baseDir + "rapl_PL1_freq_mhz";
actualFreqFile = baseDir + "rps_act_freq_mhz";
efficientFreqFile = baseDir + "rps_RP1_freq_mhz";
maxValFreqFile = baseDir + "rps_RP0_freq_mhz";
minValFreqFile = baseDir + "rps_RPn_freq_mhz";
throttleReasonStatusFile = "rps_throttle_reason_status";
throttleReasonPL1File = "rps_throttle_reason_status_pl1";
throttleReasonPL2File = "rps_throttle_reason_status_pl2";
throttleReasonPL4File = "rps_throttle_reason_status_pl4";
throttleReasonThermalFile = "rps_throttle_reason_status_thermal";
} else {
minFreqFile = "gt_min_freq_mhz";
maxFreqFile = "gt_max_freq_mhz";
requestFreqFile = "gt_cur_freq_mhz";
tdpFreqFile = "rapl_PL1_freq_mhz";
actualFreqFile = "gt_act_freq_mhz";
efficientFreqFile = "gt_RP1_freq_mhz";
maxValFreqFile = "gt_RP0_freq_mhz";
minValFreqFile = "gt_RPn_freq_mhz";
throttleReasonStatusFile = "gt_throttle_reason_status";
throttleReasonPL1File = "gt_throttle_reason_status_pl1";
throttleReasonPL2File = "gt_throttle_reason_status_pl2";
throttleReasonPL4File = "gt_throttle_reason_status_pl4";
throttleReasonThermalFile = "gt_throttle_reason_status_thermal";
}
}
LinuxFrequencyImp::LinuxFrequencyImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_freq_domain_t frequencyDomainNumber) : isSubdevice(onSubdevice), subdeviceId(subdeviceId), frequencyDomainNumber(frequencyDomainNumber) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
pDevice = Device::fromHandle(pLinuxSysmanImp->getSysmanDeviceImp()->hCoreDevice);
init();
}
OsFrequency *OsFrequency::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId, zes_freq_domain_t frequencyDomainNumber) {
LinuxFrequencyImp *pLinuxFrequencyImp = new LinuxFrequencyImp(pOsSysman, onSubdevice, subdeviceId, frequencyDomainNumber);
return static_cast<OsFrequency *>(pLinuxFrequencyImp);
}
uint16_t OsFrequency::getNumberOfFreqDoainsSupported(OsSysman *pOsSysman) {
return 1; // hardcode for now to support only ZES_FREQ_DOMAIN_GPU
}
} // namespace L0
|
[bits 32]
VID_MEMORY equ 0xb8000
WOB equ 0x0f ; wee woo
print_str_pm:
pusha
mov edx, VID_MEMORY
; 呂
print_str_pm_loop:
mov al, [ebx]
mov ah, WOB
cmp al, 0
je print_str_pm_finish
mov [edx], ax
add ebx, 1
add edx, 2
jmp print_str_pm_loop
print_str_pm_finish:
popa
ret
|
; A290199: Decimal representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 721", based on the 5-celled von Neumann neighborhood.
; 1,1,5,11,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215,33554431,67108863,134217727,268435455,536870911,1073741823,2147483647,4294967295,8589934591,17179869183,34359738367,68719476735,137438953471,274877906943,549755813887,1099511627775,2199023255551,4398046511103,8796093022207,17592186044415,35184372088831,70368744177663,140737488355327,281474976710655,562949953421311,1125899906842623,2251799813685247,4503599627370495,9007199254740991
sub $0,1
mov $2,3
sub $2,$0
mov $1,$2
mov $3,$2
trn $3,$0
trn $1,$3
lpb $0
sub $0,1
mul $1,2
add $1,2
lpe
add $1,1
|
;----------------------------------------------------------------------
; putw.asm - user-callable entry point to _putw() function.
;----------------------------------------------------------------------
;
; C/C++ Run Time Library - Version 10.0
;
; Copyright (c) 1996, 2000 by Inprise Corporation
; All Rights Reserved.
;
; $Revision: 9.0 $
include rules.asi
include entry.inc
Entry@ putw, _putw, _RTLENTRY, 8
end
|
global color
extern fputc
section .text
color:
push ebp
mov ebp, esp
sub esp, 24
mov eax, dword [ebp+14H]
mov dword [esp+4H], eax
mov eax, dword [ebp+8H]
mov dword [esp], eax
call fputc
mov eax, dword [ebp+14H]
mov dword [esp+4H], eax
mov eax, dword [ebp+0CH]
mov dword [esp], eax
call fputc
mov eax, dword [ebp+14H]
mov dword [esp+4H], eax
mov eax, dword [ebp+10H]
mov dword [esp], eax
call fputc
mov esp, ebp
pop ebp
ret
|
; A266538: Twice the partial sums of A006257 (Josephus problem).
; 0,2,4,10,12,18,28,42,44,50,60,74,92,114,140,170,172,178,188,202,220,242,268,298,332,370,412,458,508,562,620,682,684,690,700,714,732,754,780,810,844,882,924,970,1020,1074,1132,1194,1260,1330,1404,1482,1564,1650,1740,1834,1932,2034,2140,2250,2364,2482,2604
mov $5,$0
mov $9,$0
lpb $5
mov $0,$9
sub $5,1
sub $0,$5
mov $2,2
mov $3,$0
lpb $2
mov $4,$3
add $4,$3
sub $8,$8
add $8,1
lpb $4
mov $7,$4
trn $4,$8
mul $8,2
lpe
mov $6,1
mov $8,$7
add $8,1
lpb $6
trn $6,$8
add $8,6
lpe
div $2,3
lpe
sub $8,7
mul $8,2
add $1,$8
lpe
|
;;
;; Copyright (c) 2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/os.asm"
%include "imb_job.asm"
%include "mb_mgr_datastruct.asm"
%include "include/reg_sizes.asm"
%include "include/const.inc"
%define NUM_LANES 8
%ifndef AES_CBCS_ENC_X8
%define AES_CBCS_ENC_X8 aes_cbcs_1_9_enc_128_x8
%define SUBMIT_JOB_AES_CBCS_ENC submit_job_aes128_cbcs_1_9_enc_avx
%endif
; void aes_cbcs_1_9_enc_128_x8(AES_ARGS *args, UINT64 len_in_bytes);
extern AES_CBCS_ENC_X8
section .text
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%else
%define arg1 rcx
%define arg2 rdx
%endif
%define state arg1
%define job arg2
%define len2 arg2
%define job_rax rax
; idx needs to be in rbp
%define len rbp
%define idx rbp
%define tmp rbp
%define lane r8
%define tmp2 r8
%define iv r9
%define tmp3 r9
%define unused_lanes rbx
; STACK_SPACE needs to be an odd multiple of 8
; This routine and its callee clobbers all GPRs
struc STACK
_gpr_save: resq 8
_rsp_save: resq 1
endstruc
; JOB* submit_job_aes128_cbcs_1_9_enc_avx(MB_MGR_AES_OOO *state, IMB_JOB *job)
; arg 1 : state
; arg 2 : job
MKGLOBAL(SUBMIT_JOB_AES_CBCS_ENC,function,internal)
SUBMIT_JOB_AES_CBCS_ENC:
mov rax, rsp
sub rsp, STACK_size
and rsp, -16
mov [rsp + _gpr_save + 8*0], rbx
mov [rsp + _gpr_save + 8*1], rbp
mov [rsp + _gpr_save + 8*2], r12
mov [rsp + _gpr_save + 8*3], r13
mov [rsp + _gpr_save + 8*4], r14
mov [rsp + _gpr_save + 8*5], r15
%ifndef LINUX
mov [rsp + _gpr_save + 8*6], rsi
mov [rsp + _gpr_save + 8*7], rdi
%endif
mov [rsp + _rsp_save], rax ; original SP
mov unused_lanes, [state + _aes_unused_lanes]
mov lane, unused_lanes
and lane, 0xF
shr unused_lanes, 4
mov len, [job + _msg_len_to_cipher_in_bytes]
and len, -16 ; Buffer might not be aligned to block size
mov iv, [job + _iv]
mov [state + _aes_unused_lanes], unused_lanes
mov [state + _aes_job_in_lane + lane*8], job
mov [state + _aes_lens_64 + lane*8], len
mov tmp, [job + _src]
add tmp, [job + _cipher_start_src_offset_in_bytes]
vmovdqu xmm0, [iv]
mov [state + _aes_args_in + lane*8], tmp
mov tmp, [job + _enc_keys]
mov [state + _aes_args_keys + lane*8], tmp
mov tmp, [job + _dst]
mov [state + _aes_args_out + lane*8], tmp
shl lane, 4 ; multiply by 16
vmovdqa [state + _aes_args_IV + lane], xmm0
cmp unused_lanes, 0xf
jne return_null
; Find min length
mov len2, [state + _aes_lens_64 + 8*0]
xor idx, idx
mov tmp2, 1
%assign I 1
%rep 7
cmp len2, [state + _aes_lens_64 + 8*I]
cmova len2, [state + _aes_lens_64 + 8*I]
cmova idx, tmp2
%if I != 7
inc tmp2
%endif
%assign I (I+1)
%endrep
or len2, len2
jz len_is_0
; Round up to multiple of 16*10
; N = (length + 159) / 160 --> Number of 160-byte blocks
mov rax, len2
xor rdx, rdx ;; zero rdx for div
add rax, 159
mov tmp2, 160
div tmp2
; Number of 160-byte blocks in rax
mov tmp2, 160
mul tmp2
; Number of bytes to process in rax
mov len2, rax
xor tmp2, tmp2
%assign I 0
%rep NUM_LANES
mov tmp3, [state + _aes_lens_64 + 8*I]
sub tmp3, len2
cmovs tmp3, tmp2 ; 0 if negative number
mov [state + _aes_lens_64 + 8*I], tmp3
%assign I (I+1)
%endrep
; "state" and "args" are the same address, arg1
; len is arg2
call AES_CBCS_ENC_X8
; state and idx are intact
len_is_0:
; process completed job "idx"
mov job_rax, [state + _aes_job_in_lane + idx*8]
mov unused_lanes, [state + _aes_unused_lanes]
mov qword [state + _aes_job_in_lane + idx*8], 0
or dword [job_rax + _status], STS_COMPLETED_AES
shl unused_lanes, 4
or unused_lanes, idx
mov [state + _aes_unused_lanes], unused_lanes
%ifdef SAFE_DATA
;; Clear IV
vpxor xmm0, xmm0
shl idx, 3 ; multiply by 8
vmovdqa [state + _aes_args_IV + idx*2], xmm0
mov qword [state + _aes_args_keys + idx], 0
%endif
return:
mov rbx, [rsp + _gpr_save + 8*0]
mov rbp, [rsp + _gpr_save + 8*1]
mov r12, [rsp + _gpr_save + 8*2]
mov r13, [rsp + _gpr_save + 8*3]
mov r14, [rsp + _gpr_save + 8*4]
mov r15, [rsp + _gpr_save + 8*5]
%ifndef LINUX
mov rsi, [rsp + _gpr_save + 8*6]
mov rdi, [rsp + _gpr_save + 8*7]
%endif
mov rsp, [rsp + _rsp_save] ; original SP
ret
return_null:
xor job_rax, job_rax
jmp return
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
; Status reports (take forever to process)
#include text.asm
unrecoverable_exception:
_text_string(13,24,except)
andi k1,0xff
srl k1,2
_text_value(8*10+13,24,k1,1)
_text_string(8*14+13,24,errcode)
mfc0 k1,epc
_text_value(8*21+13,24,k1,7)
;mfc0 k1,epc
;nop
;lwu k1,(k1)
;_text_value(13,32,k1,7)
mfc0 k1,badvaddr
_text_string(13,40,badvaddrval)
_text_value(8*9+13,40,k1,7)
_text_string(13,8*1+40,atval)
_text_value(8*3+13,8*1+40,at,7)
_text_string(13,8*2+40,v0val)
_text_value(8*3+13,8*2+40,v0,7)
_text_string(13,8*3+40,v1val)
_text_value(8*3+13,8*3+40,v1,7)
_text_string(13,8*4+40,a0val)
_text_value(8*3+13,8*4+40,a0,7)
_text_string(13,8*5+40,a1val)
_text_value(8*3+13,8*5+40,a1,7)
_text_string(13,8*6+40,a2val)
_text_value(8*3+13,8*6+40,a2,7)
_text_string(13,8*7+40,a3val)
_text_value(8*3+13,8*7+40,a3,7)
_text_string(13,8*8+40,t0val)
_text_value(8*3+13,8*8+40,t0,7)
_text_string(13,8*9+40,t1val)
_text_value(8*3+13,8*9+40,t1,7)
_text_string(13,8*10+40,t2val)
_text_value(8*3+13,8*10+40,t2,7)
_text_string(13,8*11+40,t3val)
_text_value(8*3+13,8*11+40,t3,7)
_text_string(13,8*12+40,t4val)
_text_value(8*3+13,8*12+40,t4,7)
_text_string(13,8*13+40,t5val)
_text_value(8*3+13,8*13+40,t5,7)
_text_string(13,8*14+40,t6val)
_text_value(8*3+13,8*14+40,t6,7)
_text_string(13,8*15+40,t7val)
_text_value(8*3+13,8*15+40,t7,7)
_text_string(13+108,8*1+40,s0val)
_text_value(8*3+13+108,8*1+40,s0,7)
_text_string(13+108,8*2+40,s1val)
_text_value(8*3+13+108,8*2+40,s1,7)
_text_string(13+108,8*3+40,s2val)
_text_value(8*3+13+108,8*3+40,s2,7)
_text_string(13+108,8*4+40,s3val)
_text_value(8*3+13+108,8*4+40,s3,7)
_text_string(13+108,8*5+40,s4val)
_text_value(8*3+13+108,8*5+40,s4,7)
_text_string(13+108,8*6+40,s5val)
_text_value(8*3+13+108,8*6+40,s5,7)
_text_string(13+108,8*7+40,s6val)
_text_value(8*3+13+108,8*7+40,s6,7)
_text_string(13+108,8*8+40,s7val)
_text_value(8*3+13+108,8*8+40,s7,7)
_text_string(13+108,8*9+40,t8val)
_text_value(8*3+13+108,8*9+40,t8,7)
_text_string(13+108,8*10+40,t9val)
_text_value(8*3+13+108,8*10+40,t9,7)
_text_string(13+108,8*11+40,k0val)
_text_value(8*3+13+108,8*11+40,k0,7)
_text_string(13+108,8*12+40,k1val)
_text_value(8*3+13+108,8*12+40,k1,7)
_text_string(13+108,8*13+40,gpval)
_text_value(8*3+13+108,8*13+40,gp,7)
_text_string(13+108,8*14+40,spval)
_text_value(8*3+13+108,8*14+40,sp,7)
_text_string(13+108,8*15+40,raval)
_tpa(lw,t1,rasave)
_text_value(8*3+13+108,8*15+40,t1,7)
_text_string(13+108,8*16+40,s8val)
_tpa(lw,t1,s8save)
_text_value(8*3+13+108,8*16+40,t1,7)
jr ra
nop
; Debug Status
A6502_status:
_text_string(13,12,sptxt)
_text_value(37,12,A6502_S,1)
_text_string(13,20,pctxt)
_text_value(45,20,A6502_PC,3)
_text_string(13,28,ftxt)
_text_value(37,28,A6502_flags,3)
_text_string(13,36,xtxt)
_text_value(37,36,A6502_X,1)
_text_string(13,44,ytxt)
_text_value(37,44,A6502_Y,1)
_text_string(13,52,atxt)
_text_value(37,52,A6502_A,1)
_tpa(lwu,t1,pchcnt)
_text_string(13,60,histtxt)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,60,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,68,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,76,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,84,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,92,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,100,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,108,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,116,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,124,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,132,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,140,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,148,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,156,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,164,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,172,t0,3)
addi t1,-2
andi t1,0x1e
_vtpa(lh,t0,pchist,t1)
_text_value(61,180,t0,3)
_text_string(101,12,ppu1txt)
_tpa(lw,t0,_PPUControl1)
_text_value(149,12,t0,1)
_text_string(101,20,ppu2txt)
_tpa(lw,t0,_PPUControl2)
_text_value(149,20,t0,1)
_text_string(101,28,ppustxt)
;_tpa(lw,t0,sp_base_reg+sp_status_reg)
;srl t0,7
_tpa(lbu,t0,ppustatus)
_text_value(173,28,t0,1)
_text_string(101,36,pputtxt)
_tpa(lw,t0,_VRAM_T)
_text_value(149,36,t0,3)
_text_string(101,44,ppuvtxt)
_tpa(lhu,t0,_VRAM_V)
_text_value(149,44,t0,3)
_text_string(101,52,ctxt)
srl t0,A6502_PC,8
sll t0,2
addu t0,A6502_nespage
lw t0,(t0)
beqz t0,status_badpage
addu t0,A6502_PC
_text_value(133,52,t0,7)
_text_string(213,52,equtxt)
lbu t1,(t0)
_text_value(221,52,t1,1)
lbu t1,1(t0)
_text_value(221,60,t1,1)
lbu t1,2(t0)
_text_value(221,68,t1,1)
status_badpage
jr ra
nop
sptxt db "S: ",0
pctxt db "PC: ",0
ftxt db "F: ",0
xtxt db "X: ",0
ytxt db "Y: ",0
atxt db "A: ",0
ppu1txt db "PPU1: ",0
ppu2txt db "PPU2: ",0
ppustxt db "PPUSTAT: ",0
pputtxt db "PPUT: ",0
ppuvtxt db "PPUV: ",0
ctxt db "PC: ",0
histtxt db "DATA: ",0
equtxt db "=",0
except db "Exception "
errcode db " at PC ",0
badvaddrval db "badvaddr= ",0
atval db "at= ",0
v0val db "v0= ",0
v1val db "v1= ",0
a0val db "a0= ",0
a1val db "a1= ",0
a2val db "a2= ",0
a3val db "a3= ",0
t0val db "t0= ",0
t1val db "t1= ",0
t2val db "t2= ",0
t3val db "t3= ",0
t4val db "t4= ",0
t5val db "t5= ",0
t6val db "t6= ",0
t7val db "t7= ",0
s0val db "s0= ",0
s1val db "s1= ",0
s2val db "s2= ",0
s3val db "s3= ",0
s4val db "s4= ",0
s5val db "s5= ",0
s6val db "s6= ",0
s7val db "s7= ",0
t8val db "t8= ",0
t9val db "t9= ",0
k0val db "k0= ",0
k1val db "k1= ",0
gpval db "gp= ",0
spval db "sp= ",0
s8val db "s8= ",0
raval db "ra= ",0
_align(4)
report
|
; A022397: Fibonacci sequence beginning 1, 27.
; Submitted by Jon Maiga
; 1,27,28,55,83,138,221,359,580,939,1519,2458,3977,6435,10412,16847,27259,44106,71365,115471,186836,302307,489143,791450,1280593,2072043,3352636,5424679,8777315,14201994,22979309,37181303,60160612,97341915,157502527,254844442,412346969,667191411,1079538380,1746729791,2826268171,4572997962,7399266133,11972264095,19371530228,31343794323,50715324551,82059118874,132774443425,214833562299,347608005724,562441568023,910049573747,1472491141770,2382540715517,3855031857287,6237572572804,10092604430091
mov $1,26
mov $2,1
lpb $0
sub $0,2
add $1,$2
add $2,$1
lpe
lpb $0
sub $0,1
add $2,$1
lpe
mov $0,$2
|
;=================================================
; Name: Moya, Branden
; Username: bmoya001@ucr.edu
;
; Assignment name: assn5
; Lab section: 021
; TA: Bryan Marsh
;
; I hereby certify that I have not recieved
; assistance on this assignment, or used code, from
; ANY outside source other than the instuction team.
;
;=================================================
.ORIG x3000
;INSTRUCTIONS
JSR GET_INPUT_3200
ST R1, NUM1
JSR GET_INPUT_3200
ST R1, NUM2
LD R1, NUM1
JSR OUTPUT_3400
LEA R0, P1
PUTS
LD R1, NUM2
JSR OUTPUT_3400
LEA R0, P2
PUTS
LD R1, NUM1
LD R2, NUM2
LD R3, POINTER_3600
JSRR R3
LEA R0, P3
PUTS
HALT
;LOCAL DATA
NUM1 .FILL #0
NUM2 .FILL #0
P1 .STRINGZ " * "
P2 .STRINGZ " = "
P3 .STRINGZ "\n"
POINTER_3600 .FILL x3600
;=================================================
;subroutine:dgets input
;input:none
;post condition:stores input in r1 as decimal
;return values:r1 stores the input
.Orig x3200
GET_INPUT_3200 ;NAME
ST R2, R2_3200
ST R7, R7_3200 ;STORES R7,R2 VALUES FOR BACKUP
LD R3, ONE_CHECK
START
AND R1,R1,#0
AND R5,R5,#0 ;RESETS VALUES
AND R6,R6,#0
LD R4, FIVE
LEA R0, PROMPT ;OUPUTS PROMPT
PUTS
GET_INPUT ;GETS INPUT AND CONVERTS IT TO A SINGLE NUMBER IN R1
GETC
OUT
BR TEST_INPUT
BACK
LD R2, NINE
ADD R6,R1,#0 ;SETS R6 TO R0 FOR MULTIPLICATION
INNER
ADD R1,R1,R6
BRn ERROR
ADD R2,R2,#-1
BRp INNER
ADD R0,R0,R3
ADD R1,R1,R0 ;ADDS THE NEXT NUMBER
BRn ERROR
ADD R6,R6,#2
ADD R4,R4,#-1
BRp GET_INPUT
BR ALMOST_DONE
TEST_INPUT
LD R2, ENTER ;CHECKS FOR ENTER BAR
ADD R2,R2,R0
BRz LAST_CHECK
ADD R2,R6,#-1
BRzp NUM_CHECK
LD R2, MINUS ;CHECKS FOR '-'
ADD R2,R2,R0
BRz NEGATIVE
LD R2, PLUS ;CHECKS FOR '+'
ADD R2,R2,R0
BRz POSITIVE
NUM_CHECK
LD R2, ONE_CHECK ;CHECKS FOR < 1
ADD R2,R2,R0
BRn ERROR
LD R2, NINE_CHECK ;CHECKS FOR > 9
ADD R2,R2,R0
BRp ERROR
BR BACK
NEGATIVE ;IF '-'
ADD R5,R5,#-1
ADD R6,R6,#1
BR GET_INPUT
POSITIVE ;IF '+'
ADD R5,R5,#1
ADD R6,R6,#1
BR GET_INPUT
NEGATE ;NEGATES R1 IF NEGATIVE SIGN WAS ENTERED
NOT R1,R1
ADD R1,R1,#1
BR FINISH
LAST_CHECK
ADD R2,R6,#-1
BRn ERROR
AND R5,R5,R5
BRnp LAST_LAST_CHECK
BR FINISH
LAST_LAST_CHECK
ADD R2,R6,#-2
BRn ERROR
AND R5,R5,R5
BRn NEGATE
BR FINISH
ERROR ;ERROR OUTPUT/REASK FOR NUMBERS
LD R2, ENTER
ADD R2,R2,R0
BRnp NEW_LINE
BACK_TO_ERROR
LEA R0, WRONG
PUTS
BR START
NEW_LINE
AND R0,R0,#0
ADD R0,R0,#10
OUT
BR BACK_TO_ERROR
ALMOST_DONE
AND R0,R0,#0
ADD R0,R0,#10
OUT
FINISH
LD R2, R2_3200
LD R7, R7_3200 ;RESETS VAULES
RET
;Subroutine data
R2_3200 .BLKW #1
R7_3200 .BLKW #1
PROMPT .STRINGZ "Input a positive or negative decimal number (max 5 digits), followed by ENTER\n"
WRONG .STRINGZ "ERROR INVALID INPUT\n"
PLUS .FILL #-43
MINUS .FILL #-45
ENTER .FILL #-10
ONE_CHECK .FILL #-48 ;TEST IF CHAR IS POSITIVE AFTER
NINE_CHECK .FILL #-57 ;TEST IF CHAR IS NEGATIVE AFTER
ONE .FILL #1
NINE .FILL #9
FIVE.FILL #5
;=================================================
;subroutine:PRINT IN decinmal
;input:R1 TO BE PRINTED IN decimal
;post condition:OUTPUT
;return values:NONE
.Orig x3400
OUTPUT_3400 ;NAME
ST R7, R7_3400 ;STORES R7,R5,R2 VALUES FOR BACKUP
LD R3, POINTER
LD R4, NUM_TO_CHAR
AND R5,R5,#0
ADD R5,R5,#5 ;COUNTER
AND R6,R6,#0
AND R1,R1,R1
BRz OUTPUT_ZERO
BRp SKIP1_3400
NOT R1,R1
ADD R1,R1,#1
LD R0, MINUSOUT
OUT
BR LOOP1
SKIP1_3400
LD R0, PLUSOUT
OUT
LOOP1
LDR R2,R3,#0
AND R0,R0,#0
LOOP2
ADD R1,R1,R2
BRn SKIP
ADD R0,R0,#1
ADD R6,R6,#1
BR LOOP2
SKIP
AND R6,R6,R6
BRz SKIP2
ADD R0,R0,R4
OUT
SKIP2
NOT R2,R2
ADD R2,R2,#1
ADD R1,R1,R2
ADD R3,R3,#1
ADD R5,R5,#-1
BRp LOOP1
BR SKIP2_3400
OUTPUT_ZERO
LD R0, SERO
OUT
SKIP2_3400
LD R7, R7_3400 ;RESETS VAULES
RET
;Subroutine data
R7_3400 .FILL #0
NUM_TO_CHAR .FILL x30
POINTER .FILL x3500
.ORIG x3500
TEN_THOUSAND .FILL #-10000
THOUSAND .FILL #-1000
HOUNDRED .FILL #-100
TEN .FILL #-10
ONE1 .FILL #-1
SERO .FILL #48
PLUSOUT .FILL '+'
MINUSOUT .FILL '-'
;=================================================
;subroutine:MULTIPLY
;input:MULTIPLY R1 AND R2 STORE IN R1
;post condition:R1*R2=R1
;return values:R1 AND R6 IS THE VALUE OF THE SIGN
.Orig x3600
MULTIPLY_3600 ;NAME
AND R0,R0,#0
AND R3,R3,#0
AND R4,R4,#0
AND R5,R5,#0
AND R6,R6,#0 ; NEGATIVE ONLY IF R6 = 1
ST R7, R7_3600 ;STORES R7 VALUES FOR BACKUP
AND R1,R1,R1 ;CHECKS SIGNS OF R1 AND R2 AND MAKES THEM POSITIVE
BRz ZERO ; also checks to see if r1 or r2 are zero
BRp SKIP1_3600
NOT R1,R1
ADD R1,R1,#1
ADD R6,R6,#1
SKIP1_3600
AND R2,R2,R2
BRz ZERO
BRp SKIP2_3600
ADD R6,R6,#1
NOT R2,R2
ADD R2,R2,#1
SKIP2_3600
NOT R1,R1 ;puts the smaller in r1 and the larger in r2
ADD R1,R1,#1
ADD R0,R1,R2
NOT R1,R1
ADD R1,R1,#1
AND R0,R0,R0
BRp SKIP3_3600 ;skip if already in right regeistars
AND R0,R1,R1
AND R1,R2,R2
AND R2,R0,R0
SKIP3_3600
ADD R0,R1,#-1 ;checks if r1 is one
BRz ONE_3600
ADD R0,R1,#0 ;sets r0 to be the counter
AND R1,R1,#0 ;and r1 to be the result
LOOPDELOOP ;multiplies
ADD R1,R1,R2
BRn ERROR_3600
ADD R0,R0,#-1
BRp LOOPDELOOP
BR FINISH_3600
ZERO ;if a zero was in r1 or r2
AND R1,R1,#0
BR FINISH_3600
ONE_3600 ;if a 1 was in r1 set larger value as result
AND R1,R2,R2
BR FINISH_3600
ERROR_3600 ;overflow!
LEA R0, EPROMPT
PUTS
BR SKIP4_3600
FINISH_3600
ADD R6,R6,#-1 ;NEGATIVE IF DIFFERENT SIGNS
BRnp SKIP5_3600 ;skip if result is positive
NOT R1,R1
ADD R1,R1,#1
SKIP5_3600
JSR OUTPUT_3400
SKIP4_3600
LD R7, R7_3600 ;RESETS VAULES
RET
;Subroutine data
R7_3600 .FILL #0
EPROMPT .STRINGZ "Overflow!"
.END |
/* stuff needed for libgcc on win32. */
#ifdef L_chkstk
.global ___chkstk
.global __alloca
___chkstk:
__alloca:
pushl %ecx /* save temp */
movl %esp,%ecx /* get sp */
addl $0x8,%ecx /* and point to return addr */
probe: cmpl $0x1000,%eax /* > 4k ?*/
jb done
subl $0x1000,%ecx /* yes, move pointer down 4k*/
orl $0x0,(%ecx) /* probe there */
subl $0x1000,%eax /* decrement count */
jmp probe /* and do it again */
done: subl %eax,%ecx
orl $0x0,(%ecx) /* less that 4k, just peek here */
movl %esp,%eax
movl %ecx,%esp /* decrement stack */
movl (%eax),%ecx /* recover saved temp */
movl 4(%eax),%eax /* get return address */
jmp *%eax
#endif
|
db 0 ; species ID placeholder
db 40, 45, 40, 65, 65, 40
; hp atk def spd sat sdf
db ELECTRIC, ELECTRIC ; type
db 120 ; catch rate
db 59 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/electrike/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
; tm/hm learnset
tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, RETURN, PSYCHIC_M, SHADOW_BALL, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, THUNDERPUNCH, DREAM_EATER, REST, ATTRACT, THIEF, FIRE_PUNCH, NIGHTMARE, FLASH
; end
|
; A023562: Convolution of A023531 and odd numbers.
; 0,1,3,5,8,12,16,20,25,31,37,43,49,56,64,72,80,88,96,105,115,125,135,145,155,165,176,188,200,212,224,236,248,260,273,287,301,315,329,343,357,371,385,400,416,432,448,464,480,496,512,528,544,561
lpb $0
add $1,$0
sub $0,1
add $1,$0
trn $2,1
add $2,2
trn $0,$2
lpe
mov $0,$1
|
L__routine_start__Z11test_devicev_0:
test_device():
push rsi #270.20
call rand #272.14
mov ecx, DWORD PTR [rsp] #202.23
mov edx, ecx #203.23
and edx, -258049 #203.23
lea eax, DWORD PTR [-4096+rcx] #203.55
shr ecx, 12 #204.24
and eax, 258048 #203.97
and ecx, 63 #204.37
or edx, eax #203.97
mov DWORD PTR [rsp], edx #203.9
mov DWORD PTR [4+rsp], ecx #290.4
pop rcx #291.1
ret #291.1
|
; A011000: a(n) = binomial coefficient C(n,47).
; 1,48,1176,19600,249900,2598960,22957480,177100560,1217566350,7575968400,43183019880,227692286640,1119487075980,5166863427600,22512762077400,93052749919920,366395202809685,1379370175283520,4981058966301600,17302625882942400,57963796707857040,187692294101632320,588671286046028640,1791608261879217600,5300174441392685400,15264502391210933952,42858025944553776096,117462737773962201152,314632333323113038800,824553701122641067200,2116354499548112072480,5325020998862991666240,13146145590943010676030
add $0,47
bin $0,47
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: pareaBuild.asm
AUTHOR: John Wedgwood, Oct 9, 1991
METHODS:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
John 10/ 9/91 Initial revision
DESCRIPTION:
Method handlers for rebuilding a chart.
$Id: pareaBuild.asm,v 1.1 97/04/04 17:46:47 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PlotAreaBuild
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Build the plot area.
CALLED BY: via MSG_CHART_OBJECT_BUILD
PASS: *ds:si = Instance ptr
ds:di = Instance ptr
cl = ChartType
ch = ChartVariation
dx = ChartFlags
bp = BuildChangeFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
The PlotArea is a parent of the axes and the series area.
The pointers to the axes are stored in the PlotArea's instance
data, while the SeriesGroup's OD is hard-wired into the block
structure.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 10/ 9/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PlotAreaBuild method dynamic PlotAreaClass,
MSG_CHART_OBJECT_BUILD
uses ax, cx, dx,bp
.enter
ECCheckChartType cl
ECCheckFlags bp, BuildChangeFlags
; Move chart type into BX
clr bh
mov bl, cl
; See if we should nuke the current axes
if PZ_PCGEOS
;
; This is a HACK to get rid of the label-drawing problem
; which occurs in Pizza when changing to a chart type which
; rotates the axis. Nuke the axis on AXIS_ROTATE.
;
test bp, mask BCF_AXIS_REMOVE or mask BCF_AXIS_ROTATE
else
test bp, mask BCF_AXIS_REMOVE
endif
jz afterNukeAxes
DerefChartObject ds, si, di
add di, offset PAI_xAxis
call UtilDetachAndKill
DerefChartObject ds, si, di
add di, offset PAI_yAxis
call UtilDetachAndKill
afterNukeAxes:
DerefChartObject ds, si, di
tst ds:[di].PAI_yAxis
jnz gotAxes
ECCheckChartType bx
call cs:[bx].CreateAxisTable
jmp initialize
gotAxes:
ifdef SPIDER_CHART
ECCheckChartType cl
cmp cl, CT_SPIDER
jnz notSpider
test dx, mask CF_CATEGORY_TITLES
jz initialize
push cx
mov ax, MSG_CHART_OBJECT_MARK_INVALID
mov cx, mask COS_IMAGE_INVALID or mask COS_GEOMETRY_INVALID
call UtilCallAxes
pop cx
notSpider:
endif ;SPIDER_CHART
if not PZ_PCGEOS
test bp, mask BCF_AXIS_ROTATE
jz initialize
;
; Switch the axes. Mark their geometry invalid
;
push cx
mov ax, MSG_CHART_OBJECT_MARK_INVALID
mov cx, mask COS_IMAGE_INVALID or mask COS_GEOMETRY_INVALID
call UtilCallAxes
pop cx
DerefChartObject ds, si, di
mov ax, ds:[di].PAI_xAxis
xchg ax, ds:[di].PAI_yAxis
mov ds:[di].PAI_xAxis, ax
endif
initialize:
call InitializeAxes
; Now, call superclass
.leave
mov di, offset PlotAreaClass
GOTO ObjCallSuperNoLock
PlotAreaBuild endm
ifdef SPIDER_CHART
CreateAxisTable word \
offset CreateNormalAxes, ; column
offset CreateBar, ; Bar
offset CreateNormalAxes, ; Line
offset CreateNormalAxes, ; Area
offset CreateScatter,
offset CreatePie,
offset CreateNormalAxes,
offset CreateSpider
else ; SPIDER_CHART
CreateAxisTable word \
offset CreateNormalAxes, ; column
offset CreateBar, ; Bar
offset CreateNormalAxes, ; Line
offset CreateNormalAxes, ; Area
offset CreateScatter,
offset CreatePie,
offset CreateNormalAxes
endif ; SPIDER_CHART
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeAxes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set some bits, values, pointers, etc, in the axes
CALLED BY: PlotAreaBuild
PASS: bx - chart type
*ds:si - PlotArea
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeAxes proc near
.enter
cmp bx, CT_PIE
je done
DerefChartObject ds, si, di
ifdef SPIDER_CHART
cmp bx, CT_SPIDER
jne notSpider
call InitializeSpider
jmp done
notSpider:
endif ;SPIDER_CHART
ECCheckChartType bx
call cs:PlotAreaInitializeTable[bx]
call SetHorizontalAndVertical
call PlotAreaSetRelatedAndOther
done:
.leave
ret
InitializeAxes endp
PlotAreaInitializeTable word \
offset InitializeNormalAxes,
offset InitializeBar,
offset InitializeNormalAxes,
offset InitializeNormalAxes,
offset InitializeScatter,
offset ErrorStub,
offset InitializeNormalAxes
ErrorStub proc near
EC < ERROR ILLEGAL_CHART_TYPE >
NEC < ret >
ErrorStub endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SetHorizontalAndVertical
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set the "horizontal" and "vertical" attributes in the
axes.
CALLED BY: InitializeAxes
PASS: *ds:si - PlotArea
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetHorizontalAndVertical proc near
uses ax,cx,si
class PlotAreaClass
.enter
DerefChartObject ds, si, di
push ds:[di].PAI_xAxis
mov si, ds:[di].PAI_yAxis
mov cx, mask AA_VERTICAL ; (cl = AA_VERTICAL, ch = 0)
mov ax, MSG_AXIS_SET_ATTRIBUTES
call ObjCallInstanceNoLock
; Clear the VERTICAL bit for the x-axis
pop si ; x axis
mov cx, mask AA_VERTICAL shl 8
mov ax, MSG_AXIS_SET_ATTRIBUTES
call ObjCallInstanceNoLock
.leave
ret
SetHorizontalAndVertical endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeNormalAxes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize the axes in a column/line/area chart
CALLED BY: InitializeAxes
PASS: ds:di - PlotArea
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeNormalAxes proc near
uses ax,cx,si
class PlotAreaClass
.enter
; Set the min/max series for the value (Y) axis
mov si, ds:[di].PAI_yAxis
mov cx, MAX_SERIES_COUNT shl 8
mov ax, MSG_VALUE_AXIS_SET_SERIES
call ObjCallInstanceNoLock
.leave
ret
InitializeNormalAxes endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeBar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize the axes for a bar chart
CALLED BY: InitializeAxes
PASS: ds:di - plot area
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeBar proc near
uses ax,cx,si
class PlotAreaClass
.enter
; Set the min/max series for the value (X) axis
mov si, ds:[di].PAI_xAxis
mov cx, MAX_SERIES_COUNT shl 8
mov ax, MSG_VALUE_AXIS_SET_SERIES
call ObjCallInstanceNoLock
.leave
ret
InitializeBar endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeScatter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Init axes for a scatter chart
CALLED BY: InitializeAxes
PASS: ds:di - plot area
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 3/11/92 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeScatter proc near
uses ax,cx,si
class PlotAreaClass
.enter
; Set the min/max series for the (X) axis
mov si, ds:[di].PAI_xAxis
clr cx ; first/last are both 0
mov ax, MSG_VALUE_AXIS_SET_SERIES
call ObjCallInstanceNoLock
; Set y-axis series to (1..MAX)
mov si, ds:[di].PAI_yAxis
mov cx, (MAX_SERIES_COUNT shl 8) or 1
mov ax, MSG_VALUE_AXIS_SET_SERIES
call ObjCallInstanceNoLock
.leave
ret
InitializeScatter endp
ifdef SPIDER_CHART
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InitializeSpider
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize only one axis for Spider chart
CALLED BY: InitializeAxes
PASS: ds:di - plot area
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 8/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InitializeSpider proc near
uses ax,cx,si
class PlotAreaClass
.enter
call InitializeNormalAxes
mov cx, mask AA_VERTICAL ; (cl = AA_VERTICAL, ch = 0)
mov si, ds:[di].PAI_yAxis
mov ax, MSG_AXIS_SET_ATTRIBUTES
call ObjCallInstanceNoLock
.leave
ret
InitializeSpider endp
endif ;SPIDER_CHART
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateNormalAxes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a horizontal category axis and a vertical value
axis.
CALLED BY: PlotAreaBuild
PASS: *ds:si = PlotArea object
ds:di = PlotArea Instance data
ch = ChartVariation
dx = ChartFlags
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 10/ 9/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateNormalAxes proc near
class PlotAreaClass
uses ax
.enter
; Create a category axis for horizontal, and a value axis for
; vertical.
mov ax, offset PAI_xAxis
call CreateCategoryAxis
mov ax, offset PAI_yAxis
call CreateValueAxis
.leave
ret
CreateNormalAxes endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateBar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Build axes and series for a bar chart
CALLED BY:
PASS: *ds:si - PlotArea object
dx - ChartFlags
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 10/11/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateBar proc near
class PlotAreaClass
uses ax, cx, dx
.enter
; vertical category axis
mov ax, offset PAI_yAxis
call CreateCategoryAxis
; horizontal value axis
mov ax, offset PAI_xAxis
call CreateValueAxis
.leave
ret
CreateBar endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateScatter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Build 2 value axes: the x-axis covers only the first
series, the y-axis covers the rest.
CALLED BY: PlotAreaBuild
PASS: *ds:si - PlotArea object
RETURN:
DESTROYED:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 12/12/91 Initial Revision
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateScatter proc near
uses ax
class PlotAreaClass
.enter
; x-axis
mov ax, offset PAI_xAxis
call CreateValueAxis
; y-axis
mov ax, offset PAI_yAxis
call CreateValueAxis
.leave
ret
CreateScatter endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreatePie
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Do nothing. No axes are needed for pie, so forget it.
CALLED BY: PlotAreaBuild
PASS: ds:di - PlotArea object
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 10/11/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreatePie proc near
ret
CreatePie endp
ifdef SPIDER_CHART
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateSpider
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create one vertical value axis.
CALLED BY: PlotAreaBuild
PASS: ds:di - PlotArea object
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
VM 8/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateSpider proc near
uses ax
class PlotAreaClass
.enter
; y-axis
mov ax, offset PAI_yAxis
segmov es, <segment SpiderAxisClass>, di
mov di, offset SpiderAxisClass
call CreateAxisCommon
.leave
ret
CreateSpider endp
endif ; SPIDER_CHART
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateCategoryAxis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: create a category axis
CALLED BY: CreateScatter
PASS: *ds:si - PlotArea object
ax - offset in PlotArea instance to location to store
axis chunk handle
cl - AxisAttributes to set
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 12/12/91 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateCategoryAxis proc near
uses es,di
.enter
segmov es, <segment CategoryAxisClass>, di
mov di, offset CategoryAxisClass
call CreateAxisCommon
.leave
ret
CreateCategoryAxis endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateValueAxis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a value axis and set the firstSeries and
lastSeries fields
CALLED BY:
PASS: *ds:si - PlotArea object
ax - offset in PlotArea instance to location to store
axis chunk handle
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 12/12/91 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateValueAxis proc near
uses cx,es,di
.enter
segmov es, <segment ValueAxisClass>, di
mov di, offset ValueAxisClass
call CreateAxisCommon
.leave
ret
CreateValueAxis endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateAxisCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
CALLED BY:
PASS:
*ds:si - PlotArea object
ax = offset in instance data to place to store axis
chunk handle
RETURN: nothing
DESTROYED: bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 12/12/91 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateAxisCommon proc near
uses ax,bx,di,si
.enter
push ax, si ; PlotArea chunk handle,
; offset to storage
mov bx, ds:[LMBH_handle]
call ObjInstantiate
; store chunk handle of new object
pop ax, bx
mov di, ds:[bx]
add di, ax
mov ds:[di], si
mov dx, si ; axis chunk handle
mov si, bx ; PlotArea chunk handle
mov bp, CCO_LAST shl offset CCF_REFERENCE
call ChartCompAddChild
.leave
ret
CreateAxisCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PlotAreaSetRelatedAndOther
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Set up the relations between all the axes
CALLED BY:
PASS: *ds:si - PlotArea object
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CDB 12/ 9/91 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PlotAreaSetRelatedAndOther proc near
uses ax,cx,dx,si
class PlotAreaClass
.enter
DerefChartObject ds, si, di
mov si, ds:[di].PAI_xAxis
mov cx, ds:[di].PAI_yAxis
mov ax, MSG_AXIS_SET_RELATED_AXIS
call ObjCallInstanceNoLock
xchg si, cx
call ObjCallInstanceNoLock
.leave
ret
PlotAreaSetRelatedAndOther endp
|
REF fc_main
data 0xFCFC ; Flag for valid Force Command binary
data 0x0000 ; SAMS page count - 0x0000 means simply / no sams required
data 0x0000 ; Flag 0xFCFC == program safely uses screen, 0x0000 == FC restore screen on return
data fc_main ; program start address
|
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// Include guard
#pragma once
void AbsoluteMouseAPI::buttons(uint8_t b){
if (b != _buttons){
_buttons = b;
moveTo(xAxis, yAxis, 0);
}
}
int16_t AbsoluteMouseAPI::qadd16(int16_t base, int16_t increment) {
// Separate between subtracting and adding
if (increment < 0) {
// Subtracting more would cause an undefined overflow
if ((int16_t)0x8000 - increment > base)
base = 0x8000;
else
base += increment;
}
else {
// Adding more would cause an undefined overflow
if ((int16_t)0x7FFF - increment < base)
base = 0x7FFF;
else
base += increment;
}
return base;
}
AbsoluteMouseAPI::AbsoluteMouseAPI(void):
xAxis(0), yAxis(0), _buttons(0)
{
// Empty
}
void AbsoluteMouseAPI::begin(void){
// release all buttons
end();
}
void AbsoluteMouseAPI::end(void){
_buttons = 0;
moveTo(xAxis, yAxis, 0);
}
void AbsoluteMouseAPI::click(uint8_t b){
_buttons = b;
moveTo(xAxis, yAxis, 0);
_buttons = 0;
moveTo(xAxis, yAxis, 0);
}
void AbsoluteMouseAPI::moveTo(int x, int y, signed char wheel){
xAxis = x;
yAxis = y;
HID_MouseAbsoluteReport_Data_t report;
report.buttons = _buttons;
report.xAxis = x;
report.yAxis = y;
report.wheel = wheel;
SendReport(&report, sizeof(report));
}
void AbsoluteMouseAPI::move(int x, int y, signed char wheel){
moveTo(qadd16(xAxis, x), qadd16(yAxis, y), wheel);
}
void AbsoluteMouseAPI::buttonsAndMove(uint8_t b,signed char x, signed char y, signed char wheel = 0)
{
if (b != _buttons)
{
_buttons = b;
}
move(x,y,wheel);
}
void AbsoluteMouseAPI::press(uint8_t b){
// press LEFT by default
buttons(_buttons | b);
}
void AbsoluteMouseAPI::release(uint8_t b){
// release LEFT by default
buttons(_buttons & ~b);
}
void AbsoluteMouseAPI::releaseAll(void){
_buttons = 0;
moveTo(xAxis, yAxis, 0);
}
bool AbsoluteMouseAPI::isPressed(uint8_t b){
// check LEFT by default
if ((b & _buttons) > 0)
return true;
return false;
}
|
; size_t b_vector_insert_n_callee(b_vector_t *v, size_t idx, size_t n, int c)
SECTION code_adt_b_vector
PUBLIC _b_vector_insert_n_callee, l0_b_vector_insert_n_callee
_b_vector_insert_n_callee:
pop af
pop hl
pop bc
pop de
exx
pop bc
push af
l0_b_vector_insert_n_callee:
ld a,c
exx
INCLUDE "adt/b_vector/z80/asm_b_vector_insert_n.asm"
|
; stdio_outchar
; 05.2008 aralbrec
XLIB stdio_outchar
LIB l_jpix
INCLUDE "../../stdio.def"
; all stream character output to attached file or device passes through this function
;
; enter : ix = FILE *
; a = char for output
; bc' = number of chars output thus far
; MUST NOT ALTER DE'/HL' FOR SPRINTF FUNCTIONS
; exit : bc' = number of chars output thus far
; carry set if error on stream, ERRNO set appropriately
; uses : af, exx
.stdio_outchar
exx
push bc
ld c,a
ld a,STDIO_MSG_PUTC
call l_jpix
pop bc
jr c, error
inc bc
.error
exx
ret
|
copyright zengfr site:http://github.com/zengfr/romhack
0039FE movem.l D0-D3, -(A6)
003A02 movem.l D0-D3, -(A6)
0042B4 clr.b ($17,A6) [weapon+42]
009ACA dbra D5, $9ac8
057A64 clr.b ($42,A6) [weapon+ 2, weapon+ 4]
057A68 tst.b ($40,A6)
057B6E clr.b ($42,A6)
057B72 clr.b ($40,A6)
057DB0 clr.b ($40,A6)
058B0E clr.b ($42,A6) [weapon+ 2, weapon+ 4]
058B12 moveq #$0, D0
058DDC clr.b ($40,A6)
059658 clr.b ($40,A6)
copyright zengfr site:http://github.com/zengfr/romhack
|
; A082413: a(n) = (2*9^n + 3^n)/3.
; 1,7,57,495,4401,39447,354537,3189375,28700001,258286887,2324542617,20920765455,188286534801,1694577750327,15251196564297,137260759512735,1235346806916801,11118121176157767
mov $2,3
pow $2,$0
mov $1,$2
pow $2,2
div $1,2
add $1,$2
div $1,3
mul $1,2
add $1,1
|
UM: EQU 1
SECTION TEXT
ROT: INPUT N1
COPY N1, N4 + UM ;comentario qualquer
COPY N2, N3
COPY N3, N4
OUTPUT N4
STOP
SECTION DATA
N1: SPACE
N2: CONST -16
N3: SPACE
N4: SPACE 2
|
; A344404: a(n) = Sum_{d|n} floor(n/d^2).
; 1,2,3,5,5,7,7,10,10,12,11,16,13,17,16,21,17,24,19,26,23,27,23,33,26,32,30,36,29,41,31,42,36,42,36,52,37,47,43,53,41,57,43,57,51,57,47,69,50,64,56,68,53,74,57,74,63,72,59,87,61,77,71,85,67,90,67,89,76,90,71
add $0,1
mov $2,$0
lpb $0
mov $3,$2
add $6,$0
lpb $6
dif $3,$0
mov $5,$3
cmp $3,$2
cmp $3,0
mul $3,$0
mov $6,2
lpe
sub $0,1
mov $4,$5
cmp $4,0
add $5,$4
div $3,$5
add $1,$3
lpe
mov $0,$1
|
TITLE PR0A - Prepare for printing
page 56,132
;***
; PR0A - Prepare for printing
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;
; BASIC Syntax mapping to included runtime entry points:
;
; - LPRINT [USING] Statement :
;
; LPRINT [USING "...";] [list of expressions]
; ------ -------------- ---------------------
; | | |
; B$LPRT B$USNG (see comments in prnval.asm header)
;
; - PRINT [#] [USING] Statement:
;
; PRINT [#filenumber,] [USING "...";] [list of expresions]
; ------------- -------------- --------------------
; | | |
; B$CHOU B$USNG (see comments in prnval.asm header)
;
; - WRITE [#] Statement:
;
; WRITE [#filenumber,] [list of expressions]
; ----- ------------ ---------------------
; | | |
; B$WRIT B$CHOU (see comments in prnval.asm header)
;
; PRINT -- no preamble
; WRITE -- B$WRIT
; LPRINT -- B$LPRT
;
; # -- B$CHOU
; USING -- B$USNG
;
; Note: Currently, there are two routines which set up channels,
; namely, B$CHAN, and B$CHOU. B$CHAN sets up channel
; number without checking mode, and B$CHOU excludes the
; input mode.
;
;******************************************************************************
INCLUDE switch.inc
INCLUDE rmacros.inc
;Code segments:
useSeg DV_TEXT ;device independent I/O
useSeg DK_TEXT ;disk I/O
useSeg NH_TEXT ;near heap
useSeg ER_TEXT ;error handling
;Data segments:
useSeg CONST ;constant definitions
useSeg _DATA ;initialized variables
useSeg _BSS ;uninitialized variables
INCLUDE seg.inc
INCLUDE baslibma.inc
INCLUDE devdef.inc
INCLUDE files.inc
INCLUDE rtps.inc ; constants shared with QBI
SUBTTL local constant definitions
page
TTY EQU 0 ;default for b$PTRFIL is TTY
PRSTM EQU 0 ;print statement
CHANL EQU 1 ;#
USING EQU 2 ;using
WRSTM EQU 4 ;write statement
LPSTM EQU 8 ;lprint statement
SUBTTL data definitions
page
sBegin CONST
labelW <PUBLIC,b$FILVEC> ;vector for PRINT
staticW ,B$$POS ;cursor position
staticW ,B$$WID ;line width
staticW ,B$$WCLF ;force EOL
staticW ,B$$WCH ;write one character
staticW ,B$PRTSTR ;write a string with BX=*sd
staticW ,B$PRT_TYPCNT ;write a string with CX=length
staticW ,B$PRT_OUTCNT ;write a string char. by char.
staticW ,B$PRTCHK ; force EOL if string too long
sEnd ;end of CONST
sBegin _DATA
externB b$PRFG ;flag for PRINT/LPRINT/WRITE [#][USING]
externW B$ENTRY_BUFCNT ; fdb position before exec of current
; statment.
sEnd ;_DATA
sBegin _BSS
externW b$PTRFIL ;defined in GOSTOP.ASM
sEnd ;_BSS
SUBTTL code segment definitions
page
sBegin DK_TEXT
externNP B$WCHSET ; in prnval.asm, set dispatch vector
sEnd ;DK_TEXT
sBegin DV_TEXT
externNP B$$POS
externNP B$$WID
externNP B$$WCLF
externNP B$$WCH
externNP B$PRTSTR
externNP B$PRT_TYPCNT
externNP B$PRT_OUTCNT
externNP B$PRTCHK
sEnd ;DV_TEXT
sBegin NH_TEXT
externNP B$LHFDBLOC
sEnd
sBegin ER_TEXT
externNP B$ERR_IFN
externNP B$ERR_BFM
sEnd ;ER_TEXT
assumes CS,DK_TEXT
sBegin DK_TEXT
SUBTTL interface for set up channel -- B$CHAN & B$CHOU
page
;***
;B$CHAN -- set up channel for statements
;void B$CHAN(I2 channel)
;
;Purpose:
; Check and make the I/O channel active for current statement.
;Entry:
; Parameter is in stack.
; int Channel
;Exit:
; AL = device type
; [b$PTRFIL] is set to the active FDB
;Uses:
; none
;Exceptions:
; illegal file number -- ERC_IFN
;*******************************************************************************
cProc B$CHAN,<PUBLIC,FAR>,<SI> ;save SI
ParmW Channel ;channel #
cBegin
MOV BX,Channel ;BX has the channel #
cCall B$ChkFNUM ;check file number, must be 1-255
CALL B$LHFDBLOC ; [SI] = *FDB & NZ if channel is active
JZ ERCIFN ;illegal file number
MOV [b$PTRFIL],SI ;store the pointer/handle
FDB_PTR ES,SI,SI ;(ES:)[SI] = *FDB
MOV AX,FileDB.FD_BUFCNT ;Save current fdb position
MOV B$ENTRY_BUFCNT,AX ;Used to reset on error
MOV AL,FileDB.FD_DEVICE ;return device number
cEnd ;pop SI, exit to caller
;***
;B$CHOU -- set up channel for statements
;void B$CHOU(I2 channel)
;
;Purpose:
; Check and make the I/O channel active for current print statement.
; It also checks whether the file mode is correct. If the mode is
; input, this routine gives error message. If mode is O.K., it
; sets up flag, b$PRFG, to indicate a special channel is using.
;Entry:
; Parameter is in stack.
; int Channel
;Exit:
; [b$PTRFIL] is set to the active FDB
; [b$PRFG] OR CHANL (=1)
;Uses:
; none
;Exceptions:
; illegal file number (B$ERR_IFN)
; Bad file mode -- B$ERR_BFM
;*******************************************************************************
cProc B$CHOU,<PUBLIC,FAR>,<SI> ;save SI
ParmW Channel ;channel #
cBegin
MOV BX,Channel ;BX has the channel #
cCall B$ChkFNUM ;go check file number, must be 1-255
CALL B$LHFDBLOC ; [SI] = *FDB & NZ if channel is active
JZ ERCIFN ;illegal file number
MOV AX,FileDB.FD_BUFCNT ; Save current fdb position
MOV B$ENTRY_BUFCNT,AX ; Used to reset on error
CMP FileDB.FD_MODE,MD_SQI ;can't be input
JE ERCBFM ;give bad file mode
MOV [b$PTRFIL],SI ;store the pointer/handle
OR [b$PRFG],CHANL ;set the flag for print
; (note: can't use MOV here)
MOV SI,OFFSET DGROUP:b$FILVEC
cCall B$WCHSET ;set the dispatch vector for print items
cEnd ;pop SI, exit to caller
ERCBFM: JMP B$ERR_BFM
ERCIFN: JMP B$ERR_IFN
;***
;B$ChkFNUM -- check file number
;
;Purpose:
; Check file number is within 1-255. Otherwise give "illegal file
; number"
;Entry:
; [BX] = file number
;Exit:
; none
;Uses:
; none
;Preserves: (optional)
; all
;Exceptions:
; illegal file number -- ERC_IFN
;*******************************************************************************
cProc B$ChkFNUM,<PUBLIC,NEAR>
cBegin
OR BX,BX ;can't be 0
JZ ERCIFN ;Brif yes, give "illegal file number"
OR BH,BH ;can't exceed 255
JNZ ERCIFN ;Brif yes, give "illegal file number"
cEnd ;if no error, exit to caller
sEnd ;DK_TEXT
END
|
; item ids
; indexes for:
; - ItemNames (see data/items/names.asm)
; - ItemDescriptions (see data/items/descriptions.asm)
; - ItemAttributes (see data/items/attributes.asm)
; - ItemEffects (see engine/items/item_effects.asm)
const_def
const NO_ITEM ; 00
const MASTER_BALL ; 01
const ULTRA_BALL ; 02
const BRIGHTPOWDER ; 03
const GREAT_BALL ; 04
const POKE_BALL ; 05
const TOWN_MAP ; 06
const BICYCLE ; 07
const MOON_STONE ; 08
const ANTIDOTE ; 09
const BURN_HEAL ; 0a
const ICE_HEAL ; 0b
const AWAKENING ; 0c
const PARLYZ_HEAL ; 0d
const FULL_RESTORE ; 0e
const MAX_POTION ; 0f
const HYPER_POTION ; 10
const SUPER_POTION ; 11
const POTION ; 12
const ESCAPE_ROPE ; 13
const REPEL ; 14
const MAX_ELIXER ; 15
const FIRE_STONE ; 16
const THUNDERSTONE ; 17
const WATER_STONE ; 18
const ITEM_19 ; 19
const HP_UP ; 1a
const PROTEIN ; 1b
const IRON ; 1c
const CARBOS ; 1d
const LUCKY_PUNCH ; 1e
const CALCIUM ; 1f
const RARE_CANDY ; 20
const X_ACCURACY ; 21
const LEAF_STONE ; 22
const METAL_POWDER ; 23
const NUGGET ; 24
const POKE_DOLL ; 25
const FULL_HEAL ; 26
const REVIVE ; 27
const MAX_REVIVE ; 28
const GUARD_SPEC ; 29
const SUPER_REPEL ; 2a
const MAX_REPEL ; 2b
const DIRE_HIT ; 2c
const ITEM_2D ; 2d
const FRESH_WATER ; 2e
const SODA_POP ; 2f
const LEMONADE ; 30
const X_ATTACK ; 31
const ITEM_32 ; 32
const X_DEFEND ; 33
const X_SPEED ; 34
const X_SPECIAL ; 35
const COIN_CASE ; 36
const ITEMFINDER ; 37
const POKE_FLUTE ; 38
const EXP_SHARE ; 39
const OLD_ROD ; 3a
const GOOD_ROD ; 3b
const SILVER_LEAF ; 3c
const SUPER_ROD ; 3d
const PP_UP ; 3e
const ETHER ; 3f
const MAX_ETHER ; 40
const ELIXER ; 41
const RED_SCALE ; 42
const SECRETPOTION ; 43
const S_S_TICKET ; 44
const MYSTERY_EGG ; 45
const CLEAR_BELL ; 46
const SILVER_WING ; 47
const MOOMOO_MILK ; 48
const QUICK_CLAW ; 49
const PSNCUREBERRY ; 4a
const GOLD_LEAF ; 4b
const SOFT_SAND ; 4c
const SHARP_BEAK ; 4d
const PRZCUREBERRY ; 4e
const BURNT_BERRY ; 4f
const ICE_BERRY ; 50
const POISON_BARB ; 51
const KINGS_ROCK ; 52
const BITTER_BERRY ; 53
const MINT_BERRY ; 54
const RED_APRICORN ; 55
const TINYMUSHROOM ; 56
const BIG_MUSHROOM ; 57
const SILVERPOWDER ; 58
const BLU_APRICORN ; 59
const ITEM_5A ; 5a
const AMULET_COIN ; 5b
const YLW_APRICORN ; 5c
const GRN_APRICORN ; 5d
const CLEANSE_TAG ; 5e
const MYSTIC_WATER ; 5f
const TWISTEDSPOON ; 60
const WHT_APRICORN ; 61
const BLACKBELT ; 62
const BLK_APRICORN ; 63
const ITEM_64 ; 64
const PNK_APRICORN ; 65
const BLACKGLASSES ; 66
const SLOWPOKETAIL ; 67
const PINK_BOW ; 68
const STICK ; 69
const SMOKE_BALL ; 6a
const NEVERMELTICE ; 6b
const MAGNET ; 6c
const MIRACLEBERRY ; 6d
const PEARL ; 6e
const BIG_PEARL ; 6f
const EVERSTONE ; 70
const SPELL_TAG ; 71
const RAGECANDYBAR ; 72
const GS_BALL ; 73
const BLUE_CARD ; 74
const MIRACLE_SEED ; 75
const THICK_CLUB ; 76
const FOCUS_BAND ; 77
const ITEM_78 ; 78
const ENERGYPOWDER ; 79
const ENERGY_ROOT ; 7a
const HEAL_POWDER ; 7b
const REVIVAL_HERB ; 7c
const HARD_STONE ; 7d
const LUCKY_EGG ; 7e
const CARD_KEY ; 7f
const MACHINE_PART ; 80
const EGG_TICKET ; 81
const LOST_ITEM ; 82
const STARDUST ; 83
const STAR_PIECE ; 84
const BASEMENT_KEY ; 85
const PASS ; 86
const ITEM_87 ; 87
const ITEM_88 ; 88
const ITEM_89 ; 89
const CHARCOAL ; 8a
const BERRY_JUICE ; 8b
const SCOPE_LENS ; 8c
const ITEM_8D ; 8d
const ITEM_8E ; 8e
const METAL_COAT ; 8f
const DRAGON_FANG ; 90
const ITEM_91 ; 91
const LEFTOVERS ; 92
const ITEM_93 ; 93
const ITEM_94 ; 94
const ITEM_95 ; 95
const MYSTERYBERRY ; 96
const DRAGON_SCALE ; 97
const BERSERK_GENE ; 98
const ITEM_99 ; 99
const ITEM_9A ; 9a
const ITEM_9B ; 9b
const SACRED_ASH ; 9c
const HEAVY_BALL ; 9d
const FLOWER_MAIL ; 9e
const LEVEL_BALL ; 9f
const LURE_BALL ; a0
const FAST_BALL ; a1
const ITEM_A2 ; a2
const LIGHT_BALL ; a3
const FRIEND_BALL ; a4
const MOON_BALL ; a5
const LOVE_BALL ; a6
const NORMAL_BOX ; a7
const GORGEOUS_BOX ; a8
const SUN_STONE ; a9
const POLKADOT_BOW ; aa
const ITEM_AB ; ab
const UP_GRADE ; ac
const BERRY ; ad
const GOLD_BERRY ; ae
const SQUIRTBOTTLE ; af
const ITEM_B0 ; b0
const PARK_BALL ; b1
const RAINBOW_WING ; b2
const ITEM_B3 ; b3
const BRICK_PIECE ; b4
const SURF_MAIL ; b5
const LITEBLUEMAIL ; b6
const PORTRAITMAIL ; b7
const LOVELY_MAIL ; b8
const EON_MAIL ; b9
const MORPH_MAIL ; ba
const BLUESKY_MAIL ; bb
const MUSIC_MAIL ; bc
const MIRAGE_MAIL ; bd
const ITEM_BE ; be
const ITEM_DC ; bf
const ITEM_C3 ; c0
const ITEM_FA ; c1
add_tm: MACRO
if !DEF(TM01)
TM01 EQU const_value
enum_start 1
endc
define _\@_1, "TM_\1"
const _\@_1
enum \1_TMNUM
ENDM
; see data/moves/tmhm_moves.asm for moves
add_tm DYNAMICPUNCH ; c2
add_tm HEADBUTT ; c3
add_tm CURSE ; c4
add_tm ROLLOUT ; c5
add_tm ROAR ; c6
add_tm TOXIC ; c7
add_tm ZAP_CANNON ; c8
add_tm ROCK_SMASH ; c9
add_tm PSYCH_UP ; ca
add_tm HIDDEN_POWER ; cb
add_tm SUNNY_DAY ; cc
add_tm SWEET_SCENT ; cd
add_tm SNORE ; ce
add_tm BLIZZARD ; cf
add_tm HYPER_BEAM ; d0
add_tm ICY_WIND ; d1
add_tm PROTECT ; d2
add_tm RAIN_DANCE ; d3
add_tm GIGA_DRAIN ; d4
add_tm ENDURE ; d5
add_tm FRUSTRATION ; d6
add_tm SOLARBEAM ; d7
add_tm IRON_TAIL ; d8
add_tm DRAGONBREATH ; d9
add_tm THUNDER ; da
add_tm EARTHQUAKE ; db
add_tm RETURN ; dc
add_tm DIG ; dd
add_tm PSYCHIC_M ; de
add_tm SHADOW_BALL ; df
add_tm MUD_SLAP ; e0
add_tm DOUBLE_TEAM ; e1
add_tm ICE_PUNCH ; e2
add_tm SWAGGER ; e3
add_tm SLEEP_TALK ; e4
add_tm SLUDGE_BOMB ; e5
add_tm SANDSTORM ; e6
add_tm FIRE_BLAST ; e7
add_tm SWIFT ; e8
add_tm DEFENSE_CURL ; e9
add_tm THUNDERPUNCH ; ea
add_tm DREAM_EATER ; eb
add_tm DETECT ; ec
add_tm REST ; ed
add_tm ATTRACT ; ee
add_tm THIEF ; ef
add_tm STEEL_WING ; f0
add_tm FIRE_PUNCH ; f1
add_tm FURY_CUTTER ; f2
add_tm NIGHTMARE ; f3
NUM_TMS EQU const_value - TM01
add_hm: MACRO
if !DEF(HM01)
HM01 EQU const_value
endc
define _\@_1, "HM_\1"
const _\@_1
enum \1_TMNUM
ENDM
add_hm CUT ; f4
add_hm FLY ; f5
add_hm SURF ; f6
add_hm STRENGTH ; f7
add_hm FLASH ; f8
add_hm WHIRLPOOL ; f9
add_hm WATERFALL ; fa
NUM_HMS EQU const_value - HM01
add_mt: MACRO
enum \1_TMNUM
ENDM
add_mt FLAMETHROWER
add_mt THUNDERBOLT
add_mt ICE_BEAM
NUM_TM_HM_TUTOR EQU __enum__ + -1
USE_SCRIPT_VAR EQU $00
ITEM_FROM_MEM EQU $ff
; leftovers from red
SAFARI_BALL EQU $08 ; MOON_STONE
MOON_STONE_RED EQU $0a ; BURN_HEAL
FULL_HEAL_RED EQU $34 ; X_SPEED
|
; A256257: 6 times numbers of Gould's sequence A001316.
; 6,12,12,24,12,24,24,48,12,24,24,48,24,48,48,96,12,24,24,48,24,48,48,96,24,48,48,96,48,96,96,192,12,24,24,48,24,48,48,96,24,48,48,96,48,96,96,192,24,48,48,96,48,96,96,192,48,96,96,192,96,192,192,384,12,24,24,48,24,48,48,96,24,48,48,96,48,96,96,192
mov $1,$0
lpb $0
div $1,2
sub $0,$1
lpe
mul $1,2
pow $1,$0
add $1,1
mul $1,2
sub $1,4
div $1,2
mul $1,6
add $1,6
|
SECTION rodata_font
SECTION rodata_font_fzx
PUBLIC _ff_dkud1_UpnUp1
_ff_dkud1_UpnUp1:
BINARY "font/fzx/fonts/dkud1/UpnUp/up&up.fzx"
|
#pragma once
#include <Arduino.h>
#include <ArduinoJson.h>
#include <Streaming.h>
#include "Config.hpp"
#include "Firmware.hpp"
#include "Hardware.hpp"
#include "Http.hpp"
#include "Mqtt.hpp"
#include "Ota.hpp"
#include "System.hpp"
#include "Timer.hpp"
#include "Transducer/AbstractActuator.hpp"
#include "Transducer/AbstractSensor.hpp"
#include "Transducer/BinaryActuator.hpp"
#include "Transducer/Button.hpp"
#include "Transducer/Dht.hpp"
#include "Uptime.hpp"
#include "Wifi.hpp"
class Smarty {
public:
~Smarty();
void setup();
void loop();
private:
SmartyConfig _config{};
SmartySystem _system{};
SmartyFirmware _firmware{};
SmartyHardware _hardware{};
SmartyUptime _uptime{};
SmartyWifi _wifi{};
SmartyOta _ota{};
SmartyHttp _http{};
SmartyMqtt _mqtt{};
void _initializeHttp();
void _initializeMqtt();
};
|
#pragma once
#ifndef ZGRAPH_GRAPH_ZADJACENCY_LIST_DIGRAPH_HPP
#define ZGRAPH_GRAPH_ZADJACENCY_LIST_DIGRAPH_HPP
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <array>
#include "zgraph/graph/detail/zgraph_items.hpp"
#include "zgraph/graph/detail/zgraph_maps.hpp"
#include "zgraph/graph/zgraph_base.hpp"
#include "zgraph/detail/zvalue_map.hpp"
#include <range/v3/view/transform.hpp>
namespace zgraph
{
template<bool is_mutligraph, bool allow_self_loop>
class zadjacency_list_digraph;
template<bool is_mutligraph, bool allow_self_loop>
class zgraph_type_traits<zadjacency_list_digraph<is_mutligraph, allow_self_loop>>{
public:
using is_directed_t = std::true_type;
using is_mutligraph_t = std::integral_constant<bool, is_mutligraph>;
using allow_self_loops_t = std::integral_constant<bool, allow_self_loop>;
using graph_t = zadjacency_list_digraph<is_mutligraph, allow_self_loop>;
using node_index_t = uint64_t;
using edge_index_t = uint64_t;
template<class value_t>
class node_map : public zassociative_graph_item_map<graph_t,znode_tag,std::map<node_index_t, value_t>>{
using base_t = zassociative_graph_item_map<graph_t,znode_tag,std::map<node_index_t, value_t>>;
using base_t::base_t;
};
template<class value_t>
class edge_map : public zassociative_graph_item_map<graph_t,zedge_tag,std::map<edge_index_t, value_t>>{
using base_t = zassociative_graph_item_map<graph_t,zedge_tag,std::map<edge_index_t, value_t>>;
using base_t::base_t;
};
class node_set : public std::set<node_index_t>{
public:
node_set(const graph_t & g){
}
};
};
template<bool is_mutligraph, bool allow_self_loop>
class zadjacency_list_digraph : public zgraph_base<zadjacency_list_digraph<is_mutligraph, allow_self_loop>>
{
public:
using node_index_t = uint64_t;
using edge_index_t = uint64_t;
using adjacency_t = std::map<node_index_t, edge_index_t>;
using endpoint_array_t = std::array<node_index_t, 2>;
zadjacency_list_digraph()
: m_next_edge_index(0)
{
}
//
bool add_node(const node_index_t node){
return m_out_adjacencies.try_emplace(node, adjacency_t()).second;
}
edge_index_t add_edge(const node_index_t u, const node_index_t v){
bool new_u = this->add_node(u);
bool new_v = this->add_node(v);
if(new_u || new_v){
// edge cannot exist
const auto edge_index = m_next_edge_index++;
m_edges.emplace(edge_index, endpoint_array_t{u, v});
this->get_out_adjacency(u).emplace(edge_index, v);
this->get_in_adjacency(v).emplace(edge_index, u);
return edge_index;
} else{
// edge might exist
auto & adj_u = this->get_out_adjacency(u);
if(auto find_v = adj_u.find(v); find_v != adj_u.end()){
// edge does exist
return find_v->second;
} else{
// edge does not exist
const auto edge_index = m_next_edge_index++;
m_edges.emplace(edge_index, endpoint_array_t{u, v});
adj_u.emplace(edge_index, v);
this->get_in_adjacency(v).emplace(edge_index, u);
return edge_index;
}
}
}
// api
decltype(auto) adjacency(const node_index_t node)const{
return get_out_adjacency(node);
}
decltype(auto) in_adjacency(const node_index_t node)const{
return get_in_adjacency(node);
}
// node iter
auto num_nodes()const{
return m_out_adjacencies.size();
}
auto num_edges() const{
return m_edges.size();
}
auto nodes() const{
return m_out_adjacencies | ranges::views::keys;
}
auto edges() const{
return m_edges | ranges::views::keys;
}
const auto & endpoints(const edge_index_t & edge) const{
return m_edges.find(edge)->second;
}
private:
auto & get_out_adjacency(const node_index_t node){
return m_out_adjacencies.find(node)->second;
}
const auto & get_out_adjacency(const node_index_t node) const{
return m_out_adjacencies.find(node)->second;
}
auto & get_in_adjacency(const node_index_t node){
return m_in_adjacencies.find(node)->second;
}
const auto & get_in_adjacency(const node_index_t node) const{
return m_in_adjacencies.find(node)->second;
}
edge_index_t m_next_edge_index;
std::map<node_index_t, adjacency_t> m_out_adjacencies;
std::map<node_index_t, adjacency_t> m_in_adjacencies;
std::map<edge_index_t, endpoint_array_t> m_edges;
};
} // end namespace zgraph
#endif // ZGRAPH_GRAPH_ZADJACENCY_LIST_DIGRAPH_HPP |
; ===============================================================
; May 2017
; ===============================================================
;
; void *tshr_saddrcdown(void *saddr)
;
; Modify screen address to move down one character (eight pixels)
;
; ===============================================================
SECTION code_clib
SECTION code_arch
PUBLIC asm_tshr_saddrcdown
EXTERN asm_zx_saddrcdown
defc asm_tshr_saddrcdown = asm_zx_saddrcdown
|
; uint in_LookupKey(uchar c)
; 09.2005 aralbrec
SECTION code_clib
PUBLIC in_LookupKey
PUBLIC _in_LookupKey
EXTERN in_keytranstbl
; Given the ascii code of a character, returns the scan row and mask
; corresponding to the key that needs to be pressed to generate the
; character. Eg: Calling LookupKey with character 'a' will return
; '$fd' for key row and '$01' for the mask. You could then check to
; see if the key is pressed with the following bit of code:
;
; ld a,$fd
; in a,($fe)
; and $01
; jr z, a_is_pressed
;
; The mask returned will have bit 7 set and bit 6 set to
; indicate if CAPS, SYM SHIFTS also have to be pressed to generate the
; ascii code, respectively.
; enter: L = ascii character code
; exit : carry set & HL=0 if ascii code not found
; else: L = scan row, H = mask
; bit 7 of H set if CAPS needs to be pressed
; bit 6 of H set if SYM SHIFT needs to be pressed
; uses : AF,BC,HL
; The 16-bit value returned is a scan code understood by
; in_KeyPressed.
.in_LookupKey
._in_LookupKey
ld a,l
ld hl,in_keytranstbl
ld bc,160
cpir
jr nz, notfound
ld a,159
sub c ; A = position in table of ascii code
ld l,b
ld h,b
cp 80
jr c, nosymshift
sub 80
set 6,h
.nosymshift
cp 40
jr c, nocapshift
sub 40
set 7,h
.nocapshift
.div5loop
inc b
sub 5
jp nc, div5loop
.donedivide
add a,6 ; A = bit position + 1, B = row + 1
ld l,$7f
.rowlp
rlc l
djnz rowlp
ld b,a
ld a,$80
.masklp
rlca
djnz masklp
or h
ld h,a
ret
.notfound
ld hl,0
scf
ret
|
; A003461: Bode numbers multiplied by 10: 4 + 3*floor(2^(n-1)).
; 4,7,10,16,28,52,100,196,388,772,1540,3076,6148,12292,24580,49156,98308,196612,393220,786436,1572868,3145732,6291460,12582916,25165828,50331652,100663300,201326596,402653188,805306372,1610612740,3221225476,6442450948,12884901892,25769803780,51539607556,103079215108,206158430212,412316860420,824633720836,1649267441668,3298534883332,6597069766660,13194139533316,26388279066628,52776558133252,105553116266500,211106232532996,422212465065988,844424930131972,1688849860263940,3377699720527876,6755399441055748,13510798882111492,27021597764222980,54043195528445956,108086391056891908,216172782113783812,432345564227567620,864691128455135236,1729382256910270468,3458764513820540932,6917529027641081860,13835058055282163716,27670116110564327428,55340232221128654852,110680464442257309700,221360928884514619396,442721857769029238788,885443715538058477572,1770887431076116955140,3541774862152233910276,7083549724304467820548,14167099448608935641092,28334198897217871282180,56668397794435742564356,113336795588871485128708,226673591177742970257412,453347182355485940514820,906694364710971881029636,1813388729421943762059268,3626777458843887524118532,7253554917687775048237060,14507109835375550096474116,29014219670751100192948228,58028439341502200385896452,116056878683004400771792900,232113757366008801543585796,464227514732017603087171588,928455029464035206174343172,1856910058928070412348686340,3713820117856140824697372676,7427640235712281649394745348,14855280471424563298789490692,29710560942849126597578981380,59421121885698253195157962756,118842243771396506390315925508,237684487542793012780631851012,475368975085586025561263702020,950737950171172051122527404036
mov $1,2
pow $1,$0
div $1,2
mul $1,3
add $1,4
mov $0,$1
|
; A136506: a(n) = binomial(2^n + 2, n).
; 1,4,15,120,3060,278256,90858768,105637584000,436355999662176,6431591598617108352,340881559632021623909760,65533747894341651530074060800,46081376018330435634530315478453248
mov $1,2
pow $1,$0
add $1,2
bin $1,$0
mov $0,$1
|
%define BPM 100
%include "../src/sointu.inc"
BEGIN_PATTERNS
PATTERN 64, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0
END_PATTERNS
BEGIN_TRACKS
TRACK VOICES(1),0
END_TRACKS
BEGIN_PATCH
BEGIN_INSTRUMENT VOICES(1) ; Instrument0
SU_LOADVAL MONO,VALUE(0)
SU_LOADVAL MONO,VALUE(128)
SU_GAIN STEREO,GAIN(64)
SU_OUT STEREO,GAIN(128)
END_INSTRUMENT
END_PATCH
%include "../src/sointu.asm"
|
ShouldOverrideFileLoad:
; Y = Graphics file being loaded
CPY #$0A ; 0A = Ice/Mire floor file
BNE .no
LDA $040C ; Dungeon number
CMP #$12 ; Ice Palace
BEQ .yes
.no
CLC : RTS
.yes
SEC : RTS
BgGraphicsLoading:
; Instructions overwritten
STZ $00
STX $01
STA $02
JSR ShouldOverrideFileLoad
BCS .useSpecialIcePalaceFile
JML BgGraphicsLoadingResume
.useSpecialIcePalaceFile
; We're loading the floor tiles in Ice Palace. Instead of the normal file,
; load another one that replaces the bridge tiles with the Bombos medallion
LDA $FFFFFF
LDA.b #IcePalaceFloorGfx>>16
STA $02
REP #$20
LDA.w #IcePalaceFloorGfx
STA $00
LDX.b #64*2 ; Tiles to load * 2
-
; Unrolled loop to upload half a tile
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
LDA [$00] : STA $2118 : INC $00 : INC $00
DEX
BNE -
SEP #$20
JML BgGraphicsLoadingCancel
ReloadingFloors:
SEP #$30 ; 8 AXY
LDA $7EC2F8 ; Floor file that has been decompressed
TAY
JSR ShouldOverrideFileLoad
REP #$30 ; 16 AXY
BCS .replaceWithSpecialIcePalaceFile
; Instructions overwritten by hook
LDX.w #$0000
LDY.w #$0040
JML ReloadingFloorsResume
.replaceWithSpecialIcePalaceFile
; Block move our hardcoded graphics into the output buffer
LDX.w #IcePalaceFloorGfx ; Source
LDY.w #$0000 ; Target
LDA.w #$0800 ; Length
PHB
;MVN $7F, IcePalaceFloorGfx>>16
MVN $A07F ; CHANGE THIS IF YOU MOVE THE FILE - kkat
PLB
; Pretend that we ran the original routine
LDX.w #$0800
LDA.w #$6600
STA $03
JML ReloadingFloorsCancel
IcePalaceFloorGfx:
incbin ice_palace_floor.bin |
;
; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright 2009 D. R. Commander
;
; Based on
; x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
; the IJG's original jidctflt.c; see the jidctflt.c for more details.
;
; [TAB8]
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1,%2,0x44
%endmacro
%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1,%2,0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
alignz 16
global EXTN(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
PD_1_414 times 4 dd 1.414213562373095048801689
PD_1_847 times 4 dd 1.847759065022573512256366
PD_1_082 times 4 dd 1.082392200292393968799446
PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
alignz 16
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 64
;
; Perform dequantization and inverse DCT on one block of coefficients.
;
; GLOBAL(void)
; jsimd_idct_float_sse2 (void * dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
; r10 = void * dct_table
; r11 = JCOEFPTR coef_block
; r12 = JSAMPARRAY output_buf
; r13 = JDIMENSION output_col
%define original_rbp rbp+0
%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT
; FAST_FLOAT workspace[DCTSIZE2]
align 16
global EXTN(jsimd_idct_float_sse2)
EXTN(jsimd_idct_float_sse2):
push rbp
mov rax,rsp ; rax = original rbp
sub rsp, byte 4
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [rsp],rax
mov rbp,rsp ; rbp = aligned rbp
lea rsp, [workspace]
collect_args
push rbx
; ---- Pass 1: process columns from input, store into work array.
mov rdx, r10 ; quantptr
mov rsi, r11 ; inptr
lea rdi, [workspace] ; FAST_FLOAT * wsptr
mov rcx, DCTSIZE/4 ; ctr
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
jnz near .columnDCT
movq xmm1, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm4, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm6, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
movq xmm7, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
por xmm1,xmm2
por xmm3,xmm4
por xmm5,xmm6
por xmm1,xmm3
por xmm5,xmm7
por xmm1,xmm5
packsswb xmm1,xmm1
movd eax,xmm1
test rax,rax
jnz short .columnDCT
; -- AC terms all zero
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm1,xmm0
movaps xmm2,xmm0
movaps xmm3,xmm0
shufps xmm0,xmm0,0x00 ; xmm0=(00 00 00 00)
shufps xmm1,xmm1,0x55 ; xmm1=(01 01 01 01)
shufps xmm2,xmm2,0xAA ; xmm2=(02 02 02 02)
shufps xmm3,xmm3,0xFF ; xmm3=(03 03 03 03)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
%endif
.columnDCT:
; -- Even part
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0,xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
punpcklwd xmm1,xmm1 ; xmm1=(20 20 21 21 22 22 23 23)
psrad xmm0,(DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23)
cvtdq2ps xmm0,xmm0 ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm1,xmm1 ; xmm1=in2=(20 21 22 23)
punpcklwd xmm2,xmm2 ; xmm2=(40 40 41 41 42 42 43 43)
punpcklwd xmm3,xmm3 ; xmm3=(60 60 61 61 62 62 63 63)
psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43)
psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63)
cvtdq2ps xmm2,xmm2 ; xmm2=in4=(40 41 42 43)
cvtdq2ps xmm3,xmm3 ; xmm3=in6=(60 61 62 63)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4,xmm0
movaps xmm5,xmm1
subps xmm0,xmm2 ; xmm0=tmp11
subps xmm1,xmm3
addps xmm4,xmm2 ; xmm4=tmp10
addps xmm5,xmm3 ; xmm5=tmp13
mulps xmm1,[rel PD_1_414]
subps xmm1,xmm5 ; xmm1=tmp12
movaps xmm6,xmm4
movaps xmm7,xmm0
subps xmm4,xmm5 ; xmm4=tmp3
subps xmm0,xmm1 ; xmm0=tmp2
addps xmm6,xmm5 ; xmm6=tmp0
addps xmm7,xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movq xmm2, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm2,xmm2 ; xmm2=(10 10 11 11 12 12 13 13)
punpcklwd xmm3,xmm3 ; xmm3=(30 30 31 31 32 32 33 33)
psrad xmm2,(DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13)
psrad xmm3,(DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33)
cvtdq2ps xmm2,xmm2 ; xmm2=in1=(10 11 12 13)
cvtdq2ps xmm3,xmm3 ; xmm3=in3=(30 31 32 33)
punpcklwd xmm5,xmm5 ; xmm5=(50 50 51 51 52 52 53 53)
punpcklwd xmm1,xmm1 ; xmm1=(70 70 71 71 72 72 73 73)
psrad xmm5,(DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53)
psrad xmm1,(DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73)
cvtdq2ps xmm5,xmm5 ; xmm5=in5=(50 51 52 53)
cvtdq2ps xmm1,xmm1 ; xmm1=in7=(70 71 72 73)
mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4,xmm2
movaps xmm0,xmm5
addps xmm2,xmm1 ; xmm2=z11
addps xmm5,xmm3 ; xmm5=z13
subps xmm4,xmm1 ; xmm4=z12
subps xmm0,xmm3 ; xmm0=z10
movaps xmm1,xmm2
subps xmm2,xmm5
addps xmm1,xmm5 ; xmm1=tmp7
mulps xmm2,[rel PD_1_414] ; xmm2=tmp11
movaps xmm3,xmm0
addps xmm0,xmm4
mulps xmm0,[rel PD_1_847] ; xmm0=z5
mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3,xmm0 ; xmm3=tmp12
subps xmm4,xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3,xmm1 ; xmm3=tmp6
movaps xmm5,xmm6
movaps xmm0,xmm7
addps xmm6,xmm1 ; xmm6=data0=(00 01 02 03)
addps xmm7,xmm3 ; xmm7=data1=(10 11 12 13)
subps xmm5,xmm1 ; xmm5=data7=(70 71 72 73)
subps xmm0,xmm3 ; xmm0=data6=(60 61 62 63)
subps xmm2,xmm3 ; xmm2=tmp5
movaps xmm1,xmm6 ; transpose coefficients(phase 1)
unpcklps xmm6,xmm7 ; xmm6=(00 10 01 11)
unpckhps xmm1,xmm7 ; xmm1=(02 12 03 13)
movaps xmm3,xmm0 ; transpose coefficients(phase 1)
unpcklps xmm0,xmm5 ; xmm0=(60 70 61 71)
unpckhps xmm3,xmm5 ; xmm3=(62 72 63 73)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
addps xmm4,xmm2 ; xmm4=tmp4
movaps xmm0,xmm7
movaps xmm3,xmm5
addps xmm7,xmm2 ; xmm7=data2=(20 21 22 23)
addps xmm5,xmm4 ; xmm5=data4=(40 41 42 43)
subps xmm0,xmm2 ; xmm0=data5=(50 51 52 53)
subps xmm3,xmm4 ; xmm3=data3=(30 31 32 33)
movaps xmm2,xmm7 ; transpose coefficients(phase 1)
unpcklps xmm7,xmm3 ; xmm7=(20 30 21 31)
unpckhps xmm2,xmm3 ; xmm2=(22 32 23 33)
movaps xmm4,xmm5 ; transpose coefficients(phase 1)
unpcklps xmm5,xmm0 ; xmm5=(40 50 41 51)
unpckhps xmm4,xmm0 ; xmm4=(42 52 43 53)
movaps xmm3,xmm6 ; transpose coefficients(phase 2)
unpcklps2 xmm6,xmm7 ; xmm6=(00 10 20 30)
unpckhps2 xmm3,xmm7 ; xmm3=(01 11 21 31)
movaps xmm0,xmm1 ; transpose coefficients(phase 2)
unpcklps2 xmm1,xmm2 ; xmm1=(02 12 22 32)
unpckhps2 xmm0,xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6,xmm5 ; transpose coefficients(phase 2)
unpcklps2 xmm5,xmm7 ; xmm5=(40 50 60 70)
unpckhps2 xmm6,xmm7 ; xmm6=(41 51 61 71)
movaps xmm3,xmm4 ; transpose coefficients(phase 2)
unpcklps2 xmm4,xmm2 ; xmm4=(42 52 62 72)
unpckhps2 xmm3,xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm4
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
.nextcolumn:
add rsi, byte 4*SIZEOF_JCOEF ; coef_block
add rdx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
add rdi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
dec rcx ; ctr
jnz near .columnloop
; -- Prefetch the next coefficient block
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
; ---- Pass 2: process rows from work array, store into output array.
mov rax, [original_rbp]
lea rsi, [workspace] ; FAST_FLOAT * wsptr
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
mov rcx, DCTSIZE/4 ; ctr
.rowloop:
; -- Even part
movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4,xmm0
movaps xmm5,xmm1
subps xmm0,xmm2 ; xmm0=tmp11
subps xmm1,xmm3
addps xmm4,xmm2 ; xmm4=tmp10
addps xmm5,xmm3 ; xmm5=tmp13
mulps xmm1,[rel PD_1_414]
subps xmm1,xmm5 ; xmm1=tmp12
movaps xmm6,xmm4
movaps xmm7,xmm0
subps xmm4,xmm5 ; xmm4=tmp3
subps xmm0,xmm1 ; xmm0=tmp2
addps xmm6,xmm5 ; xmm6=tmp0
addps xmm7,xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4,xmm2
movaps xmm0,xmm5
addps xmm2,xmm1 ; xmm2=z11
addps xmm5,xmm3 ; xmm5=z13
subps xmm4,xmm1 ; xmm4=z12
subps xmm0,xmm3 ; xmm0=z10
movaps xmm1,xmm2
subps xmm2,xmm5
addps xmm1,xmm5 ; xmm1=tmp7
mulps xmm2,[rel PD_1_414] ; xmm2=tmp11
movaps xmm3,xmm0
addps xmm0,xmm4
mulps xmm0,[rel PD_1_847] ; xmm0=z5
mulps xmm3,[rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4,[rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3,xmm0 ; xmm3=tmp12
subps xmm4,xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3,xmm1 ; xmm3=tmp6
movaps xmm5,xmm6
movaps xmm0,xmm7
addps xmm6,xmm1 ; xmm6=data0=(00 10 20 30)
addps xmm7,xmm3 ; xmm7=data1=(01 11 21 31)
subps xmm5,xmm1 ; xmm5=data7=(07 17 27 37)
subps xmm0,xmm3 ; xmm0=data6=(06 16 26 36)
subps xmm2,xmm3 ; xmm2=tmp5
movaps xmm1,[rel PD_RNDINT_MAGIC] ; xmm1=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm3,xmm3
psrld xmm3,WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm6,xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **)
addps xmm7,xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **)
addps xmm0,xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **)
addps xmm5,xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **)
pand xmm6,xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --)
pslld xmm7,WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31)
pand xmm0,xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --)
pslld xmm5,WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37)
por xmm6,xmm7 ; xmm6=(00 01 10 11 20 21 30 31)
por xmm0,xmm5 ; xmm0=(06 07 16 17 26 27 36 37)
movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2
movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3
addps xmm4,xmm2 ; xmm4=tmp4
movaps xmm7,xmm1
movaps xmm5,xmm3
addps xmm1,xmm2 ; xmm1=data2=(02 12 22 32)
addps xmm3,xmm4 ; xmm3=data4=(04 14 24 34)
subps xmm7,xmm2 ; xmm7=data5=(05 15 25 35)
subps xmm5,xmm4 ; xmm5=data3=(03 13 23 33)
movaps xmm2,[rel PD_RNDINT_MAGIC] ; xmm2=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm4,xmm4
psrld xmm4,WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm3,xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **)
addps xmm7,xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **)
addps xmm1,xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **)
addps xmm5,xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **)
pand xmm3,xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --)
pslld xmm7,WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35)
pand xmm1,xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --)
pslld xmm5,WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33)
por xmm3,xmm7 ; xmm3=(04 05 14 15 24 25 34 35)
por xmm1,xmm5 ; xmm1=(02 03 12 13 22 23 32 33)
movdqa xmm2,[rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
packsswb xmm6,xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35)
packsswb xmm1,xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37)
paddb xmm6,xmm2
paddb xmm1,xmm2
movdqa xmm4,xmm6 ; transpose coefficients(phase 2)
punpcklwd xmm6,xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
punpckhwd xmm4,xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
movdqa xmm7,xmm6 ; transpose coefficients(phase 3)
punpckldq xmm6,xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
punpckhdq xmm7,xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
pshufd xmm5,xmm6,0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm3,xmm7,0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm7
mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm3
add rsi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add rdi, byte 4*SIZEOF_JSAMPROW
dec rcx ; ctr
jnz near .rowloop
pop rbx
uncollect_args
mov rsp,rbp ; rsp <- aligned rbp
pop rsp ; rsp <- original rbp
pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
dc.w AniTails2P_Tail00-AniTails2P_Tail
dc.w AniTails2P_Tail01-AniTails2P_Tail
dc.w AniTails2P_Tail01-AniTails2P_Tail
dc.w AniTails2P_Tail03-AniTails2P_Tail
AniTails2P_Tail00:dc.b $20, 0, $FF
AniTails2P_Tail01:dc.b 7, 1, 2, 3, $FF
AniTails2P_Tail03:dc.b $FC, 4, 5, 6, $FF
even
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Problem 5:
;; Write an assembly language program to find the largest number in 15 binary
;; numbers read from Data Space. Get the numbers from the Data Space starts
;; from 0x0100. Output the result to Port B. (use register z to get number)
;; (Points 20)
.include "m328Pdef.inc"
init:
;; set up aliases
.def count=r16
.def limit=r17
.def value=r18
main:
;; initialize variables
ldi limit, 16
ldi zh, 0x01
ldi zl, 0x00
ldi value, 0
;; prep for output
ser r19
out DDRB, r19
loop:
cpc zl, limit
brge end
ld r22, z+
cpc r22,value ;; compare new value
brge newlarge ;; if its a new largest value then update
rjmp loop
newlarge:
mov value, r22
rjmp loop
end:
out PORTB, value ;; output to port b
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r14
push %r9
push %rax
push %rsi
lea addresses_WT_ht+0xaba3, %r11
nop
nop
nop
nop
cmp %r9, %r9
movw $0x6162, (%r11)
nop
nop
nop
nop
cmp $38269, %r9
lea addresses_UC_ht+0xfcb3, %rsi
nop
nop
nop
nop
xor $39870, %r12
movups (%rsi), %xmm1
vpextrq $0, %xmm1, %r14
nop
cmp %rsi, %rsi
lea addresses_WC_ht+0x120e3, %r11
nop
nop
inc %r13
mov (%r11), %r14
nop
nop
nop
nop
sub $44559, %rsi
lea addresses_A_ht+0x1d3a3, %r13
nop
nop
and $36420, %r9
movl $0x61626364, (%r13)
nop
nop
nop
nop
dec %r12
lea addresses_A_ht+0xbf3, %r12
clflush (%r12)
xor $52660, %rax
mov $0x6162636465666768, %r14
movq %r14, %xmm6
movups %xmm6, (%r12)
nop
nop
nop
and %r14, %r14
lea addresses_WC_ht+0x162c7, %r9
nop
nop
nop
nop
and %r11, %r11
vmovups (%r9), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $0, %xmm0, %rax
nop
nop
inc %rsi
lea addresses_WT_ht+0xec53, %r14
nop
dec %r13
movb $0x61, (%r14)
nop
nop
nop
nop
dec %rsi
pop %rsi
pop %rax
pop %r9
pop %r14
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r9
push %rbx
push %rcx
push %rdi
// Faulty Load
lea addresses_WC+0x1eba3, %r14
nop
nop
nop
nop
xor $59234, %rbx
vmovups (%r14), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $0, %xmm5, %rdi
lea oracles, %rbx
and $0xff, %rdi
shlq $12, %rdi
mov (%rbx,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WC', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_WC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC_ht', 'same': True, 'size': 32, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'38': 21829}
38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38
*/
|
; A066983: a(n+2) = a(n+1) + a(n) + (-1)^n, with a(1) = a(2) = 1.
; 1,1,1,3,3,7,9,17,25,43,67,111,177,289,465,755,1219,1975,3193,5169,8361,13531,21891,35423,57313,92737,150049,242787,392835,635623,1028457,1664081,2692537,4356619,7049155,11405775,18454929,29860705,48315633,78176339,126491971,204668311,331160281,535828593,866988873,1402817467,2269806339,3672623807,5942430145,9615053953,15557484097,25172538051,40730022147,65902560199,106632582345,172535142545,279167724889,451702867435,730870592323,1182573459759,1913444052081,3096017511841,5009461563921
trn $0,2
seq $0,74331 ; a(n) = Fibonacci(n+1) - (1 + (-1)^n)/2.
mul $0,2
add $0,1
|
# mediaEMediaQuadrados.asm
#
# DESC: Escrever um programa que le 10 inteiros do teclado que calcule a sua media e a media de seus quadrados e informar os resultados ao usuario
#
# DDA: 18-03-2021
.data
str1: "Digite um numero: "
arr: .space 40
i: 0
arr_length: 10
.text
# Ganhar acesso a primeira posicao de arr
la $s0, arr # Carrega o endereço de arr para $s0
# Ler 10 inteiros do teclado
la $t0, i # Carrega o endereço de i para $t0
lw $s1, 0($t0) # s1 = i (0)
la $t0, arr_length # Carrega o endereço de arr_length para $s0
lw $s2, 0($t0) # s2 = arr_length (10)
FOR1:
slt $t1, $s1, $s2 # i < 10?
beq $t1, $zero, SAI1
# Loop ______
la $a0, str1 # Carrega str1 para $a0
addi $v0, $zero, 4 # Carrega o código para printar string
syscall # Printa str1
addi $v0, $zero, 5 # Carrega o codigo para ler inteiro
syscall # Le o inteiro
sw $v0, 0($s0) # Guarda o inteiro em uma posicao de $s0
add $s0, $s0, 4 # PERGUNTAR PRO ABDALA PQ ISSO FUNCIONA, deveria ser addi
# ___________
addi $s1, $s1, 1 # i++
j FOR1
SAI1:
# Calcular a media dos 10 inteiros
la $s0, arr
add $s1, $zero, $zero
add $s3, $zero, $zero
FOR2:
slt $t1, $s1, $s2
beq $t1, $zero, SAI2
# Loop ______
add $s3, $s3, 0($s0)
add $s0, $s0, 4
# ___________
addi $s1, $s1, 1
j FOR2
# Elevar os 10 inteiros ao quadrado
# Calcular a media dos quadrados
SAI2:
# Calcula a media
div $s3, $s2
mflo
# Printar os resultados
# Fim do programa (return 0)
addi $v0, $zero, 10
syscall
|
; A086374: Number of factors over Q in the factorization of T_n(x) + 1 where T_n(x) is the Chebyshev polynomial of the first kind.
; 1,2,3,2,3,4,3,2,5,4,3,4,3,4,7,2,3,6,3,4,7,4,3,4,5,4,7,4,3,8,3,2,7,4,7,6,3,4,7,4,3,8,3,4,11,4,3,4,5,6,7,4,3,8,7,4,7,4,3,8,3,4,11,2,7,8,3,4,7,8,3,6,3,4,11,4,7,8,3,4,9,4,3,8,7,4,7,4,3,12,7,4,7,4,7,4,3,6,11,6,3,8,3,4,15,4,3,8,3,8,7,4,3,8,7,4,11,4,7,8,5,4,7,4,7,12,3,2,7,8,3,8,7,4,15,4,3,8,3,8,7,4,7,6,7,4,11,4,3,12,3,4,11,8,7,8,3,4,7,4,7,10,3,4,15,4,3,8,5,8,11,4,3,8,11,4,7,4,3,12,3,8,7,4,7,8,7,4,15,8,3,4,3,4,15,6,3,12,3,6,7,4,7,8,7,4,11,4,7,16,3,4,7,4,7,8,7,4,7,8,7,8,3,4,17,4,3,8,3,8,15,4,3,12,7,4,7,8,3,8,3,6,11,4,11,8,7,4,7,8
mov $1,2
gcd $1,$0
cal $0,91954 ; Number of odd proper divisors of n. That is, the number of odd divisors of n that are less than n.
mul $0,2
add $0,236
add $1,$0
mul $1,2
sub $1,476
div $1,2
add $1,1
|
//------------------------------------------------------------------------------
// File: DDMM.cpp
//
// Desc: DirectShow base classes - implements routines for using DirectDraw
// on a multimonitor system.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
#include <streams.h>
#include <ddraw.h>
#include "ddmm.h"
/*
* FindDeviceCallback
*/
typedef struct {
LPSTR szDevice;
GUID* lpGUID;
GUID GUID;
BOOL fFound;
} FindDeviceData;
BOOL CALLBACK FindDeviceCallback(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam)
{
FindDeviceData *p = (FindDeviceData*)lParam;
if (lstrcmpiA(p->szDevice, szDevice) == 0) {
if (lpGUID) {
p->GUID = *lpGUID;
p->lpGUID = &p->GUID;
} else {
p->lpGUID = NULL;
}
p->fFound = TRUE;
return FALSE;
}
return TRUE;
}
BOOL CALLBACK FindDeviceCallbackEx(GUID* lpGUID, LPSTR szName, LPSTR szDevice, LPVOID lParam, HMONITOR hMonitor)
{
FindDeviceData *p = (FindDeviceData*)lParam;
if (lstrcmpiA(p->szDevice, szDevice) == 0) {
if (lpGUID) {
p->GUID = *lpGUID;
p->lpGUID = &p->GUID;
} else {
p->lpGUID = NULL;
}
p->fFound = TRUE;
return FALSE;
}
return TRUE;
}
/*
* DirectDrawCreateFromDevice
*
* create a DirectDraw object for a particular device
*/
IDirectDraw * DirectDrawCreateFromDevice(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
{
IDirectDraw* pdd = NULL;
FindDeviceData find;
if (szDevice == NULL) {
DirectDrawCreateP(NULL, &pdd, NULL);
return pdd;
}
find.szDevice = szDevice;
find.fFound = FALSE;
DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);
if (find.fFound)
{
//
// In 4bpp mode the following DDraw call causes a message box to be popped
// up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
// make sure it doesn't happen.
//
UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
DirectDrawCreateP(find.lpGUID, &pdd, NULL);
SetErrorMode(ErrorMode);
}
return pdd;
}
/*
* DirectDrawCreateFromDeviceEx
*
* create a DirectDraw object for a particular device
*/
IDirectDraw * DirectDrawCreateFromDeviceEx(LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
{
IDirectDraw* pdd = NULL;
FindDeviceData find;
if (szDevice == NULL) {
DirectDrawCreateP(NULL, &pdd, NULL);
return pdd;
}
find.szDevice = szDevice;
find.fFound = FALSE;
DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find,
DDENUM_ATTACHEDSECONDARYDEVICES);
if (find.fFound)
{
//
// In 4bpp mode the following DDraw call causes a message box to be popped
// up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
// make sure it doesn't happen.
//
UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
DirectDrawCreateP(find.lpGUID, &pdd, NULL);
SetErrorMode(ErrorMode);
}
return pdd;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xca41, %rax
nop
nop
dec %r14
mov $0x6162636465666768, %rbx
movq %rbx, %xmm1
movups %xmm1, (%rax)
nop
and $24734, %rax
lea addresses_normal_ht+0xa74d, %rsi
lea addresses_WT_ht+0x13e11, %rdi
clflush (%rdi)
dec %r12
mov $106, %rcx
rep movsw
nop
nop
nop
nop
dec %rbx
lea addresses_WC_ht+0x15391, %rax
nop
nop
dec %rsi
mov (%rax), %bx
nop
nop
nop
nop
xor $48523, %r14
lea addresses_A_ht+0xc0d1, %rcx
nop
nop
nop
nop
nop
cmp %rbx, %rbx
movl $0x61626364, (%rcx)
nop
nop
cmp $37923, %rsi
lea addresses_A_ht+0x13711, %rax
sub %rbx, %rbx
mov (%rax), %rdi
nop
sub $22376, %rsi
lea addresses_WT_ht+0x728a, %rsi
lea addresses_WT_ht+0x9391, %rdi
add %r12, %r12
mov $35, %rcx
rep movsq
nop
nop
nop
dec %rax
lea addresses_D_ht+0x8621, %rcx
clflush (%rcx)
nop
nop
nop
nop
xor $41443, %r14
mov (%rcx), %r12
nop
nop
nop
nop
nop
and $8244, %rsi
lea addresses_WT_ht+0x1eadc, %rsi
lea addresses_D_ht+0xce34, %rdi
nop
nop
nop
xor $7717, %rax
mov $25, %rcx
rep movsw
nop
cmp %rsi, %rsi
lea addresses_normal_ht+0x5fd6, %rcx
nop
sub $25162, %r14
and $0xffffffffffffffc0, %rcx
vmovntdqa (%rcx), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rdi
nop
nop
add %rcx, %rcx
lea addresses_WT_ht+0x19791, %rbx
nop
nop
nop
nop
nop
add %rdi, %rdi
mov $0x6162636465666768, %r14
movq %r14, (%rbx)
nop
nop
nop
add $1987, %r12
lea addresses_normal_ht+0x18791, %rcx
nop
nop
nop
nop
sub %rbx, %rbx
movb $0x61, (%rcx)
nop
nop
nop
nop
xor %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r9
push %rbp
push %rdx
// Faulty Load
lea addresses_WC+0x8f91, %rbp
nop
nop
nop
add $29701, %r9
mov (%rbp), %r13d
lea oracles, %rdx
and $0xff, %r13
shlq $12, %r13
mov (%rdx,%r13,1), %r13
pop %rdx
pop %rbp
pop %r9
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 1, 'same': False, 'NT': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; ----------------------------------------------------------------------------
; Altair, CIDLESA's 1981 arcade game remade for the ZX Spectrum and
; Amstrad CPC.
; ----------------------------------------------------------------------------
; ----------------------------------------------------------------------------
; Object behaviors
; ----------------------------------------------------------------------------
; ------------
; Object Table
; ------------
SHIP_OB_SLOT .equ 0
SHIP_OB_SLOTS .equ 1
HOUSE_OB_SLOT .equ SHIP_OB_SLOT+SHIP_OB_SLOTS
HOUSE_OB_SLOTS .equ 1
ALIEN_OB_SLOT .equ HOUSE_OB_SLOT+HOUSE_OB_SLOTS
ALIEN_OB_SLOTS .equ 6
SHIP_SHOT_OB_SLOT .equ ALIEN_OB_SLOT+ALIEN_OB_SLOTS
SHIP_SHOT_OB_SLOTS .equ 2
ALIEN_SHOT_OB_SLOT .equ SHIP_SHOT_OB_SLOT+SHIP_SHOT_OB_SLOTS
ALIEN_SHOT_OB_SLOTS .equ 6
EXPLOSION_OB_SLOT .equ ALIEN_SHOT_OB_SLOT+ALIEN_SHOT_OB_SLOTS
EXPLOSION_OB_SLOTS .equ 6
POST_OB_SLOT .equ EXPLOSION_OB_SLOT+EXPLOSION_OB_SLOTS
POST_OB_SLOTS .equ 1
NOBJS .equ POST_OB_SLOT+POST_OB_SLOTS
; Careful, we are reusing slots for the bird.
BIRD_OB_SLOT .equ HOUSE_OB_SLOT
BIRD_OB_SLOTS .equ 1
; Alien images by level.
alien_ims0
.dw alim00
.dw alim10
.dw alim20
.dw alim30
.dw alim40
.dw alim50
.dw alim60
; Alien images by level.
alien_ims1
.dw alim01
.dw alim11
.dw alim21
.dw alim31
.dw alim41
.dw alim51
.dw 0
; Starting x position (House relative), Starting dx.
; For each of the 6 spawned ships.
alien_start_poss
.db 0, 1
.db 0, 0
.db 8, 255
.db 4, 1
.db 4, 0
.db 8, 255
; Functions to calculate the starting positions for the aliens shots, by level.
ashot_startpos_funs
.dw calc_ashot_startpos
.dw calc_ashot_startpos
.dw calc_ashot_startpos
.dw calc_cross_ashot_startpos
.dw calc_ashot_startpos
.dw calc_cross_ashot_startpos
.dw calc_ashot_startpos
; Master sprites for the alien shots by level.
ashot_mstr_sps
.dw mstr_ashot_sp
.dw mstr_ashot_sp
.dw mstr_ashot_sp
.dw mstr_cross_ashot_sp
.dw mstr_ashot_sp
.dw mstr_cross_ashot_sp
.dw mstr_ashot_sp
; Aliens shots behavior functions by level.
ashot_move_funs
.dw ashot_move
.dw ashot_move
.dw ashot_move
.dw cross_ashot_move
.dw ashot_move
.dw cross_ashot_move
.dw ashot_move
; Alien animations by level.
alien_ams .dw alien_am0
.dw alien_am1
.dw alien_am2
.dw alien_am3
.dw alien_am4
.dw alien_am5
.dw alien_am6
; Counter of frames since the level started.
level_frames .dw 0
; This is the number of aliens to spawn.
HOUSE_NALIENS .equ 6
house_naliens .db 0
; This points to the alien object that can shoot.
; It can be an already killed alien; in that case we must find the next
; alien to be armed.
armed_alien .dw 0
START_POSS_SZ .equ 6
start_poss
.db HOUSE_LPOS, SHIP_MPOS
.db HOUSE_LPOS, SHIP_RPOS
.db HOUSE_MPOS, SHIP_LPOS
.db HOUSE_MPOS, SHIP_RPOS
.db HOUSE_RPOS, SHIP_LPOS
.db HOUSE_RPOS, SHIP_MPOS
house_start_pos .db 0
ship_start_pos .db 0
; 1 if the ship images are vertically flipped.
ship_flipped .db 0
; Player shots alive.
cannon_shots .db 0
; If the bird has been killed.
bird_killed .db 0
bird_visible .db 0
; Checks if it is time to end the bird's level.
BIRD_LEVEL_TIME .equ 630
bird_level_time .dw BIRD_LEVEL_TIME
; If ship collided mine.
SHIP_STUCK_TIME .equ 32
ship_stuck_time .db SHIP_STUCK_TIME
; -----------------
; 'calc_start_poss'
; -----------------
; Calc random ship and house start positions.
calc_start_poss
; On bird's level, always on center.
ld a,(level)
cp BIRD_LEVEL
jr nz,calc_start_poss_std
ld a,SHIP_MPOS
ld (ship_start_pos),a
ret
calc_start_poss_std
; Rest of levels.
ld de,START_POSS_SZ-1
call randr
ld hl,start_poss
call getwt
ld a,l
ld (house_start_pos),a
ld a,h
ld (ship_start_pos),a
ret
; ------------
; 'init_level'
; ------------
init_level
; If the ship images were flipped, fix them.
call chk_vflip_ship
; Reset Sprite and Object tables.
call init_sprtab
call init_objtab
; Ship is alive.
xor a
ld (ship_killed),a
; Aliens alive (even at bird's level).
ld (aliens_killed),a
; Don't go to next level.
ld (goto_next_level),a
; Reset time to wait if all aliens killed.
ld a,ALIENS_KILLED_WTIME
ld (aliens_killed_wtime),a
; If high score overflowed, set hscoremx.
ld a,(hscorof)
ld hl,hscormx
or (hl)
ld (hl),a
xor a
ld (hscorof),a
; If 10000 points boundary passed, add life.
call chk_add_life
; Reset 10000 points overflow.
xor a
ld (tenthof),a
; Draw lifes for current player.
ld a,(lifes)
call drlifes
; Backup player score.
ld a,(cur_player)
call backscor
; Get starting positions for House and Ship.
call calc_start_poss
; If last level init boss level, if not std level.
ld a,(level)
cp 7
jr z,init_level_0
call init_std_level
ret
init_level_0
call init_bird_level
ret
; ----------------
; 'chk_vflip_ship'
; ----------------
; If the ship images were flipped, fix them.
chk_vflip_ship
ld a,(ship_flipped)
or a
call nz, vflip_ship
ret
; -----------------
; 'init_bird_level'
; -----------------
init_bird_level
; Spawn objects.
call spawn_ship
call spawn_bird
ret
; ----------------
; 'init_std_level'
; ----------------
init_std_level
; Prepare alien images for current level.
ld hl,alien_ims0
ld a,(level)
call getwt
ld (alient0),hl
ld hl,alient0
call preimt
ld hl,alien_ims1
ld a,(level)
call getwt
ld a,h
or l
jr z,init_std_level1
ld (alient1),hl
ld hl,alient1
call preimt
init_std_level1
; Music for this level.
ld a,(level)
add a,SND_LVL1
call play_snd
; Set aliens alive.
ld a,HOUSE_NALIENS
ld (aliens_alive),a
; Init level flags.
call set_level_info
; Spawn main objects.
call spawn_ship
call spawn_house
call spawn_postf
ret
; -------------
; 'init_sprtab'
; -------------
init_sprtab
ld hl,sprtab
ld bc,SPRSZ*NSPRS
xor a
call memset
ret
; -------------
; 'init_objtab'
; -------------
init_objtab
ld hl,objtab
ld bc,OBJSZ*NOBJS
xor a
call memset
ret
; ------------
; 'stop_anims'
; ------------
; Stop all sprite animations.
stop_anims
push iy
ld a,NSPRS
ld iy,sprtab
ld bc,SPRSZ
stop_anims_loop
call stop_anim
add iy,bc
dec a
jr nz,stop_anims_loop
pop iy
ret
; -------------
; 'spawn_ship'
; -------------
; Spawns the player ship.
spawn_ship
; Reset level frames.
ld hl,0
ld (level_frames),hl
; Create Sprite.
ld hl,mstr_ship_sp
ld bc,SPRSZ*SHIP_SP_SLOTS
ld de,ship_sp
ldir
; Set position.
ld a,(ship_start_pos)
ld e,a
ld d,BBUFH-24
xor a
call set_ship_pos
; Create Object.
ld hl,mstr_ship_ob
ld de,ship_ob
ld bc,OBJSZ
ldir
; Clear shots.
xor a
ld (cannon_shots),a
; Can move.
ld (ship_stuck_time),a
; If bird level, no cannon.
; ld a,(level)
; cp BIRD_LEVEL
; ret nz
; call hide_cannon
ret
; --------------
; 'set_ship_pos'
; --------------
; Sets the ship position.
;
; In A 1 looking down, 0 up. D,E y,x position.
; Saves HL, BC, DE.
set_ship_pos
push af
; Set x positions.
ld a,e
ld (lwng_sp+SP_PX),a
add a,8
ld (ship_sp+SP_PX),a
ld (cnon_sp+SP_PX),a
ld (fire_sp+SP_PX),a
add a,8
ld (rwng_sp+SP_PX),a
; Set y positions.
pop af
or a
jr nz,set_ship_pos_down
; The ship is looking up.
ld a,d
ld (cnon_sp+SP_PY),a
add a,8
ld (ship_sp+SP_PY),a
ld (lwng_sp+SP_PY),a
ld (rwng_sp+SP_PY),a
add a,8
ld (fire_sp+SP_PY),a
ret
; The ship is looking down.
set_ship_pos_down
ld a,d
ld (fire_sp+SP_PY),a
add a,8
ld (ship_sp+SP_PY),a
ld (lwng_sp+SP_PY),a
ld (rwng_sp+SP_PY),a
add a,8
ld (cnon_sp+SP_PY),a
ret
; ----------------------
; 'get_level_anim_speed'
; ----------------------
; Returns the animation speed for aliens for each level.
get_level_anim_speed
ld a,(level)
or a
ld a,8
ret z
srl a
ret
; -------------
; 'spawn_house'
; -------------
; Spawns the house of aliens object and sprites in a random x position.
spawn_house
; Arm first alien.
ld hl,alien_ob
ld (armed_alien),hl
; 0 aliens spon.
xor a
ld (house_naliens),a
; Copy master sprites.
ld hl,mstr_house_sp
ld bc,SPRSZ*HOUSE_SP_SLOTS
ld de,house_sp_0
ldir
; Set x position.
ld a,(house_start_pos)
ld (house_sp_0+SP_PX),a
ld (house_sp_1+SP_PX),a
; Create object.
ld hl,mstr_house_ob
ld de,house_ob
ld bc,OBJSZ
ldir
ret
; -------------
; 'spawn_alien'
; -------------
; Spawns an alien at a certain position.
;
; In DE y,x position in pixels. A desired delta x.
spawn_alien
push ix
push iy
; Save position and delta x.
push af
push de
; Find free sprite slot.
ld d,ALIEN_SP_SLOT
ld e,ALIEN_SP_SLOT+ALIEN_SP_SLOTS
call getspr
jr c,spawn_alien_fail1
; Set sprite data.
push hl
pop iy
pop de
ld (iy+SP_PX),e
ld (iy+SP_PY),d
ld hl,alien_ams
ld a,(level)
call getwt
call get_level_anim_speed
ld e,1
call set_anim
; Create the object.
ld d,ALIEN_OB_SLOT
ld e,ALIEN_OB_SLOT+ALIEN_OB_SLOTS
call getob
jr c,spawn_alien_fail2
; Set the object data.
push hl
pop ix
ld (ix+OB_FUL),alienf&255
ld (ix+OB_FUH),alienf>>8
push iy
pop hl
ld (ix+OB_SPL),l
ld (ix+OB_SPH),h
; Restore and set delta x.
pop af
ld (ix+OB_DX),a
ld (ix+OB_DY),2
jr spawn_alien_end
spawn_alien_fail1
pop de
spawn_alien_fail2
pop af
spawn_alien_end
pop iy
pop ix
ret
; -----------------------
; 'housef' House Behavior
; -----------------------
;
; In IX Object Pointer.
housef
; House controls two sprites.
; Swaps their positions.
ld a,(frames)
and 1
ret nz
push ix
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
ld e,(iy+SP_PY)
ld l,(ix+OB_SP2L)
ld h,(ix+OB_SP2H)
push hl
pop ix
ld d,(ix+SP_PY)
ld (ix+SP_PY),e
ld (iy+SP_PY),d
pop ix
ret
; ---------------------------------------------
; 'house_spawn_alien' Spawn alien inside house.
; ---------------------------------------------
house_spawn_alien
; Get alien start x position and start dx.
ld hl,alien_start_poss
ld a,(house_naliens)
call getwt
; House x + alien x start position.
ld a,(house_sp_0+SP_PX)
add a,l
ld e,a
ld d,HOUSE_YPOS
; Start dx in A and spawn.
ld a,h
call spawn_alien
ret
; -----------
; 'house_end'
; -----------
; Destroys the house.
; No more aliens to spawn, disappear.
house_end
push ix
xor a
ld hl,house_sp_0
ld bc,SPRSZ*HOUSE_SP_SLOTS
call memset
ld ix,house_ob
call freeob
pop ix
ret
; --------
; 'alienf'
; --------
alienf ld a,(pace)
alienf1 push af
call movali
pop af
dec a
jr nz,alienf1
; Check collision with mines.
call chk_alien_mines
ret
; -------------
; 'spawn_postf'
; -------------
; Spawn post frame object.
spawn_postf
ld hl,mstr_post_ob
ld de,post_ob
ld bc,OBJSZ
ldir
; Init timers.
call ti_rst
ret
; ------------------
; 'next_armed_alien'
; ------------------
next_armed_alien
ld hl,(armed_alien)
ld bc,OBJSZ
add hl,bc
; Check if we have to go to the first.
ld a,+(alien_ob+(HOUSE_NALIENS*OBJSZ))&255
cp l
jr nz,next_armed_alien_ok
ld a,+(alien_ob+(HOUSE_NALIENS*OBJSZ))>>8
cp h
jr nz,next_armed_alien_ok
; We have to return to the first.
ld hl,alien_ob
next_armed_alien_ok
ld (armed_alien),hl
ret
; ---------------------------
; 'postf' Post Level Behavior
; ---------------------------
; Post Frame calculations.
postf
push ix
; Update timers.
call ti_update
; Ship - Mines.
call chk_ship_mines
; Ship - Aliens collisions.
call chk_ship_aliens
; Ship wings - Aliens collisions.
call chk_lwing_aliens
call chk_rwing_aliens
pop ix
ret
; ----------------
; 'calc_shot_dir'
; ----------------
; Calculates the direction for a shot at a certain position, given
; the position of the player's ship.
;
; In H,L shot pos y,x.
; Out H,L direction (H y direction: +2 or -2; L x direction: -1, 0, 1).
; Saves BC.
calc_shot_dir
push iy
; Get ship position, centered, in DE.
ld iy,ship_sp
ld a,(iy+SP_PX)
add a,4
ld e,a
ld a,(iy+SP_PY)
add a,4
ld d,a
; L is x position for a straight shot.
; Check if the shot must be oblique.
ld a,l
cp e
jr c,calc_shot_dir_chkright
jr nz,calc_shot_dir_chkleft
jr calc_shot_dir_straight
calc_shot_dir_chkright
; abs(shot_yc - ship_yc) .
ld a,h
sub d
jr nc,calc_shot_dir_chkright_1
neg
calc_shot_dir_chkright_1
; Divide as we advance 2 in y and 1 in x.
; abs(shot_yc - ship_yc) / 2 .
; This is distance in x between straight shot and olique shot on the
; ship's y pos.
srl a
; Divide again to find middle point.
srl a
; And add shot x to translate.
add a,l
; Where is ship about middle point?
; If ship is before middle point, shoot straight, else shoot to the right.
cp e
jr nc,calc_shot_dir_straight
; Shoot to the right.
ld l,1
jr calc_shot_dir_up_down
calc_shot_dir_chkleft
; abs(shot_yc - ship_yc) .
ld a,h
sub d
jr nc,calc_shot_dir_chkleft_1
neg
calc_shot_dir_chkleft_1
; Divide as we advance 2 in y and 1 in x.
; abs(shot_yc - ship_yc) / 2 .
; This is distance in x between straight shot and olique shot on the
; ship's y pos.
srl a
; Divide again to find middle point.
srl a
; To the left.
neg
; And add shot x to translate.
add a,l
; Where is ship about middle point?
; If ship is after middle point, shoot straight, else shoot to the left.
cp e
jr c,calc_shot_dir_straight
jr z,calc_shot_dir_straight
; Shoot to the left.
ld l,-1
jr calc_shot_dir_up_down
calc_shot_dir_straight
ld l,0
calc_shot_dir_up_down
; Get shot y center position and compare with ship's y position.
ld a,h
cp d
jr c,calc_shot_dir_down
ld h,-2
jr calc_shot_dir_end
calc_shot_dir_down
ld h,2
calc_shot_dir_end
pop iy
ret
; ------------------
; 'spawn_alien_shot'
; ------------------
;
; In ix alien object.
spawn_alien_shot
push ix
push iy
; Get alien sprite.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
; Get centered position.
ld a,(iy+SP_PX)
add a,ALIEN_IM_W/2
ld l,a
ld a,(iy+SP_PY)
add a,ALIEN_IM_H/2
ld h,a
call calc_shot_dir
; Save dy,dx.
push hl
; Find free sprite slot.
ld d,ALIEN_SHOT_SP_SLOT
ld e,ALIEN_SHOT_SP_SLOT+ALIEN_SHOT_SP_SLOTS
call getspr
jr c,spawn_alien_shot_fail
; Calculate shot starting position.
push hl
ld hl,ashot_startpos_funs
ld a,(level)
call getwt
call jphl
pop hl
; Fill sprite data.
push hl
push de
ex de,hl
ld hl,ashot_mstr_sps
ld a,(level)
call getwt
ld bc,SPRSZ
ldir
pop de
pop iy
ld (iy+SP_PX),e
ld (iy+SP_PY),d
; Get object.
ld d,ALIEN_SHOT_OB_SLOT
ld e,ALIEN_SHOT_OB_SLOT+ALIEN_SHOT_OB_SLOTS
call getob
jr c,spawn_alien_shot_fail
push hl
pop ix
; Set object.
push iy
pop hl
ld (ix+OB_SPL),l
ld (ix+OB_SPH),h
ld (ix+OB_FUL),ashotf&255
ld (ix+OB_FUH),ashotf>>8
; Restore dx,dy.
pop hl
; Continue setting object.
ld (ix+OB_DX),l
ld (ix+OB_DY),h
; Stop tune only of beeper.
ld a,(ay_detected)
or a
jr nz,spawn_alien_shot_ay
ld a,SND_CHAN1
call stop_snd
spawn_alien_shot_ay
; Set sound.
push iy
push ix
pop iy
ld a,SND_SHOT
call play_snd
pop iy
jr spawn_alien_shot_end
spawn_alien_shot_fail
pop hl
spawn_alien_shot_end
pop iy
pop ix
ret
; ------------------------------------------------------------
; 'calc_ashot_startpos' Calculate Alien Shot Starting Position
; ------------------------------------------------------------
; For the 'line' alien shot, calculates its starting position given
; the alien that shoots.
;
; In IY alien sprite.
; Out DE y,x position.
; Saves BC, HL.
calc_ashot_startpos
; Ensure y position pair.
ld a,(iy+SP_PY)
add a,ALIEN_IM_H/2
and $fe
ld d,a
ld a,(iy+SP_PX)
add a,ALIEN_IM_W/2
ld e,a
ret
; ------------------------------------------------------------------------
; 'calc_cross_ashot_startpos' Calculate Alien Cross Shot Starting Position
; ------------------------------------------------------------------------
; For the 'cross' alien shot, calculates its starting position given
; the alien that shoots.
;
; In IY alien sprite.
; Out DE y,x position.
; Saves BC, HL.
calc_cross_ashot_startpos
; Should be character aligned.
ld a,(iy+SP_PY)
add a,ALIEN_IM_H/2
and $f8
ld d,a
ld a,(iy+SP_PX)
add a,ALIEN_IM_W/2
and $f8
ld e,a
ret
; ---------
; 'ashotf'
; ---------
; Alien shot behavior.
ashotf
push ix
; Load sprite into IY.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
ld hl,ashot_move_funs
ld a,(level)
call getwt
call jphl
jr c,ashot_end
ashot_free
; Dont't free sprite if ship killed, so we can see it on top.
ld a,(ship_killed)
or a
call z,freesp
; If we had sound stop.
ld hl,(shot_snd_ob)
push ix
pop de
ld a,h
cp d
jr nz,ashot_freeob
ld a,l
cp e
jr nz,ashot_freeob
ld a,SND_CHAN0
call stop_snd
ashot_freeob
call freeob
ashot_end
pop ix
ret
; Table with 1 if the shot should follow the ship position or 0 if not.
; One entry for each level.
shot_should_follow_table
.db 0, 0, 0, 0, 1, 1, 0
; ----------------------
; 'does_shot_change_dir'
; ----------------------
;
; In None.
; Out ZF=0 if it is a shot that should follow the ship.
; Saves HL, BC, DE.
should_shot_follow
push hl
ld hl,shot_should_follow_table
ld a,(level)
call getbt
or a
pop hl
ret
; ---------------------------------
; 'ashot_move' Moves standard shot.
; ---------------------------------
;
; In IX object. IY sprite.
; Out CY 0 then shot must be freed.
; Saves C.
ashot_move
; Check if must change direction.
call should_shot_follow
jr z,ashot_move_now
; Calc shot center pos and calc direction.
ld a,(iy+SP_PX)
inc a
ld l,a
ld a,(iy+SP_PY)
add a,2
ld h,a
call calc_shot_dir
; Set new direction (only change x direction).
ld (ix+OB_DX),l
ashot_move_now
; Move.
ld b,ALIEN_SHOT_SPEED
ld e,(ix+OB_DX)
ld d,(ix+OB_DY)
ashot_move_loop
call ashot_move_step
ret nc
djnz ashot_move_loop
scf
ret
; --------------------------------------
; 'ashot_move_step' Alien shot move step
; --------------------------------------
; Moves the 'line' alien shot one step.
;
; In IY alien shot sprite. D,E dy,dx.
; Out CY 0 if shot must be destroyed.
; Saves BC, DE, HL.
ashot_move_step
; Check if going down or up.
ld a,d
cp -2
ld a,(iy+SP_PY)
jr z,ashot_move_step_up
; Going down.
cp BBUFH-4
jr z,ashot_move_step_out
jr ashot_move_step_dy
ashot_move_step_up
; Going up.
or a
jr z,ashot_move_step_out
ashot_move_step_dy
; y + dy.
add a,d
ld (iy+SP_PY),a
; Check dx.
ld a,e
or a
jr z,ashot_move_step_in
cp -1
ld a,(iy+SP_PX)
jr z,ashot_move_step_left
; Going right.
cp BBUFW - 2
jr z,ashot_move_step_out
jr ashot_move_step_dx
ashot_move_step_left
; Going left.
or a
jr z,ashot_move_step_out
ashot_move_step_dx
; x + dx.
add a,e
ld (iy+SP_PX),a
ashot_move_step_in
; Check collisions.
push bc
push de
ld de,(4<<8)+2
call chk_shot_ship
pop de
pop bc
ret
ashot_move_step_out
; Shot must be destroyed.
or a
ret
; -----------------
; cross_ashot_move
; -----------------
;
; In IX object. IY sprite.
; Out CY 0 if must be freed.
; Saves ??
cross_ashot_move
; If time to update x pos, don't check to change direction.
ld a,(frames)
and 1
jr z,cross_ashot_move_now
; Check if must change direction.
call should_shot_follow
jr z,cross_ashot_move_now
; Calc shot center pos and calc direction.
ld a,(iy+SP_PX)
add a,4
ld l,a
ld a,(iy+SP_PY)
add a,4
ld h,a
call calc_shot_dir
; Set new direction (only change x direction).
ld (ix+OB_DX),l
cross_ashot_move_now
ld e,(ix+OB_DX)
ld d,(ix+OB_DY)
; Check if going down or up.
ld a,d
cp -2
ld a,(iy+SP_PY)
jr z,cross_ashot_up
; Going down.
cp BBUFH-8
jr z,cross_ashot_out
add a,8
jr cross_ashot_dy
cross_ashot_up
; Going up.
or a
jr z,cross_ashot_out
add a,-8
cross_ashot_dy
ld (iy+SP_PY),a
; Check if time to update x pos.
ld a,(frames)
and 1
jr z,cross_ashot_in
; Check dx.
ld a,e
or a
jr z,cross_ashot_in
cp -1
ld a,(iy+SP_PX)
jr z,cross_ashot_left
; Going right.
cp BBUFW - 8
jr z,cross_ashot_out
add a,8
jr cross_ashot_dx
cross_ashot_left
; Going left.
or a
jr z,cross_ashot_out
add a,-8
cross_ashot_dx
ld (iy+SP_PX),a
cross_ashot_in
; Check collisions.
push bc
push de
ld de,(8<<8)+8
call chk_shot_ship
pop de
pop bc
ret
cross_ashot_out
; shot must be destroyed.
or a
ret
; -------------------
; 'movali' Move Alien
; -------------------
;
; In IX Object pointer.
movali
; Set IY Sprite pointer.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
; The algorithm is something like this:
;
; if (y == 0 && dy < 0) {
; dy = 2;
; goto dychanged;
; } else if (y == BBUFH-8 && dy > 0) {
; dy = -2;
; goto dy_changed;
; } else
; goto dy_not_changed;
;
; dy_changed:
; if (x == 8)
; dx = rand[0, 1];
; else if (x == BBUFW-24)
; dx = rand[-1,0];
; else
; dx = rand[-1,0,1];
; goto sum;
;
; dy_not_changed:
; if (x == 8 && dx == -1)
; dx = 1;
; else if (x == BBUFW-24 && dx == 1)
; dx = -1;
;
; sum:
; x += dx;
; y += dy;
; Load position and movement delta and start checking conditions.
ld d,(iy+SP_PX)
ld e,(iy+SP_PY)
ld h,(ix+OB_DX)
ld l,(ix+OB_DY)
call movali1
jr z,movali3
call movali2
jr z,movali3
call movali4
jr z,movali5
call movali6
jr movali5
movali3 call movali7
jr z,movali5
call movali8
jr z,movali5
call movali9
; Add delta to position (x += dx, y += dy).
movali5 ld a,d
add a,h
ld (ix+OB_DX),h
ld (iy+SP_PX),a
ld a,e
add a,l
ld (ix+OB_DY),l
ld (iy+SP_PY),a
ret
; If y is 0 and dy is negaive -> dy is 2.
movali1 ld a,e
or a
ld c,a
ld a,l
xor -2
or c
ret nz
ld l,2
ret
; If y is BBUFH-8 and dy is positive -> dy is -2.
movali2 ld a,e
xor BBUFH-8
ld c,a
ld a,l
xor 2
or c
ret nz
ld l,-2
ret
; If x is 8 and dx is -1 -> dx is 1.
movali4 ld a,d
xor 8
ld c,a
ld a,h
xor 255
or c
ret nz
ld h,1
ret
; If x is BBUFW-24 and dx is 1 -> dx is -1.
movali6 ld a,d
xor BBUFW-24
ld c,a
ld a,h
xor 1
or c
ret nz
ld h,255
ret
; If x is 8 -> dx is rand[0,1].
movali7 ld a,d
cp 8
ret nz
call rand
and 1
ld h,a
xor a
ret
; If x is BBUFW-24 -> dx is rand[-1,0].
movali8 ld a,d
xor BBUFW-24
ret nz
call rand
and 1
jr nz,moval81
ld h,a
ret
moval81 ld h,255
xor a
ret
; Set dx rand[-1,0,1].
movali9 call rand
cp 85
jr nc,moval91
ld h,255
xor a
ret
moval91 cp 85*2
jr nc,moval92
xor a
ld h,a
ret
moval92 ld h,1
xor a
ret
; --------------
; 'doubled_pace'
; --------------
; Aliens will move faster.
doubled_pace
; Double pace of the aliens animations.
push ix
push iy
ld e,ALIEN_OB_SLOTS
ld ix,alien_ob
ld bc,OBJSZ
update_peace_loop
ld a,(ix+OB_FUL)
or (ix+OB_FUH)
jr z,update_peace_next
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
srl (iy+SP_SPE)
srl (iy+SP_SPC)
update_peace_next
add ix,bc
dec e
jr nz,update_peace_loop
pop iy
pop ix
ret
; -------
; 'shipf'
; -------
; Player's ship behavior.
;
; In IX ship object.
shipf
; Inc level frames.
ld hl,(level_frames)
inc hl
ld (level_frames),hl
; Check if stuck.
ld hl,ship_stuck_time
xor a
cp (hl)
jr z,shipf_can_move
dec (hl)
jp nz,shipf_no_move
shipf_can_move
; Take current x pos.
ld a,(lwng_sp+SP_PX)
ld e,a
; Take y pos, depending on looking down or up.
ld a,(ship_flipped)
or a
jr nz,shipf_is_down
ld a,(cnon_sp+SP_PY)
jr shipf_k
shipf_is_down
ld a,(fire_sp+SP_PY)
; Check keys.
shipf_k ld d,a
; Save or flip state and current position to see at the end if we moved.
ld a,(ship_flipped)
push af
push de
; Check keys pressed.
ld hl,rinput
ld a,K_LEFT
and (hl)
jr nz,shipfl
ld a,K_RIGHT
and (hl)
jr nz,shipfr
shipf1
; Only left - right movement on last level.
ld a,(level)
cp BIRD_LEVEL
jr z,shipfp
; Check up - down.
ld hl,rinput
ld a,K_UP
and (hl)
jr nz,shipfu
ld a,K_DOWN
and (hl)
jr nz,shipfd
jr shipfp
; Wants to go left.
shipfl ld a,e
or a
jr z,shipf1
sub 8
ld e,a
jr shipf1
; Wants to go right.
shipfr ld a,e
cp BBUFW-24
jr z,shipf1
add a,8
ld e,a
jr shipf1
; Wants to go up.
shipfu
; Check if we are looking up.
ld a,(ship_flipped)
or a
jr z,shipfu_already_up
; We are looking down. Check if we are on top.
ld a,d
or a
jr z,shipfp
; We were looking down and we aren't on top. Only flip.
shipf_flip
push de
call vflip_ship
pop de
jr shipfp
; We were looking upwards already.
shipfu_already_up
ld a,d
sub 8
ld d,a
; If we reached top, flip.
or a
jr nz,shipfp
jr shipf_flip
; Wants to go down.
shipfd
; Check if we are looking down.
ld a,(ship_flipped)
or a
jr nz,shipfu_already_down
; We are looking up. Check if we are on bottom.
ld a,d
cp BBUFH-24
jr z,shipfp
; We were looking up and we aren't on bottom. Only flip.
jr shipf_flip
; We were looking downwards already.
shipfu_already_down
; Move.
ld a,d
add a,8
ld d,a
; If we reached bottom, flip.
cp BBUFH-24
jr nz,shipfp
jr shipf_flip
; Set final position.
shipfp
; Restore previous position and flipped state.
pop bc
pop af
; Now we have in BC the previous pos, and in DE the new one, and in A the
; previous flip state.
ld hl,ship_flipped
cp (hl)
jr nz,shipf_moved
ld a,d
cp b
jr nz,shipf_moved
ld a,e
cp c
jr z,shipf_no_move
shipf_moved
; We have moved, set position.
ld a,(ship_flipped)
call set_ship_pos
; Engage engines.
ld hl,fire_am
ld (fire_sp+SP_ANL),hl
jr shipf_chk_cannon
; We haven't moved, shut engines.
shipf_no_move
ld hl,0
ld (fire_sp+SP_ANL),hl
ld (fire_sp+SP_ITL),hl
; Now, check if we need to fire.
shipf_chk_cannon
; Cannon isn't ready. Check if we can spawn new shot.
ld a,(cannon_shots)
cp SHIP_SHOT_OB_SLOTS
jr z,ship_cant_shoot
; Cannon is ready again. Show it.
call show_cannon
; Cannon is ready.
shipf_cannon_ready
; Check fire key.
ld a,(finput)
and K_FIRE
ret z
; Spawn shot.
ld a,(cnon_sp+SP_PX)
add a,3
ld e,a
; If flipped (1) spawn at same y of cannon, else spawn at y+4.
ld a,(ship_flipped)
xor 1
rlca
rlca
ld hl,cnon_sp+SP_PY
add a,(hl)
ld d,a
ld a,(ship_flipped)
push ix
call spawn_ship_shot
pop ix
; Cannon must wait to be ready again.
call hide_cannon
ret
ship_cant_shoot
ret
; -------------
; 'show_cannon'
; -------------
; Shows the ship's cannon.
;
; Saves BC, DE.
show_cannon
; ld a,(level)
; cp BIRD_LEVEL
; ret z
ld hl,cnon_it
ld (cnon_sp+SP_ITL),hl
ret
; -------------
; 'hide_cannon'
; -------------
; Hides the ship's cannon.
;
; Saves AF, BC, DE.
hide_cannon
ld hl,0
ld (cnon_sp+SP_ITL),hl
ret
; ---------------------------------
; 'vflip_ship' Vertically flip ship
; ---------------------------------
; Flips ship Flip flag and vertically flips ship images.
vflip_ship
ld a,(ship_flipped)
xor 1
ld (ship_flipped),a
ld hl,ship_im
call flipv
ld hl,cnon_im
call flipv
ld hl,lwng_im
call flipv
ld hl,rwng_im
call flipv
ld hl,fire_im0
call flipv
#ifdef CPC
ld hl,fire_im1
call flipv
#endif
ret
; -----------------
; 'spawn_ship_shot'
; -----------------
;
; In D,E y,x position. A 0 go up, 1 go down.
spawn_ship_shot
push ix
push iy
; Save direction.
push af
; Find free sprite slot.
push de
ld d,SHIP_SHOT_SP_SLOT
ld e,SHIP_SHOT_SP_SLOT+SHIP_SHOT_SP_SLOTS
call getspr
pop de
jr c,spawn_ship_shot_fail
; Fill sprite data.
push hl
pop iy
ld (iy+SP_ITL),sshot_it&255
ld (iy+SP_ITH),sshot_it>>8
ld (iy+SP_PX),e
ld (iy+SP_PY),d
#ifdef ZX
ld (iy+SP_COL),YELLOW
ld (iy+SP_COH),0
#endif
; ld a,(level)
;cp BIRD_LEVEL
;jr nz,spawn_ship_shot_no_bird
;ld (iy+SP_ITL),0
;ld (iy+SP_ITH),0
spawn_ship_shot_no_bird
; Find free object slot.
ld d,SHIP_SHOT_OB_SLOT
ld e,SHIP_SHOT_OB_SLOT+SHIP_SHOT_OB_SLOTS
call getob
jr c,spawn_ship_shot_fail
; Fill object data.
push hl
pop ix
push iy
pop hl
ld (ix+OB_FUL),shotf&255
ld (ix+OB_FUH),shotf>>8
ld (ix+OB_SPL),l
ld (ix+OB_SPH),h
ld (ix+OB_DX),0
; Restore direction, set in object.
pop af
or a
jr nz,spawn_ship_shot_down
ld (ix+OB_DY),-4
jr spawn_ship_shot_ok
spawn_ship_shot_down
ld (ix+OB_DY),4
jr spawn_ship_shot_ok
spawn_ship_shot_ok
; Increment number of shots alive.
ld hl,cannon_shots
inc (hl)
jr spawn_ship_shot_end
spawn_ship_shot_fail
pop af
spawn_ship_shot_end
pop iy
pop ix
ret
; -------
; 'shotf'
; -------
;
; In IX Object pointer.
shotf
; Get sprite.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
; Go up or down in a loop, checking collisions.
ld b,SHIP_SHOT_SPEED
ld c,(ix+OB_DY)
shotf_move
push bc
call chk_shot_aliens
jr nz,shotf_bfree
call chk_shot_shield
jr nc,shotf_bfree
call chk_shot_mines
jr c,shotf_bfree
pop bc
jr shotf_no_collision
shotf_bfree
pop bc
jr shotf_free
shotf_no_collision
ld a,(iy+SP_PY)
; If we reached 0, the next move will put us out of the screen, so disappear.
or a
jr z,shotf_free
; If reached the bottom, disappear.
cp BBUFH-4
jr z,shotf_free
; If safe, move.
add a,c
ld (iy+SP_PY),a
djnz shotf_move
ret
shotf_free
; We must disappear.
; Decrement number of ship shots.
ld hl,cannon_shots
dec (hl)
; Free sprite and object.
call freesp
call freeob
ret
; -----------------
; 'chk_shot_aliens'
; -----------------
; Checks all aliens that collide with this shot and explodes them.
;
; In IY shot sprite.
; Out ZF if no collision.
chk_shot_aliens
; Don't check on bird's level.
ld a,(level)
cp 7
ret z
; Iterate aliens.
push ix
ld e,ALIEN_OB_SLOTS
ld ix,alien_ob
ld bc,OBJSZ
; D 1 collision, 0 none.
ld d,0
chk_shot_aliens_loop
; Check if alien exists.
ld a,(ix+OB_FUL)
or (ix+OB_FUH)
jr z,chk_shot_aliens_next
; If it is inside the house, can't be killed.
call chk_alien_in_house
jr c,chk_shot_aliens_next
; Check for collision.
call chk_shot_alien
jr c,chk_shot_aliens_next
; If collision, explode, add score and set D.
push bc
push de
call explode_alien
pop de
pop bc
ld d,1
chk_shot_aliens_next
; Go to next alien object.
add ix,bc
dec e
jr nz,chk_shot_aliens_loop
; End.
pop ix
; Set ZF if any collision.
ld a,d
or a
ret
; --------------------
; 'chk_alien_in_house'
; --------------------
; Checks if an alien is inside the box of the house.
;
; In IX alien object.
; Out CF 1 then is inside.
; Saves BC, DE.
chk_alien_in_house
push iy
; Load sprite into IY.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
; Are there aliens?
ld a,(house_naliens)
cp HOUSE_NALIENS
jr z,chk_alien_in_house_false
; Check if inside.
ld a,(iy+SP_PY)
cp 16-ALIEN_IM_H-1
jr nc,chk_alien_in_house_false
scf
jr chk_alien_in_house_ret
chk_alien_in_house_false
or a
chk_alien_in_house_ret
pop iy
ret
; ----------------
; 'chk_shot_alien'
; ----------------
; Checks if there is collision between a shot and an alien.
;
; In IY shot sprite. IX alien object.
; Out CY 1 no collision, 0 collision.
; Saves BC, DE.
chk_shot_alien
push ix
push de
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop ix
ld de,(4<<8)+2
ld hl,(ALIEN_IM_H<<8)+ALIEN_IM_W
call chk_spr_spr
pop de
pop ix
ret
; ----------------------------------------------
; 'chk_spr_spr' Check sprite vs sprite collision
; ----------------------------------------------
; Checks collisions between two sprites.
;
; In IY spr A. IX spr B. D, E height, width A in pixels.
; H,L height,width B in pixels.
; Out CY 1 no collision, 0 collision.
; Saves BC, DE, HL.
chk_spr_spr
push de
push hl
; Width and height minus one.
dec d
dec e
dec h
dec l
; If ax + aw - 1 < bx ret.
ld a,(iy+SP_PX)
add a,e
cp (ix+SP_PX)
jr c,chk_spr_spr_ret
; If bx + bw - 1 < ax
ld a,(ix+SP_PX)
add a,l
cp (iy+SP_PX)
jr c,chk_spr_spr_ret
; If by + bh - 1 < ay ret
ld a,(ix+SP_PY)
add a,h
cp (iy+SP_PY)
jr c,chk_spr_spr_ret
; If ay + ah - 1 < by ret
ld a,(iy+SP_PY)
add a,d
cp (ix+SP_PY)
jr c,chk_spr_spr_ret
; Collision, CY = 0.
or a
chk_spr_spr_ret
pop hl
pop de
ret
; ---------------
; 'explode_alien'
; ---------------
;
; In IX alien object.
explode_alien
push iy
; Add score for killing this one.
ld a,(level)
ld c,a
ld a,(cur_player)
call addscor
; If 10000 points boundary crossed, set tenth overflow.
call chk_tenthof
; Decrement aliens alive and check if all killed.
ld hl,aliens_alive
dec (hl)
jr nz,explode_alien_score
inc a
ld (aliens_killed),a
explode_alien_score
; Draw new score hud.
ld a,(cur_player)
call drscor
; Kill alien but save position in DE.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
ld e,(iy+SP_PX)
ld d,(iy+SP_PY)
call freesp
call freeob
; Spawn explosion.
call spawn_explosion
pop iy
ret
; -----------------
; 'spawn_explosion'
; -----------------
;
; In D,E y,x position.
spawn_explosion
; Fix position: x in char boundaries, try to center y.
ld a,e
and $f8
ld e,a
ld a,d
sub EXPLOSION_OFFS
jr nc,spawn_explosion_coordf1
xor a
spawn_explosion_coordf1
ld d,a
ld a,BBUFH-EXPLOSION_IM_H
cp d
jr nc,spawn_explosion_setpos
ld d,a
spawn_explosion_setpos
; Set position in sprite master to copy later.
ld a,e
ld (mstr_explosion_sp+SP_PX),a
ld a,d
ld (mstr_explosion_sp+SP_PY),a
; Create sprite.
ld d,EXPLOSION_SP_SLOT
ld e,EXPLOSION_SP_SLOT+EXPLOSION_SP_SLOTS
; For the birds level, we spawn an explosion sprite after the bird's ones,
; so it is painted above.
ld a,(level)
cp BIRD_LEVEL
jr nz,spawn_explosion_no_bird
ld d,BIRD_EXPLOSION_SP_SLOT
ld e,BIRD_EXPLOSION_SP_SLOT+1
spawn_explosion_no_bird
call getspr
jr c,spawn_explosion_fail
ld a,l
ld (mstr_explosion_ob+OB_SPL),a
ld a,h
ld (mstr_explosion_ob+OB_SPH),a
ex de,hl
ld hl,mstr_explosion_sp
ld bc,SPRSZ
ldir
; Create object.
ld d,EXPLOSION_OB_SLOT
ld e,EXPLOSION_OB_SLOT+EXPLOSION_OB_SLOTS
call getob
jr c,spawn_explosion_fail
ex de,hl
ld hl,mstr_explosion_ob
ld bc,OBJSZ
ldir
spawn_explosion_fail
ret
; ---------------------------
; 'explof' Explosion Function
; ---------------------------
explof
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
call is_anim_playing
ret nz
explof_end
call freesp
call freeob
ret
; -------------------------------------------------
; 'stop_multisp_anims' Stop multisprite animations.
; -------------------------------------------------
; Stops all the animations for some contiguous sprites.
;
; In IY address of first sprite. L nsprites.
; Saves IY, H, DE.
stop_multisp_anims
push iy
ld bc,SPRSZ
stop_multisp_anims_loop
ld a,(iy+SP_ANL)
or (iy+SP_ANH)
call nz,stop_anim
add iy,bc
dec l
jr nz,stop_multisp_anims_loop
pop iy
ret
; -------------------------------
; 'move_multisp' Move multisprite
; -------------------------------
; Positions some contiguous sprites by applying some offset.
;
; In D,E delta y,x. IY address of first sprite. L nsprites.
; Saves IY, H, DE.
move_multisp
push iy
ld bc,SPRSZ
move_multisp_loop
ld a,(iy+SP_PX)
add a,e
ld (iy+SP_PX),a
ld a,(iy+SP_PY)
add a,d
ld (iy+SP_PY),a
add iy,bc
dec l
jr nz,move_multisp_loop
pop iy
ret
; ------------------------------------------
; 'set_multisp_pos' Set multisprite position
; ------------------------------------------
; Positions some contiguous sprites making a frame.
;
; In D,E y,x position. L nsprites. IY address of first sprite.
; Saves H, IY.
set_multisp_pos
; Calc deltas.
ld a,e
sub (iy+SP_PX)
ld e,a
ld a,d
sub (iy+SP_PY)
ld d,a
call move_multisp
ret
; -----------------
; 'chk_shot_shield'
; -----------------
chk_shot_shield
push ix
; If not on bird's level, no collision.
ld a,(level)
cp BIRD_LEVEL
jr nz,chk_shot_shield_dont
; If already killed, do nothing.
ld a,(bird_killed)
or a
jr nz,chk_shot_shield_dont
; If not on screen yet, do nothing.
ld a,(bird_visible)
or a
jr z,chk_shot_shield_dont
; Check collision with left shield.
ld ix,bird_lshield_sp
ld a,(bird_lshield_h)
call shot_shield_chk
jr nc,shot_shield_collision
; Check collision with right shield.
ld ix,bird_rshield_sp
ld a,(bird_rshield_h)
call shot_shield_chk
jr c,chk_shot_shield_end
jr shot_shield_collision
shot_shield_chk
; Check collision.
ld de,+(4<<8)+2
ld h,a
ld l,8
call chk_spr_spr
ret
shot_shield_collision
; Go to the image.
ld l,(ix+SP_ITL)
ld h,(ix+SP_ITH)
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
; Take height.
inc hl
ld e,(hl)
; Go to first byte on.
ld d,0
add hl,de
#ifdef CPC
; For the CPC, double as we have 2 bytes per line.
add hl,de
dec hl
#endif
; Check if full or partial or empty.
ld a,(hl)
cp SHIELD_FULL
jr z,shot_shield_full
cp SHIELD_PARTIAL
jr z,shot_shield_partial
; It's empty. This can only happen on last line. We hit the bird.
call kill_bird
or a
jr chk_shot_shield_end
shot_shield_partial
; Partial, so set empty.
ld a,SHIELD_EMPTY
ld (hl),a
#ifdef CPC
inc hl
ld (hl),a
#endif
; Set carry off.
or a
; Reduce height.
sbc hl,de
#ifdef CPC
sbc hl,de
#endif
dec (hl)
jr z,shot_shield_zero
or a
jr chk_shot_shield_end
shot_shield_zero
; Don't let the height be 0.
inc (hl)
or a
jr chk_shot_shield_end
shot_shield_full
; Full, so set partial hit.
ld a,SHIELD_PARTIAL
ld (hl),a
#ifdef CPC
inc hl
ld (hl),a
#endif
or a
jr chk_shot_shield_end
chk_shot_shield_dont
scf
chk_shot_shield_end
pop ix
ret
; -----------------
; 'chk_ship_aliens'
; -----------------
chk_ship_aliens
push ix
push iy
ld iy,ship_sp
ld e,ALIEN_OB_SLOTS
ld ix,alien_ob
ld bc,OBJSZ
chk_ship_aliens_loop
ld a,(ix+OB_FUL)
or (ix+OB_FUH)
jr z,chk_ship_aliens_next
ld h,(ix+OB_SPH)
ld l,(ix+OB_SPL)
push ix
push hl
pop ix
push bc
push de
ld de,(8<<8)+8
ld hl,(ALIEN_IM_H<<8)+ALIEN_IM_W
call chk_spr_spr
call nc,kill_ship
pop de
pop bc
pop ix
chk_ship_aliens_next
add ix,bc
dec e
jr nz,chk_ship_aliens_loop
pop iy
pop ix
ret
; --------------
; 'destroy_wing'
; --------------
;
; In IY wing sprite.
; Saves BC, DE, HL.
destroy_wing
xor a
ld (iy+SP_ITL),a
ld (iy+SP_ITH),a
ret
; ------------------
; 'chk_lwing_aliens'
; ------------------
chk_lwing_aliens
push iy
ld iy,lwng_sp
ld a,(iy+SP_ITL)
or (iy+SP_ITH)
jr z,chk_lwing_aliens_end
call chk_wing_aliens
call c,destroy_wing
chk_lwing_aliens_end
pop iy
ret
; ------------------
; 'chk_rwing_aliens'
; ------------------
chk_rwing_aliens
push iy
ld iy,rwng_sp
ld a,(iy+SP_ITL)
or (iy+SP_ITH)
jr z,chk_rwing_aliens_end
call chk_wing_aliens
call c,destroy_wing
chk_rwing_aliens_end
pop iy
ret
; -----------------
; 'chk_wing_aliens'
; -----------------
chk_wing_aliens
push ix
ld e,ALIEN_OB_SLOTS
ld ix,alien_ob
ld bc,OBJSZ
chk_wing_aliens_loop
ld a,(ix+OB_FUL)
or (ix+OB_FUH)
jr z,chk_wing_aliens_next
ld h,(ix+OB_SPH)
ld l,(ix+OB_SPL)
push ix
push hl
pop ix
push bc
push de
ld de,(8<<8)+8
ld hl,(ALIEN_IM_H<<8)+ALIEN_IM_W
call chk_spr_spr
pop de
pop bc
pop ix
jr nc,chk_wing_aliens_collided
chk_wing_aliens_next
add ix,bc
dec e
jr nz,chk_wing_aliens_loop
or a
chk_wing_aliens_end
pop ix
ret
chk_wing_aliens_collided
call explode_alien
scf
jr chk_wing_aliens_end
; -----------
; 'kill_ship'
; -----------
;
; Saves BC, DE, HL.
kill_ship
ld a,1
ld (ship_killed),a
ret
; ---------------
; 'chk_shot_ship'
; ---------------
; Checks shot collision with ship body and wings.
;
; In IY shot spr. D,E height,width in pixels.
; Out CY 0 collision.
; Saves HL.
chk_shot_ship
push ix
push hl
ld hl,(8<<8)+8
ld ix,ship_sp
call chk_spr_spr
jr nc,chk_shot_ship_body
; Is there the left wing?
ld ix,lwng_sp
ld a,(ix+SP_ITL)
or (ix+SP_ITH)
jr z,chk_shot_ship_rwing_exists
; Yes, check.
call chk_spr_spr
jr nc,chk_shot_ship_wing
chk_shot_ship_rwing_exists
ld ix,rwng_sp
; Is there the right wing?
ld a,(ix+SP_ITL)
or (ix+SP_ITH)
jr nz,chk_shot_ship_rwing
scf
jr chk_shot_ship_end
chk_shot_ship_rwing
; Yes, check.
call chk_spr_spr
jr nc,chk_shot_ship_wing
jr chk_shot_ship_end
chk_shot_ship_body
ld a,(cheats_god)
or a
call z,kill_ship
jr chk_shot_ship_collision
chk_shot_ship_wing
push iy
push ix
pop iy
call destroy_wing
pop iy
chk_shot_ship_collision
or a
chk_shot_ship_end
pop hl
pop ix
ret
; Bird.
BEND .equ 0
BMOVE .equ 1
BWAIT .equ 2
BSTART .equ 3
BIRD_NMOVES .equ 5
bird_moves
.dw move1
.dw move2
.dw move3
.dw move4
.dw move5
; Special move not in table. With this one we start.
move0 .db BWAIT, 32, 0
.db BEND
move1 .db BMOVE, 0, 24, 0, 24, 0, 24, 0, 16, 0, 0
.db BWAIT, 8, 0
.db BMOVE, 8, 8, 8, 8, 8, -8, 8, -8
.db 0, -16, 0, -24, 0, -24, 0, -24, 0, 0
.db BWAIT, 64, 0
.db BEND
move2 .db BMOVE, 24, 0, 24, 0, 24, 0, 24, 0, 0, 0
.db BWAIT, 64, 0
.db BEND
move3 .db BMOVE, 16, 24, 16, 24, 16, 24, -16, 24, -16, -24, 0, 0
.db BWAIT, 16, 0
.db BMOVE, -16, -24, 0, -24, 0, -24, 0, 0
.db BEND
move4 .db BMOVE, 0, 24, 0, 24, 0, 24, 0, 24, 0, 0
.db BWAIT, 8, 0
.db BMOVE, 8, 8, 24, -8, 24, -24, 24, -24, 0, -24, 0, -24, 0, 0
.db BWAIT, 64, 0
.db BEND
move5 .db BMOVE, 0, 24, 0, 16, 0, 16, 0, 16, 0, 8, 0, 8, 0, 8, 0, 8, 0, 0
.db BWAIT, 4, 0
.db BMOVE, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0
.db 0, -8, 0, -8, 0, -16, 0, -16, 0, -16, 0, -16, 0, -24
.db 0, 0
.db BWAIT, 48
.db BEND
; Time to wait.
bird_wtime .dw 0
bird_instr .db 0
bird_pc .dw 0
bird_reverse .db 0
bird_last_move .db 255
; When the bird spawns, we show a color effect.
bird_spawn_colors .db BBUF_RED
.db BBUF_BLACK
BIRD_SPAWN_TIME .equ 32
; ------------
; 'spawn_bird'
; ------------
spawn_bird
; Bird is alive (but not shown still).
xor a
ld (bird_killed),a
ld (bird_visible),a
push ix
ld ix,bird_ob
ld (ix+OB_FUL),bird_prespawn_1&255
ld (ix+OB_FUH),bird_prespawn_1>>8
pop ix
ret
; -----------------
; 'bird_prespawn_1'
; -----------------
; Wait some time to show red color effect.
bird_prespawn_1
ld a,(level_frames)
cp BIRD_SPAWN_TIME
ret nz
ld (ix+OB_FUL),bird_prespawn_2&255
ld (ix+OB_FUH),bird_prespawn_2>>8
ld (ix+OB_CNT0),0
ld (ix+OB_CNT1),4
ld (ix+OB_CNT3),13
ret
; -----------------
; 'bird_prespawn_2'
; -----------------
bird_prespawn_2
dec (ix+OB_CNT1)
ret nz
ld (ix+OB_CNT1),4
ld a,(ix+OB_CNT0)
inc a
and 1
ld (ix+OB_CNT0),a
ld hl,bird_spawn_colors
call getbt
call set_bbuf_paper
ld hl,+BEEP_FREQX256(131*256)
ld de,+BEEP_MS(131*256, 31)
call beep
dec (ix+OB_CNT3)
ret nz
; Load sprite and reset shield.
call reset_bird_shield
call load_bird_spr
; Select random x position.
ld d,0
ld e,BBUFWC-BIRD_WC
call randr
rlca
rlca
rlca
ld e,a
ld d,0
call set_bird_pos
; Load object.
ld hl,mstr_bird_ob
ld de,bird_ob
ld bc,OBJSZ
ldir
; Now the bird is on screen.
ld a,1
ld (bird_visible),a
; Init bird's machine.
ld a,BSTART
ld (bird_instr),a
; Set timeout time.
ld hl,BIRD_LEVEL_TIME
ld (bird_level_time),hl
ret
; ---------------
; 'load_bird_spr'
; ---------------
; Loads all the bird's sprites into the sprites table.
load_bird_spr
ld hl,mstr_bird_sp
ld bc,SPRSZ*BIRD_SP_SLOTS
ld de,bird_sp
ldir
ret
; -------------------
; 'reset_bird_shield'
; -------------------
; Refills the bird's bottom shield.
reset_bird_shield
ld hl,bird_lshield_im
call reset_shield_part
ld hl,bird_rshield_im
call reset_shield_part
ret
; -------------------
; 'reset_shield_part'
; -------------------
; Refills the bird's bottom shield (left or right part).
;
; In HL bird_lshield_im or bird_rshield_im
reset_shield_part
; Width.
ld b,(hl)
inc hl
; Height.
ld c,16
ld (hl),c
inc hl
; Load all bits on.
ld a,SHIELD_FULL
reset_shield2
push bc
reset_shield1
ld (hl),a
inc hl
djnz reset_shield1
pop bc
dec c
jr nz,reset_shield2
ret
; --------------------------------
; 'set_bird_pos' Set bird position
; --------------------------------
; Position the bird.
;
; In DE y,x position in pixels.
set_bird_pos
push iy
ld iy,bird_sp
ld l,BIRD_NSPS
call set_multisp_pos
pop iy
ret
; -----------
; 'kill_bird'
; -----------
kill_bird
; Set it killed.
ld a,1
ld (bird_killed),a
ld (bird_killed_cur_game),a
ld (bird_killed_once),a
; Add score.
ld a,(level)
ld c,a
ld a,(cur_player)
call addscor
; If 10000 points boundary crossed, add life.
call chk_tenthof
; Draw the score.
ld a,(cur_player)
call drscor
; Spawn explosion.
ld a,(bird_lshield_sp+SP_PX)
ld e,a
ld a,(bird_lshield_sp+SP_PY)
add a,-16
ld d,a
call spawn_explosion
bird_level_finish
; (This is called too from birdf directly, when timeout).
; Stop bird animations.
push iy
ld iy,bird_sp
ld l,BIRD_NSPS
call stop_multisp_anims
pop iy
; And bird must die.
push ix
ld ix,bird_ob
ld (ix+OB_FUL),bird_die_f&255
ld (ix+OB_FUH),bird_die_f>>8
ld (ix+OB_CNT0),0
ld (ix+OB_CNT1),19
pop ix
; And player too. Don't let him move.
push ix
ld ix,ship_ob
call freeob
pop ix
ld a,SND_CHAN1
call stop_snd
ld a,SND_DIE
call play_snd
ret
; -----------
; 'bird_die_f
; -----------
; Cicle colors again.
bird_die_f
ld a,(ix+OB_CNT0)
inc a
and 1
ld (ix+OB_CNT0),a
ld hl,kill_colors
call getbt
call set_bbuf_paper
dec (ix+OB_CNT1)
ret nz
call freeob
ld a,BBUF_BLACK
call set_bbuf_paper
ld a,1
ld (goto_next_level),a
ret
; -------
; 'birdf'
; -------
birdf
push iy
; Check collision with ship.
push ix
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop ix
ld iy,ship_sp
ld de,+(8<<8)+8
ld hl,+((BIRD_HC*8)<<8)+(BIRD_WC*8)
call chk_spr_spr
pop ix
jr c,birdf_chk_time
; Collision.
call kill_ship
jr birdf_end
birdf_chk_time
; Check if too much time has passed...
ld hl,(bird_level_time)
dec hl
ld (bird_level_time),hl
ld a,h
or l
jr nz,birdf_run
; Timeout, end level.
call bird_level_finish
jr birdf_end
birdf_run
; Behave.
ld iy,bird_sp
call bird_exec
birdf_end
pop iy
ret
bird_pre_select
xor a
ld (bird_reverse),a
ld a,$ff
ld (bird_last_move),a
ld hl,move0
jr bird_next
bird_exec
ld hl,(bird_pc)
ld a,(bird_instr)
cp BSTART
jr z,bird_pre_select
cp BMOVE
jr z,bird_move
cp BWAIT
jr z,bird_wait
bird_select
ld d,0
ld e,BIRD_NMOVES-1
call randr
; Don't let choose the same last move.
ld hl,bird_last_move
cp (hl)
jr z,bird_select
; Set last move.
ld (hl),a
; Select move.
ld hl,bird_moves
call getwt
bird_next
ld a,(hl)
ld (bird_instr),a
inc hl
ld (bird_pc),hl
cp BWAIT
jr z,bird_prewait
ld a,SND_BIRD
call play_snd
jr bird_exec
bird_prewait
; Prepare BWAIT intruction.
ld a,SND_BIRD2
call play_snd
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (bird_pc),hl
ex de,hl
ld (bird_wtime),hl
jr bird_exec
bird_move
ld e,(hl)
inc hl
ld d,(hl)
inc hl
ld (bird_pc),hl
ld a,e
or d
jr z,bird_next
; We have to reverse sign?
ld a,(bird_reverse)
or a
jr z,bird_move_chk
; Reverse X sign.
ld a,e
neg
ld e,a
bird_move_chk
; Check if going left or right.
bit 7,e
jr z,bird_move_chk_right
; Going left.
ld a,e
neg
sub (iy+SP_PX)
jr z,bird_move_do
jr c,bird_move_do
; We will reverse. New offset already in A.
ld e,a
bird_move_reverse
; Reverse.
ld a,(bird_reverse)
xor 1
ld (bird_reverse),a
jr bird_move_do
bird_move_chk_right
; Going right.
ld a,BBUFW-(BIRD_WC*8)
sub (iy+SP_PX)
sub e
jr nc,bird_move_do
; We will reverse. New offset in A.
ld e,a
jr bird_move_reverse
bird_move_do
ld l,BIRD_NSPS
call move_multisp
ret
bird_wait
ld hl,bird_wtime
dec (hl)
ret nz
ld hl,(bird_pc)
jr bird_next
; ---------
; 'addmine'
; ---------
; Adds a mine if there is a free slot.
;
; In DE y,x position in pixels.
addmine
; Change position in master sprite.
ld a,e
ld (mstr_mine_sp+SP_PX),a
ld a,d
ld (mstr_mine_sp+SP_PY),a
; Try to get a free slot.
ld d,MINE_SP_SLOT
ld e,MINE_SP_SLOT+MINE_SP_SLOTS
call getspr
ret c
; Load sprite.
ex de,hl
ld hl,mstr_mine_sp
ld bc,SPRSZ
ldir
ret
; -----------------
; 'chk_alien_mines'
; -----------------
; Checks collisions between aliens and mines. If an alien overlaps
; a mine, the mine disappears. Only checks if we are in the correct level.
;
; In IX alien object.
chk_alien_mines
; Check if correct level.
ld a,(level)
cp BIRD_LEVEL-1
ret nz
; Get sprite.
ld l,(ix+OB_SPL)
ld h,(ix+OB_SPH)
push hl
pop iy
; Run through all mines.
ld ix,mine_sp
ld b,MINE_SP_SLOTS
ld de,+(6<<8)+16
ld hl,+(8<<8)+8
chk_alien_mines_loop
push bc
; Check if mine exists.
ld a,(ix+SP_ITL)
or (ix+SP_ITH)
jr z,chk_alien_mines_next
; Check for collision.
call chk_spr_spr
jr c,chk_alien_mines_next
; Collision, free mine.
push iy
push ix
pop iy
call freesp
pop iy
chk_alien_mines_next
; Next mine sprite.
ld bc,SPRSZ
add ix,bc
pop bc
djnz chk_alien_mines_loop
pop ix
ret
; ----------------
; 'chk_ship_mines'
; ----------------
; Checks collision between ship and mines. If the ship collides with
; mines, they disappear, but the ship won't be able to move for some time.
chk_ship_mines
; Are we in correct level?
ld a,(level)
cp BIRD_LEVEL-1
ret nz
; We are; check.
push ix
push iy
ld ix,mine_sp
ld de,SPRSZ
ld b,MINE_SP_SLOTS
chk_ship_mines_loop
; Check if mine exists.
ld a,(ix+SP_ITL)
or (ix+SP_ITH)
jr z,chk_ship_mines_next
; If not in the same y position, no collision.
ld iy,ship_sp
ld a,(iy+SP_PY)
cp (ix+SP_PY)
jr nz,chk_ship_mines_next
; Get mine character position in H.
ld a,(ix+SP_PX)
call tochrp
ld h,a
; Get character position of ship's body in L.
ld a,(iy+SP_PX)
call tochrp
ld l,a
; Check body.
cp h
jr z,chk_ship_mines_overlap
; Check left wing.
; Check if destroyed.
ld iy,lwng_sp
ld a,(iy+SP_ITL)
or (iy+SP_ITH)
jr z,chk_ship_mines_rwing
; Not destroyed.
ld a,l
dec a
cp h
jr z,chk_ship_mines_overlap
chk_ship_mines_rwing
; Check right wing.
; Check if destroyed.
ld iy,rwng_sp
ld a,(iy+SP_ITL)
or (iy+SP_ITH)
jr z,chk_ship_mines_next
; Not destroyed.
ld a,l
inc a
cp h
jr nz,chk_ship_mines_next
chk_ship_mines_overlap
; They overlap, destroy mine.
push ix
pop iy
call freesp
; And player won't be able to move.
ld a,SHIP_STUCK_TIME
ld (ship_stuck_time),a
chk_ship_mines_next
add ix,de
djnz chk_ship_mines_loop
pop iy
pop ix
ret
; ----------------
; 'chk_shot_mines'
; ----------------
; Checks collision between ship's shot and mines.
;
; In IY shot sprite.
; Out CY 1 collision.
chk_shot_mines
push ix
; Are we in correct level?
ld a,(level)
cp BIRD_LEVEL-1
jr nz,chk_mines_no_overlap
; Check.
ld ix,mine_sp
ld b,MINE_SP_SLOTS
ld de,SPRSZ
chk_shot_mines_loop
; Check if mine exists.
ld a,(ix+SP_ITL)
or (ix+SP_ITH)
jr z,chk_shot_mines_next
; Check if shot is in the same square.
ld a,(iy+SP_PY)
and $f8
cp (ix+SP_PY)
jr nz,chk_shot_mines_next
ld a,(iy+SP_PX)
and $f8
cp (ix+SP_PX)
jr nz,chk_shot_mines_next
; Overlap.
; Free mine.
push iy
push ix
pop iy
call freesp
pop iy
scf
jr chk_shot_mines_end
; Next mine.
chk_shot_mines_next
add ix,de
djnz chk_shot_mines_loop
chk_mines_no_overlap
; No collision.
or a
chk_shot_mines_end
pop ix
ret
|
// The MIT License (MIT)
// Copyright (c) 2013 lailongwei<lailongwei@126.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "comm/TestCase_Comm_Svc.h"
namespace
{
const int OPCODE = 0;
class TestFacade : public LLBC_IFacade
{
public:
TestFacade()
{
_recvBytes = 0;
_prevRecv100MB = 0;
_packets = 0;
}
public:
virtual bool OnInitialize()
{
LLBC_PrintLine("Service create!");
return true;
}
virtual void OnDestroy()
{
LLBC_PrintLine("Service destroy!");
}
public:
virtual void OnSessionCreate(const LLBC_SessionInfo &sessionInfo)
{
LLBC_PrintLine("Session Create: %s", sessionInfo.ToString().c_str());
}
virtual void OnSessionDestroy(const LLBC_SessionDestroyInfo &destroyInfo)
{
LLBC_PrintLine("Session Destroy, info: %s", destroyInfo.ToString().c_str());
}
virtual void OnAsyncConnResult(const LLBC_AsyncConnResult &result)
{
LLBC_PrintLine("Async-Conn result: %s", result.ToString().c_str());
}
virtual void OnUnHandledPacket(const LLBC_Packet &packet)
{
LLBC_PrintLine("Unhandled packet, sessionId: %d, opcode: %d, payloadLen: %ld",
packet.GetSessionId(), packet.GetOpcode(), packet.GetPayloadLength());
}
virtual void OnProtoReport(const LLBC_ProtoReport &report)
{
LLBC_PrintLine("Proto report: %s", report.ToString().c_str());
}
public:
void OnDataArrival(LLBC_Packet &packet)
{
if ((_packets += 1) % 1000 == 0)
LLBC_PrintLine("[%lld]Received %ld packets!", LLBC_GetMilliSeconds(), _packets);
_recvBytes += packet.GetPayloadLength();
uint64 recv100MB = _recvBytes / (100 * 1024 * 1024);
if (recv100MB > _prevRecv100MB)
{
LLBC_PrintLine("[%lld]Received %llu MB data!", LLBC_GetMilliSeconds(), _recvBytes / (1024 * 1024));
_prevRecv100MB = recv100MB;
}
// LLBC_Packet *resPacket = LLBC_New(LLBC_Packet);
LLBC_Packet *resPacket = GetService()->GetPacketObjectPool().GetObject();
resPacket->SetHeader(packet, OPCODE, 0);
resPacket->Write(packet.GetPayload(), packet.GetPayloadLength());
GetService()->Send(resPacket);
}
private:
uint64 _recvBytes;
uint64 _prevRecv100MB;
size_t _packets;
};
}
TestCase_Comm_Svc::TestCase_Comm_Svc()
{
}
TestCase_Comm_Svc::~TestCase_Comm_Svc()
{
}
int TestCase_Comm_Svc::Run(int argc, char *argv[])
{
LLBC_PrintLine("Server/Client test:");
if (argc < 5)
{
LLBC_PrintLine("argument error, eg: ./a [client/server] [normal/raw] ip port");
return -1;
}
// Parse arguments.
const char *ip = argv[3];
const int port = LLBC_Str2Int32(argv[4]);
const bool asClient = LLBC_String(argv[1]) == "client" ? true : false;
LLBC_IService::Type svcType =
LLBC_String(argv[2]) == "normal" ? LLBC_IService::Normal : LLBC_IService::Raw;
LLBC_PrintLine("Will start %s type service, service type: %s",
asClient ? "CLIENT" : "SERVER",
svcType == LLBC_IService::Normal ? "Normal" : "Raw");
// Create service
LLBC_IService *svc = LLBC_IService::Create(svcType, "SvcTest");
TestFacade *facade = LLBC_New(TestFacade);
svc->RegisterFacade(facade);
svc->Subscribe(OPCODE, facade, &TestFacade::OnDataArrival);
svc->SuppressCoderNotFoundWarning();
svc->Start(8);
// Connect to server / Create listen session to wait client connect.
int sessionId;
LLBC_SessionOpts sessionOpts;
sessionOpts.SetSockSendBufSize(1 * 1024 * 1024);
sessionOpts.SetSockRecvBufSize(1 * 1024 * 1024);
sessionOpts.SetMaxPacketSize(64 * 1024);
if (!asClient)
{
LLBC_PrintLine("Will listening in %s:%d", ip, port);
if ((sessionId = svc->Listen(ip, port, NULL, sessionOpts)) == 0)
{
LLBC_PrintLine("Create session failed, reason: %s", LLBC_FormatLastError());
LLBC_Delete(svc);
return -1;
}
}
else
{
// Client service, we create some clients to test service.
int clientCount;
const int pollerType = LLBC_PollerType::Str2Type(LLBC_CFG_COMM_POLLER_MODEL);
if (pollerType == LLBC_PollerType::SelectPoller)
clientCount = 50;
else
clientCount = 200;
LLBC_PrintLine("Create %d clients to test", clientCount);
for (int i = 0; i < clientCount; ++i)
{
const int sessionId = svc->Connect(ip, port, -1, NULL, sessionOpts);
const int dataSize = 512 * 1024;
char *data = LLBC_Malloc(char, dataSize);
::memset(data, 1, dataSize);
// LLBC_Packet *packet = LLBC_New(LLBC_Packet);
LLBC_Packet *packet = svc->GetPacketObjectPool().GetObject();
packet->SetHeader(sessionId, OPCODE, 0);
packet->Write(data, dataSize);
LLBC_Free(data);
svc->Send(packet);
// Test unhandled packet(unsubscribe opcode).
// LLBC_Packet *unhandledPacket = LLBC_New(LLBC_Packet);
LLBC_Packet *unhandledPacket = svc->GetPacketObjectPool().GetObject();
unhandledPacket->SetHeader(sessionId, OPCODE + 10000, 0);
unhandledPacket->Write("Hello World", 12);
svc->Send(unhandledPacket);
}
}
LLBC_PrintLine("Press any key to continue...");
getchar();
return 0;
}
|
; FILE *fopen(const char *filename, const char *mode)
SECTION code_stdio
PUBLIC _fopen
EXTERN l0_fopen_callee
_fopen:
pop af
pop hl
pop de
push de
push hl
push af
jp l0_fopen_callee
|
; A017394: a(n) = (11*n)^6.
; 0,1771561,113379904,1291467969,7256313856,27680640625,82653950016,208422380089,464404086784,941480149401,1771561000000,3138428376721,5289852801024,8550986578849,13339032325696,20179187015625,29721861554176,42761175875209,60254729561664,83344647990241,113379904000000,151939915084881,200859416110144,262254607552729,338550579265536,432510009765625,547263141046336,686339028913329,853698068844544,1053765797374081,1291467969000000,1572266908616041,1902199139467264,2287914286629609,2736715256013376,3256599688890625,3856302691946496,4545340842854449,5334057471375424,6233669215980921,7256313856000000,8415099419290201,9724154565432384,11198680244449489,12855002631049216,14710627334390625,16784294883374656,19096037487458569,21667237072994304,24520684595090761,27680640625000000,31172897213027361,35024841026965504,39265517766052369,43925697850453056,49037943386265625,54636676406050816,60758248384885689,67441011031941184,74725388357583601,82653950016000000,91271485923347521,100625082151426624,110764198096878249,121740744925904896,133609165294515625,146426514344294976,160252541973695809,175149776384856064,191183608905939441,208422380089000000,226937467083370681,246803372284575744,268097813258767129,290901813942684736,315299797119140625,341379678168027136,369232960092848929,398954829822778944,430644255790238281,464404086784000000,500341152077816841,538566362834572864,579194814785959009,622345892187672576,668143373050140625,716715535644767296,768195266285705049,822720168387149824,880432672796160121,941480149401000000,1006015020015006001,1074194872535977984,1146182576381093889,1222146399197348416,1302260124847515625,1386703172671635456,1475660718024024169,1569323814085808704,1667889514952984961
pow $0,6
mul $0,1771561
|
; A192068: a(n) = Fibonacci(2*n) - (n mod 2).
; 0,3,7,21,54,144,376,987,2583,6765,17710,46368,121392,317811,832039,2178309,5702886,14930352,39088168,102334155,267914295,701408733,1836311902,4807526976,12586269024,32951280099,86267571271,225851433717,591286729878
lpb $0
mov $2,$0
trn $0,2
seq $2,5248 ; Bisection of Lucas numbers: a(n) = L(2*n) = A000032(2*n).
add $1,$2
lpe
mov $0,$1
|
; A165866: Totally multiplicative sequence with a(p) = 45.
; Submitted by Jon Maiga
; 1,45,45,2025,45,2025,45,91125,2025,2025,45,91125,45,2025,2025,4100625,45,91125,45,91125,2025,2025,45,4100625,2025,2025,91125,91125,45,91125,45,184528125,2025,2025,2025,4100625,45,2025,2025,4100625,45,91125,45,91125,91125,2025,45,184528125,2025,91125,2025,91125,45,4100625,2025,4100625,2025,2025,45,4100625,45,2025,91125,8303765625,2025,91125,45,91125,2025,91125,45,184528125,45,2025,91125,91125,2025,91125,45,184528125,4100625,2025,45,4100625,2025,2025,2025,4100625,45,4100625,2025,91125,2025,2025
add $0,1
mov $1,1
lpb $0
sub $0,1
seq $0,32742 ; a(1) = 1; for n > 1, a(n) = largest proper divisor of n.
mul $1,45
lpe
mov $0,$1
|
; A056545: a(n) = 4*n*a(n-1) + 1 with a(0)=1.
; Submitted by Jamie Morken(s2)
; 1,5,41,493,7889,157781,3786745,106028861,3392923553,122145247909,4885809916361,214975636319885,10318830543354481,536579188254433013,30048434542248248729,1802906072534894923741,115385988642233275119425,7846247227671862708120901,564929800392374114984704873,42934664829820432738837570349,3434773186385634619107005627921,288520947656393308004988472745365,25389843393762611104438985601592121,2335865592226160221608386675346475133,224243096853711381274405120833261612769
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $2,$3
add $1,$2
sub $3,4
lpe
mov $0,$1
add $0,1
|
;;; Copyright (c) 1995, Colin Plumb.
;;; For licensing and other legal details, see the file legal.c.
;;;
;;; Assembly primitives for bignum library, 80386 family, 32-bit code.
;;;
;;; Several primitives are included here. Only lbnMulAdd1 is *really*
;;; critical, but once that's written, lnmMulN1 and lbnMulSub1 are quite
;;; easy to write as well, so they are included here as well.
;;; lbnDiv21 and lbnModQ are so easy to write that they're included, too.
;;;
;;; All functions here are for 32-bit flat mode. I.e. near code and
;;; near data, although the near offsets are 32 bits.
;;;
;;; The usual 80x86 calling conventions have AX, BX, CX and DX
;;; volatile, and SI, DI, SP and BP preserved across calls.
;;; This includes the "E"xtended forms of all of those registers
;;;
;;; However, just to be confusing, recent 32-bit DOS compilers have
;;; quietly changed that to require EBX preserved across calls, too.
;;; Joy.
.386
;_TEXT segment para public use32 'CODE' ; 16-byte aligned because 486 cares
;_TEXT ends
ifdef @Version
if @Version le 510
FLAT group _TEXT
endif
else
FLAT group _TEXT
endif
assume cs:FLAT, ds:FLAT, ss:FLAT
_TEXT segment para public use32 'CODE' ; 16-byte aligned because 486 cares
public _lbnMulN1_32
public _lbnMulAdd1_32
public _lbnMulSub1_32
public _lbnDiv21_32
public _lbnModQ_32
;; Register usage:
;; eax - low half of product
;; ebx - carry to next iteration
;; ecx - multiplier (k)
;; edx - high half of product
;; esi - source pointer
;; edi - dest pointer
;; ebp - loop counter
;;
;; Stack frame:
;; +--------+ esp+20 esp+24 esp+28 esp+32 esp+36
;; | k |
;; +--------+ esp+16 esp+20 esp+24 esp+28 esp+32
;; | len |
;; +--------+ esp+12 esp+16 esp+20 esp+24 esp+28
;; | in |
;; +--------+ esp+8 esp+12 esp+16 esp+20 esp+24
;; | out |
;; +--------+ esp+4 esp+8 esp+12 esp+16 esp+20
;; | return |
;; +--------+ esp esp+4 esp+8 esp+12 esp+16
;; | esi |
;; +--------+ esp esp+4 esp+8 esp+12
;; | ebp |
;; +--------+ esp esp+4 esp+8
;; | ebx |
;; +--------+ esp esp+4
;; | edi |
;; +--------+ esp
align 16
_lbnMulN1_32 proc near
push esi ; U
mov esi,[esp+12] ; V load in
push ebp ; U
mov ebp,[esp+20] ; V load len
push ebx ; U
mov ecx,[esp+28] ; V load k
push edi ; U
mov edi,[esp+20] ; V load out
;; First multiply step has no carry in.
mov eax,[esi] ; U
lea ebx,[ebp*4-4] ; V loop unrolling
mul ecx ; NP first multiply
mov [edi],eax ; U
and ebx,12 ; V loop unrolling
add esi,ebx ; U loop unrolling
add edi,ebx ; V loop unrolling
jmp DWORD PTR m32_jumptable[ebx] ; NP loop unrolling
align 4
m32_jumptable:
dd m32_case0
dd m32_case1
dd m32_case2
dd m32_case3
nop
align 8
nop
nop
nop ; Get loop nicely aligned
m32_case0:
sub ebp,4 ; U
jbe SHORT m32_done ; V
m32_loop:
mov eax,[esi+4] ; U
mov ebx,edx ; V Remember carry for later
add esi,16 ; U
add edi,16 ; V
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
adc edx,0 ; U
mov [edi-12],eax ; V
m32_case3:
mov eax,[esi-8] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
adc edx,0 ; U
mov [edi-8],eax ; V
m32_case2:
mov eax,[esi-4] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
adc edx,0 ; U
mov [edi-4],eax ; V
m32_case1:
mov eax,[esi] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
adc edx,0 ; U
mov [edi],eax ; V
sub ebp,4 ; U
ja SHORT m32_loop ; V
m32_done:
mov [edi+4],edx ; U
pop edi ; V
pop ebx ; U
pop ebp ; V
pop esi ; U
ret ; NP
_lbnMulN1_32 endp
align 16
_lbnMulAdd1_32 proc near
push esi ; U
mov esi,[esp+12] ; V load in
push edi ; U
mov edi,[esp+12] ; V load out
push ebp ; U
mov ebp,[esp+24] ; V load len
push ebx ; U
mov ecx,[esp+32] ; V load k
;; First multiply step has no carry in.
mov eax,[esi] ; U
mov ebx,[edi] ; V
mul ecx ; NP first multiply
add ebx,eax ; U
lea eax,[ebp*4-4] ; V loop unrolling
adc edx,0 ; U
and eax,12 ; V loop unrolling
mov [edi],ebx ; U
add esi,eax ; V loop unrolling
add edi,eax ; U loop unrolling
jmp DWORD PTR ma32_jumptable[eax] ; NP loop unrolling
align 4
ma32_jumptable:
dd ma32_case0
dd ma32_case1
dd ma32_case2
dd ma32_case3
nop
align 8
nop
nop
nop ; To align loop properly
ma32_case0:
sub ebp,4 ; U
jbe SHORT ma32_done ; V
ma32_loop:
mov eax,[esi+4] ; U
mov ebx,edx ; V Remember carry for later
add esi,16 ; U
add edi,16 ; V
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-12] ; V
adc edx,0 ; U
add ebx,eax ; V
adc edx,0 ; U
mov [edi-12],ebx ; V
ma32_case3:
mov eax,[esi-8] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-8] ; V
adc edx,0 ; U
add ebx,eax ; V
adc edx,0 ; U
mov [edi-8],ebx ; V
ma32_case2:
mov eax,[esi-4] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-4] ; V
adc edx,0 ; U
add ebx,eax ; V
adc edx,0 ; U
mov [edi-4],ebx ; V
ma32_case1:
mov eax,[esi] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi] ; V
adc edx,0 ; U
add ebx,eax ; V
adc edx,0 ; U
mov [edi],ebx ; V
sub ebp,4 ; U
ja SHORT ma32_loop ; V
ma32_done:
pop ebx ; U
pop ebp ; V
mov eax,edx ; U
pop edi ; V
pop esi ; U
ret ; NP
_lbnMulAdd1_32 endp
align 16
_lbnMulSub1_32 proc near
push esi ; U
mov esi,[esp+12] ; V load in
push edi ; U
mov edi,[esp+12] ; V load out
push ebp ; U
mov ebp,[esp+24] ; V load len
push ebx ; U
mov ecx,[esp+32] ; V load k
;; First multiply step has no carry in.
push esi ; U
mov esi,[esp+12] ; V load in
push edi ; U
mov edi,[esp+12] ; V load out
push ebp ; U
mov ebp,[esp+24] ; V load len
mov ecx,[esp+28] ; U load k
;; First multiply step has no carry in.
mov eax,[esi] ; V
mov ebx,[edi] ; U
mul ecx ; NP first multiply
sub ebx,eax ; U
lea eax,[ebp*4-4] ; V loop unrolling
adc edx,0 ; U
and eax,12 ; V loop unrolling
mov [edi],ebx ; U
add esi,eax ; V loop unrolling
add edi,eax ; U loop unrolling
jmp DWORD PTR ms32_jumptable[eax] ; NP loop unrolling
align 4
ms32_jumptable:
dd ms32_case0
dd ms32_case1
dd ms32_case2
dd ms32_case3
nop
align 8
nop
nop
nop
ms32_case0:
sub ebp,4 ; U
jbe SHORT ms32_done ; V
ms32_loop:
mov eax,[esi+4] ; U
mov ebx,edx ; V Remember carry for later
add esi,16 ; U
add edi,16 ; V
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-12] ; V
adc edx,0 ; U
sub ebx,eax ; V
adc edx,0 ; U
mov [edi-12],ebx ; V
ms32_case3:
mov eax,[esi-8] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-8] ; V
adc edx,0 ; U
sub ebx,eax ; V
adc edx,0 ; U
mov [edi-8],ebx ; V
ms32_case2:
mov eax,[esi-4] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi-4] ; V
adc edx,0 ; U
sub ebx,eax ; V
adc edx,0 ; U
mov [edi-4],ebx ; V
ms32_case1:
mov eax,[esi] ; U
mov ebx,edx ; V Remember carry for later
mul ecx ; NP
add eax,ebx ; U Add carry in from previous word
mov ebx,[edi] ; V
adc edx,0 ; U
sub ebx,eax ; V
adc edx,0 ; U
mov [edi],ebx ; V
sub ebp,4 ; U
ja SHORT ms32_loop ; V
ms32_done:
pop ebx ; U
pop ebp ; V
mov eax,edx ; U
pop edi ; V
pop esi ; U
ret ; NP
_lbnMulSub1_32 endp
;; Two-word by one-word divide. Stores quotient, returns remainder.
;; BNWORD32 lbnDiv21_32(BNWORD32 *q, BNWORD32 nh, BNWORD32 nl, BNWORD32 d)
;; 4 8 12 16
align 4
_lbnDiv21_32 proc near
mov edx,[esp+8] ; U Load nh
mov eax,[esp+12] ; V Load nl
mov ecx,[esp+4] ; U Load q
div DWORD PTR [esp+16] ; NP
mov [ecx],eax ; U Store quotient
mov eax,edx ; V Return remainder
ret
_lbnDiv21_32 endp
;; Multi-word by one-word remainder.
;; This speeds up key generation. It's not worth unrolling and so on;
;; using 32-bit divides is enough of a speedup.
;;
;; The modulus (in ebp) is often 16 bits. Given that the dividend is 32
;; bits, the chances of saving the first divide because the high word of the
;; dividend is less than the modulus are low enough it's not worth taking
;; the cycles to test for it.
;;
;; unsigned lbnModQ_32(BNWORD32 const *n, unsigned len, unsigned d)
;; 4 8 12
align 4
_lbnModQ_32 proc near
mov eax,[esp+4] ; U Load n
push ebp ; V
mov ebp,[esp+12] ; U Load len
push esi ; V
lea esi,[ebp*4+eax-4] ; U
mov ecx,[esp+20] ; V Load d
xor edx,edx ; U Clear edx for first iteration
modq32_loop:
mov eax,[esi] ; U Load new low word for divide
sub esi,4 ; V
div ecx ; NP edx = edx:eax % ecx
dec ebp ; U
jnz SHORT modq32_loop ; V
pop esi ; U
mov eax,edx ; V Return remainder in eax
pop ebp ; U
ret ; NP
_lbnModQ_32 endp
end
|
; A075692: Upper irredundance number for queens graph Q_n on n^2 nodes.
; 1,1,2,4,5,7,9,11,13,15
mov $1,$0
pow $1,2
sub $1,$0
add $0,1
mul $1,2
div $1,$0
mov $0,$1
add $0,1
|
; A246780: Strictly increasing terms of the sequence A246778: a(1)= A246778(1) and for n>0 a(n+1) is next term greater than a(n) after that a(n) appears in A246778 for the first time.
; 2,3,4,6,8,9,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70
mov $1,2
add $1,$0
mov $2,$0
mov $3,3
mov $4,$0
mov $5,2
lpb $2
lpb $4
add $1,1
sub $2,4
trn $4,$3
sub $3,1
add $5,$4
lpe
sub $4,1
lpb $5
mov $2,6
add $3,$4
mov $4,3
mov $5,0
lpe
sub $2,$4
trn $2,1
add $4,5
lpe
|
;Compressed bitmaps for the font used by HT2.
;
; Five nibbles (2.5 bytes) per character
; Will be unpacked to 5 bytes per character
; Currently 0x00 to 0x1a => 27 different characters
; - Compressed space in RAM = 27*2.5 = 67.5 => 68 bytes = 0x44
; - Uncompressed space in RAM = 27*5 = 135 bytes = 0x87
; Then right-shifted variants of all but the ones that doesn't need it (G, M, STOP, PLAY)
; - Uncompressed space in RAM = (27-4)*5 = 115 bytes = 0x73
; Total needed space in RAM = 135+115=250 bytes, fits in one page.
CHAR_0 equ #00
CHAR_1 equ #01
CHAR_2 equ #02
CHAR_3 equ #03
CHAR_4 equ #04
CHAR_5 equ #05
CHAR_6 equ #06
CHAR_7 equ #07
CHAR_8 equ #08
CHAR_9 equ #09
CHAR_A equ #0a
CHAR_B equ #0b
CHAR_C equ #0c
CHAR_D equ #0d
CHAR_E equ #0e
CHAR_F equ #0f
CHAR_L equ #10
CHAR_N equ #11
CHAR_P equ #12
CHAR_O equ CHAR_0
CHAR_S equ #13
CHAR_T equ #14
CHAR_SHARP equ #15
CHAR_DASH equ #16
CHAR_G equ #17
CHAR_M equ #18
CHAR_STOP equ #19
CHAR_PLAY equ #1a
charNumTotal equ CHAR_PLAY-CHAR_0+1 ; Number of characters, total
charNumShifted equ CHAR_DASH-CHAR_0+1 ; Number of characters to be available as both left and right shifted
IF (charNumTotal+charNumShifted)*5 > 256 ; Make sure we don't need more than one page of uncompressed font
.error Uncompressed font will cross page boundary
ENDIF
cmprFontStart
db %01001010 ;0
db %10101010
db %01000100 ;....|1
db %11000100
db %01001110
db %11000010 ;2
db %01001000
db %11101100 ;....|3
db %00100100
db %00101100
db %10001010 ;4
db %11100010
db %00101100 ;....|5
db %10001100
db %00101100
db %01001000 ;6
db %11001010
db %01001110 ;....|7
db %00100100
db %01000100
db %01001010 ;8
db %01001010
db %01000100 ;....|9
db %10100110
db %00100100
db %01101010 ;A
db %11101010
db %10101100 ;....|B
db %10101100
db %10101100
db %01101000 ;C
db %10001000
db %01101100 ;....|D
db %10101010
db %10101100
db %11101000 ;E
db %11001000
db %11101110 ;....|F
db %10001100
db %10001000
db %10001000 ;10 - L
db %10001000
db %11101100 ;....|N
db %10101010
db %10101010
db %11001010 ;12 - P
db %11001000
db %10000110 ;....|S
db %10000100
db %00101100
db %11100100 ;14 - T
db %01000100
db %01001010 ;....|#
db %11101010
db %11101010
db %00000000 ;16 - -
db %11100000
db %00000110 ;....|G (17)
db %10001010
db %10101110
db %10101110 ;18 - M
db %11101010
db %10100000 ;....|STOP (19)
db %11101110
db %11100000
db %10001100 ;PLAY (1a)
db %11101100
db %10000000 ;....|<unused>
cmprFontSize equ $-cmprFontStart
|
/*! \file
\brief A character width.
Copyright (C) 2019-2021 kaoru https://www.tetengo.org/
*/
#include <cstddef>
#include <boost/preprocessor.hpp>
#include <boost/test/unit_test.hpp>
#include <tetengo/text/grapheme_splitting/character_width.hpp>
namespace
{
class concrete_character_width : public tetengo::text::grapheme_splitting::character_width
{
public:
// constructors and destructor
virtual ~concrete_character_width() = default;
private:
// virtual functions
virtual std::size_t width_of_impl(const class_type class_, const emoji_type) const override
{
return class_ == class_type::fullwidth ? 2 : 1;
}
};
}
BOOST_AUTO_TEST_SUITE(test_tetengo)
BOOST_AUTO_TEST_SUITE(text)
BOOST_AUTO_TEST_SUITE(grapheme_splitting)
BOOST_AUTO_TEST_SUITE(character_width)
BOOST_AUTO_TEST_CASE(construction)
{
BOOST_TEST_PASSPOINT();
const concrete_character_width char_width{};
}
BOOST_AUTO_TEST_CASE(width_of)
{
BOOST_TEST_PASSPOINT();
const concrete_character_width char_width{};
BOOST_TEST(
char_width.width_of(
tetengo::text::grapheme_splitting::character_width::class_type::halfwidth,
tetengo::text::grapheme_splitting::character_width::emoji_type::emoji) == 1U);
BOOST_TEST(
char_width.width_of(
tetengo::text::grapheme_splitting::character_width::class_type::halfwidth,
tetengo::text::grapheme_splitting::character_width::emoji_type::normal) == 1U);
BOOST_TEST(
char_width.width_of(
tetengo::text::grapheme_splitting::character_width::class_type::fullwidth,
tetengo::text::grapheme_splitting::character_width::emoji_type::emoji) == 2U);
BOOST_TEST(
char_width.width_of(
tetengo::text::grapheme_splitting::character_width::class_type::fullwidth,
tetengo::text::grapheme_splitting::character_width::emoji_type::normal) == 2U);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/resiliencehub/model/DeleteAppRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::ResilienceHub::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
DeleteAppRequest::DeleteAppRequest() :
m_appArnHasBeenSet(false),
m_clientToken(Aws::Utils::UUID::RandomUUID()),
m_clientTokenHasBeenSet(true),
m_forceDelete(false),
m_forceDeleteHasBeenSet(false)
{
}
Aws::String DeleteAppRequest::SerializePayload() const
{
JsonValue payload;
if(m_appArnHasBeenSet)
{
payload.WithString("appArn", m_appArn);
}
if(m_clientTokenHasBeenSet)
{
payload.WithString("clientToken", m_clientToken);
}
if(m_forceDeleteHasBeenSet)
{
payload.WithBool("forceDelete", m_forceDelete);
}
return payload.View().WriteReadable();
}
|
; A052907: Expansion of 1/(1 - 2*x^2 - 2*x^3).
; Submitted by Christian Krause
; 1,0,2,2,4,8,12,24,40,72,128,224,400,704,1248,2208,3904,6912,12224,21632,38272,67712,119808,211968,375040,663552,1174016,2077184,3675136,6502400,11504640,20355072,36014080,63719424,112738304,199467008,352915456,624410624,1104764928,1954652160,3458351104,6118834176,10826006528,19154370560,33889681408,59960754176,106088103936,187700871168,332097716224,587577950208,1039597174784,1839351332864,3254350249984,5757897015296,10187403165696,18024494530560,31890600361984,56423795392512,99830189785088
mov $4,1
lpb $0
sub $0,1
mov $1,$4
mul $2,2
mov $4,$2
mov $2,$1
add $2,$3
mov $3,$1
lpe
mov $0,$4
|
; *****************************************************************************
; *****************************************************************************
;
; Name: sourunary.asm
; Purpose: Sour16 unary routines
; Date: 21st June 2020
; Author: Paul Robson (paul@robsons.org.uk)
;
; *****************************************************************************
; *****************************************************************************
;
; These routines generally pass the level into RF, so if RF = 4
; The register involved is R4, or R4/R5.
;
; *****************************************************************************
;
; String Length
;
; *****************************************************************************
StringLength: ;; [unarystrlen1]
.byte CodeOpcode
tax ; save Base in X.
clc
adc 15*2,X ; add the base register in RF to it
adc 15*2,X ; twice.
tax
lda 0,x ; string pos to temp0
sta temp0
lda 1,x
sta temp0+1
ldy #255 ; get length (max 255)
_SLLoop:
iny ; pre increment
lda (temp0),y
bne _SLLoop
sty 0,x ; write result out and exit.
stz 1,x
rts
; *****************************************************************************
;
; Absolute value
;
; *****************************************************************************
Absolute: ;; [unaryabs1]
.byte CodeOpcode
tax ; save Base in X.
clc
adc 15*2,X ; add the base register in RF to it
adc 15*2,X ; twice.
tax
bit 1,x
bpl _AbsExit
sec
lda #0 ; negate
sbc 0,x
sta 0,x
lda #0
sbc 1,x
sta 1,x
_AbsExit:
rts
; *****************************************************************************
;
; Sign of value
;
; *****************************************************************************
SignInteger: ;; [unarysign1]
.byte CodeOpcode
tax ; save Base in X.
clc
adc 15*2,X ; add the base register in RF to it
adc 15*2,X ; twice.
tax
ldy #0 ; return value
lda 0,x
ora 1,x
beq _SIWrite ; 0 if zero
dey ; now return -1
bit 1,x ; if -ve return that
bmi _SIWrite
stz 1,x ; return 1
lda #1
sta 0,x
rts
_SIWrite:
sty 0,x
sty 1,x
rts
; *****************************************************************************
;
; Random Integer
;
; *****************************************************************************
RndInteger: ;; [unaryrandom1]
.byte CodeOpcode
tax ; save Base in X.
clc
adc 15*2,X ; add the base register in RF to it
adc 15*2,X ; twice.
tax
lda rseed ; seed cannot be zero
ora rseed+1
bne _RINotZero
dec rseed
_RINotZero:
lda rseed+1 ; 16 bit xorshift rng
lsr a
lda rseed
ror a
eor rseed+1
sta rseed+1
ror a
eor rseed
sta rseed
sta 0,x
eor rseed+1
sta rseed+1
sta 1,x
rts |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.