text
stringlengths
1
1.05M
TITLE_FRAME_COUNT = 512 RASTER_BAR_START_Y = 220 RASTER_BAR_STEP_ANGLE = 240 RASTER_BAR_SPEED = 64 RASTER_BAR_SIZE = 128 RASTER_BAR_RESOLUTION = 18 RASTER_BAR_STEP = 65536 / RASTER_BAR_RESOLUTION TITLE_BG_COLOR = $1ff .rsset _zp_fx raster_bar_angle .rs 2 raster_bar_start_y .rs 4 raster_bar_offset .rs 2 raster_bar_t .rs 2 raster_bar_index .rs 1 raster_bar_y_count .rs 2 raster_bar_i .rs 1 .bss raster_bar_y .ds 128 .code ;---------------------------------------------------------------------- ; rasterBar_init: ; Disable interrupts vec_off #VSYNC vec_off #HSYNC ; map data lda #TITLE_DATA_BANK tam #TITLE_DATA_PAGE st0 #00 st1 #low(TITLE_SPRITE_VRAM_ADDR) st2 #high(TITLE_SPRITE_VRAM_ADDR) st0 #02 tia title_data, $0002, 3840 stz <raster_bar_angle stz <raster_bar_angle+1 stz <raster_bar_start_y stz <raster_bar_start_y+1 stz <raster_bar_offset stz <raster_bar_offset+1 stz <raster_bar_index stz <raster_bar_y_count stz <raster_bar_i ; load title palette lda #low(0) sta color_reg_l lda #high(0) sta color_reg_h clx .pal_loop: lda title_pal_lo, X sta color_data_l lda title_pal_hi, X sta color_data_h inx cpx #16 bne .pal_loop lda #BGMAP_SIZE_32x64 jsr set_bat_size jsr set_xres256 stz color_ctrl ; setup bg tile st0 #$00 stw #(BACKGROUND_TILE << 4), video_data st0 #$02 st1 #$00 ldx #32 .tile_cleanup: st2 #$00 dex bne .tile_cleanup ; clean BAT st0 #$00 st1 #$00 st2 #$00 st0 #$02 ldy bat_height .bat_clean_y: ldx bat_width .bat_clean_x: stw #BACKGROUND_TILE, video_data dex bne .bat_clean_x dey bne .bat_clean_y ; setup BAT stw #$01A0, <_di stw #$0300, <_si cly .bat_loop_y: st0 #$00 lda <_di sta video_data_l clc adc #$20 sta <_di lda <_di+1 sta video_data_h adc #$00 sta <_di+1 st0 #$02 clx .bat_loop_x: lda <_si sta video_data_l lda <_si+1 sta video_data_h incw <_si inx cpx #(240/8) bne .bat_loop_x iny cpy #4 bne .bat_loop_y st0 #7 st1 #$fa st2 #$ff st0 #8 st1 #12 st2 #00 ; set and enable vdc interrupts; set_vec #VSYNC,rasterBarVsyncProc vec_on #VSYNC set_vec #HSYNC,rasterBarHsyncProc vec_on #HSYNC ; set vdc control register vreg #5 ; enable bg, vertical blanking and scanline interrupt ; disable sprite lda #%10001100 sta <vdc_crl sta video_data_l st2 #$00 rts ;---------------------------------------------------------------------- ; rasterBar_update: addw #RASTER_BAR_SPEED, <raster_bar_offset cmp #high(RASTER_BAR_STEP) bcc .no_reset bne .reset lda <raster_bar_offset cmp #low(RASTER_BAR_STEP) bcc .no_reset .reset: stwz <raster_bar_offset .no_reset: stw <raster_bar_offset, <raster_bar_t addw #RASTER_BAR_STEP_ANGLE, <raster_bar_angle tax adc #high(RASTER_BAR_STEP_ANGLE) sta <raster_bar_angle+1 cly lda sinTable, X bpl .l0 ldy #$ff .l0: clc adc #low(RASTER_BAR_START_Y) sta <raster_bar_start_y tya adc #high(RASTER_BAR_START_Y) ;lsr A ;ror <raster_bar_start_y lsr A sta <raster_bar_start_y+1 ror <raster_bar_start_y stz <raster_bar_y_count lda <raster_bar_i eor #1 tay lda raster_bar_start_i, Y tax lda <raster_bar_t+1 clc adc #127 tay lda sinTable, Y cmp #$80 ror A clc adc #RASTER_BAR_SIZE sta raster_bar_y+32, X lsr A sta raster_bar_y, X inx .loop: lda <raster_bar_offset+1 clc adc #127 cmp <raster_bar_t+1 bcs .update .no_update: bra .loop_end .update: addw #RASTER_BAR_STEP, <raster_bar_t adc #127 tay lda sinTable, Y cmp #$80 ror A clc adc #RASTER_BAR_SIZE sta raster_bar_y+32, X lsr A sta raster_bar_y, X cmp (raster_bar_y-1), X beq .stalled bcs .continue .stalled: bra .loop .continue: inx bra .loop .loop_end: stx <raster_bar_y_count lda <raster_bar_i eor #1 sta <raster_bar_i sta <raster_bar_i+1 rts ;---------------------------------------------------------------------- ; VSYNC (raster bar) rasterBarVsyncProc: ldy <raster_bar_i lda raster_bar_start_i, Y sta <raster_bar_index tay stw <raster_bar_start_y, <raster_bar_start_y+2 lda <raster_bar_y_count sta <raster_bar_y_count+1 stz color_reg_l stz color_reg_h lda #low(TITLE_BG_COLOR) sta color_data_l lda #high(TITLE_BG_COLOR) sta color_data_h st0 #6 lda raster_bar_y, Y clc adc <raster_bar_start_y+2 sta video_data_l lda <raster_bar_start_y+3 adc #0 sta video_data_h jsr vgm_update irq1_end ;---------------------------------------------------------------------- ; HSYNC (raster bar) rasterBarHsyncProc: inc <raster_bar_index ldy <raster_bar_index cpy <raster_bar_y_count+1 bcs .no_update .update: lda raster_bar_y+32, Y clc adc (raster_bar_y+31), Y bpl .none eor #$ff inc A .none tax stz color_reg_l stz color_reg_h lda raster_bar_color_lo, X sta color_data_l lda raster_bar_color_hi, X sta color_data_h st0 #6 lda raster_bar_y, Y clc adc <raster_bar_start_y+2 sta video_data_l cla adc <raster_bar_start_y+3 sta video_data_h irq1_end .no_update: stz color_reg_l stz color_reg_h lda #low(TITLE_BG_COLOR) sta color_data_l lda #high(TITLE_BG_COLOR) sta color_data_h irq1_end ;---------------------------------------------------------------------- ; Data: ;----------------------------------------------------------------------
; This snippet, 0x07, sets rax with its initial value. ; Assemble with $ nasm -felf64 0x07.asm && ld 0x07.o && ./a.out global _start section .text _start: mov rax, 1 ; Initialize rax (can be any number) inc rax ; rax = rax + 1 (makes value negative) neg rax ; rax = ~rax + 1 inc rax ; rax = rax + 1 neg rax ; rax = ~rax + 1 ; C code Comparison: ; ; #include <stdio.h> ; int main(void) ; { ; int rax = 5; ; printf("in: %d\n", rax); ; rax = ~((~(rax + 1) + 1) + 1) + 1; ; printf("out: %d\n", rax); ; } ; ; The main takeway here (as in the previous snippet) ; is that "not rax" can be rewritten as: ; ; inc rax ; neg rax ; ; Similarly, "neg rax" can be rewritten as: ; ; not rax ; inc rax
#include "RenderWindow_linux32.cpp"
; A176534: Decimal expansion of (35+sqrt(1295))/7. ; Submitted by Christian Krause ; 1,0,1,4,0,8,7,2,6,3,2,9,8,4,7,3,7,5,9,9,1,6,1,2,4,5,2,0,7,9,6,8,1,8,4,4,3,0,6,4,9,8,7,4,1,7,1,2,2,8,4,5,0,6,2,9,4,6,5,7,5,2,4,8,0,7,9,3,1,2,3,6,5,7,5,2,4,3,3,1,7,2,8,7,0,7,4,7,0,0,0,3,0,5,5,8,7,5,9,5 mov $2,1 mov $3,$0 lpb $3 add $1,$5 add $5,$2 add $5,$2 add $1,$5 cmp $2,2 add $2,$1 mul $2,70 sub $3,1 lpe mov $1,1 add $1,$5 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/smartag/model/DeleteFlowLogResult.h> #include <json/json.h> using namespace AlibabaCloud::Smartag; using namespace AlibabaCloud::Smartag::Model; DeleteFlowLogResult::DeleteFlowLogResult() : ServiceResult() {} DeleteFlowLogResult::DeleteFlowLogResult(const std::string &payload) : ServiceResult() { parse(payload); } DeleteFlowLogResult::~DeleteFlowLogResult() {} void DeleteFlowLogResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); }
section .realmode int_08_ticks_counter: dd 0 int_08_callback: dd 0 int_08_isr: bits 16 pushf inc dword [cs:int_08_ticks_counter] popf jmp far [cs:int_08_callback] bits 32 extern getchar_internal global _pit_sleep_and_quit_on_keypress _pit_sleep_and_quit_on_keypress: ; Hook int 0x08 mov edx, dword [0x08*4] mov dword [int_08_callback], edx mov edx, int_08_isr mov dword [0x08*4], int_08_isr ; pit_ticks in edx mov edx, dword [esp+4] mov dword [int_08_ticks_counter], 0 ; Save GDT in case BIOS overwrites it sgdt [.gdt] ; Save IDT sidt [.idt] ; Load BIOS IVT lidt [.rm_idt] ; Save non-scratch GPRs push ebx push esi push edi push ebp ; Jump to real mode jmp 0x08:.bits16 .bits16: bits 16 mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax mov eax, cr0 and al, 0xfe mov cr0, eax jmp 0x00:.cszero .cszero: xor ax, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax sti .loop: cmp dword [int_08_ticks_counter], edx je .timeout push ecx push edx mov ah, 0x01 xor al, al int 0x16 pop edx pop ecx jz .loop ; on keypress xor ax, ax int 0x16 jmp .done .timeout: xor eax, eax .done: cli ; Restore GDT o32 lgdt [ss:.gdt] ; Restore IDT o32 lidt [ss:.idt] ; Jump back to pmode mov ebx, cr0 or bl, 1 mov cr0, ebx jmp 0x18:.bits32 .bits32: bits 32 mov bx, 0x20 mov ds, bx mov es, bx mov fs, bx mov gs, bx mov ss, bx ; Restore non-scratch GPRs pop ebp pop edi pop esi pop ebx ; Dehook int 0x08 mov edx, dword [int_08_callback] mov dword [0x08*4], edx xor edx, edx mov dl, ah xor ah, ah push eax push edx call getchar_internal pop edx pop edx ret .gdt: dq 0 .idt: dq 0 .rm_idt: dw 0x3ff dd 0
; A301672: Coordination sequence for node of type V2 in "krr" 2-D tiling (or net). ; 1,4,8,13,17,20,25,30,33,37,42,46,50,54,58,63,67,70,75,80,83,87,92,96,100,104,108,113,117,120,125,130,133,137,142,146,150,154,158,163,167,170,175,180,183,187,192,196,200,204,208,213,217,220,225,230,233,237,242,246,250,254,258,263,267,270,275,280,283,287,292,296,300,304,308,313,317,320,325,330,333,337,342,346,350,354,358,363,367,370,375,380,383,387,392,396,400,404,408,413,417,420,425,430,433,437,442,446,450,454,458,463,467,470,475,480,483,487,492,496,500,504,508,513,517,520,525,530,533,537,542,546,550,554,558,563,567,570,575,580,583,587,592,596,600,604,608,613,617,620,625,630,633,637,642,646,650,654,658,663,667,670,675,680,683,687,692,696,700,704,708,713,717,720,725,730,733,737,742,746,750,754,758,763,767,770,775,780,783,787,792,796,800,804,808,813,817,820,825,830,833,837,842,846,850,854,858,863,867,870,875,880,883,887,892,896,900,904,908,913,917,920,925,930,933,937,942,946,950,954,958,963,967,970,975,980,983,987,992,996,1000,1004,1008,1013,1017,1020,1025,1030,1033,1037 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 sub $0,1 cal $0,301673 ; Partial sums of A301672. mov $2,$3 mov $4,$0 lpb $2 mov $1,$4 sub $2,1 lpe lpe lpb $5 sub $1,$4 mov $5,0 lpe
.global s_prepare_buffers s_prepare_buffers: push %r12 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x14dad, %rsi lea addresses_A_ht+0x12cad, %rdi nop nop nop and %rbx, %rbx mov $114, %rcx rep movsl nop nop dec %r12 lea addresses_WC_ht+0x12d6d, %rbx nop nop nop and $17379, %rbp movb (%rbx), %r12b and %rbx, %rbx lea addresses_UC_ht+0x7b9d, %rsi lea addresses_UC_ht+0x18a4e, %rdi nop nop nop add %rbp, %rbp mov $103, %rcx rep movsb nop cmp %rbx, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %rax push %rbx push %rcx push %rsi // Load lea addresses_A+0xcc3d, %r14 nop nop inc %rsi movb (%r14), %bl nop dec %rbx // Store lea addresses_A+0x1c1c5, %rax nop xor $14094, %r11 mov $0x5152535455565758, %r14 movq %r14, %xmm3 vmovaps %ymm3, (%rax) nop xor $24918, %r13 // Store lea addresses_US+0x30ed, %rcx nop nop sub %r14, %r14 mov $0x5152535455565758, %rsi movq %rsi, (%rcx) nop nop nop nop nop cmp $44106, %rax // Store lea addresses_A+0xbb6d, %rcx and %rbx, %rbx mov $0x5152535455565758, %rax movq %rax, (%rcx) nop nop nop nop dec %rcx // Faulty Load lea addresses_US+0x1916d, %r11 nop xor %r14, %r14 mov (%r11), %ebx lea oracles, %rsi and $0xff, %rbx shlq $12, %rbx mov (%rsi,%rbx,1), %rbx pop %rsi pop %rcx pop %rbx pop %rax pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': True, 'congruent': 2, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; =============================================================== ; Feb 2014 ; =============================================================== ; ; size_t w_vector_insert_n(w_vector_t *v, size_t idx, size_t n, void *item) ; ; Insert n words before vector.array[idx], fill that area with ; item and return the index of the first word inserted. ; ; =============================================================== SECTION code_clib SECTION code_adt_w_vector PUBLIC asm_w_vector_insert_n EXTERN asm_b_vector_insert_block, asm1_w_array_insert_n, error_mc asm_w_vector_insert_n: ; enter : hl = vector * ; de = n ; bc = idx ; af = item ; ; exit : success ; ; de = & vector.data[idx ; hl = idx of first word inserted ; carry reset ; ; fail ; ; hl = -1 ; carry set ; ; uses : af, bc, de, hl push bc ; save idx push af ; save item sla c rl b jp c, error_mc - 2 sla e rl d jp c, error_mc - 2 push de ; save n*2 call asm_b_vector_insert_block jp asm1_w_array_insert_n
// Copyright 2021 The Autoware Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // //    http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Co-developed by Tier IV, Inc. and Apex.AI, Inc. #include "hello_world/hello_world.hpp" #include <iostream> namespace autoware { int32_t hello_world::print_hello() { std::cout << "Hello World" << std::endl; return 0; } } // namespace autoware
/* * This software is distributed under BSD 3-clause license (see LICENSE file). * * Authors: Heiko Strathmann, Soeren Sonnenburg, Soumyajit De, Thoralf Klein, * Pan Deng, Fernando Iglesias, Sergey Lisitsyn, Viktor Gal, * Michele Mazzoni, Yingrui Chang, Weijie Lin, Khaled Nasr, * Koen van de Sande, Roman Votyakov */ #include <shogun/lib/config.h> #include <shogun/io/SGIO.h> #include <shogun/io/File.h> #include <shogun/lib/SGMatrix.h> #include <shogun/lib/SGVector.h> #include <shogun/mathematics/eigen3.h> #include <shogun/mathematics/Math.h> #include <shogun/mathematics/lapack.h> #include <limits> #include <algorithm> namespace shogun { template <class T> SGMatrix<T>::SGMatrix() : SGReferencedData() { init_data(); } template <class T> SGMatrix<T>::SGMatrix(bool ref_counting) : SGReferencedData(ref_counting) { init_data(); } template <class T> SGMatrix<T>::SGMatrix(T* m, index_t nrows, index_t ncols, bool ref_counting) : SGReferencedData(ref_counting), matrix(m), num_rows(nrows), num_cols(ncols), gpu_ptr(nullptr) { #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(T* m, index_t nrows, index_t ncols, index_t offset) : SGReferencedData(false), matrix(m+offset), num_rows(nrows), num_cols(ncols) { #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(index_t nrows, index_t ncols, bool ref_counting) : SGReferencedData(ref_counting), num_rows(nrows), num_cols(ncols), gpu_ptr(nullptr) { matrix=SG_ALIGNED_MALLOC( T, ((int64_t) nrows)*ncols, alignment::container_alignment); std::fill_n(matrix, ((int64_t) nrows)*ncols, 0); #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(SGVector<T> vec) : SGReferencedData(vec) { require((vec.vector || vec.gpu_ptr), "Vector not initialized!"); matrix=vec.vector; num_rows=vec.vlen; num_cols=1; gpu_ptr = vec.gpu_ptr; #ifdef HAVE_VIENNACL m_on_gpu.store(vec.on_gpu(), std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(SGVector<T> vec, index_t nrows, index_t ncols) : SGReferencedData(vec) { require((vec.vector || vec.gpu_ptr), "Vector not initialized!"); require(nrows>0, "Number of rows ({}) has to be a positive integer!", nrows); require(ncols>0, "Number of cols ({}) has to be a positive integer!", ncols); require(vec.vlen==nrows*ncols, "Number of elements in the matrix ({}) must " "be the same as the number of elements in the vector ({})!", nrows*ncols, vec.vlen); matrix=vec.vector; num_rows=nrows; num_cols=ncols; gpu_ptr = vec.gpu_ptr; #ifdef HAVE_VIENNACL m_on_gpu.store(vec.on_gpu(), std::memory_order_release); #endif } template<class T> SGMatrix<T>::SGMatrix(GPUMemoryBase<T>* mat, index_t nrows, index_t ncols) : SGReferencedData(true), matrix(NULL), num_rows(nrows), num_cols(ncols), gpu_ptr(std::shared_ptr<GPUMemoryBase<T>>(mat)) { #ifdef HAVE_VIENNACL m_on_gpu.store(true, std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(const SGMatrix &orig) : SGReferencedData(orig) { copy_data(orig); } template <class T> SGMatrix<T>::SGMatrix(SGMatrix&& orig) noexcept : SGReferencedData(std::move(orig)), matrix{std::exchange(orig.matrix ,nullptr)}, num_rows{std::exchange(orig.num_rows, 0)}, num_cols{std::exchange(orig.num_cols, 0)}, gpu_ptr(std::move(orig.gpu_ptr)) { #ifdef HAVE_VIENNACL m_on_gpu.store(orig.m_on_gpu.load( std::memory_order_acquire), std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(EigenMatrixXt& mat) : SGReferencedData(false), matrix(mat.data()), num_rows(mat.rows()), num_cols(mat.cols()), gpu_ptr(nullptr) { #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif } template <class T> SGMatrix<T>::SGMatrix(const std::initializer_list<std::initializer_list<T>>& list): SGReferencedData(), num_rows((*list.begin()).size()), num_cols(list.size()), gpu_ptr(nullptr) { matrix = SG_CALLOC(T, ((int64_t) num_rows)*num_cols); #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif int64_t curr_pos = 0; for (const auto& r: list) for (const auto& c: r) matrix[curr_pos++] = c; } template <class T> SGMatrix<T>::operator EigenMatrixXtMap() const { assert_on_cpu(); return EigenMatrixXtMap(matrix, num_rows, num_cols); } template<class T> SGMatrix<T>& SGMatrix<T>::operator=(const SGMatrix<T>& other) { if(&other == this) return *this; unref(); copy_data(other); copy_refcount(other); ref(); return *this; } template <class T> SGMatrix<T>::~SGMatrix() { unref(); } template <class T> bool SGMatrix<T>::equals(const SGMatrix<T>& other) const { // avoid comparing elements when both are same. // the case where both matrices are uninitialized is handled here as well. if (*this==other) return true; // both empty if (!(num_rows || num_cols || other.num_rows || other.num_cols)) return true; // only one empty if (!matrix || !other.matrix) return false; // different size if (num_rows!=other.num_rows || num_cols!=other.num_cols) return false; // content return std::equal(matrix, matrix+size(), other.matrix); } #ifndef REAL_EQUALS #define REAL_EQUALS(real_t) \ template <> \ bool SGMatrix<real_t>::equals(const SGMatrix<real_t>& other) const \ { \ if (*this == other) \ return true; \ \ if (!(num_rows || num_cols || other.num_rows || other.num_cols)) \ return true; \ \ if (!matrix || !other.matrix) \ return false; \ \ if (num_rows != other.num_rows || num_cols != other.num_cols) \ return false; \ \ return std::equal( \ matrix, matrix + size(), other.matrix, \ [](const real_t& a, const real_t& b) { \ return Math::fequals<real_t>( \ a, b, std::numeric_limits<real_t>::epsilon()); \ }); \ } REAL_EQUALS(float32_t) REAL_EQUALS(float64_t) REAL_EQUALS(floatmax_t) #undef REAL_EQUALS #endif // REAL_EQUALS template <> bool SGMatrix<complex128_t>::equals(const SGMatrix<complex128_t>& other) const { if (*this==other) return true; if (matrix==nullptr || other.matrix==nullptr) return false; if (num_rows!=other.num_rows || num_cols!=other.num_cols) return false; return std::equal(matrix, matrix+size(), other.matrix, [](const complex128_t& a, const complex128_t& b) { return Math::fequals<float64_t>(a.real(), b.real(), LDBL_EPSILON) && Math::fequals<float64_t>(a.imag(), b.imag(), LDBL_EPSILON); }); } template <class T> void SGMatrix<T>::set_const(T const_elem) { assert_on_cpu(); require(matrix!=nullptr, "The underlying matrix is not allocated!"); require(num_rows>0, "Number of rows ({}) has to be positive!", num_rows); require(num_cols>0, "Number of cols ({}) has to be positive!", num_cols); std::fill(matrix, matrix+size(), const_elem); } template <class T> void SGMatrix<T>::zero() { set_const(static_cast<T>(0)); } template <class T> bool SGMatrix<T>::is_symmetric() const { assert_on_cpu(); require(matrix!=nullptr, "The underlying matrix is not allocated!"); require(num_rows>0, "Number of rows ({}) has to be positive!", num_rows); require(num_cols>0, "Number of cols ({}) has to be positive!", num_cols); if (num_rows!=num_cols) return false; for (index_t i=0; i<num_rows; ++i) { for (index_t j=i+1; j<num_cols; ++j) { if (matrix[j*num_rows+i]!=matrix[i*num_rows+j]) return false; } } return true; } #ifndef REAL_IS_SYMMETRIC #define REAL_IS_SYMMETRIC(real_t) \ template <> \ bool SGMatrix<real_t>::is_symmetric() const \ { \ assert_on_cpu(); \ \ require(matrix!=nullptr, "The underlying matrix is not allocated!"); \ require(num_rows>0, "Number of rows ({}) has to be positive!", num_rows); \ require(num_cols>0, "Number of cols ({}) has to be positive!", num_cols); \ \ if (num_rows!=num_cols) \ return false; \ \ for (index_t i=0; i<num_rows; ++i) \ { \ for (index_t j=i+1; j<num_cols; ++j) \ { \ if (!Math::fequals<real_t>(matrix[j*num_rows+i], \ matrix[i*num_rows+j], std::numeric_limits<real_t>::epsilon())) \ return false; \ } \ } \ \ return true; \ } REAL_IS_SYMMETRIC(float32_t) REAL_IS_SYMMETRIC(float64_t) REAL_IS_SYMMETRIC(floatmax_t) #undef REAL_IS_SYMMETRIC #endif // REAL_IS_SYMMETRIC template <> bool SGMatrix<complex128_t>::is_symmetric() const { assert_on_cpu(); require(matrix!=nullptr, "The underlying matrix is not allocated!"); require(num_rows>0, "Number of rows ({}) has to be positive!", num_rows); require(num_cols>0, "Number of cols ({}) has to be positive!", num_cols); if (num_rows!=num_cols) return false; for (index_t i=0; i<num_rows; ++i) { for (index_t j=i+1; j<num_cols; ++j) { if (!(Math::fequals<float64_t>(matrix[j*num_rows+i].real(), matrix[i*num_rows+j].real(), DBL_EPSILON) && Math::fequals<float64_t>(matrix[j*num_rows+i].imag(), matrix[i*num_rows+j].imag(), DBL_EPSILON))) return false; } } return true; } template <class T> T SGMatrix<T>::max_single() const { assert_on_cpu(); require(matrix!=nullptr, "The underlying matrix is not allocated!"); require(num_rows>0, "Number of rows ({}) has to be positive!", num_rows); require(num_cols>0, "Number of cols ({}) has to be positive!", num_cols); return *std::max_element(matrix, matrix+size()); } template <> complex128_t SGMatrix<complex128_t>::max_single() const { error("SGMatrix::max_single():: Not supported for complex128_t"); return complex128_t(0.0); } template <class T> SGMatrix<T> SGMatrix<T>::clone() const { if (on_gpu()) { return SGMatrix<T>(gpu_ptr->clone_vector(gpu_ptr.get(), num_rows*num_cols), num_rows, num_cols); } else { return SGMatrix<T>(clone_matrix(matrix, num_rows, num_cols), num_rows, num_cols); } } template <class T> T* SGMatrix<T>::clone_matrix(const T* matrix, int32_t nrows, int32_t ncols) { if (!matrix || !nrows || !ncols) return nullptr; require(nrows > 0, "Number of rows ({}) has to be positive!", nrows); require(ncols > 0, "Number of cols ({}) has to be positive!", ncols); auto size=int64_t(nrows)*ncols; T* result=SG_ALIGNED_MALLOC(T, size, alignment::container_alignment); sg_memcpy(result, matrix, size*sizeof(T)); return result; } template <class T> SGMatrix<T> SGMatrix<T>::empty_like(const SGMatrix<T>& other) { return SGMatrix<T>(other.num_rows, other.num_cols); } template <class T> void SGMatrix<T>::create_diagonal_matrix(T* matrix, T* v,int32_t size) { /* Need assert v.size() */ for(int64_t i=0;i<size;i++) { for(int64_t j=0;j<size;j++) { if(i==j) matrix[j*size+i]=v[i]; else matrix[j*size+i]=0; } } } template <class T> SGMatrix<T> SGMatrix<T>::slice(index_t col_start, index_t col_end) const { assert_on_cpu(); return SGMatrix<T>( get_column_vector(col_start), num_rows, col_end - col_start, false); } template <class T> SGVector<T> SGMatrix<T>::get_column(index_t col) const { assert_on_cpu(); return SGVector<T>(get_column_vector(col), num_rows, false); } template <class T> void SGMatrix<T>::set_column(index_t col, const SGVector<T>& vec) { assert_on_cpu(); ASSERT(!vec.on_gpu()) ASSERT(vec.vlen == num_rows) sg_memcpy(&matrix[num_rows * col], vec.vector, sizeof(T) * num_rows); } template <class T> void SGMatrix<T>::set_column(index_t col, SGVector<T>&& vec) { assert_on_cpu(); ASSERT(!vec.on_gpu()) ASSERT(vec.vlen == num_rows) sg_memcpy(&matrix[num_rows * col], vec.vector, sizeof(T) * num_rows); } template <class T> float64_t SGMatrix<T>::trace(float64_t* mat, int32_t cols, int32_t rows) { float64_t trace=0; for (int64_t i=0; i<rows; i++) trace+=mat[i*cols+i]; return trace; } /* Already in linalg */ template <class T> T* SGMatrix<T>::get_row_sum(T* matrix, int32_t m, int32_t n) { T* rowsums=SG_CALLOC(T, n); for (int64_t i=0; i<n; i++) { for (int64_t j=0; j<m; j++) rowsums[i]+=matrix[j+i*m]; } return rowsums; } /* Already in linalg */ template <class T> T* SGMatrix<T>::get_column_sum(T* matrix, int32_t m, int32_t n) { T* colsums=SG_CALLOC(T, m); for (int64_t i=0; i<n; i++) { for (int64_t j=0; j<m; j++) colsums[j]+=matrix[j+i*m]; } return colsums; } template <class T> void SGMatrix<T>::center() { assert_on_cpu(); center_matrix(matrix, num_rows, num_cols); } template <class T> void SGMatrix<T>::center_matrix(T* matrix, int32_t m, int32_t n) { float64_t num_data=n; T* colsums=get_column_sum(matrix, m,n); T* rowsums=get_row_sum(matrix, m,n); for (int32_t i=0; i<m; i++) colsums[i]/=num_data; for (int32_t j=0; j<n; j++) rowsums[j]/=num_data; T s=SGVector<T>::sum(rowsums, n)/num_data; for (int64_t i=0; i<n; i++) { for (int64_t j=0; j<m; j++) matrix[i*m+j]+=s-colsums[j]-rowsums[i]; } SG_FREE(rowsums); SG_FREE(colsums); } template <class T> void SGMatrix<T>::remove_column_mean() { assert_on_cpu(); /* compute "row" sums (which I would call column sums), i.e. sum of all * elements in a fixed column */ T* means=get_row_sum(matrix, num_rows, num_cols); /* substract column mean from every corresponding entry */ for (int64_t i=0; i<num_cols; ++i) { means[i]/=num_rows; for (int64_t j=0; j<num_rows; ++j) matrix[i*num_rows+j]-=means[i]; } SG_FREE(means); } template<class T> std::string SGMatrix<T>::to_string() const { assert_on_cpu(); return to_string(matrix, num_rows, num_cols); } template<class T> std::string SGMatrix<T>::to_string(const T* matrix, index_t rows, index_t cols) { std::stringstream ss; ss << std::boolalpha << "[\n"; if (rows != 0 && cols != 0) { for (int64_t i=0; i<rows; ++i) { ss << "["; for (int64_t j=0; j<cols; ++j) ss << "\t" << matrix[j*rows+i] << (j == cols - 1 ? "" : ","); ss << "]" << (i == rows-1 ? "" : ",") << "\n"; } } ss << "]"; return ss.str(); } template<class T> void SGMatrix<T>::display_matrix(const char* name) const { assert_on_cpu(); display_matrix(matrix, num_rows, num_cols, name); } template <class T> void SGMatrix<T>::display_matrix( const SGMatrix<T> matrix, const char* name, const char* prefix) { matrix.display_matrix(); } template <class T> void SGMatrix<T>::display_matrix( const T* matrix, int32_t rows, int32_t cols, const char* name, const char* prefix) { ASSERT(rows>=0 && cols>=0) io::print("{}{}={}\n", prefix, name, to_string(matrix, rows, cols).c_str()); } template <> SGMatrix<char> SGMatrix<char>::create_identity_matrix(index_t size, char scale) { not_implemented(SOURCE_LOCATION); return SGMatrix<char>(); } template <> SGMatrix<int8_t> SGMatrix<int8_t>::create_identity_matrix(index_t size, int8_t scale) { SGMatrix<int8_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<uint8_t> SGMatrix<uint8_t>::create_identity_matrix(index_t size, uint8_t scale) { SGMatrix<uint8_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<bool> SGMatrix<bool>::create_identity_matrix(index_t size, bool scale) { SGMatrix<bool> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : (!scale); } return identity_matrix; } template <> SGMatrix<int16_t> SGMatrix<int16_t>::create_identity_matrix(index_t size, int16_t scale) { SGMatrix<int16_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<uint16_t> SGMatrix<uint16_t>::create_identity_matrix(index_t size, uint16_t scale) { SGMatrix<uint16_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<int32_t> SGMatrix<int32_t>::create_identity_matrix(index_t size, int32_t scale) { SGMatrix<int32_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<uint32_t> SGMatrix<uint32_t>::create_identity_matrix(index_t size, uint32_t scale) { SGMatrix<uint32_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<int64_t> SGMatrix<int64_t>::create_identity_matrix(index_t size, int64_t scale) { SGMatrix<int64_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<uint64_t> SGMatrix<uint64_t>::create_identity_matrix(index_t size, uint64_t scale) { SGMatrix<uint64_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<float32_t> SGMatrix<float32_t>::create_identity_matrix(index_t size, float32_t scale) { SGMatrix<float32_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<float64_t> SGMatrix<float64_t>::create_identity_matrix(index_t size, float64_t scale) { SGMatrix<float64_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<floatmax_t> SGMatrix<floatmax_t>::create_identity_matrix(index_t size, floatmax_t scale) { SGMatrix<floatmax_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : 0.0; } return identity_matrix; } template <> SGMatrix<complex128_t> SGMatrix<complex128_t>::create_identity_matrix(index_t size, complex128_t scale) { SGMatrix<complex128_t> identity_matrix(size, size); for (index_t i=0; i<size; ++i) { for (index_t j=0; j<size; ++j) identity_matrix(i,j)=i==j ? scale : complex128_t(0.0); } return identity_matrix; } #ifdef HAVE_LAPACK /// inverses square matrix in-place template <class T> void SGMatrix<T>::inverse(SGMatrix<float64_t> matrix) { require(!matrix.on_gpu(), "Operation is not possible when data is in GPU memory."); ASSERT(matrix.num_cols==matrix.num_rows); int32_t* ipiv = SG_MALLOC(int32_t, matrix.num_cols); clapack_dgetrf(CblasColMajor,matrix.num_cols,matrix.num_cols,matrix.matrix,matrix.num_cols,ipiv); clapack_dgetri(CblasColMajor,matrix.num_cols,matrix.matrix,matrix.num_cols,ipiv); SG_FREE(ipiv); } template <class T> SGVector<float64_t> SGMatrix<T>::compute_eigenvectors(SGMatrix<float64_t> matrix) { require(!matrix.on_gpu(), "Operation is not possible when data is in GPU memory."); if (matrix.num_rows!=matrix.num_cols) { error("SGMatrix::compute_eigenvectors(SGMatrix<float64_t>): matrix" " rows and columns are not equal!"); } /* use reference counting for SGVector */ SGVector<float64_t> result(NULL, 0, true); result.vlen=matrix.num_rows; result.vector=compute_eigenvectors(matrix.matrix, matrix.num_rows, matrix.num_rows); return result; } template <class T> double* SGMatrix<T>::compute_eigenvectors(double* matrix, int n, int m) { ASSERT(n == m) char V='V'; char U='U'; int info; int ord=n; int lda=n; double* eigenvalues=SG_CALLOC(float64_t, n+1); // lapack sym matrix eigenvalues+vectors wrap_dsyev(V, U, ord, matrix, lda, eigenvalues, &info); if (info!=0) error("DSYEV failed with code {}", info); return eigenvalues; } template <class T> void SGMatrix<T>::compute_few_eigenvectors(double* matrix_, double*& eigenvalues, double*& eigenvectors, int n, int il, int iu) { eigenvalues = SG_MALLOC(double, n); eigenvectors = SG_MALLOC(double, (iu-il+1)*n); int status = 0; wrap_dsyevr('V','U',n,matrix_,n,il,iu,eigenvalues,eigenvectors,&status); ASSERT(status==0) } #endif //HAVE_LAPACK /* Already in linalg */ template <class T> SGMatrix<float64_t> SGMatrix<T>::matrix_multiply( SGMatrix<float64_t> A, SGMatrix<float64_t> B, bool transpose_A, bool transpose_B, float64_t scale) { require((!A.on_gpu()) && (!B.on_gpu()), "Operation is not possible when data is in GPU memory."); /* these variables store size of transposed matrices*/ index_t cols_A=transpose_A ? A.num_rows : A.num_cols; index_t rows_A=transpose_A ? A.num_cols : A.num_rows; index_t rows_B=transpose_B ? B.num_cols : B.num_rows; index_t cols_B=transpose_B ? B.num_rows : B.num_cols; /* do a dimension check */ if (cols_A!=rows_B) { error("SGMatrix::matrix_multiply(): Dimension mismatch: " "A({}x{})*B({}x%D)", rows_A, cols_A, rows_B, cols_B); } /* allocate result matrix */ SGMatrix<float64_t> C(rows_A, cols_B); C.zero(); #ifdef HAVE_LAPACK /* multiply */ cblas_dgemm(CblasColMajor, transpose_A ? CblasTrans : CblasNoTrans, transpose_B ? CblasTrans : CblasNoTrans, rows_A, cols_B, cols_A, scale, A.matrix, A.num_rows, B.matrix, B.num_rows, 0.0, C.matrix, C.num_rows); #else /* C(i,j) = scale * \Sigma A(i,k)*B(k,j) */ for (int32_t i=0; i<rows_A; i++) { for (int32_t j=0; j<cols_B; j++) { for (int32_t k=0; k<cols_A; k++) { float64_t x1=transpose_A ? A(k,i):A(i,k); float64_t x2=transpose_B ? B(j,k):B(k,j); C(i,j)+=x1*x2; } C(i,j)*=scale; } } #endif //HAVE_LAPACK return C; } template<class T> SGMatrix<T> SGMatrix<T>::get_allocated_matrix(index_t num_rows, index_t num_cols, SGMatrix<T> pre_allocated) { SGMatrix<T> result; /* evtl use pre-allocated space */ if (pre_allocated.matrix || pre_allocated.gpu_ptr) { result=pre_allocated; /* check dimension consistency */ if (pre_allocated.num_rows!=num_rows || pre_allocated.num_cols!=num_cols) { error("SGMatrix<T>::get_allocated_matrix(). Provided target" "matrix dimensions ({}x{}) do not match passed data " "dimensions ({}x{})!", pre_allocated.num_rows, pre_allocated.num_cols, num_rows, num_cols); } } else { /* otherwise, allocate space */ result=SGMatrix<T>(num_rows, num_cols); } return result; } template<class T> void SGMatrix<T>::copy_data(const SGReferencedData &orig) { gpu_ptr=((SGMatrix*)(&orig))->gpu_ptr; matrix=((SGMatrix*)(&orig))->matrix; num_rows=((SGMatrix*)(&orig))->num_rows; num_cols=((SGMatrix*)(&orig))->num_cols; #ifdef HAVE_VIENNACL m_on_gpu.store(((SGMatrix*)(&orig))->m_on_gpu.load( std::memory_order_acquire), std::memory_order_release); #endif } template<class T> void SGMatrix<T>::init_data() { matrix=NULL; num_rows=0; num_cols=0; gpu_ptr=nullptr; #ifdef HAVE_VIENNACL m_on_gpu.store(false, std::memory_order_release); #endif } template<class T> void SGMatrix<T>::free_data() { SG_FREE(matrix); matrix=NULL; num_rows=0; num_cols=0; } template<class T> void SGMatrix<T>::load(const std::shared_ptr<File>& loader) { ASSERT(loader) unref(); SG_SET_LOCALE_C; SGMatrix<T> mat; loader->get_matrix(mat.matrix, mat.num_rows, mat.num_cols); mat.gpu_ptr = nullptr; copy_data(mat); copy_refcount(mat); ref(); SG_RESET_LOCALE; } template<> void SGMatrix<complex128_t>::load(const std::shared_ptr<File>& loader) { error("SGMatrix::load():: Not supported for complex128_t"); } template<class T> void SGMatrix<T>::save(const std::shared_ptr<File>& writer) { assert_on_cpu(); ASSERT(writer) SG_SET_LOCALE_C; writer->set_matrix(matrix, num_rows, num_cols); SG_RESET_LOCALE; } template<> void SGMatrix<complex128_t>::save(const std::shared_ptr<File>& saver) { error("SGMatrix::save():: Not supported for complex128_t"); } template<class T> SGVector<T> SGMatrix<T>::get_row_vector(index_t row) const { assert_on_cpu(); SGVector<T> rowv(num_cols); for (int64_t i = 0; i < num_cols; i++) { rowv[i] = matrix[i*num_rows+row]; } return rowv; } template<class T> SGVector<T> SGMatrix<T>::get_diagonal_vector() const { assert_on_cpu(); index_t diag_vlen=Math::min(num_cols, num_rows); SGVector<T> diag(diag_vlen); for (int64_t i=0; i<diag_vlen; i++) { diag[i]=matrix[i*num_rows+i]; } return diag; } template class SGMatrix<bool>; template class SGMatrix<char>; template class SGMatrix<int8_t>; template class SGMatrix<uint8_t>; template class SGMatrix<int16_t>; template class SGMatrix<uint16_t>; template class SGMatrix<int32_t>; template class SGMatrix<uint32_t>; template class SGMatrix<int64_t>; template class SGMatrix<uint64_t>; template class SGMatrix<float32_t>; template class SGMatrix<float64_t>; template class SGMatrix<floatmax_t>; template class SGMatrix<complex128_t>; }
COMMENT 0 DEFINE COMMENT 0 eJxTYWBg0JfRMAZSDPGWT9aBaN0rD96D6Cn1K5o9lk6Tf3u4ja1q+ZJZP/d1+qdfnygCkvNNk4vjjZaL yw39l5cbum8Cb/S8hb5p8xaC5G6n8thbJ4BwT9Pt1J4mkJiXlUwEl75MRJamjXuWZo0ql/4cES+rOSKv 7GtUX9mfsVtlAsJvdBlGwSgYBXQFAEEjMOw;
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x387e, %rsi lea addresses_normal_ht+0x2ebe, %rdi clflush (%rsi) nop nop nop nop mfence mov $37, %rcx rep movsl nop nop and %rsi, %rsi lea addresses_WT_ht+0x6d62, %r9 nop nop nop nop nop inc %r14 movb (%r9), %dl nop nop nop nop cmp %r9, %r9 lea addresses_WT_ht+0x3cde, %rdx nop nop xor %r14, %r14 movw $0x6162, (%rdx) lfence lea addresses_normal_ht+0x1991a, %rbp and $17505, %r14 movb (%rbp), %dl nop nop nop nop nop add %rsi, %rsi lea addresses_D_ht+0x74fe, %rbp nop nop nop nop xor %rcx, %rcx mov $0x6162636465666768, %rsi movq %rsi, %xmm5 and $0xffffffffffffffc0, %rbp movaps %xmm5, (%rbp) nop inc %r9 lea addresses_WC_ht+0x4936, %rsi lea addresses_UC_ht+0x9027, %rdi nop nop nop and $24040, %rbp mov $4, %rcx rep movsq nop nop nop nop sub $33139, %r14 lea addresses_UC_ht+0x2c9e, %rsi lea addresses_normal_ht+0xf87e, %rdi dec %r12 mov $38, %rcx rep movsl nop nop nop nop dec %r14 lea addresses_WC_ht+0x1692e, %rcx nop nop nop nop nop sub %rdx, %rdx vmovups (%rcx), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $1, %xmm2, %rsi nop nop nop dec %rdx lea addresses_WT_ht+0x96ae, %rsi lea addresses_D_ht+0x1347e, %rdi clflush (%rsi) sub $54642, %r14 mov $23, %rcx rep movsb nop nop sub %rcx, %rcx lea addresses_WC_ht+0x1404e, %r9 and %rcx, %rcx vmovups (%r9), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %r14 nop sub %r9, %r9 lea addresses_D_ht+0x1a5de, %r14 nop nop xor %rsi, %rsi mov (%r14), %cx xor $49694, %rcx lea addresses_D_ht+0x159fe, %r9 nop nop nop nop cmp %rdx, %rdx vmovups (%r9), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $0, %xmm5, %r14 nop nop and $1237, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r14 push %r15 push %r8 push %r9 push %rbp push %rbx push %rdx // Load mov $0xbe, %rbx nop nop inc %r8 movb (%rbx), %r14b nop sub %rbx, %rbx // Store lea addresses_UC+0x3919, %rdx nop nop nop inc %rbp mov $0x5152535455565758, %r14 movq %r14, (%rdx) nop nop nop nop add %rbp, %rbp // Store lea addresses_UC+0x10c7e, %r9 nop add $27638, %rbp movw $0x5152, (%r9) sub $56591, %rbx // Store lea addresses_D+0x1f424, %r9 and %rbp, %rbp movw $0x5152, (%r9) nop nop cmp $45064, %rbx // Load lea addresses_WT+0xa37e, %r15 nop dec %r9 mov (%r15), %dx nop cmp $44666, %r15 // Load lea addresses_normal+0x1bcbe, %r14 nop nop nop nop dec %r8 mov (%r14), %rbp nop nop nop nop nop sub %r15, %r15 // Store lea addresses_WC+0x11c7e, %r9 nop nop nop nop sub %r15, %r15 movl $0x51525354, (%r9) nop add $10521, %r15 // Faulty Load lea addresses_UC+0x10c7e, %rbx sub %r15, %r15 mov (%rbx), %r14 lea oracles, %r9 and $0xff, %r14 shlq $12, %r14 mov (%r9,%r14,1), %r14 pop %rdx pop %rbx pop %rbp pop %r9 pop %r8 pop %r15 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 6, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 11, 'size': 4, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 4, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 1, 'size': 1, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 5, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 6, 'size': 32, 'same': False, 'NT': False}} {'52': 66, '0a': 1, '7a': 1, '7c': 1, '96': 1, '54': 21758, '74': 1} 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 52 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 52 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 */
; Super Face Right ; Sprite mode is 8 x 16 Meta_00: .byte $F6, $00, $00, $20, $02 .byte $06, $00, $02, $20, $02 .byte $F6, $10, $20, $20, $02 .byte $06, $10, $22, $20, $02 .byte $80 ;end of data ; Super Face Left ; Sprite mode is 8 x 16 Meta_01: .byte $F6, $00, $02, $60, $02 .byte $06, $00, $00, $60, $02 .byte $F6, $10, $22, $60, $02 .byte $06, $10, $20, $60, $02 .byte $80 ;end of data ; Spike Ball ; Sprite mode is 8 x 16 Meta_02: .byte $FD, $FE, $04, $22, $02 .byte $0D, $FE, $06, $22, $02 .byte $FD, $0E, $24, $22, $02 .byte $0D, $0E, $26, $22, $02 .byte $80 ;end of data
; ; Memory buffer writer ; Writer: MACRO ; a = value ; hl = return address ; ix = this Write: ld (0),a bufferPosition: equ $ - 2 inc (ix + Writer.bufferPosition) jr z,Write_Continue ; unlikely jp hl Write_Continue: push hl jp Writer_Write.Continue bufferStart: dw 0 bufferSize: dw 0 bufferEnd: dw 0 bufferEndCopyMargin: db 0 flusher: dw System_ThrowException count: dd 0 _size: ENDM Writer_class: Class Writer, Writer_template, Heap_main Writer_template: Writer ; hl = buffer start ; bc = buffer size ; de = buffer flusher ; ix = this ; ix <- this ; de <- this Writer_Construct: ld a,l ; check if buffer is 256-byte aligned or c call nz,System_ThrowException ld (ix + Writer.bufferStart),l ld (ix + Writer.bufferStart + 1),h ld (ix + Writer.bufferSize),c ld (ix + Writer.bufferSize + 1),b ld (ix + Writer.flusher),e ld (ix + Writer.flusher + 1),d ld (ix + Writer.bufferPosition),l ld (ix + Writer.bufferPosition + 1),h add hl,bc ld (ix + Writer.bufferEnd),l ld (ix + Writer.bufferEnd + 1),h dec h dec h dec h ld (ix + Writer.bufferEndCopyMargin),h ld (ix + Writer.count),0 ld (ix + Writer.count + 1),0 ld (ix + Writer.count + 2),0 ld (ix + Writer.count + 3),0 ld e,ixl ld d,ixh ret ; ix = this ; ix <- this Writer_Destruct: ret ; a = value ; ix = this ; Modifies: hl Writer_WriteInline_JumpHL: MACRO jp ix ENDM ; a = value ; ix = this ; Modifies: f, hl Writer_Write: PROC pop hl Writer_WriteInline_JumpHL Continue: push af ld a,(ix + Writer.bufferPosition + 1) inc a ld (ix + Writer.bufferPosition + 1),a cp (ix + Writer.bufferEnd + 1) call z,Writer_FinishBlock pop af ret ENDP ; bc = byte count (range 3-258) ; hl = -distance ; ix = this ; Modifies: af, bc, de, hl Writer_Copy: PROC ld e,(ix + Writer.bufferPosition) ld d,(ix + Writer.bufferPosition + 1) add hl,de ld a,h jr nc,Wrap cp (ix + Writer.bufferStart + 1) jr c,Wrap ld a,(ix + Writer.bufferEndCopyMargin) WrapContinue: cp d ; does the destination have a 512 byte margin without wrapping? jr c,Writer_Copy_Slow ldi ldi ldir ld (ix + Writer.bufferPosition),e ld (ix + Writer.bufferPosition + 1),d ret Wrap: add a,(ix + Writer.bufferSize + 1) ld h,a ld a,(ix + Writer.bufferEndCopyMargin) cp h ; does the source have a 512 byte margin without wrapping? jp nc,WrapContinue jp Writer_Copy_Slow ENDP ; bc = byte count ; hl = buffer source ; ix = this ; Modifies: af, bc, de, hl Writer_Copy_Slow: PROC ld e,l ld d,h add hl,bc jr c,Split ld a,h cp (ix + Writer.bufferEnd + 1) jp c,Writer_WriteBlock ; hl = end address Split: push bc ld c,(ix + Writer.bufferEnd) ld b,(ix + Writer.bufferEnd + 1) and a sbc hl,bc ; hl = bytes past end ex (sp),hl pop bc push bc sbc hl,bc ; hl = bytes until end ld c,l ld b,h call Writer_WriteBlock pop bc ld l,(ix + Writer.bufferStart) ld h,(ix + Writer.bufferStart + 1) ld a,b or c jp nz,Writer_Copy_Slow ret ENDP ; bc = byte count ; de = source ; ix = this ; Modifies: af, bc, de, hl Writer_WriteBlock: PROC ld l,(ix + Writer.bufferPosition) ld h,(ix + Writer.bufferPosition + 1) add hl,bc jr c,Split ld a,h cp (ix + Writer.bufferEnd + 1) jr nc,Split and a sbc hl,bc ex de,hl call System_FastLDIR ld (ix + Writer.bufferPosition),e ld (ix + Writer.bufferPosition + 1),d ret ; hl = end address Split: push bc ld c,(ix + Writer.bufferEnd) ld b,(ix + Writer.bufferEnd + 1) and a sbc hl,bc ; hl = bytes past end ld c,l ld b,h ex (sp),hl and a sbc hl,bc ; hl = bytes until end ld c,l ld b,h ex de,hl ld e,(ix + Writer.bufferPosition) ld d,(ix + Writer.bufferPosition + 1) call System_FastLDIR ld (ix + Writer.bufferPosition),e ld (ix + Writer.bufferPosition + 1),d call Writer_FinishBlock ex de,hl ld l,(ix + Writer.bufferPosition) ld h,(ix + Writer.bufferPosition + 1) pop bc ld a,b or c jp nz,Writer_WriteBlock ret ENDP ; Write block directly into buffer ; Afterwards, invoke Advance with the nr of bytes actually written ; ix = this ; bc <- max bytes to write ; de <- destination ; Modifies: af Writer_WriteBlockDirect: ld e,(ix + Writer.bufferPosition) ld d,(ix + Writer.bufferPosition + 1) ld a,e neg ld c,a ld a,(ix + Writer.bufferEnd + 1) sbc a,d ld b,a ret ; bc = nr of bytes to advance ; ix = this ; Modifies: af, bc, hl Writer_Advance: PROC ld l,(ix + Writer.bufferPosition) ld h,(ix + Writer.bufferPosition + 1) add hl,bc ld b,(ix + Writer.bufferEnd + 1) jr c,Overflow ld a,h cp b jr nc,Overflow ld (ix + Writer.bufferPosition),l ld (ix + Writer.bufferPosition + 1),h ret Overflow: ld c,0 ld (ix + Writer.bufferPosition),c ld (ix + Writer.bufferPosition + 1),b call Writer_FinishBlock and a sbc hl,bc jr nz,Writer_Advance ret ENDP ; bc = byte count ; ix = this ; iy = reader Writer_CopyFromReader: PROC Loop: ld a,c or b ret z push bc call Reader_ReadBlockDirect_IY push bc ex de,hl call Writer_WriteBlock pop bc pop hl and a sbc hl,bc call c,System_ThrowException ld c,l ld b,h jp Loop ENDP ; debc = byte count ; iy = this ; iy = reader Writer_CopyFromReader32: PROC ld a,c or b push de call nz,Writer_CopyFromReader pop de inc de Loop: dec de ld a,e or d ret z push de ld bc,8000H call Writer_CopyFromReader ld bc,8000H call Writer_CopyFromReader pop de jp Loop ENDP ; ix = this ; hl <- buffer position ; Modifies: af Writer_FinishBlock: PROC push bc push de push hl ld l,(ix + Writer.bufferPosition) ld h,(ix + Writer.bufferPosition + 1) ld e,(ix + Writer.bufferStart) ld d,(ix + Writer.bufferStart + 1) and a sbc hl,de call c,System_ThrowException jr z,Empty ld c,l ld b,h push bc push de call Writer_IncreaseCount pop de pop bc call Writer_FlushBuffer Empty: pop hl pop de pop bc ld a,(ix + Writer.bufferStart) ld (ix + Writer.bufferPosition),a ld a,(ix + Writer.bufferStart + 1) ld (ix + Writer.bufferPosition + 1),a ret ENDP ; The flusher is called with bc = byte count, de = buffer start ; ix = this ; Modifies: af, bc, de, hl Writer_FlushBuffer: ld l,(ix + Writer.flusher) ld h,(ix + Writer.flusher + 1) jp hl ; bc = byte count ; de = buffer start ; ix = this Writer_DefaultFlusher: ret ; bc = byte count ; ix = this ; Modifies: hl Writer_IncreaseCount: ld l,(ix + Writer.count) ld h,(ix + Writer.count + 1) add hl,bc ld (ix + Writer.count),l ld (ix + Writer.count + 1),h ret nc inc (ix + Writer.count + 2) ret nz inc (ix + Writer.count + 3) ret ; ix = this ; bcde <- count bytes written Writer_GetCount: ld e,(ix + Writer.count) ld d,(ix + Writer.count + 1) ld c,(ix + Writer.count + 2) ld b,(ix + Writer.count + 3) ret
; A159918: Number of ones in binary representation of n^2. ; 0,1,1,2,1,3,2,3,1,3,3,5,2,4,3,4,1,3,3,5,3,6,5,3,2,5,4,6,3,5,4,5,1,3,3,5,3,6,5,7,3,5,6,7,5,8,3,4,2,5,5,5,4,8,6,7,3,6,5,7,4,6,5,6,1,3,3,5,3,6,5,7,3,6,6,9,5,7,7,5,3,6,5,8,6,7,7,7,5,9,8,5,3,6,4,5,2,5,5,6 pow $0,2 mov $2,$0 lpb $0 div $2,2 sub $0,$2 lpe
section .data newline_char: db 10 codes: db '0123456789abcdef' section .text global _start print_newline: mov rax, 1 ; 'write' syscall identifier mov rdi, 1 ; stdout file descriptor mov rsi, newline_char ; where do we take data from mov rdx, 1 ; the amount of bytes to write syscall ret print_hex: mov rax, rdi mov rdi, 1 mov rdx, 1 mov rcx, 64 ; how far are we shifting rax? iterate: push rax ; save the initial rax value sub rcx, 4 sar rax, cl ; shift to 60, 56, 52, ... 4, 0 ; the cl register is the smallest part of rcx and rax, 0xf ; clear all bits but the lowest four lea rsi, [codes + rax] ; take a hexadecimal digit character code mov rax, 1 push rcx ; syscall will break rcx syscall ; rax = 1 (31) -- the write identifier ; rdi = 1 for stdout ; rsi = the address of a character, see line 29 pop rcx pop rax ; see line 24 test rcx, rcx ; rcx = 0 when all digits are shown jnz iterate ret _start: mov rdi, 0x1122334455667788 call print_hex call print_newline mov rax, 60 xor rdi, rdi syscall
2D sparse table? Range Max
; ---------------------------------------------------------------------------------------- ; Infinite Counter Runs on 64-bit Linux only. ; To assemble and run: ; ; nasm -felf64 randomOutput.asm && ld randomOutput.o && ./a.out ; ---------------------------------------------------------------------------------------- section .text global _start _start: mov rax, 1 mov rdi, 1 mov rsi, count mov rdx, 13 syscall inc word [count] jmp _start section .data count: DW 0
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; ==++== ; ; ; ==--== ; *********************************************************************** ; File: JitHelpers_SingleAppDomain.asm ; ; Notes: JIT Static access helpers when coreclr host specifies single ; appdomain flag ; *********************************************************************** include AsmMacros.inc include asmconstants.inc ; Min amount of stack space that a nested function should allocate. MIN_SIZE equ 28h extern JIT_GetSharedNonGCStaticBase_Helper:proc extern JIT_GetSharedGCStaticBase_Helper:proc LEAF_ENTRY JIT_GetSharedNonGCStaticBase_SingleAppDomain, _TEXT ; If class is not initialized, bail to C++ helper test byte ptr [rcx + OFFSETOF__DomainLocalModule__m_pDataBlob + rdx], 1 jz CallHelper mov rax, rcx REPRET align 16 CallHelper: ; Tail call JIT_GetSharedNonGCStaticBase_Helper jmp JIT_GetSharedNonGCStaticBase_Helper LEAF_END JIT_GetSharedNonGCStaticBase_SingleAppDomain, _TEXT LEAF_ENTRY JIT_GetSharedNonGCStaticBaseNoCtor_SingleAppDomain, _TEXT mov rax, rcx ret LEAF_END JIT_GetSharedNonGCStaticBaseNoCtor_SingleAppDomain, _TEXT LEAF_ENTRY JIT_GetSharedGCStaticBase_SingleAppDomain, _TEXT ; If class is not initialized, bail to C++ helper test byte ptr [rcx + OFFSETOF__DomainLocalModule__m_pDataBlob + rdx], 1 jz CallHelper mov rax, [rcx + OFFSETOF__DomainLocalModule__m_pGCStatics] REPRET align 16 CallHelper: ; Tail call Jit_GetSharedGCStaticBase_Helper jmp JIT_GetSharedGCStaticBase_Helper LEAF_END JIT_GetSharedGCStaticBase_SingleAppDomain, _TEXT LEAF_ENTRY JIT_GetSharedGCStaticBaseNoCtor_SingleAppDomain, _TEXT mov rax, [rcx + OFFSETOF__DomainLocalModule__m_pGCStatics] ret LEAF_END JIT_GetSharedGCStaticBaseNoCtor_SingleAppDomain, _TEXT end
; A040461: Continued fraction for sqrt(483). ; 21,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42 mov $1,21 lpb $0 mod $0,2 mul $1,2 lpe gcd $1,$0
// Never Spawn Fat Race Penguin in CCM origin 0x0CB7FC base 0x803107FC b 0x8031083C // 813107FC 1000
;****************************************************************************** ;* I_TOFS16.ASM - 16 BIT STATE - * ;* * ;* Copyright (c) 1996 Texas Instruments Incorporated * ;* http://www.ti.com/ * ;* * ;* Redistribution and use in source and binary forms, with or without * ;* modification, are permitted provided that the following conditions * ;* are met: * ;* * ;* Redistributions of source code must retain the above copyright * ;* notice, this list of conditions and the following disclaimer. * ;* * ;* Redistributions in binary form must reproduce the above copyright * ;* notice, this list of conditions and the following disclaimer in * ;* the documentation and/or other materials provided with the * ;* distribution. * ;* * ;* Neither the name of Texas Instruments Incorporated nor the names * ;* of its contributors may be used to endorse or promote products * ;* derived from this software without specific prior written * ;* permission. * ;* * ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * ;* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * ;* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * ;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * ;* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * ;* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * ;* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ;* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ;* * ;****************************************************************************** ;**************************************************************************** ;* I$TOFS - CONVERT A 32 BIT SIGNED INTEGER TO AN IEEE 754 FORMAT ;* SINGLE PRECISION FLOATING POINT NUMBER ;**************************************************************************** ;* ;* o INPUT OP IS IN R0 ;* o RESULT IS RETURNED IN R0 ;* ;* o ROUNDING MODE: ROUND TO NEAREST ;* ;**************************************************************************** ;* ;* +--------------------------------------------------------------+ ;* | SINGLE PRECISION FLOATING POINT FORMAT | ;* | | ;* | 31 30 23 22 0 | ;* | +-+--------+-----------------------+ | ;* | |S| E | M + | ;* | +-+--------+-----------------------+ | ;* | | ;* | <S> SIGN FIELD : 0 - POSITIVE VALUE | ;* | 1 - NEGATIVE VALUE | ;* | | ;* | <E> EXPONENT FIELD: 00 - ZERO IFF M == 0 | ;* | 01...FE - EXPONENT VALUE (127 BIAS) | ;* | FF - INFINITY | ;* | | ;* | <M> MANTISSA FIELD: FRACTIONAL MAGNITUDE WITH IMPLIED 1 | ;* +--------------------------------------------------------------+ ;* ;**************************************************************************** .thumb .if __TI_EABI_ASSEMBLER ; ASSIGN EXTERNAL NAMES BASED ON .asg __aeabi_i2f, __TI_I$TOFS ; RTS BEING BUILT .else .clink .asg I$TOFS, __TI_I$TOFS .endif m0 .set r1 e0 .set r2 .if __TI_ARM9ABI_ASSEMBLER | __TI_EABI_ASSEMBLER .thumbfunc __TI_I$TOFS .endif .global __TI_I$TOFS __TI_I$TOFS: .asmfunc stack_usage(8) PUSH {r1, r2} ; SAVE CONTEXT MOVS e0, #0x9E ; SET THE EXPONENT FIELD CMP r0, #0 ; IF ZERO, RETURN ZERO BMI $1 ; BNE $2 ; POP {r1, r2} ; BX lr ; $1: NEGS m0, r0 ; IF NEGATIVE, NEGATE IT BMI cont ; B loop ; $2: MOVS m0, r0 ; loop: SUBS e0, #1 ; NORMALIZE THE MANTISSA LSLS m0, m0, #1 ; ADJUSTING THE EXPONENT, ACCORDINGLY BPL loop ; cont: ADDS m0, #0x80 ; ADD 1/2 TO ROUND BCC $3 ; ADDS e0, #0x1 ; AND ADJUST THE EXPONENT ACCORDINGLY B $4 ; $3: LSLS m0, m0, #1 ; MASK IMPLIED 1 OUT OF THE MANTISSA $4: LSRS m0, m0, #9 ; PACK THE MANTISSA LSLS e0, e0, #23 ; ORRS m0, e0 ; PACK THE EXPONENT CMP r0, #0 ; IF THE INPUT WAS NEGATIVE BPL $5 ; MOVS e0, #1 ; LSLS e0, e0, #31 ; ORRS m0, e0 ; THEN SET THE SIGN FIELD $5: MOVS r0, m0 ; POP {r1, r2} ; RESTORE CONTEXT BX lr ; .endasmfunc .end
;***************************************************************** ;* - Description: Device definition file for RC Calibration ;* - File: m8535.asm ;* - AppNote: AVR053 - Production calibration of the ;* RC oscillator ;* ;* - Author: Atmel Corporation: http://www.atmel.com ;* Support email: avr@atmel.com ;* ;* $Name$ ;* $Revision: 56 $ ;* $RCSfile$ ;* $Date: 2006-02-16 17:44:45 +0100 (to, 16 feb 2006) $ ;***************************************************************** .include "m8535def.inc" .include "Common\memoryMap.inc" .include "Device specific\s8535_family_pinout.inc" .equ OSC_VER = 3
; KC Driver ; ; We need to be low in memory or we might get paged out ; ; The screen layout is "interesting" to say the least on the KC machines ; SECTION driver_clib PUBLIC generic_console_cls PUBLIC generic_console_scrollup PUBLIC generic_console_printc PUBLIC generic_console_set_ink PUBLIC generic_console_set_paper PUBLIC generic_console_set_attribute PUBLIC generic_console_xypos PUBLIC kc_attr PUBLIC kc_type EXTERN conio_map_colour EXTERN generic_console_udg32 EXTERN generic_console_font32 EXTERN generic_console_flags EXTERN generic_console_w EXTERN CONSOLE_COLUMNS EXTERN CONSOLE_ROWS EXTERN l_jphl INCLUDE "target/kc/def/caos.def" generic_console_set_ink: call conio_map_colour rlca rlca rlca and @01111000 ld b,@10000111 set_attr: ld c,a ld hl,kc_attr ld a,(hl) and b or c ld (hl),a generic_console_set_attribute: ret generic_console_set_paper: call conio_map_colour and 7 ld b,@11111000 jr set_attr ret generic_console_cls: in a,($88) push af ;Save value set 2,a ;Page video in out ($88),a ld a,(iy+1) ;port 84 res 1,a ld (iy+1),a out ($84),a ;pixels ld hl,32768 ld de,32769 ld bc,+(CONSOLE_ROWS * CONSOLE_COLUMNS * 8 ) ld (hl),0 ldir ld a,(kc_type) and a jr z,clear_attributes_kc85_2_3 ld a,(iy+1) ;port 84 set 1,a ld (iy+1),a out ($84),a ;pixels ld hl,32768 ld de,32769 ld bc,+(CONSOLE_ROWS * CONSOLE_COLUMNS * 8 ) ld a,(kc_attr) ld (hl),a ldir jr cls_rejoin clear_attributes_kc85_2_3: ; Now we point to start of colour memory ; Consider KC85/2 first of all ld bc,+(CONSOLE_ROWS * CONSOLE_COLUMNS * 2) ld a,(kc_attr) ld (hl),a ldir cls_rejoin: pop af ;And restore paging out ($88),a ret scrollup_85_4: ld b,CONSOLE_COLUMNS ld hl,$8008 ld de,$8000 scrollup_85_4_1: push bc push hl push de ld a,(iy+1) res 1,a ld (iy+1),a out ($84),a ld bc,248 ldir set 1,a ld (iy+1),a out ($84),a pop de pop hl push hl push de ld bc,248 ldir pop de pop hl inc d inc h pop bc djnz scrollup_85_4_1 ; Now blank some characters ld bc, + (CONSOLE_ROWS - 1) * 256 jp print_blank_row generic_console_scrollup: push de push bc in a,($88) push af set 2,a out ($88),a ld a,(kc_type) and a jr nz,scrollup_85_4 ld bc, 0 loop: push bc push bc call generic_console_xypos pop bc push hl ;save destination address inc b ;row 1 call generic_console_xypos pop de ;de = destination, hl = source row push hl push de ld c,$20 call scroll_half pop hl ;destination ld bc,$20 add hl,bc ex de,hl pop hl add hl,bc ld c,$20 call scroll_half ; Now do the RHS pop bc push bc ld c,32 push bc call generic_console_xypos pop bc push hl ;Save destination address inc b call generic_console_xypos pop de ;Get back destination address push hl push de ld c,$08 call scroll_half pop hl ;destination ld bc,$20 add hl,bc ex de,hl pop hl add hl,bc ld c,$08 call scroll_half ; Now do the colour attributes pop bc push bc ;LHS push bc call cxypos pop bc push hl ;Save destination address inc b call cxypos pop de ;Get back destination address ld c,$20 call scroll_colour_half ; Now do the RHS of the colour pop bc push bc ld c,32 push bc call cxypos pop bc push hl ;Save destination address inc b call cxypos pop de ;Get back destination address ld c,$08 call scroll_colour_half pop bc inc b ld a,b cp 31 jp nz,loop print_blank_row: ; And now blank out the bottom row - print a space ld a,40 blank_row: push af ld a,' ' ld d,a ld e,0 push bc call generic_console_printc pop bc inc c pop af dec a jr nz,blank_row pop af out ($88),a scrollup_done: pop bc pop de ret ; Scroll x number of rows (graphics) ; Entry: de = destination ; hl = source ; c = number of columns ; b = number of rows scroll_half: ld b,4 scroll_half_loop: push bc push hl push de ld b,0 ldir pop hl ;dest ld bc,128 add hl,bc ex de,hl pop hl ;source add hl,bc pop bc djnz scroll_half_loop ret ; Scroll x number of rows (colour) ; Entry: de = destination ; hl = source ; c = number of columns ; b = number of rows scroll_colour_half: ld b,2 scroll_colour_half_loop: push bc push hl push de ld b,0 ldir pop hl ;dest ld bc,32 add hl,bc ex de,hl pop hl ;source add hl,bc pop bc djnz scroll_colour_half_loop ret ; c = x ; b = y ; a = d = character to print ; e = raw generic_console_printc: ; Here we can interpret any extra codes (eg for setting colours) ex af,af in a,($88) push af set 2,a out ($88),a ex af,af ld l,d ld h,0 ld de,(generic_console_font32) bit 7,l jr z,not_udg res 7,l ld de,(generic_console_udg32) inc d not_udg: add hl,hl add hl,hl add hl,hl add hl,de dec h ex de,hl ;de = font ld a,(kc_type) and a jr nz,printc_kc85_4 push bc push de call generic_console_xypos pop de push hl ld a,(generic_console_flags) rlca sbc a,a ld c,a ;c = 0 /255 call print_half pop hl ld a,l add $20 ld l,a call print_half ; And now colour (again only KC82/2) pop bc call cxypos ld de,$20 ld a,(kc_attr) ld (hl),a add hl,de ld (hl),a pop af out ($88),a ret print_half: ld b,4 hires_printc_1: ld a,(de) xor c ld (hl),a inc de ld a,l add $80 ld l,a jr nc,no_overflow inc h no_overflow: djnz hires_printc_1 ret ; Print to a kc85_4 screen ; de = font ; bc = xypos ; On stack, old value for port 88 printc_kc85_4: ld a,(iy+1) ;iy = ix, this is port 0x84 copy res 1,a ld (iy+1),a out ($84),a call xypos_85_4 push hl ;Save address ld a,(generic_console_flags) rlca sbc a,a ld c,a ;c = 0 /255 ld b,8 printc_kc85_4_1: ld a,(de) xor c ld (hl),a inc de inc l djnz printc_kc85_4_1 ; Now, do the attributes pop hl ;address back ld a,(iy+1) ;iy = ix, this is port 0x84 copy set 1,a ;select attributes ld (iy+1),a out ($84),a ld b,8 ld a,(kc_attr) printc_kc85_4_2: ld (hl),a inc l djnz printc_kc85_4_2 pop af out ($88),a ret ; Colour generic_console_xypos ; Columns 0 - 31 = row * $40 $a8 base ; Columns 32 - 40 = for every 8 by $80, for each 2 rows increment by $8, if odd add $40 $b000 base cxypos: ld a,c sub 32 jr c,colour_lhs ld c,a ld a,b rrca rrca rrca and @00000111 ld h,a ld l,0 srl h ;*80 rr l ld a,b ; (y / 2) * 8 rlca rlca and @00011000 add c ld c,a rr b ld b,$b0 jr nc,not_overflow add $40 ld c,a jr nc,not_overflow inc b not_overflow: add hl,bc ret colour_lhs: ld h,b ld l,0 srl h rr l srl h rr l ld b,$a8 add hl,bc ret ; Entry: b = row ; c = column ; Exit: hl = address xypos_85_4: Ld a,c add $80 ld h,a ld a,b add a add a add a ld l,a ret ; $8000 base ; Columns 0 - 31 for every 8 by $800 For each 2 rows increment by $200, if the odd row add $40 ; $a000 ; Colums 32-40 for every 8 rows $200 for each 2 rows increment by $8, if odd add $40 generic_console_xypos: ld a,(kc_type) and a jr nz,xypos_85_4 ld a,c sub 32 jr c,lhs ld c,a ld a,b ;per block of 8 rrca rrca and @00000110 ld h,a ld l,0 ld a,b ;per block of two rlca rlca and @00011000 bit 0,b jr z,not_odd_rhs add $40 not_odd_rhs: ld l,a ld b,$a0 add hl,bc ret lhs: ld a,b ;y and @11111110 ;Disregard low bit ld h,a ld l,0 bit 0,b jr z,not_odd_lhs ld l,$40 not_odd_lhs: ld b,$80 add hl,bc ret SECTION code_crt_init ; Remove the cursor ld hl,0xffff ld (CURSO_COL),hl ld hl,$0001 call PV1 defb FNPADR ld l,0 ld a,h cp $81 jr nz,not_kc85_4 inc l ld a,(iy+1) res 0,a ;display image 0 res 2,a ;cpu access 0 set 3,a ;disable hicolor ld (iy+1),a out ($84),a not_kc85_4: ld a,l ld (kc_type),a SECTION bss_clib .kc_type defb 0 ;holds 1 for KC85/4 SECTION data_clib .kc_attr defb @01111000
; A047589: Numbers that are congruent to {6, 7} mod 8. ; 6,7,14,15,22,23,30,31,38,39,46,47,54,55,62,63,70,71,78,79,86,87,94,95,102,103,110,111,118,119,126,127,134,135,142,143,150,151,158,159,166,167,174,175,182,183,190,191,198,199,206,207,214,215,222,223,230,231 mov $1,$0 div $0,2 mul $0,6 add $1,$0 add $1,6
_rm: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: bf 01 00 00 00 mov $0x1,%edi 16: 83 ec 08 sub $0x8,%esp 19: 8b 31 mov (%ecx),%esi 1b: 8b 59 04 mov 0x4(%ecx),%ebx 1e: 83 c3 04 add $0x4,%ebx int i; if(argc < 2){ 21: 83 fe 01 cmp $0x1,%esi 24: 7e 3e jle 64 <main+0x64> 26: 8d 76 00 lea 0x0(%esi),%esi 29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi printf(2, "Usage: rm files...\n"); exit(); } for(i = 1; i < argc; i++){ if(unlink(argv[i]) < 0){ 30: 83 ec 0c sub $0xc,%esp 33: ff 33 pushl (%ebx) 35: e8 e8 02 00 00 call 322 <unlink> 3a: 83 c4 10 add $0x10,%esp 3d: 85 c0 test %eax,%eax 3f: 78 0f js 50 <main+0x50> for(i = 1; i < argc; i++){ 41: 83 c7 01 add $0x1,%edi 44: 83 c3 04 add $0x4,%ebx 47: 39 fe cmp %edi,%esi 49: 75 e5 jne 30 <main+0x30> printf(2, "rm: %s failed to delete\n", argv[i]); break; } } exit(); 4b: e8 82 02 00 00 call 2d2 <exit> printf(2, "rm: %s failed to delete\n", argv[i]); 50: 50 push %eax 51: ff 33 pushl (%ebx) 53: 68 bc 07 00 00 push $0x7bc 58: 6a 02 push $0x2 5a: e8 f1 03 00 00 call 450 <printf> break; 5f: 83 c4 10 add $0x10,%esp 62: eb e7 jmp 4b <main+0x4b> printf(2, "Usage: rm files...\n"); 64: 52 push %edx 65: 52 push %edx 66: 68 a8 07 00 00 push $0x7a8 6b: 6a 02 push $0x2 6d: e8 de 03 00 00 call 450 <printf> exit(); 72: e8 5b 02 00 00 call 2d2 <exit> 77: 66 90 xchg %ax,%ax 79: 66 90 xchg %ax,%ax 7b: 66 90 xchg %ax,%ax 7d: 66 90 xchg %ax,%ax 7f: 90 nop 00000080 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 80: 55 push %ebp 81: 89 e5 mov %esp,%ebp 83: 53 push %ebx 84: 8b 45 08 mov 0x8(%ebp),%eax 87: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 8a: 89 c2 mov %eax,%edx 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 90: 83 c1 01 add $0x1,%ecx 93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 97: 83 c2 01 add $0x1,%edx 9a: 84 db test %bl,%bl 9c: 88 5a ff mov %bl,-0x1(%edx) 9f: 75 ef jne 90 <strcpy+0x10> ; return os; } a1: 5b pop %ebx a2: 5d pop %ebp a3: c3 ret a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000b0 <strcmp>: int strcmp(const char *p, const char *q) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 53 push %ebx b4: 8b 55 08 mov 0x8(%ebp),%edx b7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) ba: 0f b6 02 movzbl (%edx),%eax bd: 0f b6 19 movzbl (%ecx),%ebx c0: 84 c0 test %al,%al c2: 75 1c jne e0 <strcmp+0x30> c4: eb 2a jmp f0 <strcmp+0x40> c6: 8d 76 00 lea 0x0(%esi),%esi c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; d0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) d3: 0f b6 02 movzbl (%edx),%eax p++, q++; d6: 83 c1 01 add $0x1,%ecx d9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) dc: 84 c0 test %al,%al de: 74 10 je f0 <strcmp+0x40> e0: 38 d8 cmp %bl,%al e2: 74 ec je d0 <strcmp+0x20> return (uchar)*p - (uchar)*q; e4: 29 d8 sub %ebx,%eax } e6: 5b pop %ebx e7: 5d pop %ebp e8: c3 ret e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; f2: 29 d8 sub %ebx,%eax } f4: 5b pop %ebx f5: 5d pop %ebp f6: c3 ret f7: 89 f6 mov %esi,%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <strlen>: uint strlen(const char *s) { 100: 55 push %ebp 101: 89 e5 mov %esp,%ebp 103: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 106: 80 39 00 cmpb $0x0,(%ecx) 109: 74 15 je 120 <strlen+0x20> 10b: 31 d2 xor %edx,%edx 10d: 8d 76 00 lea 0x0(%esi),%esi 110: 83 c2 01 add $0x1,%edx 113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 117: 89 d0 mov %edx,%eax 119: 75 f5 jne 110 <strlen+0x10> ; return n; } 11b: 5d pop %ebp 11c: c3 ret 11d: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 120: 31 c0 xor %eax,%eax } 122: 5d pop %ebp 123: c3 ret 124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000130 <memset>: void* memset(void *dst, int c, uint n) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 57 push %edi 134: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 137: 8b 4d 10 mov 0x10(%ebp),%ecx 13a: 8b 45 0c mov 0xc(%ebp),%eax 13d: 89 d7 mov %edx,%edi 13f: fc cld 140: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 142: 89 d0 mov %edx,%eax 144: 5f pop %edi 145: 5d pop %ebp 146: c3 ret 147: 89 f6 mov %esi,%esi 149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000150 <strchr>: char* strchr(const char *s, char c) { 150: 55 push %ebp 151: 89 e5 mov %esp,%ebp 153: 53 push %ebx 154: 8b 45 08 mov 0x8(%ebp),%eax 157: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 15a: 0f b6 10 movzbl (%eax),%edx 15d: 84 d2 test %dl,%dl 15f: 74 1d je 17e <strchr+0x2e> if(*s == c) 161: 38 d3 cmp %dl,%bl 163: 89 d9 mov %ebx,%ecx 165: 75 0d jne 174 <strchr+0x24> 167: eb 17 jmp 180 <strchr+0x30> 169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 170: 38 ca cmp %cl,%dl 172: 74 0c je 180 <strchr+0x30> for(; *s; s++) 174: 83 c0 01 add $0x1,%eax 177: 0f b6 10 movzbl (%eax),%edx 17a: 84 d2 test %dl,%dl 17c: 75 f2 jne 170 <strchr+0x20> return (char*)s; return 0; 17e: 31 c0 xor %eax,%eax } 180: 5b pop %ebx 181: 5d pop %ebp 182: c3 ret 183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000190 <gets>: char* gets(char *buf, int max) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 57 push %edi 194: 56 push %esi 195: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 196: 31 f6 xor %esi,%esi 198: 89 f3 mov %esi,%ebx { 19a: 83 ec 1c sub $0x1c,%esp 19d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 1a0: eb 2f jmp 1d1 <gets+0x41> 1a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 1a8: 8d 45 e7 lea -0x19(%ebp),%eax 1ab: 83 ec 04 sub $0x4,%esp 1ae: 6a 01 push $0x1 1b0: 50 push %eax 1b1: 6a 00 push $0x0 1b3: e8 32 01 00 00 call 2ea <read> if(cc < 1) 1b8: 83 c4 10 add $0x10,%esp 1bb: 85 c0 test %eax,%eax 1bd: 7e 1c jle 1db <gets+0x4b> break; buf[i++] = c; 1bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1c3: 83 c7 01 add $0x1,%edi 1c6: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1c9: 3c 0a cmp $0xa,%al 1cb: 74 23 je 1f0 <gets+0x60> 1cd: 3c 0d cmp $0xd,%al 1cf: 74 1f je 1f0 <gets+0x60> for(i=0; i+1 < max; ){ 1d1: 83 c3 01 add $0x1,%ebx 1d4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1d7: 89 fe mov %edi,%esi 1d9: 7c cd jl 1a8 <gets+0x18> 1db: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1dd: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1e0: c6 03 00 movb $0x0,(%ebx) } 1e3: 8d 65 f4 lea -0xc(%ebp),%esp 1e6: 5b pop %ebx 1e7: 5e pop %esi 1e8: 5f pop %edi 1e9: 5d pop %ebp 1ea: c3 ret 1eb: 90 nop 1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1f0: 8b 75 08 mov 0x8(%ebp),%esi 1f3: 8b 45 08 mov 0x8(%ebp),%eax 1f6: 01 de add %ebx,%esi 1f8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1fa: c6 03 00 movb $0x0,(%ebx) } 1fd: 8d 65 f4 lea -0xc(%ebp),%esp 200: 5b pop %ebx 201: 5e pop %esi 202: 5f pop %edi 203: 5d pop %ebp 204: c3 ret 205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <stat>: int stat(const char *n, struct stat *st) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 56 push %esi 214: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 215: 83 ec 08 sub $0x8,%esp 218: 6a 00 push $0x0 21a: ff 75 08 pushl 0x8(%ebp) 21d: e8 f0 00 00 00 call 312 <open> if(fd < 0) 222: 83 c4 10 add $0x10,%esp 225: 85 c0 test %eax,%eax 227: 78 27 js 250 <stat+0x40> return -1; r = fstat(fd, st); 229: 83 ec 08 sub $0x8,%esp 22c: ff 75 0c pushl 0xc(%ebp) 22f: 89 c3 mov %eax,%ebx 231: 50 push %eax 232: e8 f3 00 00 00 call 32a <fstat> close(fd); 237: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 23a: 89 c6 mov %eax,%esi close(fd); 23c: e8 b9 00 00 00 call 2fa <close> return r; 241: 83 c4 10 add $0x10,%esp } 244: 8d 65 f8 lea -0x8(%ebp),%esp 247: 89 f0 mov %esi,%eax 249: 5b pop %ebx 24a: 5e pop %esi 24b: 5d pop %ebp 24c: c3 ret 24d: 8d 76 00 lea 0x0(%esi),%esi return -1; 250: be ff ff ff ff mov $0xffffffff,%esi 255: eb ed jmp 244 <stat+0x34> 257: 89 f6 mov %esi,%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000260 <atoi>: int atoi(const char *s) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 53 push %ebx 264: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 267: 0f be 11 movsbl (%ecx),%edx 26a: 8d 42 d0 lea -0x30(%edx),%eax 26d: 3c 09 cmp $0x9,%al n = 0; 26f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 274: 77 1f ja 295 <atoi+0x35> 276: 8d 76 00 lea 0x0(%esi),%esi 279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 280: 8d 04 80 lea (%eax,%eax,4),%eax 283: 83 c1 01 add $0x1,%ecx 286: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 28a: 0f be 11 movsbl (%ecx),%edx 28d: 8d 5a d0 lea -0x30(%edx),%ebx 290: 80 fb 09 cmp $0x9,%bl 293: 76 eb jbe 280 <atoi+0x20> return n; } 295: 5b pop %ebx 296: 5d pop %ebp 297: c3 ret 298: 90 nop 299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000002a0 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 2a0: 55 push %ebp 2a1: 89 e5 mov %esp,%ebp 2a3: 56 push %esi 2a4: 53 push %ebx 2a5: 8b 5d 10 mov 0x10(%ebp),%ebx 2a8: 8b 45 08 mov 0x8(%ebp),%eax 2ab: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 2ae: 85 db test %ebx,%ebx 2b0: 7e 14 jle 2c6 <memmove+0x26> 2b2: 31 d2 xor %edx,%edx 2b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 2b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 2bc: 88 0c 10 mov %cl,(%eax,%edx,1) 2bf: 83 c2 01 add $0x1,%edx while(n-- > 0) 2c2: 39 d3 cmp %edx,%ebx 2c4: 75 f2 jne 2b8 <memmove+0x18> return vdst; } 2c6: 5b pop %ebx 2c7: 5e pop %esi 2c8: 5d pop %ebp 2c9: c3 ret 000002ca <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2ca: b8 01 00 00 00 mov $0x1,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <exit>: SYSCALL(exit) 2d2: b8 02 00 00 00 mov $0x2,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <wait>: SYSCALL(wait) 2da: b8 03 00 00 00 mov $0x3,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <pipe>: SYSCALL(pipe) 2e2: b8 04 00 00 00 mov $0x4,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <read>: SYSCALL(read) 2ea: b8 05 00 00 00 mov $0x5,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <write>: SYSCALL(write) 2f2: b8 10 00 00 00 mov $0x10,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <close>: SYSCALL(close) 2fa: b8 15 00 00 00 mov $0x15,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <kill>: SYSCALL(kill) 302: b8 06 00 00 00 mov $0x6,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <exec>: SYSCALL(exec) 30a: b8 07 00 00 00 mov $0x7,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <open>: SYSCALL(open) 312: b8 0f 00 00 00 mov $0xf,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <mknod>: SYSCALL(mknod) 31a: b8 11 00 00 00 mov $0x11,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <unlink>: SYSCALL(unlink) 322: b8 12 00 00 00 mov $0x12,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <fstat>: SYSCALL(fstat) 32a: b8 08 00 00 00 mov $0x8,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <link>: SYSCALL(link) 332: b8 13 00 00 00 mov $0x13,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <mkdir>: SYSCALL(mkdir) 33a: b8 14 00 00 00 mov $0x14,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <chdir>: SYSCALL(chdir) 342: b8 09 00 00 00 mov $0x9,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <dup>: SYSCALL(dup) 34a: b8 0a 00 00 00 mov $0xa,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <getpid>: SYSCALL(getpid) 352: b8 0b 00 00 00 mov $0xb,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <sbrk>: SYSCALL(sbrk) 35a: b8 0c 00 00 00 mov $0xc,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <sleep>: SYSCALL(sleep) 362: b8 0d 00 00 00 mov $0xd,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <uptime>: SYSCALL(uptime) 36a: b8 0e 00 00 00 mov $0xe,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <hello>: SYSCALL(hello) 372: b8 16 00 00 00 mov $0x16,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <hello_name>: SYSCALL(hello_name) 37a: b8 17 00 00 00 mov $0x17,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <get_num_proc>: SYSCALL(get_num_proc) 382: b8 18 00 00 00 mov $0x18,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <get_max_pid>: SYSCALL(get_max_pid) 38a: b8 19 00 00 00 mov $0x19,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <get_proc_info>: SYSCALL(get_proc_info) 392: b8 1a 00 00 00 mov $0x1a,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <set_prio>: SYSCALL(set_prio) 39a: b8 1b 00 00 00 mov $0x1b,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <get_prio>: SYSCALL(get_prio) 3a2: b8 1c 00 00 00 mov $0x1c,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 3aa: 66 90 xchg %ax,%ax 3ac: 66 90 xchg %ax,%ax 3ae: 66 90 xchg %ax,%ax 000003b0 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 3b0: 55 push %ebp 3b1: 89 e5 mov %esp,%ebp 3b3: 57 push %edi 3b4: 56 push %esi 3b5: 53 push %ebx 3b6: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 3b9: 85 d2 test %edx,%edx { 3bb: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 3be: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 3c0: 79 76 jns 438 <printint+0x88> 3c2: f6 45 08 01 testb $0x1,0x8(%ebp) 3c6: 74 70 je 438 <printint+0x88> x = -xx; 3c8: f7 d8 neg %eax neg = 1; 3ca: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3d1: 31 f6 xor %esi,%esi 3d3: 8d 5d d7 lea -0x29(%ebp),%ebx 3d6: eb 0a jmp 3e2 <printint+0x32> 3d8: 90 nop 3d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3e0: 89 fe mov %edi,%esi 3e2: 31 d2 xor %edx,%edx 3e4: 8d 7e 01 lea 0x1(%esi),%edi 3e7: f7 f1 div %ecx 3e9: 0f b6 92 dc 07 00 00 movzbl 0x7dc(%edx),%edx }while((x /= base) != 0); 3f0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3f2: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3f5: 75 e9 jne 3e0 <printint+0x30> if(neg) 3f7: 8b 45 c4 mov -0x3c(%ebp),%eax 3fa: 85 c0 test %eax,%eax 3fc: 74 08 je 406 <printint+0x56> buf[i++] = '-'; 3fe: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 403: 8d 7e 02 lea 0x2(%esi),%edi 406: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 40a: 8b 7d c0 mov -0x40(%ebp),%edi 40d: 8d 76 00 lea 0x0(%esi),%esi 410: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 413: 83 ec 04 sub $0x4,%esp 416: 83 ee 01 sub $0x1,%esi 419: 6a 01 push $0x1 41b: 53 push %ebx 41c: 57 push %edi 41d: 88 45 d7 mov %al,-0x29(%ebp) 420: e8 cd fe ff ff call 2f2 <write> while(--i >= 0) 425: 83 c4 10 add $0x10,%esp 428: 39 de cmp %ebx,%esi 42a: 75 e4 jne 410 <printint+0x60> putc(fd, buf[i]); } 42c: 8d 65 f4 lea -0xc(%ebp),%esp 42f: 5b pop %ebx 430: 5e pop %esi 431: 5f pop %edi 432: 5d pop %ebp 433: c3 ret 434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 438: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 43f: eb 90 jmp 3d1 <printint+0x21> 441: eb 0d jmp 450 <printf> 443: 90 nop 444: 90 nop 445: 90 nop 446: 90 nop 447: 90 nop 448: 90 nop 449: 90 nop 44a: 90 nop 44b: 90 nop 44c: 90 nop 44d: 90 nop 44e: 90 nop 44f: 90 nop 00000450 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 450: 55 push %ebp 451: 89 e5 mov %esp,%ebp 453: 57 push %edi 454: 56 push %esi 455: 53 push %ebx 456: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 459: 8b 75 0c mov 0xc(%ebp),%esi 45c: 0f b6 1e movzbl (%esi),%ebx 45f: 84 db test %bl,%bl 461: 0f 84 b3 00 00 00 je 51a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 467: 8d 45 10 lea 0x10(%ebp),%eax 46a: 83 c6 01 add $0x1,%esi state = 0; 46d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 46f: 89 45 d4 mov %eax,-0x2c(%ebp) 472: eb 2f jmp 4a3 <printf+0x53> 474: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 478: 83 f8 25 cmp $0x25,%eax 47b: 0f 84 a7 00 00 00 je 528 <printf+0xd8> write(fd, &c, 1); 481: 8d 45 e2 lea -0x1e(%ebp),%eax 484: 83 ec 04 sub $0x4,%esp 487: 88 5d e2 mov %bl,-0x1e(%ebp) 48a: 6a 01 push $0x1 48c: 50 push %eax 48d: ff 75 08 pushl 0x8(%ebp) 490: e8 5d fe ff ff call 2f2 <write> 495: 83 c4 10 add $0x10,%esp 498: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 49b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 49f: 84 db test %bl,%bl 4a1: 74 77 je 51a <printf+0xca> if(state == 0){ 4a3: 85 ff test %edi,%edi c = fmt[i] & 0xff; 4a5: 0f be cb movsbl %bl,%ecx 4a8: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 4ab: 74 cb je 478 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 4ad: 83 ff 25 cmp $0x25,%edi 4b0: 75 e6 jne 498 <printf+0x48> if(c == 'd'){ 4b2: 83 f8 64 cmp $0x64,%eax 4b5: 0f 84 05 01 00 00 je 5c0 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 4bb: 81 e1 f7 00 00 00 and $0xf7,%ecx 4c1: 83 f9 70 cmp $0x70,%ecx 4c4: 74 72 je 538 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 4c6: 83 f8 73 cmp $0x73,%eax 4c9: 0f 84 99 00 00 00 je 568 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4cf: 83 f8 63 cmp $0x63,%eax 4d2: 0f 84 08 01 00 00 je 5e0 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 4d8: 83 f8 25 cmp $0x25,%eax 4db: 0f 84 ef 00 00 00 je 5d0 <printf+0x180> write(fd, &c, 1); 4e1: 8d 45 e7 lea -0x19(%ebp),%eax 4e4: 83 ec 04 sub $0x4,%esp 4e7: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4eb: 6a 01 push $0x1 4ed: 50 push %eax 4ee: ff 75 08 pushl 0x8(%ebp) 4f1: e8 fc fd ff ff call 2f2 <write> 4f6: 83 c4 0c add $0xc,%esp 4f9: 8d 45 e6 lea -0x1a(%ebp),%eax 4fc: 88 5d e6 mov %bl,-0x1a(%ebp) 4ff: 6a 01 push $0x1 501: 50 push %eax 502: ff 75 08 pushl 0x8(%ebp) 505: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 508: 31 ff xor %edi,%edi write(fd, &c, 1); 50a: e8 e3 fd ff ff call 2f2 <write> for(i = 0; fmt[i]; i++){ 50f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 513: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 516: 84 db test %bl,%bl 518: 75 89 jne 4a3 <printf+0x53> } } } 51a: 8d 65 f4 lea -0xc(%ebp),%esp 51d: 5b pop %ebx 51e: 5e pop %esi 51f: 5f pop %edi 520: 5d pop %ebp 521: c3 ret 522: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 528: bf 25 00 00 00 mov $0x25,%edi 52d: e9 66 ff ff ff jmp 498 <printf+0x48> 532: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 538: 83 ec 0c sub $0xc,%esp 53b: b9 10 00 00 00 mov $0x10,%ecx 540: 6a 00 push $0x0 542: 8b 7d d4 mov -0x2c(%ebp),%edi 545: 8b 45 08 mov 0x8(%ebp),%eax 548: 8b 17 mov (%edi),%edx 54a: e8 61 fe ff ff call 3b0 <printint> ap++; 54f: 89 f8 mov %edi,%eax 551: 83 c4 10 add $0x10,%esp state = 0; 554: 31 ff xor %edi,%edi ap++; 556: 83 c0 04 add $0x4,%eax 559: 89 45 d4 mov %eax,-0x2c(%ebp) 55c: e9 37 ff ff ff jmp 498 <printf+0x48> 561: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 568: 8b 45 d4 mov -0x2c(%ebp),%eax 56b: 8b 08 mov (%eax),%ecx ap++; 56d: 83 c0 04 add $0x4,%eax 570: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 573: 85 c9 test %ecx,%ecx 575: 0f 84 8e 00 00 00 je 609 <printf+0x1b9> while(*s != 0){ 57b: 0f b6 01 movzbl (%ecx),%eax state = 0; 57e: 31 ff xor %edi,%edi s = (char*)*ap; 580: 89 cb mov %ecx,%ebx while(*s != 0){ 582: 84 c0 test %al,%al 584: 0f 84 0e ff ff ff je 498 <printf+0x48> 58a: 89 75 d0 mov %esi,-0x30(%ebp) 58d: 89 de mov %ebx,%esi 58f: 8b 5d 08 mov 0x8(%ebp),%ebx 592: 8d 7d e3 lea -0x1d(%ebp),%edi 595: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 598: 83 ec 04 sub $0x4,%esp s++; 59b: 83 c6 01 add $0x1,%esi 59e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 5a1: 6a 01 push $0x1 5a3: 57 push %edi 5a4: 53 push %ebx 5a5: e8 48 fd ff ff call 2f2 <write> while(*s != 0){ 5aa: 0f b6 06 movzbl (%esi),%eax 5ad: 83 c4 10 add $0x10,%esp 5b0: 84 c0 test %al,%al 5b2: 75 e4 jne 598 <printf+0x148> 5b4: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 5b7: 31 ff xor %edi,%edi 5b9: e9 da fe ff ff jmp 498 <printf+0x48> 5be: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 5c0: 83 ec 0c sub $0xc,%esp 5c3: b9 0a 00 00 00 mov $0xa,%ecx 5c8: 6a 01 push $0x1 5ca: e9 73 ff ff ff jmp 542 <printf+0xf2> 5cf: 90 nop write(fd, &c, 1); 5d0: 83 ec 04 sub $0x4,%esp 5d3: 88 5d e5 mov %bl,-0x1b(%ebp) 5d6: 8d 45 e5 lea -0x1b(%ebp),%eax 5d9: 6a 01 push $0x1 5db: e9 21 ff ff ff jmp 501 <printf+0xb1> putc(fd, *ap); 5e0: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 5e3: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 5e6: 8b 07 mov (%edi),%eax write(fd, &c, 1); 5e8: 6a 01 push $0x1 ap++; 5ea: 83 c7 04 add $0x4,%edi putc(fd, *ap); 5ed: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 5f0: 8d 45 e4 lea -0x1c(%ebp),%eax 5f3: 50 push %eax 5f4: ff 75 08 pushl 0x8(%ebp) 5f7: e8 f6 fc ff ff call 2f2 <write> ap++; 5fc: 89 7d d4 mov %edi,-0x2c(%ebp) 5ff: 83 c4 10 add $0x10,%esp state = 0; 602: 31 ff xor %edi,%edi 604: e9 8f fe ff ff jmp 498 <printf+0x48> s = "(null)"; 609: bb d5 07 00 00 mov $0x7d5,%ebx while(*s != 0){ 60e: b8 28 00 00 00 mov $0x28,%eax 613: e9 72 ff ff ff jmp 58a <printf+0x13a> 618: 66 90 xchg %ax,%ax 61a: 66 90 xchg %ax,%ax 61c: 66 90 xchg %ax,%ax 61e: 66 90 xchg %ax,%ax 00000620 <free>: static Header base; static Header *freep; void free(void *ap) { 620: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 621: a1 8c 0a 00 00 mov 0xa8c,%eax { 626: 89 e5 mov %esp,%ebp 628: 57 push %edi 629: 56 push %esi 62a: 53 push %ebx 62b: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 62e: 8d 4b f8 lea -0x8(%ebx),%ecx 631: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 638: 39 c8 cmp %ecx,%eax 63a: 8b 10 mov (%eax),%edx 63c: 73 32 jae 670 <free+0x50> 63e: 39 d1 cmp %edx,%ecx 640: 72 04 jb 646 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 642: 39 d0 cmp %edx,%eax 644: 72 32 jb 678 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 646: 8b 73 fc mov -0x4(%ebx),%esi 649: 8d 3c f1 lea (%ecx,%esi,8),%edi 64c: 39 fa cmp %edi,%edx 64e: 74 30 je 680 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 650: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 653: 8b 50 04 mov 0x4(%eax),%edx 656: 8d 34 d0 lea (%eax,%edx,8),%esi 659: 39 f1 cmp %esi,%ecx 65b: 74 3a je 697 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 65d: 89 08 mov %ecx,(%eax) freep = p; 65f: a3 8c 0a 00 00 mov %eax,0xa8c } 664: 5b pop %ebx 665: 5e pop %esi 666: 5f pop %edi 667: 5d pop %ebp 668: c3 ret 669: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 670: 39 d0 cmp %edx,%eax 672: 72 04 jb 678 <free+0x58> 674: 39 d1 cmp %edx,%ecx 676: 72 ce jb 646 <free+0x26> { 678: 89 d0 mov %edx,%eax 67a: eb bc jmp 638 <free+0x18> 67c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 680: 03 72 04 add 0x4(%edx),%esi 683: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 686: 8b 10 mov (%eax),%edx 688: 8b 12 mov (%edx),%edx 68a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 68d: 8b 50 04 mov 0x4(%eax),%edx 690: 8d 34 d0 lea (%eax,%edx,8),%esi 693: 39 f1 cmp %esi,%ecx 695: 75 c6 jne 65d <free+0x3d> p->s.size += bp->s.size; 697: 03 53 fc add -0x4(%ebx),%edx freep = p; 69a: a3 8c 0a 00 00 mov %eax,0xa8c p->s.size += bp->s.size; 69f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6a2: 8b 53 f8 mov -0x8(%ebx),%edx 6a5: 89 10 mov %edx,(%eax) } 6a7: 5b pop %ebx 6a8: 5e pop %esi 6a9: 5f pop %edi 6aa: 5d pop %ebp 6ab: c3 ret 6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000006b0 <malloc>: return freep; } void* malloc(uint nbytes) { 6b0: 55 push %ebp 6b1: 89 e5 mov %esp,%ebp 6b3: 57 push %edi 6b4: 56 push %esi 6b5: 53 push %ebx 6b6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6b9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6bc: 8b 15 8c 0a 00 00 mov 0xa8c,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6c2: 8d 78 07 lea 0x7(%eax),%edi 6c5: c1 ef 03 shr $0x3,%edi 6c8: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 6cb: 85 d2 test %edx,%edx 6cd: 0f 84 9d 00 00 00 je 770 <malloc+0xc0> 6d3: 8b 02 mov (%edx),%eax 6d5: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 6d8: 39 cf cmp %ecx,%edi 6da: 76 6c jbe 748 <malloc+0x98> 6dc: 81 ff 00 10 00 00 cmp $0x1000,%edi 6e2: bb 00 10 00 00 mov $0x1000,%ebx 6e7: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 6ea: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 6f1: eb 0e jmp 701 <malloc+0x51> 6f3: 90 nop 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6f8: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6fa: 8b 48 04 mov 0x4(%eax),%ecx 6fd: 39 f9 cmp %edi,%ecx 6ff: 73 47 jae 748 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 701: 39 05 8c 0a 00 00 cmp %eax,0xa8c 707: 89 c2 mov %eax,%edx 709: 75 ed jne 6f8 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 70b: 83 ec 0c sub $0xc,%esp 70e: 56 push %esi 70f: e8 46 fc ff ff call 35a <sbrk> if(p == (char*)-1) 714: 83 c4 10 add $0x10,%esp 717: 83 f8 ff cmp $0xffffffff,%eax 71a: 74 1c je 738 <malloc+0x88> hp->s.size = nu; 71c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 71f: 83 ec 0c sub $0xc,%esp 722: 83 c0 08 add $0x8,%eax 725: 50 push %eax 726: e8 f5 fe ff ff call 620 <free> return freep; 72b: 8b 15 8c 0a 00 00 mov 0xa8c,%edx if((p = morecore(nunits)) == 0) 731: 83 c4 10 add $0x10,%esp 734: 85 d2 test %edx,%edx 736: 75 c0 jne 6f8 <malloc+0x48> return 0; } } 738: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 73b: 31 c0 xor %eax,%eax } 73d: 5b pop %ebx 73e: 5e pop %esi 73f: 5f pop %edi 740: 5d pop %ebp 741: c3 ret 742: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 748: 39 cf cmp %ecx,%edi 74a: 74 54 je 7a0 <malloc+0xf0> p->s.size -= nunits; 74c: 29 f9 sub %edi,%ecx 74e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 751: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 754: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 757: 89 15 8c 0a 00 00 mov %edx,0xa8c } 75d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 760: 83 c0 08 add $0x8,%eax } 763: 5b pop %ebx 764: 5e pop %esi 765: 5f pop %edi 766: 5d pop %ebp 767: c3 ret 768: 90 nop 769: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 770: c7 05 8c 0a 00 00 90 movl $0xa90,0xa8c 777: 0a 00 00 77a: c7 05 90 0a 00 00 90 movl $0xa90,0xa90 781: 0a 00 00 base.s.size = 0; 784: b8 90 0a 00 00 mov $0xa90,%eax 789: c7 05 94 0a 00 00 00 movl $0x0,0xa94 790: 00 00 00 793: e9 44 ff ff ff jmp 6dc <malloc+0x2c> 798: 90 nop 799: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 7a0: 8b 08 mov (%eax),%ecx 7a2: 89 0a mov %ecx,(%edx) 7a4: eb b1 jmp 757 <malloc+0xa7>
-- 7 Billion Humans -- -- 07: Collation station -- -- Size: 8/6 -- -- Speed: 7/7 -- a: if c == nothing: step s jump a endif pickup c b: if s == nothing: step s jump b endif drop
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x935a, %rax nop nop nop cmp $57840, %r11 movups (%rax), %xmm5 vpextrq $0, %xmm5, %r10 nop nop nop xor $15443, %r9 lea addresses_UC_ht+0x1cd70, %rsi lea addresses_WC_ht+0x17932, %rdi nop nop nop inc %r10 mov $107, %rcx rep movsl cmp %rcx, %rcx lea addresses_D_ht+0xf4aa, %r10 nop nop nop nop add $49753, %rcx mov $0x6162636465666768, %rax movq %rax, %xmm3 movups %xmm3, (%r10) nop nop inc %rax lea addresses_WT_ht+0x17d22, %r11 nop nop nop nop cmp %rsi, %rsi vmovups (%r11), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $1, %xmm0, %rdi nop nop nop cmp $33689, %rdi lea addresses_UC_ht+0x99da, %rsi lea addresses_UC_ht+0x26d3, %rdi nop inc %rax mov $23, %rcx rep movsw nop nop and %rcx, %rcx lea addresses_WT_ht+0x75ba, %rsi lea addresses_normal_ht+0x190aa, %rdi nop and $19008, %rdx mov $35, %rcx rep movsq nop nop nop nop nop inc %rsi lea addresses_A_ht+0xbcda, %rcx nop nop nop nop sub $24456, %r10 mov $0x6162636465666768, %rdx movq %rdx, (%rcx) nop nop nop add $922, %rsi lea addresses_A_ht+0x1e372, %rsi lea addresses_WT_ht+0x5246, %rdi nop add %r9, %r9 mov $59, %rcx rep movsb nop nop nop and %r11, %r11 lea addresses_normal_ht+0xc23a, %rdx nop nop dec %rsi movb (%rdx), %al nop nop nop nop dec %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %rax push %rcx push %rdi push %rdx // Store lea addresses_D+0x9e3a, %rdi nop and $61121, %r14 movl $0x51525354, (%rdi) nop nop nop and $36021, %rdx // Store lea addresses_D+0x1a3a, %rax nop nop sub $34946, %r10 mov $0x5152535455565758, %rcx movq %rcx, %xmm0 vmovups %ymm0, (%rax) nop nop nop and $22550, %r12 // Store lea addresses_D+0x1989a, %r14 nop and %rdi, %rdi movl $0x51525354, (%r14) sub $30783, %rcx // Load lea addresses_WT+0x523a, %rdi nop nop nop nop inc %r12 vmovups (%rdi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %r10 nop nop nop nop xor %rcx, %rcx // Store lea addresses_US+0x12616, %rax nop nop nop nop inc %rcx mov $0x5152535455565758, %rdx movq %rdx, %xmm4 vmovups %ymm4, (%rax) sub $53765, %rdx // Faulty Load lea addresses_WT+0x1da3a, %rcx nop nop nop cmp %rdx, %rdx movups (%rcx), %xmm6 vpextrq $0, %xmm6, %r10 lea oracles, %rdi and $0xff, %r10 shlq $12, %r10 mov (%rdi,%r10,1), %r10 pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'58': 17913} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
; Got this example from Nerdy Nights: ; http://www.nintendoage.com/forum/messageview.cfm?catid=22&threadid=7155 ; this is the scrolling example ; http://www.nintendoage.com/forum/messageview.cfm?catid=22&threadid=36958 .inesprg 1 ; 1x 16KB PRG code .ineschr 1 ; 1x 8KB CHR data .inesmap 0 ; mapper 0 = NROM, no bank swapping .inesmir 1 ; VERT mirroring for HORIZ scrolling ;;;;;;;;;;;;;;; ;; DECLARE SOME VARIABLES HERE .rsset $0000 ;;start variables at ram location 0 scroll .rs 1 ; horizontal scroll count nametable .rs 1 ; which nametable to use, 0 or 1 columnLow .rs 1 ; low byte of new column address columnHigh .rs 1 ; high byte of new column address sourceLow .rs 1 ; source for column data sourceHigh .rs 1 columnNumber .rs 1 ; which column of level data to draw ;;;;;;;;;;;; .bank 0 .org $C000 RESET: SEI ; disable IRQs CLD ; disable decimal mode LDX #$40 STX $4017 ; disable APU frame IRQ LDX #$FF TXS ; Set up stack INX ; now X = 0 STX $2000 ; disable NMI STX $2001 ; disable rendering STX $4010 ; disable DMC IRQs vblankwait1: ; First wait for vblank to make sure PPU is ready BIT $2002 BPL vblankwait1 clrmem: LDA #$00 STA $0000, x STA $0100, x STA $0300, x STA $0400, x STA $0500, x STA $0600, x STA $0700, x LDA #$FE STA $0200, x INX BNE clrmem vblankwait2: ; Second wait for vblank, PPU is ready after this BIT $2002 BPL vblankwait2 LoadPalettes: LDA $2002 ; read PPU status to reset the high/low latch LDA #$3F STA $2006 ; write the high byte of $3F00 address LDA #$00 STA $2006 ; write the low byte of $3F00 address LDX #$00 ; start out at 0 LoadPalettesLoop: LDA palette, x ; load data from address (palette + the value in x) STA $2007 ; write to PPU INX ; X = X + 1 CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero ; if compare was equal to 32, keep going down LoadSprites: LDX #$00 ; start at 0 LoadSpritesLoop: LDA sprites, x ; load data from address (sprites + x) STA $0200, x ; store into RAM address ($0200 + x) INX ; X = X + 1 CPX #$10 ; Compare X to hex $20, decimal 16 BNE LoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero ; if compare was equal to 16, keep going down InitializeNametables: LDA #$01 STA nametable LDA #$00 STA scroll STA columnNumber InitializeNametablesLoop: JSR DrawNewColumn ; draw bg column LDA scroll ; go to next column CLC ADC #$08 STA scroll INC columnNumber LDA columnNumber ; repeat for first nametable CMP #$20 BNE InitializeNametablesLoop LDA #$00 STA nametable LDA #$00 STA scroll JSR DrawNewColumn ; draw first column of second nametable INC columnNumber LDA #$00 ; set back to increment +1 mode STA $2000 InitializeNametablesDone: InitializeAttributes: LDA #$01 STA nametable LDA #$00 STA scroll STA columnNumber InitializeAttributesLoop: JSR DrawNewAttributes ; draw attribs LDA scroll ; go to next column CLC ADC #$20 STA scroll LDA columnNumber ; repeat for first nametable CLC ADC #$04 STA columnNumber CMP #$20 BNE InitializeAttributesLoop LDA #$00 STA nametable LDA #$00 STA scroll JSR DrawNewAttributes ; draw first column of second nametable InitializeAttributesDone: LDA #$21 STA columnNumber LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1 STA $2000 LDA #%00011110 ; enable sprites, enable background, no clipping on left side STA $2001 Forever: JMP Forever ;jump back to Forever, infinite loop NMI: INC scroll ; add one to our scroll variable each frame NTSwapCheck: LDA scroll ; check if the scroll just wrapped from 255 to 0 BNE NTSwapCheckDone NTSwap: LDA nametable ; load current nametable number (0 or 1) EOR #$01 ; exclusive OR of bit 0 will flip that bit STA nametable ; so if nametable was 0, now 1 ; if nametable was 1, now 0 NTSwapCheckDone: NewAttribCheck: LDA scroll AND #%00011111 ; check for multiple of 32 BNE NewAttribCheckDone ; if low 5 bits = 0, time to write new attribute bytes JSR DrawNewAttributes NewAttribCheckDone: NewColumnCheck: LDA scroll AND #%00000111 ; throw away higher bits to check for multiple of 8 BNE NewColumnCheckDone ; done if lower bits != 0 JSR DrawNewColumn ; if lower bits = 0, time for new column LDA columnNumber CLC ADC #$01 ; go to next column AND #%01111111 ; only 128 columns of data, throw away top bit to wrap STA columnNumber NewColumnCheckDone: LDA #$00 STA $2003 LDA #$02 STA $4014 ; sprite DMA from $0200 ; run other game graphics updating code here LDA #$00 STA $2006 ; clean up PPU address registers STA $2006 LDA scroll STA $2005 ; write the horizontal scroll count register LDA #$00 ; no vertical scrolling STA $2005 ;;This is the PPU clean up section, so rendering the next frame starts properly. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1 ORA nametable ; select correct nametable for bit 0 STA $2000 LDA #%00011110 ; enable sprites, enable background, no clipping on left side STA $2001 ; run normal game engine code here ; reading from controllers, etc RTI ; return from interrupt DrawNewColumn: LDA scroll ; calculate new column address using scroll register LSR A LSR A LSR A ; shift right 3 times = divide by 8 STA columnLow ; $00 to $1F, screen is 32 tiles wide LDA nametable ; calculate new column address using current nametable EOR #$01 ; invert low bit, A = $00 or $01 ASL A ; shift up, A = $00 or $02 ASL A ; $00 or $04 CLC ADC #$20 ; add high byte of nametable base address ($2000) STA columnHigh ; now address = $20 or $24 for nametable 0 or 1 LDA columnNumber ; column number * 32 = column data offset ASL A ASL A ASL A ASL A ASL A STA sourceLow LDA columnNumber LSR A LSR A LSR A STA sourceHigh LDA sourceLow ; column data start + offset = address to load column data from CLC ADC #LOW(columnData) STA sourceLow LDA sourceHigh ADC #HIGH(columnData) STA sourceHigh DrawColumn: LDA #%00000100 ; set to increment +32 mode STA $2000 LDA $2002 ; read PPU status to reset the high/low latch LDA columnHigh STA $2006 ; write the high byte of column address LDA columnLow STA $2006 ; write the low byte of column address LDX #$1E ; copy 30 bytes LDY #$00 DrawColumnLoop: LDA [sourceLow], y STA $2007 INY DEX BNE DrawColumnLoop RTS DrawNewAttributes: LDA nametable EOR #$01 ; invert low bit, A = $00 or $01 ASL A ; shift up, A = $00 or $02 ASL A ; $00 or $04 CLC ADC #$23 ; add high byte of attribute base address ($23C0) STA columnHigh ; now address = $23 or $27 for nametable 0 or 1 LDA scroll LSR A LSR A LSR A LSR A LSR A CLC ADC #$C0 STA columnLow ; attribute base + scroll / 32 LDA columnNumber ; (column number / 4) * 8 = column data offset AND #%11111100 ASL A STA sourceLow LDA columnNumber LSR A LSR A LSR A LSR A LSR A LSR A LSR A STA sourceHigh LDA sourceLow ; column data start + offset = address to load column data from CLC ADC #LOW(attribData) STA sourceLow LDA sourceHigh ADC #HIGH(attribData) STA sourceHigh LDY #$00 LDA $2002 ; read PPU status to reset the high/low latch DrawNewAttributesLoop: LDA columnHigh STA $2006 ; write the high byte of column address LDA columnLow STA $2006 ; write the low byte of column address LDA [sourceLow], y ; copy new attribute byte STA $2007 INY CPY #$08 ; copy 8 attribute bytes BEQ DrawNewAttributesLoopDone LDA columnLow ; next attribute byte is at address + 8 CLC ADC #$08 STA columnLow JMP DrawNewAttributesLoop DrawNewAttributesLoopDone: RTS ;;;;;;;;;;;;;; .bank 1 .org $E000 palette: .db $22,$29,$1A,$0F, $22,$36,$17,$0F, $22,$30,$21,$0F, $22,$27,$17,$0F ;;background palette .db $22,$16,$27,$18, $22,$1A,$30,$27, $22,$16,$30,$27, $22,$0F,$36,$17 ;;sprite palette sprites: ;vert tile attr horiz .db $80, $32, $00, $80 ;sprite 0 .db $80, $33, $00, $88 ;sprite 1 .db $88, $34, $00, $80 ;sprite 2 .db $88, $35, $00, $88 ;sprite 3 columnData: .incbin "SMBlevel.bin" attribData: .incbin "SMBattrib.bin" .org $FFFA ;first of the three vectors starts here .dw NMI ;when an NMI happens (once per frame if enabled) the ;processor will jump to the label NMI: .dw RESET ;when the processor first turns on or is reset, it will jump ;to the label RESET: .dw 0 ;external interrupt IRQ is not used in this tutorial ;;;;;;;;;;;;;; .bank 2 .org $0000 .incbin "mario.chr" ;includes 8KB graphics file from SMB1
#include "sineWaveController.h" #include "../../math/predefinedTaylorExpansions.h" #include "../../math/constants.h" namespace P3D { SineWaveController::SineWaveController(double minValue, double maxValue, double period) : minValue(minValue), maxValue(maxValue), period(period), currentStepInPeriod(0) { assert(maxValue >= minValue); } void SineWaveController::update(double deltaT) { currentStepInPeriod += deltaT; if(currentStepInPeriod >= period) currentStepInPeriod -= period; } double SineWaveController::getValue() const { double multiplier = (maxValue - minValue) / 2; double offset = minValue + multiplier; double currentAngle = currentStepInPeriod * (2 * PI / period); return sin(currentAngle) * multiplier + offset; } FullTaylor<double> SineWaveController::getFullTaylorExpansion() const { double multiplier = (maxValue - minValue) / 2; double offset = minValue + multiplier; double divPeriodToRadians = 2 * PI / period; FullTaylor<double> result = generateFullTaylorForSinWave<double, 3>(currentStepInPeriod, (2 * PI / period)) * multiplier; result += offset; return result; } };
// Copyright 2017 The Fuchsia 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 "src/ui/lib/escher/shape/rounded_rect.h" #include <lib/syslog/cpp/macros.h> #include "src/ui/lib/escher/geometry/types.h" #include "src/ui/lib/escher/shape/mesh_spec.h" #include "src/ui/lib/escher/util/trace_macros.h" namespace escher { namespace { // Number of times that the quarter-circle that makes up each corner is // sub-divided. For example, if this is zero, then the corner consists of // a single right-angled triangle. constexpr uint32_t kCornerDivisions = 8; // The central "square" consists of 4 vertices connected to their neighbors, and // to a central vertex. The 4 arms of the "cross" each share 2 vertices with // the central square, and add 2 more. Each corner adds kCornerDivisions more. constexpr uint32_t kVertexCount = 1 + 4 + (4 * 2) + 4 * kCornerDivisions; // The central "square" consists of 4 triangles, and the 4 arms of the "cross" // each have 2. constexpr uint32_t kTriangleCount = 4 + (4 * 2) + 4 * (kCornerDivisions + 1); // Triangles have 3 indices. constexpr uint32_t kIndexCount = kTriangleCount * 3; // Vertex format used when tessellating a RoundedRectSpec (for now, only a // single format is supported). struct PosUvVertex { vec2 pos; vec2 uv; }; struct PosVertex { vec2 pos; }; struct UvVertex { vec2 uv; }; } // anonymous namespace RoundedRectSpec::RoundedRectSpec(float width, float height, float top_left_radius, float top_right_radius, float bottom_right_radius, float bottom_left_radius) : width(width), height(height), top_left_radius(top_left_radius), top_right_radius(top_right_radius), bottom_right_radius(bottom_right_radius), bottom_left_radius(bottom_left_radius) {} RoundedRectSpec::RoundedRectSpec() : width(0.f), height(0.f), top_left_radius(0.f), top_right_radius(0.f), bottom_right_radius(0.f), bottom_left_radius(0.f) {} // Return the number of vertices and indices that are required to tessellate the // specified rounded-rect. std::pair<uint32_t, uint32_t> GetRoundedRectMeshVertexAndIndexCounts(const RoundedRectSpec& spec) { return std::make_pair(kVertexCount, kIndexCount); } // See escher/shape/doc/RoundedRectTessellation.JPG. void GenerateRoundedRectIndices(const RoundedRectSpec& spec, const MeshSpec& mesh_spec, void* indices_out, uint32_t max_bytes) { TRACE_DURATION("gfx", "escher::GenerateRoundedRectIndices"); FX_DCHECK(max_bytes >= kIndexCount * sizeof(MeshSpec::IndexType)); uint32_t* indices = static_cast<uint32_t*>(indices_out); // Central square triangles. indices[0] = 0; indices[1] = 4; indices[2] = 1; indices[3] = 0; indices[4] = 1; indices[5] = 2; indices[6] = 0; indices[7] = 2; indices[8] = 3; indices[9] = 0; indices[10] = 3; indices[11] = 4; // "Cross arm 1" triangles. indices[12] = 1; indices[13] = 7; indices[14] = 2; indices[15] = 1; indices[16] = 6; indices[17] = 7; // "Cross arm 2" triangles. indices[18] = 2; indices[19] = 9; indices[20] = 3; indices[21] = 2; indices[22] = 8; indices[23] = 9; // "Cross arm 3" triangles. indices[24] = 3; indices[25] = 11; indices[26] = 4; indices[27] = 3; indices[28] = 10; indices[29] = 11; // "Cross arm 4" triangles. indices[30] = 4; indices[31] = 5; indices[32] = 1; indices[33] = 4; indices[34] = 12; indices[35] = 5; // WARNING: here's where it gets confusing; the number of indices generated is // dependent on kCornerDivisions. // We've already generated output indices for the "cross triangles". constexpr uint32_t kCrossTriangles = 12; // Holds the position of the next index to output. uint32_t out = kCrossTriangles * 3; // Holds the highest index of any vertex used thus far (the central "cross" // consists of 13 vertices, whose indices are 0-12). uint32_t highest_index = 12; // These are the indices of the 4 triangles that would be output if // kCornerDivisions were zero. const uint32_t corner_tris[] = {1, 6, 5, 2, 8, 7, 3, 10, 9, 4, 12, 11}; // For each corner, generate wedges in clockwise order. for (uint32_t corner = 0; corner < 4; ++corner) { // Index of the vertex at the center of the current corner. const uint32_t center = corner_tris[corner * 3]; // As we move clockwise around the corner, this holds the index of the // previous perimeter vertex. uint32_t prev = corner_tris[corner * 3 + 2]; for (uint32_t i = 0; i < kCornerDivisions; ++i) { indices[out++] = center; indices[out++] = prev; indices[out++] = prev = ++highest_index; } // One last triangle (or the only one, if kCornerDivisions == 0). indices[out++] = center; indices[out++] = prev; indices[out++] = corner_tris[corner * 3 + 1]; } FX_DCHECK(out == kIndexCount); } namespace { // Helper for GenerateRoundedRectVertices(). template <typename VertT> void GenerateRoundedRectVertexUVs(const RoundedRectSpec& spec, VertT* verts) { TRACE_DURATION("gfx", "escher::GenerateRoundedRectVertexUVs"); const float width = spec.width; const float height = spec.height; // First compute UV coordinates of the four "corner centers". verts[1].uv = vec2(spec.top_left_radius / width, spec.top_left_radius / height); verts[2].uv = vec2(1.f - spec.top_right_radius / width, spec.top_right_radius / height); verts[3].uv = vec2(1.f - spec.bottom_right_radius / width, 1.f - spec.bottom_right_radius / height); verts[4].uv = vec2(spec.bottom_left_radius / width, 1.f - spec.bottom_left_radius / height); // The "center" vertex is the average of the four "corner centers". verts[0].uv = 0.25f * ((verts[1].uv + verts[2].uv + verts[3].uv + verts[4].uv)); // Next, compute UV coords for the 8 vertices where the rounded corners meet // the straight side sections. verts[6].uv = vec2(verts[1].uv.x, 0.f); verts[7].uv = vec2(verts[2].uv.x, 0.f); verts[8].uv = vec2(1.f, verts[2].uv.y); verts[9].uv = vec2(1.f, verts[3].uv.y); verts[10].uv = vec2(verts[3].uv.x, 1.f); verts[11].uv = vec2(verts[4].uv.x, 1.f); verts[12].uv = vec2(0.f, verts[4].uv.y); verts[5].uv = vec2(0.f, verts[1].uv.y); // Next, compute UV coords for the vertices that make up the rounded corners. // We start at index 13; indices 0-12 were computed above. uint32_t out = 13; constexpr float kPI = 3.14159265f; constexpr float kAngleStep = kPI / 2 / (kCornerDivisions + 1); // Generate UV coordinates for top-left corner. float angle = kPI + kAngleStep; vec2 scale = vec2(spec.top_left_radius / width, spec.top_left_radius / height); for (size_t i = 0; i < kCornerDivisions; ++i) { verts[out++].uv = verts[1].uv + vec2(cos(angle), sin(angle)) * scale; angle += kAngleStep; } // Generate UV coordinates for top-right corner. angle = 1.5f * kPI + kAngleStep; scale = vec2(spec.top_right_radius / width, spec.top_right_radius / height); for (size_t i = 0; i < kCornerDivisions; ++i) { verts[out++].uv = verts[2].uv + vec2(cos(angle), sin(angle)) * scale; angle += kAngleStep; } // Generate UV coordinates for bottom-right corner. angle = kAngleStep; scale = vec2(spec.bottom_right_radius / width, spec.bottom_right_radius / height); for (size_t i = 0; i < kCornerDivisions; ++i) { verts[out++].uv = verts[3].uv + vec2(cos(angle), sin(angle)) * scale; angle += kAngleStep; } // Generate UV coordinates for bottom-right corner. angle = 0.5f * kPI + kAngleStep; scale = vec2(spec.bottom_left_radius / width, spec.bottom_left_radius / height); for (size_t i = 0; i < kCornerDivisions; ++i) { verts[out++].uv = verts[4].uv + vec2(cos(angle), sin(angle)) * scale; angle += kAngleStep; } } // Helper for GenerateRoundedRectVertices(). template <typename UvVertT, typename PosVertT> void GenerateRoundedRectVertexPositionsFromUVs(const RoundedRectSpec& spec, UvVertT* uv_verts, PosVertT* pos_verts) { TRACE_DURATION("gfx", "escher::GenerateRoundedRectVertexPositionsFromUVs"); const vec2 extent(spec.width, spec.height); const vec2 offset = -0.5f * extent; for (size_t i = 0; i < kVertexCount; ++i) { pos_verts[i].pos = uv_verts[i].uv * extent + offset; } } } // namespace void GenerateRoundedRectVertices(const RoundedRectSpec& spec, const MeshSpec& mesh_spec, void* vertices_out, uint32_t max_bytes) { TRACE_DURATION("gfx", "escher::GenerateRoundedRectVertices"); const float width = spec.width; const float height = spec.height; FX_DCHECK(width >= spec.top_left_radius + spec.top_right_radius); FX_DCHECK(width >= spec.bottom_left_radius + spec.bottom_right_radius); FX_DCHECK(height >= spec.top_left_radius + spec.bottom_left_radius); FX_DCHECK(height >= spec.top_right_radius + spec.bottom_right_radius); FX_DCHECK(mesh_spec.total_attribute_count() == 2); FX_DCHECK(mesh_spec.attributes[0] == (MeshAttribute::kPosition2D | MeshAttribute::kUV)); FX_DCHECK(max_bytes >= kVertexCount * mesh_spec.stride(0)); FX_DCHECK(sizeof(PosUvVertex) == mesh_spec.stride(0)); FX_DCHECK(0U == mesh_spec.attribute_offset(0, MeshAttribute::kPosition2D)); FX_DCHECK(sizeof(vec2) == mesh_spec.attribute_offset(0, MeshAttribute::kUV)); // We first generate the UV-coordinates for each vertex, then make a second // pass where we use these UV-coords to generate the vertex positions. PosUvVertex* const verts = static_cast<PosUvVertex*>(vertices_out); GenerateRoundedRectVertexUVs(spec, verts); GenerateRoundedRectVertexPositionsFromUVs(spec, verts, verts); } void GenerateRoundedRectVertices(const RoundedRectSpec& spec, const MeshSpec& mesh_spec, void* primary_attributes_out, uint32_t max_primary_attribute_bytes, void* secondary_attributes_out, uint32_t max_secondary_attribute_bytes) { TRACE_DURATION("gfx", "escher::GenerateRoundedRectVertices"); const float width = spec.width; const float height = spec.height; FX_DCHECK(width >= spec.top_left_radius + spec.top_right_radius); FX_DCHECK(width >= spec.bottom_left_radius + spec.bottom_right_radius); FX_DCHECK(height >= spec.top_left_radius + spec.bottom_left_radius); FX_DCHECK(height >= spec.top_right_radius + spec.bottom_right_radius); FX_DCHECK(mesh_spec.total_attribute_count() == 2); FX_DCHECK(mesh_spec.attributes[0] == MeshAttribute::kPosition2D); FX_DCHECK(mesh_spec.attributes[1] == MeshAttribute::kUV); FX_DCHECK(max_primary_attribute_bytes == kVertexCount * (mesh_spec.stride(0))); FX_DCHECK(max_secondary_attribute_bytes == kVertexCount * (mesh_spec.stride(1))); FX_DCHECK(sizeof(PosVertex) == mesh_spec.stride(0)); FX_DCHECK(sizeof(UvVertex) == mesh_spec.stride(1)); // We first generate the UV-coordinates for each vertex, then make a second // pass where we use these UV-coords to generate the vertex positions. PosVertex* const positions = static_cast<PosVertex*>(primary_attributes_out); UvVertex* const uvs = reinterpret_cast<UvVertex*>(secondary_attributes_out); GenerateRoundedRectVertexUVs(spec, uvs); GenerateRoundedRectVertexPositionsFromUVs(spec, uvs, positions); } bool RoundedRectSpec::ContainsPoint(vec2 point) const { // Adjust point so that we can test against a rect with bounds (0,0),(w,h). // This is saves some multiplications, but mostly makes the code below more // concise. point += vec2(0.5f * width, 0.5f * height); // Check if point is outside of the bounding rectangle; if so, we don't need // to test the corner cases. if (point.x < 0 || point.y < 0 || point.x > width || point.y > height) { return false; } // Now we know that the point is would be contained, if all corner radii were // zero. But, since the radii are not zero, it is possible that the point is // outside one of the four quarter-circles that comprise the rounded corners. // Check if point is inside the top-left corner. { // Start by computing the vector from the corner-center to the test-point, // and checking whether the direction of the vector is within the corner's // quarter-circle arc. If so, we can immediately determine whether or not // the point is contained; otherwise, we need to test against the other // corners. float rad = top_left_radius; vec2 diff = point - vec2(rad, rad); if (diff.x < 0.f && diff.y < 0.f) { // The direction is within the corner's arc. Compare squared-distances to // determine whether the point is beyond the arc. return diff.x * diff.x + diff.y * diff.y <= rad * rad; } else { // The direction is not within the corner's quarter circle, so we proceed // on to the other corners. } } // Check if point is inside the top-right corner. // // For this corner, and subsequent ones, we follow the same approach as above, // with slight adjustments to the computation of the difference-vector, and // how we test the direction of that vector. { float rad = top_right_radius; vec2 diff = point - vec2(width - rad, rad); if (diff.x > 0.f && diff.y < 0.f) { return diff.x * diff.x + diff.y * diff.y <= rad * rad; } } // Check if point is inside the bottom-right corner. { float rad = bottom_right_radius; vec2 diff = point - vec2(width - rad, height - rad); if (diff.x > 0.f && diff.y > 0.f) { return diff.x * diff.x + diff.y * diff.y <= rad * rad; } } // Check if point is inside the bottom-left corner. { float rad = bottom_left_radius; vec2 diff = point - vec2(rad, height - rad); if (diff.x < 0.f && diff.y > 0.f) { return diff.x * diff.x + diff.y * diff.y <= rad * rad; } } // Point isn't in the corner areas, so it is definitely contained. return true; } RoundedRectSpec RoundedRectSpec::operator*(float t) const { return RoundedRectSpec(width * t, height * t, top_left_radius * t, top_right_radius * t, bottom_right_radius * t, bottom_left_radius * t); } RoundedRectSpec RoundedRectSpec::operator+(const RoundedRectSpec& other) const { return RoundedRectSpec( width + other.width, height + other.height, top_left_radius + other.top_left_radius, top_right_radius + other.top_right_radius, bottom_right_radius + other.bottom_right_radius, bottom_left_radius + other.bottom_left_radius); } } // namespace escher
/* The MIT License (MIT) Copyright (c) 2013-2015 winlin 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. */ #ifndef _htl_os_st_hpp #define _htl_os_st_hpp /* #include <htl_os_st.hpp> */ #include <map> #include <string> #include <st.h> #include <htl_core_log.hpp> // the statistic for each st-thread(task) class StStatistic { private: int threads, alive; int64_t starttime, task_duration; int64_t nread, nwrite; int64_t tasks, err_tasks, sub_tasks, err_sub_tasks; public: StStatistic(); virtual ~StStatistic(); public: virtual void OnRead(int tid, ssize_t nread_bytes); virtual void OnWrite(int tid, ssize_t nwrite_bytes); public: // when task thread run. virtual void OnThreadRun(int tid); // when task thread quit. virtual void OnThreadQuit(int tid); // when task start request url, ie. get m3u8 virtual void OnTaskStart(int tid, std::string task_url); // when task error. virtual void OnTaskError(int tid, int duration_seconds); // when task finish request url, ie. finish all ts in m3u8 virtual void OnTaskEnd(int tid, int duration_seconds); // when sub task start, ie. get ts in m3u8 virtual void OnSubTaskStart(int tid, std::string sub_task_url); // when sub task error. virtual void OnSubTaskError(int tid, int duration_seconds); // when sub task finish, ie. finish a ts. virtual void OnSubTaskEnd(int tid, int duration_seconds); public: virtual void DoReport(double sleep_ms); }; extern StStatistic* statistic; // abstract task for st, which run in a st-thread. class StTask { private: int id; public: StTask(); virtual ~StTask(); public: virtual int GetId(); public: /** * the framework will start a thread for the task, * then invoke the Process function to do actual transaction. */ virtual int Process() = 0; }; // the farm for all StTask, to spawn st-thread and process all task. class StFarm { private: double report_seconds; public: StFarm(); virtual ~StFarm(); public: virtual int Initialize(double report); virtual int Spawn(StTask* task); virtual int WaitAll(); private: static void* st_thread_function(void* args); }; // the socket status enum SocketStatus{ SocketInit, SocketConnected, SocketDisconnected, }; // the socket base on st. class StSocket { private: SocketStatus status; st_netfd_t sock_nfd; public: StSocket(); virtual ~StSocket(); public: virtual st_netfd_t GetStfd(); virtual SocketStatus Status(); virtual int Connect(const char* ip, int port); virtual int Read(const void* buf, size_t size, ssize_t* nread); virtual int Readv(const iovec *iov, int iov_size, ssize_t* nread); virtual int ReadFully(const void* buf, size_t size, ssize_t* nread); virtual int Write(const void* buf, size_t size, ssize_t* nwrite); virtual int Writev(const iovec *iov, int iov_size, ssize_t* nwrite); virtual int Close(); }; // common utilities. class StUtility { public: static int64_t GetCurrentTime(); static void InitRandom(); static st_utime_t BuildRandomMTime(double sleep_seconds); static int DnsResolve(std::string host, std::string& ip); }; // st-thread based log context. class StLogContext : public LogContext { private: std::map<st_thread_t, int> cache; public: StLogContext(); virtual ~StLogContext(); public: virtual void SetId(int id); virtual int GetId(); }; #endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %include "md5_job.asm" %include "md5_mb_mgr_datastruct.asm" %include "reg_sizes.asm" extern md5_mb_x8x2_avx2 default rel %if 1 %ifidn __OUTPUT_FORMAT__, elf64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; UN*X register definitions %define arg1 rdi ; rcx %define arg2 rsi ; rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %else ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WINDOWS register definitions %define arg1 rcx %define arg2 rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %endif ; Common register definitions %define state arg1 %define len2 arg2 ; idx must be a register not clobberred by md5_mb_x8x2_avx2 %define idx rbp %define unused_lanes r9 %define lane_data r10 %define job_rax rax %define tmp rax %define num_lanes_inuse r8 %endif ;; if 1 ; STACK_SPACE needs to be an odd multiple of 8 _XMM_SAVE_SIZE equ 10*16 _GPR_SAVE_SIZE equ 8*8 _ALIGN_SIZE equ 8 _XMM_SAVE equ 0 _GPR_SAVE equ _XMM_SAVE + _XMM_SAVE_SIZE STACK_SPACE equ _GPR_SAVE + _GPR_SAVE_SIZE + _ALIGN_SIZE %define APPEND(a,b) a %+ b ; JOB* md5_mb_mgr_flush_avx2(MB_MGR_HMAC_OOO *state) ; arg 1 : rcx : state mk_global md5_mb_mgr_flush_avx2, function md5_mb_mgr_flush_avx2: sub rsp, STACK_SPACE mov [rsp + _GPR_SAVE + 8*0], rbx mov [rsp + _GPR_SAVE + 8*3], rbp mov [rsp + _GPR_SAVE + 8*4], r12 mov [rsp + _GPR_SAVE + 8*5], r13 mov [rsp + _GPR_SAVE + 8*6], r14 mov [rsp + _GPR_SAVE + 8*7], r15 %ifidn __OUTPUT_FORMAT__, win64 mov [rsp + _GPR_SAVE + 8*1], rsi mov [rsp + _GPR_SAVE + 8*2], rdi vmovdqa [rsp + _XMM_SAVE + 16*0], xmm6 vmovdqa [rsp + _XMM_SAVE + 16*1], xmm7 vmovdqa [rsp + _XMM_SAVE + 16*2], xmm8 vmovdqa [rsp + _XMM_SAVE + 16*3], xmm9 vmovdqa [rsp + _XMM_SAVE + 16*4], xmm10 vmovdqa [rsp + _XMM_SAVE + 16*5], xmm11 vmovdqa [rsp + _XMM_SAVE + 16*6], xmm12 vmovdqa [rsp + _XMM_SAVE + 16*7], xmm13 vmovdqa [rsp + _XMM_SAVE + 16*8], xmm14 vmovdqa [rsp + _XMM_SAVE + 16*9], xmm15 %endif mov DWORD(num_lanes_inuse), [state + _num_lanes_inuse] cmp num_lanes_inuse, 0 jz return_null ; find a lane with a non-null job xor idx, idx %assign I 1 %rep 15 cmp qword [state + _ldata + I * _LANE_DATA_size + _job_in_lane], 0 cmovne idx, [APPEND(lane_,I)] %assign I (I+1) %endrep ; copy idx to empty lanes copy_lane_data: mov tmp, [state + _args + _data_ptr + 8*idx] %assign I 0 %rep 16 cmp qword [state + _ldata + I * _LANE_DATA_size + _job_in_lane], 0 jne APPEND(skip_,I) mov [state + _args + _data_ptr + 8*I], tmp mov dword [state + _lens + 4*I], 0xFFFFFFFF APPEND(skip_,I): %assign I (I+1) %endrep ; Find min length vmovdqu ymm0, [state + _lens + 0*32] vmovdqu ymm1, [state + _lens + 1*32] vpminud ymm2, ymm0, ymm1 ; ymm2 has {D,C,B,A} vpalignr ymm3, ymm3, ymm2, 8 ; ymm3 has {x,x,D,C} vpminud ymm2, ymm2, ymm3 ; ymm2 has {x,x,E,F} vpalignr ymm3, ymm3, ymm2, 4 ; ymm3 has {x,x,x,E} vpminud ymm2, ymm2, ymm3 ; ymm2 has min value in low dword vperm2i128 ymm3, ymm2, ymm2, 1 ; ymm3 has halves of ymm2 reversed vpminud ymm2, ymm2, ymm3 ; ymm2 has min value in low dword vmovd DWORD(idx), xmm2 mov len2, idx and idx, 0xF shr len2, 4 jz len_is_0 vpand ymm2, ymm2, [rel clear_low_nibble] vpshufd ymm2, ymm2, 0 vpsubd ymm0, ymm0, ymm2 vpsubd ymm1, ymm1, ymm2 vmovdqu [state + _lens + 0*32], ymm0 vmovdqu [state + _lens + 1*32], ymm1 ; "state" and "args" are the same address, arg1 ; len is arg2 call md5_mb_x8x2_avx2 ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _LANE_DATA_size lea lane_data, [state + _ldata + lane_data] mov job_rax, [lane_data + _job_in_lane] mov unused_lanes, [state + _unused_lanes] mov qword [lane_data + _job_in_lane], 0 mov dword [job_rax + _status], STS_COMPLETED shl unused_lanes, 4 or unused_lanes, idx mov [state + _unused_lanes], unused_lanes mov DWORD(num_lanes_inuse), [state + _num_lanes_inuse] sub num_lanes_inuse, 1 mov [state + _num_lanes_inuse], DWORD(num_lanes_inuse) mov dword [state + _lens + 4*idx], 0xFFFFFFFF vmovd xmm0, [state + _args_digest + 4*idx + 0*64] vpinsrd xmm0, [state + _args_digest + 4*idx + 1*64], 1 vpinsrd xmm0, [state + _args_digest + 4*idx + 2*64], 2 vpinsrd xmm0, [state + _args_digest + 4*idx + 3*64], 3 vmovdqa [job_rax + _result_digest + 0*16], xmm0 return: %ifidn __OUTPUT_FORMAT__, win64 vmovdqa xmm6, [rsp + _XMM_SAVE + 16*0] vmovdqa xmm7, [rsp + _XMM_SAVE + 16*1] vmovdqa xmm8, [rsp + _XMM_SAVE + 16*2] vmovdqa xmm9, [rsp + _XMM_SAVE + 16*3] vmovdqa xmm10, [rsp + _XMM_SAVE + 16*4] vmovdqa xmm11, [rsp + _XMM_SAVE + 16*5] vmovdqa xmm12, [rsp + _XMM_SAVE + 16*6] vmovdqa xmm13, [rsp + _XMM_SAVE + 16*7] vmovdqa xmm14, [rsp + _XMM_SAVE + 16*8] vmovdqa xmm15, [rsp + _XMM_SAVE + 16*9] mov rsi, [rsp + _GPR_SAVE + 8*1] mov rdi, [rsp + _GPR_SAVE + 8*2] %endif mov rbx, [rsp + _GPR_SAVE + 8*0] mov rbp, [rsp + _GPR_SAVE + 8*3] mov r12, [rsp + _GPR_SAVE + 8*4] mov r13, [rsp + _GPR_SAVE + 8*5] mov r14, [rsp + _GPR_SAVE + 8*6] mov r15, [rsp + _GPR_SAVE + 8*7] add rsp, STACK_SPACE ret return_null: xor job_rax, job_rax jmp return section .data align=16 align 16 clear_low_nibble: dq 0x00000000FFFFFFF0, 0x0000000000000000 dq 0x00000000FFFFFFF0, 0x0000000000000000 lane_1: dq 1 lane_2: dq 2 lane_3: dq 3 lane_4: dq 4 lane_5: dq 5 lane_6: dq 6 lane_7: dq 7 lane_8: dq 8 lane_9: dq 9 lane_10: dq 10 lane_11: dq 11 lane_12: dq 12 lane_13: dq 13 lane_14: dq 14 lane_15: dq 15
; A108647: a(n) = (n+1)^2*(n+2)^2*(n+3)^2*(n+4)/144. ; 1,20,150,700,2450,7056,17640,39600,81675,157300,286286,496860,828100,1332800,2080800,3162816,4694805,6822900,9728950,13636700,18818646,25603600,34385000,45630000,59889375,77808276,100137870,127747900,161640200,202963200,253027456,313322240,385533225,471561300,573542550,693869436,835213210,1000547600,1193173800,1416746800,1675303091,1973289780,2315595150,2707580700,3155114700,3664607296,4243047200,4898040000,5637848125,6471432500,7408495926,8459528220,9635853150,10949677200,12414140200,14043367856,15852526215,17857878100,20076841550,22528050300,25231416336,28208194560,31481049600,35074124800,39013113425,43325332116,48039796630,53187299900,58800492450,64913965200,71564334696,78790330800,86632886875,95135232500,104342988750,114304266076,125069764820,136692878400,149229799200,162739627200,177284481381,192929613940,209743527350,227798094300,247168680550,267934270736,290177597160,313985271600,339447920175,366660321300,395721546766,426735105980,459809093400,495056339200,532594563200,572546532096,615040220025,660208972500,708191673750,759132917500,813183181226,870499003920,931243167400,995584881200,1063699971075,1135771071156,1211987819790,1292547059100,1377653038300,1467517620800,1562360495136,1662409389760,1767900291725,1879077669300,1996194698550,2119513493916,2249305342830,2385850944400,2529440652200,2680374721200,2838963558871,3005527980500,3180399468750,3363920437500,3556444500000,3758336741376,3969973995520,4191745126400,4424051313825,4667306343700,4921936902806,5188382878140,5467097660850,5758548454800,6063216589800,6381597839536,6714202744235,7061556938100,7424201481550,7802693198300,8197605017316,8609526319680,9039063290400,9486839275200,9953495142325,10439689649396,10946099815350,11473421297500,12022368773750,12593676330000,13188097852776,13806407427120,14449399739775,15117890487700,15812716791950,16534737616956,17284834195240,18063910457600,18872893468800,19712733868800,20584406319561,21488909957460,22427268851350,23400532466300,24409776133050,25456101523216,26540637130280,27664538756400,28828990005075,30035202779700,31284417788046,32577905052700,33916964427500,35302926120000,36737151220000,38221032234176,39755993626845,41343492366900,42985018480950,44682095612700,46436281588606,48249168989840,50122385730600,52057595642800,54056499067175,56120833450836,58252373951310,60452934047100,62724366154800,65068562252800,67487454511616,69983015930880,72557260983025,75212246263700,77950071148950,80772878459196,83682855130050,86682232890000,89773288945000,92958346670000,96239776307451,99619995672820,103101470867150,106686716996700,110378298899700,114178831880256,118090982449440,122117469073600,126261062929925,130524588669300,134910925186486,139423006397660,144063822025350,148836418390800,153743899213800,158789426420016,163976220955855,169307563610900,174786795847950,180417320640700,186202603319096,192146172422400,198251620560000,204522605280000,210962849945625,217576144619476,224366346955670,231337383099900,238493248597450,245838009309200,253375802335656,261110836949040,269047395533475,277189834533300,285542585409550,294110155604636,302897129515260,311908169473600,321148016736800,330621492484800,340333498826541,350289019814580,360493122468150,370950957804700,381667761879950,392648856836496,403899651961000,415425644750000,427232421984375,439325660812500 add $0,4 mov $1,$0 sub $0,1 bin $0,3 pow $0,2 mul $1,$0 mul $1,108 sub $1,432 div $1,432 add $1,1
; $Id: X86Stub.asm $ ;; @file ; VMM - World Switchers, X86 Stub. ; ; ; Copyright (C) 2006-2015 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ;******************************************************************************* ;* Defined Constants And Macros * ;******************************************************************************* %define NAME_OVERLOAD(name) vmmR3SwitcherX86Stub_ %+ name ;******************************************************************************* ;* Header Files * ;******************************************************************************* %include "VBox/asmdefs.mac" %include "VBox/err.mac" %include "VMMSwitcher.mac" BEGINCODE GLOBALNAME Start BITS 32 BEGINPROC vmmR0ToRawMode mov eax, VERR_VMM_SWITCHER_STUB ret ENDPROC vmmR0ToRawMode BEGINPROC vmmRCCallTrampoline .tight_loop: int3 jmp .tight_loop ENDPROC vmmRCCallTrampoline BEGINPROC vmmRCToHost mov eax, VERR_VMM_SWITCHER_STUB ret ENDPROC vmmRCToHost BEGINPROC vmmRCToHostAsmNoReturn mov eax, VERR_VMM_SWITCHER_STUB ret ENDPROC vmmRCToHostAsmNoReturn BEGINPROC vmmRCToHostAsm mov eax, VERR_VMM_SWITCHER_STUB ret ENDPROC vmmRCToHostAsm GLOBALNAME End ; ; The description string (in the text section). ; NAME(Description): db "X86 Stub." db 0 ; ; Dummy fixups. ; BEGINDATA GLOBALNAME Fixups db FIX_THE_END ; final entry. GLOBALNAME FixupsEnd ;; ; The switcher definition structure. ALIGNDATA(16) GLOBALNAME Def istruc VMMSWITCHERDEF at VMMSWITCHERDEF.pvCode, RTCCPTR_DEF NAME(Start) at VMMSWITCHERDEF.pvFixups, RTCCPTR_DEF NAME(Fixups) at VMMSWITCHERDEF.pszDesc, RTCCPTR_DEF NAME(Description) at VMMSWITCHERDEF.pfnRelocate, RTCCPTR_DEF 0 at VMMSWITCHERDEF.enmType, dd VMMSWITCHER_X86_STUB at VMMSWITCHERDEF.cbCode, dd NAME(End) - NAME(Start) at VMMSWITCHERDEF.offR0ToRawMode, dd NAME(vmmR0ToRawMode) - NAME(Start) at VMMSWITCHERDEF.offRCToHost, dd NAME(vmmRCToHost) - NAME(Start) at VMMSWITCHERDEF.offRCCallTrampoline, dd NAME(vmmRCCallTrampoline) - NAME(Start) at VMMSWITCHERDEF.offRCToHostAsm, dd NAME(vmmRCToHostAsm) - NAME(Start) at VMMSWITCHERDEF.offRCToHostAsmNoReturn, dd NAME(vmmRCToHostAsmNoReturn) - NAME(Start) ; disasm help at VMMSWITCHERDEF.offHCCode0, dd 0 at VMMSWITCHERDEF.cbHCCode0, dd NAME(vmmRCCallTrampoline) - NAME(Start) at VMMSWITCHERDEF.offHCCode1, dd 0 at VMMSWITCHERDEF.cbHCCode1, dd 0 at VMMSWITCHERDEF.offIDCode0, dd 0 at VMMSWITCHERDEF.cbIDCode0, dd 0 at VMMSWITCHERDEF.offIDCode1, dd 0 at VMMSWITCHERDEF.cbIDCode1, dd 0 at VMMSWITCHERDEF.offGCCode, dd NAME(vmmRCCallTrampoline) - NAME(Start) at VMMSWITCHERDEF.cbGCCode, dd NAME(End) - NAME(vmmRCCallTrampoline) iend
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_D_ht+0xf5c6, %r12 nop nop nop nop nop sub $11014, %r15 movl $0x61626364, (%r12) nop nop nop nop cmp $56070, %rsi lea addresses_UC_ht+0x1c8e6, %rsi lea addresses_D_ht+0xc3ca, %rdi sub $39668, %rax mov $21, %rcx rep movsl add %rdi, %rdi lea addresses_normal_ht+0x8f66, %rsi lea addresses_A_ht+0x1c439, %rdi nop nop xor $41299, %r14 mov $47, %rcx rep movsb nop sub %r14, %r14 lea addresses_normal_ht+0x7566, %rsi nop inc %r12 mov (%rsi), %r11d nop nop nop nop sub %rcx, %rcx lea addresses_UC_ht+0x20e6, %rsi lea addresses_WT_ht+0xdf66, %rdi nop cmp $35318, %r11 mov $47, %rcx rep movsw nop xor $38610, %r12 lea addresses_UC_ht+0x1e2b6, %rdi nop sub %rcx, %rcx mov (%rdi), %r14w nop nop nop nop sub %rsi, %rsi lea addresses_normal_ht+0x16a56, %rax nop nop nop sub $64912, %r14 mov (%rax), %r12w add %r14, %r14 lea addresses_D_ht+0x1776, %r15 xor %rax, %rax mov (%r15), %r11d nop nop nop nop add %r14, %r14 pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %rax push %rcx // Faulty Load lea addresses_US+0x158e6, %r15 cmp %rax, %rax mov (%r15), %rcx lea oracles, %r14 and $0xff, %rcx shlq $12, %rcx mov (%r14,%rcx,1), %rcx pop %rcx pop %rax pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'00': 6} 00 00 00 00 00 00 */
; A199805: G.f.: 1/(1 + x + 5*x^2 - x^3 + x^4). ; Submitted by Jon Maiga ; 1,-1,-4,10,8,-61,35,268,-512,-732,3525,-645,-17200,24682,57148,-197113,-46745,1064776,-1085312,-4088200,10626281,7664631,-63798924,40190250,275842720,-548257525,-726966901,3703906996,-893172736,-17805071620,26701809197,57726469171,-208147414040,-35978050998,1107739781172,-1193723409393,-4172806133425 mul $0,3 add $0,3 mov $3,8 lpb $0 sub $0,1 sub $3,$4 add $1,$3 mov $5,$4 mov $4,$2 add $5,$2 mov $2,$3 add $4,$1 sub $5,$1 mov $3,$5 lpe mov $0,$2 div $0,24
; A169124: Number of reduced words of length n in Coxeter group on 15 generators S_i with relations (S_i)^2 = (S_i S_j)^26 = I. ; 1,15,210,2940,41160,576240,8067360,112943040,1581202560,22136835840,309915701760,4338819824640,60743477544960,850408685629440,11905721598812160,166680102383370240,2333521433367183360 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,14 lpe mov $0,$2 div $0,14
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1bd30, %rsi lea addresses_D_ht+0x49a7, %rdi clflush (%rsi) nop nop nop nop nop sub %r9, %r9 mov $108, %rcx rep movsq nop nop nop nop add $32394, %r10 lea addresses_A_ht+0x17bf8, %rcx nop nop nop nop nop sub $39204, %rbx mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop nop nop cmp $47202, %rbx lea addresses_WT_ht+0xa388, %r9 nop nop nop sub %rdx, %rdx mov $0x6162636465666768, %rsi movq %rsi, (%r9) nop nop nop cmp %r10, %r10 lea addresses_A_ht+0x15478, %rsi lea addresses_A_ht+0xa388, %rdi nop nop nop nop add $8909, %rdx mov $34, %rcx rep movsl nop add $45423, %r10 lea addresses_normal_ht+0xe208, %rsi inc %rbx mov $0x6162636465666768, %r10 movq %r10, %xmm6 movups %xmm6, (%rsi) nop and $60456, %rdx lea addresses_A_ht+0x10b88, %r9 nop nop nop nop inc %rsi mov $0x6162636465666768, %r10 movq %r10, %xmm0 vmovups %ymm0, (%r9) nop nop cmp %rdx, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r8 push %r9 push %rax push %rsi // Store lea addresses_UC+0xe88, %r12 nop nop nop nop nop dec %r9 movb $0x51, (%r12) and %r8, %r8 // Store mov $0x18c22c0000000088, %rax nop nop nop xor $63932, %r11 movw $0x5152, (%rax) nop nop nop nop nop xor $36117, %r15 // Load lea addresses_US+0x1d788, %r12 nop nop nop nop xor $38669, %rsi movaps (%r12), %xmm6 vpextrq $0, %xmm6, %rax nop nop nop xor %rsi, %rsi // Faulty Load lea addresses_US+0x1d788, %r15 nop and %rsi, %rsi movups (%r15), %xmm3 vpextrq $0, %xmm3, %r8 lea oracles, %r15 and $0xff, %r8 shlq $12, %r8 mov (%r15,%r8,1), %r8 pop %rsi pop %rax pop %r9 pop %r8 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 0, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'00': 25} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A017360: a(n) = (10*n + 7)^8. ; 5764801,6975757441,282429536481,3512479453921,23811286661761,111429157112001,406067677556641,1235736291547681,3282116715437121,7837433594376961,17181861798319201,35114532758015841,67675234241018881,124097929967680321,218041257467152161,369145194573386401,604967116961135041,963354501121950081,1495315559180183521,2268453123948987361,3371031134626313601,4916747105530914241,7050287992278341281,9953750901796946721,13854014124583882561,19031147999601100801,25827959154211353441,34660765693554192481 mul $0,10 add $0,7 pow $0,8
; [fail] [cpu 8086] pause shl ax, 2 [cpu 386] fninit [cpu 386 fpu] fninit [cpu 8086] shl ax, 1 shl ax, 2 movsd push 0
.ORIG x3000 LEA R0, HELLOWORLD PUTS HALT HELLOWORLD .STRINGZ "Hello World\n" .END
zero .INT 0 six .INT 6;19 ltue .INT 42 outp .INT 0 ; Program values ret .BYT 10 EOT .BYT 3 ; End of text hw .BYT 'H' .BYT 'e' .BYT 'l' .BYT 'l' .BYT 'o' spc .BYT 32 .BYT 'w' .BYT 'o' .BYT 'r' .BYT 'l' .BYT 'd' .BYT '!' .BYT 3 ; End of text JMP MAIN prtf LCK hw MOV R7 SP ; Test for overflow ADI R7 -8 ; Adjust for Rtn address & PFP ADI R7 -24 ; Registers ADI R7 -4 ; Vars CMP R7 SL BLT R7 OVERFLOW ; === Store Ret and PFP ============================================== MOV R7 FP ; Save FP in R1, this will be PFP MOV FP SP ; Point at current activation record ADI SP -4 ; Adjust SP for ret address MOV R6 PC ; PC incremented by 1 instruction ADI R6 252 ; Compute return address STR R6 (SP) ; Push return address ADI SP -4 ; Adjust for PFP STR R7 (SP) ; Push PFP to top of stack ; === Store registers ================================================ ADI SP -4 ; R0 STR R0 (SP) ADI SP -4 ; R1 STR R1 (SP) ADI SP -4 ; R2 STR R2 (SP) ADI SP -4 ; R3 STR R3 (SP) ADI SP -4 ; R4 STR R4 (SP) ADI SP -4 ; R5 STR R5 (SP) ; === Store variables ================================================ ADI SP -4 LDA R6 hw STR R6 (SP) ; === Function call ================================================== JMP print ; === Restore the registers MOV R6 FP ADI R6 -12 LDR R0 (R6) ADI R6 -4 LDR R1 (R6) ADI R6 -4 LDR R2 (R6) ADI R6 -4 LDR R3 (R6) ADI R6 -4 LDR R4 (R6) ADI R6 -4 LDR R5 (R6) ADI R6 -4 ; === Roll back SP and FP ============================================ MOV SP FP ADI FP -8 LDR FP (FP) ; === End function call ============================================== ULK hw END print MOV R1 FP ; Copy over the FP ADI R1 -36 ; Bypass the ret addr, PFP, and Registers LDR R2 (R1) ; Load in the value at the 3rd slot up in AR LDB R3 (R2) ; R2 = addr of argument ps_ LDB R0 EOT CMP R0 R3 BRZ R0 eps_ TRP 3 ADI R2 1 LDB R3 (R2) JMP ps_ ; === Begin return call eps_ MOV SP FP ; Test for underflow MOV R5 SP CMP R6 SB BGT R6 UNDERFLOW ; === Store Ret value LDR R7 ZERO ; Return value ; === Return to last location MOV R6 FP ; Return address pointed to by FP ADI R6 -4 LDR R6 (R6) JMR R6 ; === END print ===================================================== func1 ADI R0 1 ADI R0 0 ADI R0 0 ADI R0 0 ADI R0 0 ADI R0 0 ADI R0 1 LDR R1 outp ADD R1 R0 STR R1 outp END MAIN LDR R0 zero RUN R3 prtf TRP 1 RUN R3 prtf TRP 1 BLK LDR R3 ltue TRP 1 TRP 0
; A029007: Expansion of 1/((1-x)(1-x^2)(1-x^4)(1-x^5)). ; 1,1,2,2,4,5,7,8,11,13,17,19,24,27,33,37,44,49,57,63,73,80,91,99,112,122,136,147,163,176,194,208,228,244,266,284,308,328,354,376,405,429,460,486,520,549,585,616,655,689,731,767,812,851,899,941,992,1037,1091,1139,1197,1248,1309,1363,1428,1486,1554,1615,1687,1752,1828,1896,1976,2048,2132,2208,2296,2376,2468,2552,2649,2737,2838,2930,3036,3133,3243,3344,3459,3565,3685,3795,3920,4035,4165,4285,4420,4545,4685,4815,4961,5096,5247,5387,5544,5690,5852,6003,6171,6328,6502,6664,6844,7012,7198,7372,7564,7744,7942,8128,8333,8525,8736,8934,9152,9357,9581,9792,10023,10241,10479,10703,10948,11179,11431,11669,11928,12173,12439,12691,12965,13224,13505,13771,14060,14334,14630,14911,15215,15504,15816,16112,16432,16736,17064,17376,17712,18032,18376,18704,19057,19393,19754,20098,20468,20821,21199,21560,21947,22317,22713,23091,23496,23883,24297,24693,25116,25521,25953,26367,26809,27232,27683,28115,28576,29018,29488,29939,30419,30880,31370,31840,32340,32820,33330,33820,34340,34840,35370,35880,36421,36941,37492,38022,38584,39125,39697,40248,40831,41393,41987,42559,43164,43747,44363,44957,45584,46189,46827,47443,48093,48720,49381,50019,50692,51342,52026,52687,53383,54056,54764,55448,56168,56864,57596,58304,59048,59768,60524,61256,62025,62769,63550,64306,65100,65869,66675,67456,68275,69069 mov $1,17 lpb $0,1 mov $2,$0 sub $0,1 cal $2,25772 ; Expansion of 1/((1-x)(1-x^4)(1-x^5)). sub $0,1 add $1,$2 lpe sub $1,16
#include "blocks/FigureFactory.h" #include "blocks/BrickInfo.h" #include "blocks/FigureInfo.h" #include "SixCatsLogger.h" #include "SixCatsLoggerMacro.h" #include <sstream> USING_NS_CC; using namespace std; using namespace blocks; map<FigureType, FigureType> rotationVariants = { {kQuad, kQuad}, {kZR1, kZR2 }, {kZR2, kZR1}, {kZMirroredR1, kZMirroredR2 }, {kZMirroredR2, kZMirroredR1}, {kTR1, kTR2}, {kTR2, kTR3}, {kTR3, kTR4}, {kTR4, kTR1}, {kLR1, kLR2}, {kLR2, kLR3}, {kLR3, kLR4}, {kLR4, kLR1}, {kLMirroredR1, kLMirroredR2}, {kLMirroredR2, kLMirroredR3}, {kLMirroredR3, kLMirroredR4}, {kLMirroredR4, kLMirroredR1}, {kIR1, kIR2}, {kIR2, kIR1}, }; // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FigureFactory::FigureFactory() { } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FigureFactory::~FigureFactory() { // ntdh } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FigureInfo* FigureFactory::composeNewFigure(const int initialRow) { FigureInfo* result = new FigureInfo(); result->setLogger(c6); const FigureType baseFigureType = getNextRandomType(); list<pair<int, int> > brickData = getNewFigureTemplate(baseFigureType); list<string> brickImages = getNewFigureImages(baseFigureType); const int initialColumn = 3; // int rotationsAmount = 1; result->setRotationsAmount(1); for (const auto& bd: brickData) { BrickInfo positionedBrick; positionedBrick.node = nullptr; if (!brickImages.empty()) { positionedBrick.fileName = brickImages.front(); brickImages.pop_front(); } else { positionedBrick.fileName = ""; } positionedBrick.gameX = bd.first + initialColumn; positionedBrick.gameY = bd.second + initialRow; result->addInitialBrick(0, positionedBrick); } FigureType figureType2 = baseFigureType; auto searchResult = rotationVariants.find(baseFigureType); if (searchResult != rotationVariants.end()) { figureType2 = searchResult->second; } if (baseFigureType == figureType2) { return result; } result->setRotationsAmount(2); brickData = getNewFigureTemplate(figureType2); brickImages = getNewFigureImages(figureType2); for (const auto& bd: brickData) { BrickInfo positionedBrick; positionedBrick.node = nullptr; if (!brickImages.empty()) { positionedBrick.fileName = brickImages.front(); brickImages.pop_front(); } else { positionedBrick.fileName = ""; } positionedBrick.gameX = bd.first + initialColumn; positionedBrick.gameY = bd.second + initialRow; result->addInitialBrick(1, positionedBrick); } FigureType figureType3 = figureType2; searchResult = rotationVariants.find(figureType2); if (searchResult != rotationVariants.end()) { figureType3 = searchResult->second; } if ((baseFigureType == figureType3)||(figureType2 == figureType3)) { return result; } result->setRotationsAmount(3); brickData = getNewFigureTemplate(figureType3); brickImages = getNewFigureImages(figureType3); for (const auto& bd: brickData) { BrickInfo positionedBrick; positionedBrick.node = nullptr; if (!brickImages.empty()) { positionedBrick.fileName = brickImages.front(); brickImages.pop_front(); } else { positionedBrick.fileName = ""; } positionedBrick.gameX = bd.first + initialColumn; positionedBrick.gameY = bd.second + initialRow; result->addInitialBrick(2, positionedBrick); } FigureType figureType4 = figureType3; searchResult = rotationVariants.find(figureType3); if (searchResult != rotationVariants.end()) { figureType4 = searchResult->second; } if ((baseFigureType == figureType4) ||(figureType2 == figureType4)||(figureType3 == figureType4)) { return result; } result->setRotationsAmount(4); brickData = getNewFigureTemplate(figureType4); brickImages = getNewFigureImages(figureType4); for (const auto& bd: brickData) { BrickInfo positionedBrick; positionedBrick.node = nullptr; if (!brickImages.empty()) { positionedBrick.fileName = brickImages.front(); brickImages.pop_front(); } else { positionedBrick.fileName = ""; } positionedBrick.gameX = bd.first + initialColumn; positionedBrick.gameY = bd.second + initialRow; result->addInitialBrick(3, positionedBrick); } return result; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . std::list<std::pair<int, int> > FigureFactory::getNewFigureTemplate(const FigureType type) { list<pair<int, int> > result; switch (type) { case kQuad: result.push_back(make_pair(1,1)); result.push_back(make_pair(2,1)); result.push_back(make_pair(1,2)); result.push_back(make_pair(2,2)); break; case kZR1: result.push_back(make_pair(1,0)); result.push_back(make_pair(2,0)); result.push_back(make_pair(0,1)); result.push_back(make_pair(1,1)); break; case kZR2: result.push_back(make_pair(1,0)); result.push_back(make_pair(1,1)); result.push_back(make_pair(2,1)); result.push_back(make_pair(2,2)); break; case kZMirroredR1: result.push_back(make_pair(0,0)); result.push_back(make_pair(1,0)); result.push_back(make_pair(1,1)); result.push_back(make_pair(2,1)); break; case kZMirroredR2: result.push_back(make_pair(1,0)); result.push_back(make_pair(0,1)); result.push_back(make_pair(1,1)); result.push_back(make_pair(0,2)); break; case kTR1: result.push_back(make_pair(0,0)); //2x result.push_back(make_pair(0,1)); //1xx result.push_back(make_pair(1,1)); //0x result.push_back(make_pair(0,2)); // 012 break; case kTR2: result.push_back(make_pair(0,0)); result.push_back(make_pair(1,0)); result.push_back(make_pair(2,0)); result.push_back(make_pair(1,1)); break; case kTR3: result.push_back(make_pair(2,0)); //2 x result.push_back(make_pair(1,1)); //1 xx result.push_back(make_pair(2,1)); //0 x result.push_back(make_pair(2,2)); // 012 break; case kTR4: result.push_back(make_pair(1,1)); //2xxx result.push_back(make_pair(0,2)); //1 x result.push_back(make_pair(1,2)); //0 result.push_back(make_pair(2,2)); // 012 break; case kLR1: result.push_back(make_pair(0,0)); //2x result.push_back(make_pair(1,0)); //1x result.push_back(make_pair(0,1)); //0xx result.push_back(make_pair(0,2)); // 012 break; case kLR2: result.push_back(make_pair(0,0)); //2 result.push_back(make_pair(1,0)); //1 x result.push_back(make_pair(2,0)); //0xxx result.push_back(make_pair(2,1)); // 012 break; case kLR3: result.push_back(make_pair(2,0)); //2 xx result.push_back(make_pair(2,1)); //1 x result.push_back(make_pair(1,2)); //0 x result.push_back(make_pair(2,2)); // 012 break; case kLR4: result.push_back(make_pair(0,1)); //2xxx result.push_back(make_pair(0,2)); //1x result.push_back(make_pair(1,2)); //0 result.push_back(make_pair(2,2)); // 012 break; // --- case kLMirroredR1: result.push_back(make_pair(1,0)); //2 x result.push_back(make_pair(2,0)); //1 x result.push_back(make_pair(2,1)); //0 xx result.push_back(make_pair(2,2)); // 012 break; case kLMirroredR2: result.push_back(make_pair(2,1)); //2xxx result.push_back(make_pair(0,2)); //1 x result.push_back(make_pair(1,2)); //0 result.push_back(make_pair(2,2)); // 012 break; case kLMirroredR3: result.push_back(make_pair(0,0)); //2xx result.push_back(make_pair(0,1)); //1x result.push_back(make_pair(0,2)); //0x result.push_back(make_pair(1,2)); // 012 break; case kLMirroredR4: result.push_back(make_pair(0,0)); //2 result.push_back(make_pair(1,0)); //1x result.push_back(make_pair(2,0)); //0xxx result.push_back(make_pair(0,1)); // 012 break; // --- case kIR1: // x result.push_back(make_pair(0,0)); //2x result.push_back(make_pair(0,1)); //1x result.push_back(make_pair(0,2)); //0x result.push_back(make_pair(0,3)); // 012 break; case kIR2: result.push_back(make_pair(0,0)); //2 result.push_back(make_pair(1,0)); //1x result.push_back(make_pair(2,0)); //0xxx result.push_back(make_pair(3,0)); // 012 break; default: break; } return result; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . std::list<std::string> FigureFactory::getNewFigureImages(const FigureType type) { list<string> result; switch (type) { case kQuad: result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(1,1)); result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(2,1)); result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(1,2)); result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,2)); break; case kZR1: result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(1,0)); result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(2,0)); result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,1)); result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(1,1)); break; case kZR2: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(1,0)); result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(1,1)); result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(2,1)); result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(2,2)); break; case kZMirroredR1: result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,0)); result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(1,0)); result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(1,1)); result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,1)); break; case kZMirroredR2: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(1,0)); result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,1)); result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(1,1)); result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(0,2)); break; case kTR1: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,0)); //2x result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,1)); //1xx result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(1,1)); //0x result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(0,2)); // 012 break; case kTR2: result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,0)); result.push_back("blocks/bricks/plain_bricks_M1.png");//make_pair(1,0)); result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,0)); result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(1,1)); break; case kTR3: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(2,0)); //2 x result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(1,1)); //1 xx result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,1)); //0 x result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(2,2)); // 012 break; case kTR4: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(1,1)); //2xxx result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,2)); //1 x result.push_back("blocks/bricks/plain_bricks_M1.png");//make_pair(1,2)); //0 result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,2)); // 012 break; case kLR1: result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,0)); //2x result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(1,0)); //1x result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,1)); //0xx result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(0,2)); // 012 break; case kLR2: result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,0)); //2 result.push_back("blocks/bricks/plain_bricks_M1.png");//make_pair(1,0)); //1 x result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,0)); //0xxx result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(2,1)); // 012 break; case kLR3: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(2,0)); //2 xx result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(2,1)); //1 x result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(1,2)); //0 x result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,2)); // 012 break; case kLR4: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,1)); //2xxx result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,2)); //1x result.push_back("blocks/bricks/plain_bricks_M2.png");//make_pair(1,2)); //0 result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(2,2)); // 012 break; case kLMirroredR1: result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(1,0)); //2 x result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,0)); //1 x result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(2,1)); //0 xx result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(2,2)); // 012 break; case kLMirroredR2: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(2,1)); //2xxx result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,2)); //1 x result.push_back("blocks/bricks/plain_bricks_M2.png");//make_pair(1,2)); //0 result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(2,2)); // 012 break; case kLMirroredR3: result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,0)); //2xx result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,1)); //1x result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,2)); //0x result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(1,2)); // 012 break; case kLMirroredR4: result.push_back("blocks/bricks/plain_bricks_L1.png");//make_pair(0,0)); //2 result.push_back("blocks/bricks/plain_bricks_M1.png");//make_pair(1,0)); //1x result.push_back("blocks/bricks/plain_bricks_R1.png");//make_pair(2,0)); //0xxx result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(0,1)); // 012 break; case kIR1: // x result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,0)); //2x result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,1)); //1x result.push_back("blocks/bricks/plain_bricks_S1.png");//make_pair(0,2)); //0x result.push_back("blocks/bricks/plain_bricks_S2.png");//make_pair(0,3)); // 012 break; case kIR2: result.push_back("blocks/bricks/plain_bricks_L2.png");//make_pair(0,0)); //2 result.push_back("blocks/bricks/plain_bricks_M2.png");//make_pair(1,0)); //1x result.push_back("blocks/bricks/plain_bricks_M2.png");//make_pair(2,0)); //0xxx result.push_back("blocks/bricks/plain_bricks_R2.png");//make_pair(3,0)); // 012 break; default: break; } return result; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FigureType FigureFactory::getNextRandomType() { FigureType result = kQuad; if (randomSeq.empty()) { generateRandomSeq(); } if (!randomSeq.empty()) { result = randomSeq.front(); randomSeq.pop_front(); } return result; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . void FigureFactory::generateRandomSeq() { const int availableTypesCount = 19; FigureType availableTypes[] = { kQuad, kZR1, kZR2, kZMirroredR1, kZMirroredR2, kTR1, kTR2, kTR3, kTR4, kLR1, kLR2, kLR3, kLR4, kLMirroredR1, kLMirroredR2, kLMirroredR3, kLMirroredR4, kIR1, kIR2, }; for(int i = 0; i<40; i++ ) { int rv = RandomHelper::random_int((int)0, availableTypesCount-1); randomSeq.push_back(availableTypes[rv]); C6_D4(c6, "Added ", availableTypes[rv], " for ", rv); } } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
; A317637: a(n) = n*(n+1)*(n+3). ; 0,8,30,72,140,240,378,560,792,1080,1430,1848,2340,2912,3570,4320,5168,6120,7182,8360,9660,11088,12650,14352,16200,18200,20358,22680,25172,27840,30690,33728,36960,40392,44030,47880,51948,56240,60762,65520,70520,75768,81270,87032 mov $1,3 add $1,$0 add $0,1 mul $1,$0 sub $0,1 mul $1,$0
// Copyright (c) 2016-2019 The XBit Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <versionbits.h> #include <consensus/params.h> ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const { int nPeriod = Period(params); int nThreshold = Threshold(params); int64_t nTimeStart = BeginTime(params); int64_t nTimeTimeout = EndTime(params); // Check if this deployment is always active. if (nTimeStart == Consensus::BIP9Deployment::ALWAYS_ACTIVE) { return ThresholdState::ACTIVE; } // A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1. if (pindexPrev != nullptr) { pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod)); } // Walk backwards in steps of nPeriod to find a pindexPrev whose information is known std::vector<const CBlockIndex*> vToCompute; while (cache.count(pindexPrev) == 0) { if (pindexPrev == nullptr) { // The genesis block is by definition defined. cache[pindexPrev] = ThresholdState::DEFINED; break; } if (pindexPrev->GetMedianTimePast() < nTimeStart) { // Optimization: don't recompute down further, as we know every earlier block will be before the start time cache[pindexPrev] = ThresholdState::DEFINED; break; } vToCompute.push_back(pindexPrev); pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - nPeriod); } // At this point, cache[pindexPrev] is known assert(cache.count(pindexPrev)); ThresholdState state = cache[pindexPrev]; // Now walk forward and compute the state of descendants of pindexPrev while (!vToCompute.empty()) { ThresholdState stateNext = state; pindexPrev = vToCompute.back(); vToCompute.pop_back(); switch (state) { case ThresholdState::DEFINED: { if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) { stateNext = ThresholdState::FAILED; } else if (pindexPrev->GetMedianTimePast() >= nTimeStart) { stateNext = ThresholdState::STARTED; } break; } case ThresholdState::STARTED: { if (pindexPrev->GetMedianTimePast() >= nTimeTimeout) { stateNext = ThresholdState::FAILED; break; } // We need to count const CBlockIndex* pindexCount = pindexPrev; int count = 0; for (int i = 0; i < nPeriod; i++) { if (Condition(pindexCount, params)) { count++; } pindexCount = pindexCount->pprev; } if (count >= nThreshold) { stateNext = ThresholdState::LOCKED_IN; } break; } case ThresholdState::LOCKED_IN: { // Always progresses into ACTIVE. stateNext = ThresholdState::ACTIVE; break; } case ThresholdState::FAILED: case ThresholdState::ACTIVE: { // Nothing happens, these are terminal states. break; } } cache[pindexPrev] = state = stateNext; } return state; } BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockIndex* pindex, const Consensus::Params& params) const { BIP9Stats stats = {}; stats.period = Period(params); stats.threshold = Threshold(params); if (pindex == nullptr) return stats; // Find beginning of period const CBlockIndex* pindexEndOfPrevPeriod = pindex->GetAncestor(pindex->nHeight - ((pindex->nHeight + 1) % stats.period)); stats.elapsed = pindex->nHeight - pindexEndOfPrevPeriod->nHeight; // Count from current block to beginning of period int count = 0; const CBlockIndex* currentIndex = pindex; while (pindexEndOfPrevPeriod->nHeight != currentIndex->nHeight){ if (Condition(currentIndex, params)) count++; currentIndex = currentIndex->pprev; } stats.count = count; stats.possible = (stats.period - stats.threshold ) >= (stats.elapsed - count); return stats; } int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const { int64_t start_time = BeginTime(params); if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE) { return 0; } const ThresholdState initialState = GetStateFor(pindexPrev, params, cache); // BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment." if (initialState == ThresholdState::DEFINED) { return 0; } const int nPeriod = Period(params); // A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1. // To ease understanding of the following height calculation, it helps to remember that // right now pindexPrev points to the block prior to the block that we are computing for, thus: // if we are computing for the last block of a period, then pindexPrev points to the second to last block of the period, and // if we are computing for the first block of a period, then pindexPrev points to the last block of the previous period. // The parent of the genesis block is represented by nullptr. pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod)); const CBlockIndex* previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeight - nPeriod); while (previousPeriodParent != nullptr && GetStateFor(previousPeriodParent, params, cache) == initialState) { pindexPrev = previousPeriodParent; previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeight - nPeriod); } // Adjust the result because right now we point to the parent block. return pindexPrev->nHeight + 1; } namespace { /** * Class to implement versionbits logic. */ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { private: const Consensus::DeploymentPos id; protected: int64_t BeginTime(const Consensus::Params& params) const override { return params.vDeployments[id].nStartTime; } int64_t EndTime(const Consensus::Params& params) const override { return params.vDeployments[id].nTimeout; } int Period(const Consensus::Params& params) const override { return params.nMinerConfirmationWindow; } int Threshold(const Consensus::Params& params) const override { return params.nRuleChangeActivationThreshold; } bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const override { return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (pindex->nVersion & Mask(params)) != 0); } public: explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {} uint32_t Mask(const Consensus::Params& params) const { return ((uint32_t)1) << params.vDeployments[id].bit; } }; } // namespace ThresholdState VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache) { return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.caches[pos]); } BIP9Stats VersionBitsStatistics(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos) { return VersionBitsConditionChecker(pos).GetStateStatisticsFor(pindexPrev, params); } int VersionBitsStateSinceHeight(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache) { return VersionBitsConditionChecker(pos).GetStateSinceHeightFor(pindexPrev, params, cache.caches[pos]); } uint32_t VersionBitsMask(const Consensus::Params& params, Consensus::DeploymentPos pos) { return VersionBitsConditionChecker(pos).Mask(params); } void VersionBitsCache::Clear() { for (unsigned int d = 0; d < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; d++) { caches[d].clear(); } }
; Copyright 2018-2019 Brian Otto @ https://hackerpulp.com ; ; Permission to use, copy, modify, and/or distribute this software for any ; purpose with or without fee is hereby granted, provided that the above ; copyright notice and this permission notice appear in all copies. ; ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH ; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, ; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. ; we use the same calling conventions as UEFI ; see http://www.uefi.org/sites/default/files/resources/UEFI Spec 2_7_A Sept 6.pdf#G6.1000069 apiVerifySignature: ; get the signature for the loaded EFI_SYSTEM_TABLE mov rcx, [ptrSystemTable] mov rcx, [rcx + EFI_SYSTEM_TABLE.Hdr + EFI_TABLE_HEADER.Signature] ; get the signature defined in the UEFI spec ; see http://www.uefi.org/sites/default/files/resources/UEFI Spec 2_7_A Sept 6.pdf#G8.1001773 mov rdx, EFI_SYSTEM_TABLE_SIGNATURE ; set our error code mov rax, EFI_LOAD_ERROR ; compare the signatures and return the error code when they don't match cmp rdx, rcx jne error mov rax, EFI_SUCCESS ret apiOutputHeader: ; clear the screen call efiClearScreen ; write the header mov rcx, strHeader call efiOutputString ; write the firmware vendor mov rcx, [ptrSystemTable] mov rcx, [rcx + EFI_SYSTEM_TABLE.FirmwareVendor] call efiOutputString ; write the v mov rcx, strHeaderV call efiOutputString ; write the firmware revision mov rcx, [ptrSystemTable] mov rcx, [rcx + EFI_SYSTEM_TABLE.FirmwareRevision] call funIntegerToAscii ret apiGetFrameBuffer: ; locate the first EFI_GRAPHICS_OUTPUT_PROTOCOL ; and allocate a frame buffer call efiLocateProtocol ; get the base address of the frame buffer mov rcx, [ptrInterface] mov rcx, [rcx + EFI_GRAPHICS_OUTPUT_PROTOCOL.Mode] mov rcx, [rcx + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.FrameBufferBase] mov [ptrFrameBuffer], rcx ret apiExitUEFI: call efiGetMemoryMap call efiExitBootServices ret apiLoadKernel: ; verify we have reached this point ; by resetting the machine ; mov rax, [ptrSystemTable] ; mov rax, [rax + EFI_SYSTEM_TABLE.RuntimeServices] ; call [rax + EFI_RUNTIME_SERVICES.ResetSystem] ; set the 1st argument to our frame buffer mov rcx, [ptrFrameBuffer] ; set the 2nd argument to our start position mov rdx, 0 ; set the 3rd argument to our end position ; this should be in multiples of 4 mov r8, 1024 * 100 call funDrawLine ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x19935, %rsi lea addresses_A_ht+0xffd7, %rdi nop nop nop nop nop and $58593, %r12 mov $25, %rcx rep movsb nop nop nop nop nop dec %rdx lea addresses_A_ht+0x12f35, %rbx nop nop nop nop dec %rdx movw $0x6162, (%rbx) and $14995, %rsi lea addresses_UC_ht+0x10190, %rsi lea addresses_WT_ht+0x7135, %rdi nop sub $29575, %r9 mov $85, %rcx rep movsq nop inc %rsi lea addresses_D_ht+0x5935, %rdi nop dec %rsi mov $0x6162636465666768, %r12 movq %r12, (%rdi) sub $2970, %rbx lea addresses_D_ht+0x9f1d, %r12 nop nop nop nop xor $61298, %rdi movb $0x61, (%r12) nop nop nop inc %rbx lea addresses_A_ht+0x10d35, %rsi lea addresses_D_ht+0x10535, %rdi nop sub $51831, %r10 mov $124, %rcx rep movsq nop xor $52025, %r12 lea addresses_WC_ht+0x12135, %rsi lea addresses_normal_ht+0x156cd, %rdi nop cmp %r10, %r10 mov $83, %rcx rep movsw nop nop and %r10, %r10 lea addresses_D_ht+0x6135, %rsi lea addresses_WT_ht+0x10935, %rdi nop nop nop nop nop sub %r12, %r12 mov $68, %rcx rep movsq nop inc %rbx lea addresses_WC_ht+0x4335, %rdi nop nop nop nop nop dec %rcx movb $0x61, (%rdi) nop nop nop nop nop xor $4758, %rcx lea addresses_UC_ht+0x14335, %rsi dec %rcx movups (%rsi), %xmm1 vpextrq $1, %xmm1, %rbx nop nop nop nop nop sub $2023, %rcx lea addresses_D_ht+0x7619, %rdx add $65503, %rsi mov (%rdx), %rdi nop nop nop sub %r10, %r10 lea addresses_UC_ht+0x1b4c5, %rdi nop nop nop nop nop and %r10, %r10 mov $0x6162636465666768, %rsi movq %rsi, (%rdi) nop nop nop nop sub %rdx, %rdx lea addresses_A_ht+0x8d35, %rsi lea addresses_D_ht+0x193a5, %rdi nop nop sub %r9, %r9 mov $49, %rcx rep movsb nop nop sub $36232, %r9 lea addresses_A_ht+0x19e5, %r10 nop nop nop nop nop xor %r12, %r12 mov (%r10), %di nop nop nop add $62600, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r15 push %rbp push %rcx push %rsi // Faulty Load lea addresses_normal+0x11135, %r11 nop nop nop cmp %rsi, %rsi movb (%r11), %r14b lea oracles, %r12 and $0xff, %r14 shlq $12, %r14 mov (%r12,%r14,1), %r14 pop %rsi pop %rcx pop %rbp pop %r15 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 0, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 2, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
/* * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. * * GROMACS is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * GROMACS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with GROMACS; if not, see * http://www.gnu.org/licenses, or write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * If you want to redistribute modifications to GROMACS, please * consider that scientific software is very special. Version * control is crucial - bugs must be traceable. We will be happy to * consider code for inclusion in the official distribution, but * derived work must not be called official GROMACS. Details are found * in the README & COPYING files - if they are missing, get the * official version at http://www.gromacs.org. * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ #include "gmxpre.h" #include "gromacs/fileio/filetypes.h" #include <cstring> #include "gromacs/utility/arraysize.h" #include "gromacs/utility/cstringutil.h" enum { eftASC, eftXDR, eftTNG, eftGEN, eftNR }; /* To support multiple file types with one general (eg TRX) we have * these arrays. */ static const int trxs[] = { efXTC, efTRR, efCPT, efGRO, efG96, efPDB, efTNG }; #define NTRXS asize(trxs) static const int trcompressed[] = { efXTC, efTNG }; #define NTRCOMPRESSED asize(trcompressed) static const int tros[] = { efXTC, efTRR, efGRO, efG96, efPDB, efTNG }; #define NTROS asize(tros) static const int trns[] = { efTRR, efCPT, efTNG }; #define NTRNS asize(trns) static const int stos[] = { efGRO, efG96, efPDB, efBRK, efENT, efESP }; #define NSTOS asize(stos) static const int stxs[] = { efGRO, efG96, efPDB, efBRK, efENT, efESP, efTPR }; #define NSTXS asize(stxs) static const int tpss[] = { efTPR, efGRO, efG96, efPDB, efBRK, efENT }; #define NTPSS asize(tpss) typedef struct // NOLINT(clang-analyzer-optin.performance.Padding) { int ftype; const char* ext; const char* defnm; const char* defopt; const char* descr; int ntps; const int* tps; } t_deffile; /* this array should correspond to the enum in filetypes.h */ static const t_deffile deffile[efNR] = { { eftASC, ".mdp", "grompp", "-f", "grompp input file with MD parameters" }, { eftGEN, ".???", "traj", "-f", "Trajectory", NTRXS, trxs }, { eftGEN, ".???", "trajout", "-f", "Trajectory", NTROS, tros }, { eftGEN, ".???", "traj", nullptr, "Full precision trajectory", NTRNS, trns }, { eftXDR, ".trr", "traj", nullptr, "Trajectory in portable xdr format" }, { eftGEN, ".???", "traj_comp", nullptr, "Compressed trajectory (tng format or portable xdr format)", NTRCOMPRESSED, trcompressed }, { eftXDR, ".xtc", "traj", nullptr, "Compressed trajectory (portable xdr format): xtc" }, { eftTNG, ".tng", "traj", nullptr, "Trajectory file (tng format)" }, { eftXDR, ".edr", "ener", nullptr, "Energy file" }, { eftGEN, ".???", "conf", "-c", "Structure file", NSTXS, stxs }, { eftGEN, ".???", "out", "-o", "Structure file", NSTOS, stos }, { eftASC, ".gro", "conf", "-c", "Coordinate file in Gromos-87 format" }, { eftASC, ".g96", "conf", "-c", "Coordinate file in Gromos-96 format" }, { eftASC, ".pdb", "eiwit", "-f", "Protein data bank file" }, { eftASC, ".brk", "eiwit", "-f", "Brookhaven data bank file" }, { eftASC, ".ent", "eiwit", "-f", "Entry in the protein date bank" }, { eftASC, ".esp", "conf", "-f", "Coordinate file in Espresso format" }, { eftASC, ".pqr", "state", "-o", "Coordinate file for MEAD" }, { eftXDR, ".cpt", "state", "-cp", "Checkpoint file" }, { eftASC, ".log", "run", "-l", "Log file" }, { eftASC, ".xvg", "graph", "-o", "xvgr/xmgr file" }, { eftASC, ".out", "hello", "-o", "Generic output file" }, { eftASC, ".ndx", "index", "-n", "Index file", }, { eftASC, ".top", "topol", "-p", "Topology file" }, { eftASC, ".itp", "topinc", nullptr, "Include file for topology" }, { eftGEN, ".???", "topol", "-s", "Structure+mass(db)", NTPSS, tpss }, { eftXDR, ".tpr", "topol", "-s", "Portable xdr run input file" }, { eftASC, ".tex", "doc", "-o", "LaTeX file" }, { eftASC, ".rtp", "residue", nullptr, "Residue Type file used by pdb2gmx" }, { eftASC, ".atp", "atomtp", nullptr, "Atomtype file used by pdb2gmx" }, { eftASC, ".hdb", "polar", nullptr, "Hydrogen data base" }, { eftASC, ".dat", "nnnice", nullptr, "Generic data file" }, { eftASC, ".dlg", "user", nullptr, "Dialog Box data for ngmx" }, { eftASC, ".map", "ss", nullptr, "File that maps matrix data to colors" }, { eftASC, ".eps", "plot", nullptr, "Encapsulated PostScript (tm) file" }, { eftASC, ".mat", "ss", nullptr, "Matrix Data file" }, { eftASC, ".m2p", "ps", nullptr, "Input file for mat2ps" }, { eftXDR, ".mtx", "hessian", "-m", "Hessian matrix" }, { eftASC, ".edi", "sam", nullptr, "ED sampling input" }, { eftASC, ".cub", "pot", nullptr, "Gaussian cube file" }, { eftASC, ".xpm", "root", nullptr, "X PixMap compatible matrix file" }, { eftASC, "", "rundir", nullptr, "Run directory" }, { eftASC, ".csv", "bench", nullptr, "CSV data file" }, { eftASC, ".inp", "topol-qmmm", nullptr, "Input file for QM program" } }; const char* ftp2ext(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].ext[0] != '\0' ? deffile[ftp].ext + 1 : ""; } else { return "unknown"; } } const char* ftp2ext_generic(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { switch (ftp) { case efTRX: return "trx"; case efTRN: return "trn"; case efSTO: return "sto"; case efSTX: return "stx"; case efTPS: return "tps"; default: return ftp2ext(ftp); } } else { return "unknown"; } } const char* ftp2ext_with_dot(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].ext; } else { return "unknown"; } } int ftp2generic_count(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].ntps; } else { return 0; } } const int* ftp2generic_list(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].tps; } else { return nullptr; } } const char* ftp2desc(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].descr; } else { return "unknown filetype"; } } gmx_bool ftp_is_text(int ftp) { if ((ftp >= 0) && (ftp < efNR)) { return deffile[ftp].ftype == eftASC; } return FALSE; } gmx_bool ftp_is_xdr(int ftp) { if ((ftp >= 0) && (ftp < efNR)) { return deffile[ftp].ftype == eftXDR; } return FALSE; } const char* ftp2defnm(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].defnm; } else { return nullptr; } } const char* ftp2defopt(int ftp) { if ((0 <= ftp) && (ftp < efNR)) { return deffile[ftp].defopt; } else { return nullptr; } } int fn2ftp(const char* fn) { int i, len; const char* feptr; const char* eptr; if (!fn) { return efNR; } len = std::strlen(fn); if ((len >= 4) && (fn[len - 4] == '.')) { feptr = &(fn[len - 4]); } else { return efNR; } for (i = 0; (i < efNR); i++) { if ((eptr = deffile[i].ext) != nullptr) { if (gmx_strcasecmp(feptr, eptr) == 0) { break; } } } return i; }
//********************************************* // This is auto generated by G4gen 0.6 // author:Qian #ifndef MyRunAction_h #define MyRunAction_h 1 #include "G4UserRunAction.hh" #include "globals.hh" class MyRunAction : public G4UserRunAction { public: MyRunAction(); virtual ~MyRunAction(); virtual void BeginOfRunAction(const G4Run *run); virtual void EndOfRunAction(const G4Run *run); int particleNumber; }; #endif
;@DOES Close an open file slot ;@INPUT A = file handle ;@DESTROYS HL,DE,BC,AF,IX ;@NOTE does nothing if A==0 or A>31 fs_Close: call fs_GetFileHandlePtr ret nc ex hl,de ld bc,8 jq util_VoidPtr
SECTION rodata_font_fzx PUBLIC _ff_dkud2_Roman _ff_dkud2_Roman: BINARY "font/fzx/fonts/dkud2/Roman/roman.fzx"
; Assembly for testright-native.bas ; compiled with mcbasic -native ; Equates for MC-10 MICROCOLOR BASIC 1.0 ; ; Direct page equates DP_LNUM .equ $E2 ; current line in BASIC DP_TABW .equ $E4 ; current tab width on console DP_LPOS .equ $E6 ; current line position on console DP_LWID .equ $E7 ; current line width of console ; ; Memory equates M_KBUF .equ $4231 ; keystrobe buffer (8 bytes) M_PMSK .equ $423C ; pixel mask for SET, RESET and POINT M_IKEY .equ $427F ; key code for INKEY$ M_CRSR .equ $4280 ; cursor location M_LBUF .equ $42B2 ; line input buffer (130 chars) M_MSTR .equ $4334 ; buffer for small string moves M_CODE .equ $4346 ; start of program space ; ; ROM equates R_BKMSG .equ $E1C1 ; 'BREAK' string location R_ERROR .equ $E238 ; generate error and restore direct mode R_BREAK .equ $E266 ; generate break and restore direct mode R_RESET .equ $E3EE ; setup stack and disable CONT R_SPACE .equ $E7B9 ; emit " " to console R_QUEST .equ $E7BC ; emit "?" to console R_REDO .equ $E7C1 ; emit "?REDO" to console R_EXTRA .equ $E8AB ; emit "?EXTRA IGNORED" to console R_DMODE .equ $F7AA ; display OK prompt and restore direct mode R_KPOLL .equ $F879 ; if key is down, do KEYIN, else set Z CCR flag R_KEYIN .equ $F883 ; poll key for key-down transition set Z otherwise R_PUTC .equ $F9C9 ; write ACCA to console R_MKTAB .equ $FA7B ; setup tabs for console R_GETLN .equ $FAA4 ; get line, returning with X pointing to M_BUF-1 R_SETPX .equ $FB44 ; write pixel character to X R_CLRPX .equ $FB59 ; clear pixel character in X R_MSKPX .equ $FB7C ; get pixel screen location X and mask in R_PMSK R_CLSN .equ $FBC4 ; clear screen with color code in ACCB R_CLS .equ $FBD4 ; clear screen with space character R_SOUND .equ $FFAB ; play sound with pitch in ACCA and duration in ACCB R_MCXID .equ $FFDA ; ID location for MCX BASIC ; direct page registers .org $80 strtcnt .block 1 strbuf .block 2 strend .block 2 strfree .block 2 strstop .block 2 dataptr .block 2 inptptr .block 2 redoptr .block 2 letptr .block 2 .org $a3 r1 .block 5 r2 .block 5 rend rvseed .block 2 tmp1 .block 2 tmp2 .block 2 tmp3 .block 2 tmp4 .block 2 tmp5 .block 2 argv .block 10 ; main program .org M_CODE jsr progbegin jsr clear LINE_0 ; X=3 ldx #INTVAR_X ldab #3 jsr ld_ix_pb LINE_10 ; PRINT RIGHT$("FRED",X) jsr ld_sr1_ss .text 4, "FRED" ldx #INTVAR_X jsr right_sr1_sr1_ix jsr pr_sr1 jsr pr_ss .text 1, "\r" LINE_20 ; PRINT RIGHT$("FRED",X-1) jsr ld_sr1_ss .text 4, "FRED" ldx #INTVAR_X jsr ld_ir2_ix ldab #1 jsr sub_ir2_ir2_pb jsr right_sr1_sr1_ir2 jsr pr_sr1 jsr pr_ss .text 1, "\r" LINE_30 ; PRINT RIGHT$("FRED",X-2) jsr ld_sr1_ss .text 4, "FRED" ldx #INTVAR_X jsr ld_ir2_ix ldab #2 jsr sub_ir2_ir2_pb jsr right_sr1_sr1_ir2 jsr pr_sr1 jsr pr_ss .text 1, "\r" LINE_40 ; PRINT RIGHT$("FRED",X-3) jsr ld_sr1_ss .text 4, "FRED" ldx #INTVAR_X jsr ld_ir2_ix ldab #3 jsr sub_ir2_ir2_pb jsr right_sr1_sr1_ir2 jsr pr_sr1 jsr pr_ss .text 1, "\r" LINE_50 ; PRINT jsr pr_ss .text 1, "\r" LINE_60 ; PRINT "D" jsr pr_ss .text 2, "D\r" LINE_70 ; PRINT "ED" jsr pr_ss .text 3, "ED\r" LINE_80 ; PRINT "RED" jsr pr_ss .text 4, "RED\r" LLAST ; END jsr progend .module mdprint print _loop ldaa ,x jsr R_PUTC inx decb bne _loop rts .module mdstrrel ; release a temporary string ; ENTRY: X holds string start ; EXIT: <all reg's preserved> ; sttrel should be called from: ; - ASC, VAL, LEN, PRINT ; - right hand side of strcat ; - relational operators ; - when LEFT$, MID$, RIGHT$ return null strrel cpx strend bls _rts cpx strstop bhs _rts tst strtcnt beq _panic dec strtcnt beq _restore stx strfree _rts rts _restore pshx ldx strend inx inx stx strfree pulx rts _panic ldab #1 jmp error clear ; numCalls = 1 .module modclear clra ldx #bss bra _start _again staa ,x inx _start cpx #bes bne _again stx strbuf stx strend inx inx stx strfree ldx #$8FFF stx strstop ldx #startdata stx dataptr rts ld_ir2_ix ; numCalls = 3 .module modld_ir2_ix ldd 1,x std r2+1 ldab 0,x stab r2 rts ld_ix_pb ; numCalls = 1 .module modld_ix_pb stab 2,x ldd #0 std 0,x rts ld_sr1_ss ; numCalls = 4 .module modld_sr1_ss pulx ldab ,x stab r1 inx stx r1+1 abx jmp ,x pr_sr1 ; numCalls = 4 .module modpr_sr1 ldab r1 beq _rts ldx r1+1 jsr print ldx r1+1 jmp strrel _rts rts pr_ss ; numCalls = 8 .module modpr_ss pulx ldab ,x beq _null inx jsr print jmp ,x _null jmp 1,x progbegin ; numCalls = 1 .module modprogbegin ldx R_MCXID cpx #'h'*256+'C' bne _mcbasic pulx clrb pshb pshb pshb stab strtcnt jmp ,x _reqmsg .text "?MICROCOLOR BASIC ROM REQUIRED" _mcbasic ldx #_reqmsg ldab #30 jsr print pulx rts progend ; numCalls = 1 .module modprogend pulx pula pula pula jsr R_RESET jmp R_DMODE NF_ERROR .equ 0 RG_ERROR .equ 4 OD_ERROR .equ 6 FC_ERROR .equ 8 OV_ERROR .equ 10 OM_ERROR .equ 12 BS_ERROR .equ 16 DD_ERROR .equ 18 LS_ERROR .equ 28 error jmp R_ERROR right_sr1_sr1_ir2 ; numCalls = 3 .module modright_sr1_sr1_ir2 ldd r2 bne _rts ldab r1 subb r2+2 bls _rts clra addd r1+1 std r1+1 ldab r2+2 beq _zero cmpb r1 bhs _rts stab r1 rts _zero pshx ldx r1+1 jsr strrel pulx ldd #$0100 std r1+1 stab r1 _rts rts right_sr1_sr1_ix ; numCalls = 1 .module modright_sr1_sr1_ix ldd 0,x bne _rts ldab r1 subb 2,x bls _rts clra addd r1+1 std r1+1 ldab 2,x beq _zero cmpb r1 bhs _rts stab r1 rts _zero pshx ldx r1+1 jsr strrel pulx ldd #$0100 std r1+1 stab r1 _rts rts sub_ir2_ir2_pb ; numCalls = 3 .module modsub_ir2_ir2_pb stab tmp1 ldd r2+1 subb tmp1 sbca #0 std r2+1 ldab r2 sbcb #0 stab r2 rts ; data table startdata enddata ; block started by symbol bss ; Numeric Variables INTVAR_X .block 3 ; String Variables ; Numeric Arrays ; String Arrays ; block ended by symbol bes .end
/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \class QGraphicsItemAnimation \brief The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem. \since 4.2 \ingroup graphicsview-api \inmodule QtWidgets \deprecated The QGraphicsItemAnimation class animates a QGraphicsItem. You can schedule changes to the item's transformation matrix at specified steps. The QGraphicsItemAnimation class has a current step value. When this value changes the transformations scheduled at that step are performed. The current step of the animation is set with the \c setStep() function. QGraphicsItemAnimation will do a simple linear interpolation between the nearest adjacent scheduled changes to calculate the matrix. For instance, if you set the position of an item at values 0.0 and 1.0, the animation will show the item moving in a straight line between these positions. The same is true for scaling and rotation. It is usual to use the class with a QTimeLine. The timeline's \l{QTimeLine::}{valueChanged()} signal is then connected to the \c setStep() slot. For example, you can set up an item for rotation by calling \c setRotationAt() for different step values. The animations timeline is set with the setTimeLine() function. An example animation with a timeline follows: \snippet timeline/main.cpp 0 Note that steps lie between 0.0 and 1.0. It may be necessary to use \l{QTimeLine::}{setUpdateInterval()}. The default update interval is 40 ms. A scheduled transformation cannot be removed when set, so scheduling several transformations of the same kind (e.g., rotations) at the same step is not recommended. \sa QTimeLine, {Graphics View Framework} */ #include "qgraphicsitemanimation.h" #ifndef QT_NO_GRAPHICSVIEW #include "qgraphicsitem.h" #include <QtCore/qtimeline.h> #include <QtCore/qpoint.h> #include <QtCore/qpointer.h> #include <QtCore/qpair.h> #include <QtGui/qmatrix.h> #include <algorithm> QT_BEGIN_NAMESPACE static inline bool check_step_valid(qreal step, const char *method) { if (!(step >= 0 && step <= 1)) { qWarning("QGraphicsItemAnimation::%s: invalid step = %f", method, step); return false; } return true; } class QGraphicsItemAnimationPrivate { public: inline QGraphicsItemAnimationPrivate() : q(0), timeLine(0), item(0), step(0) { } QGraphicsItemAnimation *q; QPointer<QTimeLine> timeLine; QGraphicsItem *item; QPointF startPos; QMatrix startMatrix; qreal step; struct Pair { Pair(qreal a, qreal b) : step(a), value(b) {} bool operator <(const Pair &other) const { return step < other.step; } bool operator==(const Pair &other) const { return step == other.step; } qreal step; qreal value; }; QList<Pair> xPosition; QList<Pair> yPosition; QList<Pair> rotation; QList<Pair> verticalScale; QList<Pair> horizontalScale; QList<Pair> verticalShear; QList<Pair> horizontalShear; QList<Pair> xTranslation; QList<Pair> yTranslation; qreal linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue = 0); void insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method); }; qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue) { if (source->isEmpty()) return defaultValue; step = qMin<qreal>(qMax<qreal>(step, 0), 1); if (step == 1) return source->last().value; qreal stepBefore = 0; qreal stepAfter = 1; qreal valueBefore = source->first().step == 0 ? source->first().value : defaultValue; qreal valueAfter = source->last().value; // Find the closest step and value before the given step. for (int i = 0; i < source->size() && step >= source->at(i).step; ++i) { stepBefore = source->at(i).step; valueBefore = source->at(i).value; } // Find the closest step and value after the given step. for (int j = source->size() - 1; j >= 0 && step < source->at(j).step; --j) { stepAfter = source->at(j).step; valueAfter = source->at(j).value; } // Do a simple linear interpolation. return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore)); } void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method) { if (!check_step_valid(step, method)) return; Pair pair(step, value); QList<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair); if ((result != binList->end()) && !(pair < *result)) result->value = value; else { *binList << pair; std::sort(binList->begin(), binList->end()); } } /*! Constructs an animation object with the given \a parent. */ QGraphicsItemAnimation::QGraphicsItemAnimation(QObject *parent) : QObject(parent), d(new QGraphicsItemAnimationPrivate) { d->q = this; } /*! Destroys the animation object. */ QGraphicsItemAnimation::~QGraphicsItemAnimation() { delete d; } /*! Returns the item on which the animation object operates. \sa setItem() */ QGraphicsItem *QGraphicsItemAnimation::item() const { return d->item; } /*! Sets the specified \a item to be used in the animation. \sa item() */ void QGraphicsItemAnimation::setItem(QGraphicsItem *item) { d->item = item; d->startPos = d->item->pos(); } /*! Returns the timeline object used to control the rate at which the animation occurs. \sa setTimeLine() */ QTimeLine *QGraphicsItemAnimation::timeLine() const { return d->timeLine; } /*! Sets the timeline object used to control the rate of animation to the \a timeLine specified. \sa timeLine() */ void QGraphicsItemAnimation::setTimeLine(QTimeLine *timeLine) { if (d->timeLine == timeLine) return; if (d->timeLine) delete d->timeLine; if (!timeLine) return; d->timeLine = timeLine; connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setStep(qreal))); } /*! Returns the position of the item at the given \a step value. \sa setPosAt() */ QPointF QGraphicsItemAnimation::posAt(qreal step) const { check_step_valid(step, "posAt"); return QPointF(d->linearValueForStep(step, &d->xPosition, d->startPos.x()), d->linearValueForStep(step, &d->yPosition, d->startPos.y())); } /*! \fn void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &point) Sets the position of the item at the given \a step value to the \a point specified. \sa posAt() */ void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos) { d->insertUniquePair(step, pos.x(), &d->xPosition, "setPosAt"); d->insertUniquePair(step, pos.y(), &d->yPosition, "setPosAt"); } /*! Returns all explicitly inserted positions. \sa posAt(), setPosAt() */ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const { QList<QPair<qreal, QPointF> > list; for (int i = 0; i < d->xPosition.size(); ++i) list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value)); return list; } /*! Returns the matrix used to transform the item at the specified \a step value. */ QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const { check_step_valid(step, "matrixAt"); QMatrix matrix; if (!d->rotation.isEmpty()) matrix.rotate(rotationAt(step)); if (!d->verticalScale.isEmpty()) matrix.scale(horizontalScaleAt(step), verticalScaleAt(step)); if (!d->verticalShear.isEmpty()) matrix.shear(horizontalShearAt(step), verticalShearAt(step)); if (!d->xTranslation.isEmpty()) matrix.translate(xTranslationAt(step), yTranslationAt(step)); return matrix; } /*! Returns the angle at which the item is rotated at the specified \a step value. \sa setRotationAt() */ qreal QGraphicsItemAnimation::rotationAt(qreal step) const { check_step_valid(step, "rotationAt"); return d->linearValueForStep(step, &d->rotation); } /*! Sets the rotation of the item at the given \a step value to the \a angle specified. \sa rotationAt() */ void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle) { d->insertUniquePair(step, angle, &d->rotation, "setRotationAt"); } /*! Returns all explicitly inserted rotations. \sa rotationAt(), setRotationAt() */ QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const { QList<QPair<qreal, qreal> > list; for (int i = 0; i < d->rotation.size(); ++i) list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value); return list; } /*! Returns the horizontal translation of the item at the specified \a step value. \sa setTranslationAt() */ qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const { check_step_valid(step, "xTranslationAt"); return d->linearValueForStep(step, &d->xTranslation); } /*! Returns the vertical translation of the item at the specified \a step value. \sa setTranslationAt() */ qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const { check_step_valid(step, "yTranslationAt"); return d->linearValueForStep(step, &d->yTranslation); } /*! Sets the translation of the item at the given \a step value using the horizontal and vertical coordinates specified by \a dx and \a dy. \sa xTranslationAt(), yTranslationAt() */ void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy) { d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt"); d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt"); } /*! Returns all explicitly inserted translations. \sa xTranslationAt(), yTranslationAt(), setTranslationAt() */ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const { QList<QPair<qreal, QPointF> > list; for (int i = 0; i < d->xTranslation.size(); ++i) list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value)); return list; } /*! Returns the vertical scale for the item at the specified \a step value. \sa setScaleAt() */ qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const { check_step_valid(step, "verticalScaleAt"); return d->linearValueForStep(step, &d->verticalScale, 1); } /*! Returns the horizontal scale for the item at the specified \a step value. \sa setScaleAt() */ qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const { check_step_valid(step, "horizontalScaleAt"); return d->linearValueForStep(step, &d->horizontalScale, 1); } /*! Sets the scale of the item at the given \a step value using the horizontal and vertical scale factors specified by \a sx and \a sy. \sa verticalScaleAt(), horizontalScaleAt() */ void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy) { d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt"); d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt"); } /*! Returns all explicitly inserted scales. \sa verticalScaleAt(), horizontalScaleAt(), setScaleAt() */ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const { QList<QPair<qreal, QPointF> > list; for (int i = 0; i < d->horizontalScale.size(); ++i) list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value)); return list; } /*! Returns the vertical shear for the item at the specified \a step value. \sa setShearAt() */ qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const { check_step_valid(step, "verticalShearAt"); return d->linearValueForStep(step, &d->verticalShear, 0); } /*! Returns the horizontal shear for the item at the specified \a step value. \sa setShearAt() */ qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const { check_step_valid(step, "horizontalShearAt"); return d->linearValueForStep(step, &d->horizontalShear, 0); } /*! Sets the shear of the item at the given \a step value using the horizontal and vertical shear factors specified by \a sh and \a sv. \sa verticalShearAt(), horizontalShearAt() */ void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv) { d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt"); d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt"); } /*! Returns all explicitly inserted shears. \sa verticalShearAt(), horizontalShearAt(), setShearAt() */ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const { QList<QPair<qreal, QPointF> > list; for (int i = 0; i < d->horizontalShear.size(); ++i) list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value)); return list; } /*! Clears the scheduled transformations used for the animation, but retains the item and timeline. */ void QGraphicsItemAnimation::clear() { d->xPosition.clear(); d->yPosition.clear(); d->rotation.clear(); d->verticalScale.clear(); d->horizontalScale.clear(); d->verticalShear.clear(); d->horizontalShear.clear(); d->xTranslation.clear(); d->yTranslation.clear(); } /*! \fn void QGraphicsItemAnimation::setStep(qreal step) Sets the current \a step value for the animation, causing the transformations scheduled at this step to be performed. */ void QGraphicsItemAnimation::setStep(qreal step) { if (!check_step_valid(step, "setStep")) return; beforeAnimationStep(step); d->step = step; if (d->item) { if (!d->xPosition.isEmpty() || !d->yPosition.isEmpty()) d->item->setPos(posAt(step)); if (!d->rotation.isEmpty() || !d->verticalScale.isEmpty() || !d->horizontalScale.isEmpty() || !d->verticalShear.isEmpty() || !d->horizontalShear.isEmpty() || !d->xTranslation.isEmpty() || !d->yTranslation.isEmpty()) { d->item->setMatrix(d->startMatrix * matrixAt(step)); } } afterAnimationStep(step); } /*! Resets the item to its starting position and transformation. \obsolete You can call setStep(0) instead. */ void QGraphicsItemAnimation::reset() { if (!d->item) return; d->startPos = d->item->pos(); d->startMatrix = d->item->matrix(); } /*! \fn void QGraphicsItemAnimation::beforeAnimationStep(qreal step) This method is meant to be overridden by subclassed that needs to execute additional code before a new step takes place. The animation \a step is provided for use in cases where the action depends on its value. */ void QGraphicsItemAnimation::beforeAnimationStep(qreal step) { Q_UNUSED(step); } /*! \fn void QGraphicsItemAnimation::afterAnimationStep(qreal step) This method is meant to be overridden in subclasses that need to execute additional code after a new step has taken place. The animation \a step is provided for use in cases where the action depends on its value. */ void QGraphicsItemAnimation::afterAnimationStep(qreal step) { Q_UNUSED(step); } QT_END_NAMESPACE #endif // QT_NO_GRAPHICSVIEW
/* * Copyright (c) 2016, The OpenThread Authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /** * @file * This file implements the Energy Scan Server. */ #define WPP_NAME "energy_scan_server.tmh" #include "energy_scan_server.hpp" #include <openthread/platform/random.h> #include "coap/coap_header.hpp" #include "common/code_utils.hpp" #include "common/debug.hpp" #include "common/instance.hpp" #include "common/logging.hpp" #include "common/owner-locator.hpp" #include "meshcop/meshcop.hpp" #include "meshcop/meshcop_tlvs.hpp" #include "thread/thread_netif.hpp" #include "thread/thread_uri_paths.hpp" namespace ot { EnergyScanServer::EnergyScanServer(Instance &aInstance) : InstanceLocator(aInstance) , mChannelMask(0) , mChannelMaskCurrent(0) , mPeriod(0) , mScanDuration(0) , mCount(0) , mActive(false) , mScanResultsLength(0) , mTimer(aInstance, &EnergyScanServer::HandleTimer, this) , mNotifierCallback(&EnergyScanServer::HandleStateChanged, this) , mEnergyScan(OT_URI_PATH_ENERGY_SCAN, &EnergyScanServer::HandleRequest, this) { aInstance.GetNotifier().RegisterCallback(mNotifierCallback); GetNetif().GetCoap().AddResource(mEnergyScan); } void EnergyScanServer::HandleRequest(void * aContext, otCoapHeader * aHeader, otMessage * aMessage, const otMessageInfo *aMessageInfo) { static_cast<EnergyScanServer *>(aContext)->HandleRequest(*static_cast<Coap::Header *>(aHeader), *static_cast<Message *>(aMessage), *static_cast<const Ip6::MessageInfo *>(aMessageInfo)); } void EnergyScanServer::HandleRequest(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { MeshCoP::CountTlv count; MeshCoP::PeriodTlv period; MeshCoP::ScanDurationTlv scanDuration; MeshCoP::ChannelMaskTlv channelMask; Ip6::MessageInfo responseInfo(aMessageInfo); VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST); SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kCount, sizeof(count), count)); VerifyOrExit(count.IsValid()); SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kPeriod, sizeof(period), period)); VerifyOrExit(period.IsValid()); SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kScanDuration, sizeof(scanDuration), scanDuration)); VerifyOrExit(scanDuration.IsValid()); SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask)); VerifyOrExit(channelMask.IsValid() && channelMask.GetChannelPage() == OT_RADIO_CHANNEL_PAGE); mChannelMask = channelMask.GetMask(); mChannelMaskCurrent = mChannelMask; mCount = count.GetCount(); mPeriod = period.GetPeriod(); mScanDuration = scanDuration.GetScanDuration(); mScanResultsLength = 0; mActive = true; mTimer.Start(kScanDelay); mCommissioner = aMessageInfo.GetPeerAddr(); if (aHeader.IsConfirmable() && !aMessageInfo.GetSockAddr().IsMulticast()) { SuccessOrExit(GetNetif().GetCoap().SendEmptyAck(aHeader, responseInfo)); otLogInfoMeshCoP("sent energy scan query response"); } exit: return; } void EnergyScanServer::HandleTimer(Timer &aTimer) { aTimer.GetOwner<EnergyScanServer>().HandleTimer(); } void EnergyScanServer::HandleTimer(void) { VerifyOrExit(mActive); if (mCount) { // grab the lowest channel to scan uint32_t channelMask = mChannelMaskCurrent & ~(mChannelMaskCurrent - 1); GetNetif().GetMac().EnergyScan(channelMask, mScanDuration, HandleScanResult, this); } else { SendReport(); } exit: return; } void EnergyScanServer::HandleScanResult(void *aContext, otEnergyScanResult *aResult) { static_cast<EnergyScanServer *>(aContext)->HandleScanResult(aResult); } void EnergyScanServer::HandleScanResult(otEnergyScanResult *aResult) { VerifyOrExit(mActive); if (aResult) { mScanResults[mScanResultsLength++] = aResult->mMaxRssi; } else { // clear the lowest channel to scan mChannelMaskCurrent &= mChannelMaskCurrent - 1; if (mChannelMaskCurrent == 0) { mChannelMaskCurrent = mChannelMask; mCount--; } if (mCount) { mTimer.Start(mPeriod); } else { mTimer.Start(kReportDelay); } } exit: return; } otError EnergyScanServer::SendReport(void) { otError error = OT_ERROR_NONE; Coap::Header header; MeshCoP::ChannelMaskTlv channelMask; MeshCoP::EnergyListTlv energyList; Ip6::MessageInfo messageInfo; Message * message; header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST); header.SetToken(Coap::Header::kDefaultTokenLength); header.AppendUriPathOptions(OT_URI_PATH_ENERGY_REPORT); header.SetPayloadMarker(); VerifyOrExit((message = MeshCoP::NewMeshCoPMessage(GetNetif().GetCoap(), header)) != NULL, error = OT_ERROR_NO_BUFS); channelMask.Init(); channelMask.SetChannelPage(OT_RADIO_CHANNEL_PAGE); channelMask.SetMask(mChannelMask); SuccessOrExit(error = message->Append(&channelMask, sizeof(channelMask))); energyList.Init(); energyList.SetLength(mScanResultsLength); SuccessOrExit(error = message->Append(&energyList, sizeof(energyList))); SuccessOrExit(error = message->Append(mScanResults, mScanResultsLength)); messageInfo.SetSockAddr(GetNetif().GetMle().GetMeshLocal16()); messageInfo.SetPeerAddr(mCommissioner); messageInfo.SetPeerPort(kCoapUdpPort); SuccessOrExit(error = GetNetif().GetCoap().SendMessage(*message, messageInfo)); otLogInfoMeshCoP("sent scan results"); exit: if (error != OT_ERROR_NONE && message != NULL) { message->Free(); } mActive = false; return error; } void EnergyScanServer::HandleStateChanged(Notifier::Callback &aCallback, otChangedFlags aFlags) { aCallback.GetOwner<EnergyScanServer>().HandleStateChanged(aFlags); } void EnergyScanServer::HandleStateChanged(otChangedFlags aFlags) { if ((aFlags & OT_CHANGED_THREAD_NETDATA) != 0 && !mActive && GetNetif().GetNetworkDataLeader().GetCommissioningData() == NULL) { mActive = false; mTimer.Stop(); } } } // namespace ot
section .text extern _init extern main extern exit extern envc extern envp extern _late_init_stdlib global _start _start: mov ebp,0 push ebp push ebp mov ebp,esp call _early_init_stdlib push ecx push eax call _init call _late_init_stdlib call main push eax call exit global _early_init_stdlib _early_init_stdlib: mov [envc],ebx mov [envp],edx ret
/* * Copyright 2007, 2011, Stephan Aßmus <superstippi@gmx.de>. * All rights reserved. Distributed under the terms of the MIT License. */ #include "NativeSaver.h" #include <stdio.h> #include <string.h> #include "FlatIconFormat.h" #include "MessageExporter.h" NativeSaver::NativeSaver(const entry_ref& ref) : SimpleFileSaver(new MessageExporter(), ref), fAttrSaver(ref, kVectorAttrNodeName) { } NativeSaver::~NativeSaver() { } status_t NativeSaver::Save(Document* document) { status_t ret = SimpleFileSaver::Save(document); if (ret != B_OK) { fprintf(stderr, "Error saving icon: %s\n", strerror(ret)); return ret; } WaitForExportThread(); ret = fAttrSaver.Save(document); if (ret != B_OK) { fprintf(stderr, "Error saving icon attribute: %s\n", strerror(ret)); return ret; } return B_OK; }
; A053667: Product of digits of n^2. ; 0,1,4,9,6,10,18,36,24,8,0,2,16,54,54,20,60,144,24,18,0,16,128,90,210,60,252,126,224,32,0,54,0,0,30,20,108,162,64,10,0,48,168,288,162,0,12,0,0,0,0,0,0,0,108,0,54,216,216,96,0,42,384,1458,0,80,360,1152,192,168,0,0,160 pow $0,2 mov $3,34 lpb $0,1 mov $2,$0 div $0,10 mod $2,10 mul $3,$2 mov $1,$3 lpe div $1,34
_rm: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 20 sub $0x20,%esp int i; if(argc < 2){ 9: 83 7d 08 01 cmpl $0x1,0x8(%ebp) d: 7f 19 jg 28 <main+0x28> printf(2, "Usage: rm files...\n"); f: c7 44 24 04 83 08 00 movl $0x883,0x4(%esp) 16: 00 17: c7 04 24 02 00 00 00 movl $0x2,(%esp) 1e: e8 94 04 00 00 call 4b7 <printf> exit(); 23: e8 cf 02 00 00 call 2f7 <exit> } for(i = 1; i < argc; i++){ 28: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 2f: 00 30: eb 4f jmp 81 <main+0x81> if(unlink(argv[i]) < 0){ 32: 8b 44 24 1c mov 0x1c(%esp),%eax 36: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 3d: 8b 45 0c mov 0xc(%ebp),%eax 40: 01 d0 add %edx,%eax 42: 8b 00 mov (%eax),%eax 44: 89 04 24 mov %eax,(%esp) 47: e8 fb 02 00 00 call 347 <unlink> 4c: 85 c0 test %eax,%eax 4e: 79 2c jns 7c <main+0x7c> printf(2, "rm: %s failed to delete\n", argv[i]); 50: 8b 44 24 1c mov 0x1c(%esp),%eax 54: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 5b: 8b 45 0c mov 0xc(%ebp),%eax 5e: 01 d0 add %edx,%eax 60: 8b 00 mov (%eax),%eax 62: 89 44 24 08 mov %eax,0x8(%esp) 66: c7 44 24 04 97 08 00 movl $0x897,0x4(%esp) 6d: 00 6e: c7 04 24 02 00 00 00 movl $0x2,(%esp) 75: e8 3d 04 00 00 call 4b7 <printf> break; 7a: eb 0e jmp 8a <main+0x8a> if(argc < 2){ printf(2, "Usage: rm files...\n"); exit(); } for(i = 1; i < argc; i++){ 7c: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 81: 8b 44 24 1c mov 0x1c(%esp),%eax 85: 3b 45 08 cmp 0x8(%ebp),%eax 88: 7c a8 jl 32 <main+0x32> printf(2, "rm: %s failed to delete\n", argv[i]); break; } } exit(); 8a: e8 68 02 00 00 call 2f7 <exit> 0000008f <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 8f: 55 push %ebp 90: 89 e5 mov %esp,%ebp 92: 57 push %edi 93: 53 push %ebx asm volatile("cld; rep stosb" : 94: 8b 4d 08 mov 0x8(%ebp),%ecx 97: 8b 55 10 mov 0x10(%ebp),%edx 9a: 8b 45 0c mov 0xc(%ebp),%eax 9d: 89 cb mov %ecx,%ebx 9f: 89 df mov %ebx,%edi a1: 89 d1 mov %edx,%ecx a3: fc cld a4: f3 aa rep stos %al,%es:(%edi) a6: 89 ca mov %ecx,%edx a8: 89 fb mov %edi,%ebx aa: 89 5d 08 mov %ebx,0x8(%ebp) ad: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } b0: 5b pop %ebx b1: 5f pop %edi b2: 5d pop %ebp b3: c3 ret 000000b4 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { b4: 55 push %ebp b5: 89 e5 mov %esp,%ebp b7: 83 ec 10 sub $0x10,%esp char *os; os = s; ba: 8b 45 08 mov 0x8(%ebp),%eax bd: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) c0: 90 nop c1: 8b 45 08 mov 0x8(%ebp),%eax c4: 8d 50 01 lea 0x1(%eax),%edx c7: 89 55 08 mov %edx,0x8(%ebp) ca: 8b 55 0c mov 0xc(%ebp),%edx cd: 8d 4a 01 lea 0x1(%edx),%ecx d0: 89 4d 0c mov %ecx,0xc(%ebp) d3: 0f b6 12 movzbl (%edx),%edx d6: 88 10 mov %dl,(%eax) d8: 0f b6 00 movzbl (%eax),%eax db: 84 c0 test %al,%al dd: 75 e2 jne c1 <strcpy+0xd> ; return os; df: 8b 45 fc mov -0x4(%ebp),%eax } e2: c9 leave e3: c3 ret 000000e4 <strcmp>: int strcmp(const char *p, const char *q) { e4: 55 push %ebp e5: 89 e5 mov %esp,%ebp while(*p && *p == *q) e7: eb 08 jmp f1 <strcmp+0xd> p++, q++; e9: 83 45 08 01 addl $0x1,0x8(%ebp) ed: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) f1: 8b 45 08 mov 0x8(%ebp),%eax f4: 0f b6 00 movzbl (%eax),%eax f7: 84 c0 test %al,%al f9: 74 10 je 10b <strcmp+0x27> fb: 8b 45 08 mov 0x8(%ebp),%eax fe: 0f b6 10 movzbl (%eax),%edx 101: 8b 45 0c mov 0xc(%ebp),%eax 104: 0f b6 00 movzbl (%eax),%eax 107: 38 c2 cmp %al,%dl 109: 74 de je e9 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 10b: 8b 45 08 mov 0x8(%ebp),%eax 10e: 0f b6 00 movzbl (%eax),%eax 111: 0f b6 d0 movzbl %al,%edx 114: 8b 45 0c mov 0xc(%ebp),%eax 117: 0f b6 00 movzbl (%eax),%eax 11a: 0f b6 c0 movzbl %al,%eax 11d: 29 c2 sub %eax,%edx 11f: 89 d0 mov %edx,%eax } 121: 5d pop %ebp 122: c3 ret 00000123 <strlen>: uint strlen(char *s) { 123: 55 push %ebp 124: 89 e5 mov %esp,%ebp 126: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 129: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 130: eb 04 jmp 136 <strlen+0x13> 132: 83 45 fc 01 addl $0x1,-0x4(%ebp) 136: 8b 55 fc mov -0x4(%ebp),%edx 139: 8b 45 08 mov 0x8(%ebp),%eax 13c: 01 d0 add %edx,%eax 13e: 0f b6 00 movzbl (%eax),%eax 141: 84 c0 test %al,%al 143: 75 ed jne 132 <strlen+0xf> ; return n; 145: 8b 45 fc mov -0x4(%ebp),%eax } 148: c9 leave 149: c3 ret 0000014a <memset>: void* memset(void *dst, int c, uint n) { 14a: 55 push %ebp 14b: 89 e5 mov %esp,%ebp 14d: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 150: 8b 45 10 mov 0x10(%ebp),%eax 153: 89 44 24 08 mov %eax,0x8(%esp) 157: 8b 45 0c mov 0xc(%ebp),%eax 15a: 89 44 24 04 mov %eax,0x4(%esp) 15e: 8b 45 08 mov 0x8(%ebp),%eax 161: 89 04 24 mov %eax,(%esp) 164: e8 26 ff ff ff call 8f <stosb> return dst; 169: 8b 45 08 mov 0x8(%ebp),%eax } 16c: c9 leave 16d: c3 ret 0000016e <strchr>: char* strchr(const char *s, char c) { 16e: 55 push %ebp 16f: 89 e5 mov %esp,%ebp 171: 83 ec 04 sub $0x4,%esp 174: 8b 45 0c mov 0xc(%ebp),%eax 177: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 17a: eb 14 jmp 190 <strchr+0x22> if(*s == c) 17c: 8b 45 08 mov 0x8(%ebp),%eax 17f: 0f b6 00 movzbl (%eax),%eax 182: 3a 45 fc cmp -0x4(%ebp),%al 185: 75 05 jne 18c <strchr+0x1e> return (char*)s; 187: 8b 45 08 mov 0x8(%ebp),%eax 18a: eb 13 jmp 19f <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 18c: 83 45 08 01 addl $0x1,0x8(%ebp) 190: 8b 45 08 mov 0x8(%ebp),%eax 193: 0f b6 00 movzbl (%eax),%eax 196: 84 c0 test %al,%al 198: 75 e2 jne 17c <strchr+0xe> if(*s == c) return (char*)s; return 0; 19a: b8 00 00 00 00 mov $0x0,%eax } 19f: c9 leave 1a0: c3 ret 000001a1 <gets>: char* gets(char *buf, int max) { 1a1: 55 push %ebp 1a2: 89 e5 mov %esp,%ebp 1a4: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 1a7: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 1ae: eb 4c jmp 1fc <gets+0x5b> cc = read(0, &c, 1); 1b0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 1b7: 00 1b8: 8d 45 ef lea -0x11(%ebp),%eax 1bb: 89 44 24 04 mov %eax,0x4(%esp) 1bf: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1c6: e8 44 01 00 00 call 30f <read> 1cb: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 1ce: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 1d2: 7f 02 jg 1d6 <gets+0x35> break; 1d4: eb 31 jmp 207 <gets+0x66> buf[i++] = c; 1d6: 8b 45 f4 mov -0xc(%ebp),%eax 1d9: 8d 50 01 lea 0x1(%eax),%edx 1dc: 89 55 f4 mov %edx,-0xc(%ebp) 1df: 89 c2 mov %eax,%edx 1e1: 8b 45 08 mov 0x8(%ebp),%eax 1e4: 01 c2 add %eax,%edx 1e6: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1ea: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 1ec: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1f0: 3c 0a cmp $0xa,%al 1f2: 74 13 je 207 <gets+0x66> 1f4: 0f b6 45 ef movzbl -0x11(%ebp),%eax 1f8: 3c 0d cmp $0xd,%al 1fa: 74 0b je 207 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1fc: 8b 45 f4 mov -0xc(%ebp),%eax 1ff: 83 c0 01 add $0x1,%eax 202: 3b 45 0c cmp 0xc(%ebp),%eax 205: 7c a9 jl 1b0 <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 207: 8b 55 f4 mov -0xc(%ebp),%edx 20a: 8b 45 08 mov 0x8(%ebp),%eax 20d: 01 d0 add %edx,%eax 20f: c6 00 00 movb $0x0,(%eax) return buf; 212: 8b 45 08 mov 0x8(%ebp),%eax } 215: c9 leave 216: c3 ret 00000217 <stat>: int stat(char *n, struct stat *st) { 217: 55 push %ebp 218: 89 e5 mov %esp,%ebp 21a: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 21d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 224: 00 225: 8b 45 08 mov 0x8(%ebp),%eax 228: 89 04 24 mov %eax,(%esp) 22b: e8 07 01 00 00 call 337 <open> 230: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 233: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 237: 79 07 jns 240 <stat+0x29> return -1; 239: b8 ff ff ff ff mov $0xffffffff,%eax 23e: eb 23 jmp 263 <stat+0x4c> r = fstat(fd, st); 240: 8b 45 0c mov 0xc(%ebp),%eax 243: 89 44 24 04 mov %eax,0x4(%esp) 247: 8b 45 f4 mov -0xc(%ebp),%eax 24a: 89 04 24 mov %eax,(%esp) 24d: e8 fd 00 00 00 call 34f <fstat> 252: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 255: 8b 45 f4 mov -0xc(%ebp),%eax 258: 89 04 24 mov %eax,(%esp) 25b: e8 bf 00 00 00 call 31f <close> return r; 260: 8b 45 f0 mov -0x10(%ebp),%eax } 263: c9 leave 264: c3 ret 00000265 <atoi>: int atoi(const char *s) { 265: 55 push %ebp 266: 89 e5 mov %esp,%ebp 268: 83 ec 10 sub $0x10,%esp int n; n = 0; 26b: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 272: eb 25 jmp 299 <atoi+0x34> n = n*10 + *s++ - '0'; 274: 8b 55 fc mov -0x4(%ebp),%edx 277: 89 d0 mov %edx,%eax 279: c1 e0 02 shl $0x2,%eax 27c: 01 d0 add %edx,%eax 27e: 01 c0 add %eax,%eax 280: 89 c1 mov %eax,%ecx 282: 8b 45 08 mov 0x8(%ebp),%eax 285: 8d 50 01 lea 0x1(%eax),%edx 288: 89 55 08 mov %edx,0x8(%ebp) 28b: 0f b6 00 movzbl (%eax),%eax 28e: 0f be c0 movsbl %al,%eax 291: 01 c8 add %ecx,%eax 293: 83 e8 30 sub $0x30,%eax 296: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 299: 8b 45 08 mov 0x8(%ebp),%eax 29c: 0f b6 00 movzbl (%eax),%eax 29f: 3c 2f cmp $0x2f,%al 2a1: 7e 0a jle 2ad <atoi+0x48> 2a3: 8b 45 08 mov 0x8(%ebp),%eax 2a6: 0f b6 00 movzbl (%eax),%eax 2a9: 3c 39 cmp $0x39,%al 2ab: 7e c7 jle 274 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 2ad: 8b 45 fc mov -0x4(%ebp),%eax } 2b0: c9 leave 2b1: c3 ret 000002b2 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 2b2: 55 push %ebp 2b3: 89 e5 mov %esp,%ebp 2b5: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 2b8: 8b 45 08 mov 0x8(%ebp),%eax 2bb: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 2be: 8b 45 0c mov 0xc(%ebp),%eax 2c1: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 2c4: eb 17 jmp 2dd <memmove+0x2b> *dst++ = *src++; 2c6: 8b 45 fc mov -0x4(%ebp),%eax 2c9: 8d 50 01 lea 0x1(%eax),%edx 2cc: 89 55 fc mov %edx,-0x4(%ebp) 2cf: 8b 55 f8 mov -0x8(%ebp),%edx 2d2: 8d 4a 01 lea 0x1(%edx),%ecx 2d5: 89 4d f8 mov %ecx,-0x8(%ebp) 2d8: 0f b6 12 movzbl (%edx),%edx 2db: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 2dd: 8b 45 10 mov 0x10(%ebp),%eax 2e0: 8d 50 ff lea -0x1(%eax),%edx 2e3: 89 55 10 mov %edx,0x10(%ebp) 2e6: 85 c0 test %eax,%eax 2e8: 7f dc jg 2c6 <memmove+0x14> *dst++ = *src++; return vdst; 2ea: 8b 45 08 mov 0x8(%ebp),%eax } 2ed: c9 leave 2ee: c3 ret 000002ef <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2ef: b8 01 00 00 00 mov $0x1,%eax 2f4: cd 40 int $0x40 2f6: c3 ret 000002f7 <exit>: SYSCALL(exit) 2f7: b8 02 00 00 00 mov $0x2,%eax 2fc: cd 40 int $0x40 2fe: c3 ret 000002ff <wait>: SYSCALL(wait) 2ff: b8 03 00 00 00 mov $0x3,%eax 304: cd 40 int $0x40 306: c3 ret 00000307 <pipe>: SYSCALL(pipe) 307: b8 04 00 00 00 mov $0x4,%eax 30c: cd 40 int $0x40 30e: c3 ret 0000030f <read>: SYSCALL(read) 30f: b8 05 00 00 00 mov $0x5,%eax 314: cd 40 int $0x40 316: c3 ret 00000317 <write>: SYSCALL(write) 317: b8 10 00 00 00 mov $0x10,%eax 31c: cd 40 int $0x40 31e: c3 ret 0000031f <close>: SYSCALL(close) 31f: b8 15 00 00 00 mov $0x15,%eax 324: cd 40 int $0x40 326: c3 ret 00000327 <kill>: SYSCALL(kill) 327: b8 06 00 00 00 mov $0x6,%eax 32c: cd 40 int $0x40 32e: c3 ret 0000032f <exec>: SYSCALL(exec) 32f: b8 07 00 00 00 mov $0x7,%eax 334: cd 40 int $0x40 336: c3 ret 00000337 <open>: SYSCALL(open) 337: b8 0f 00 00 00 mov $0xf,%eax 33c: cd 40 int $0x40 33e: c3 ret 0000033f <mknod>: SYSCALL(mknod) 33f: b8 11 00 00 00 mov $0x11,%eax 344: cd 40 int $0x40 346: c3 ret 00000347 <unlink>: SYSCALL(unlink) 347: b8 12 00 00 00 mov $0x12,%eax 34c: cd 40 int $0x40 34e: c3 ret 0000034f <fstat>: SYSCALL(fstat) 34f: b8 08 00 00 00 mov $0x8,%eax 354: cd 40 int $0x40 356: c3 ret 00000357 <link>: SYSCALL(link) 357: b8 13 00 00 00 mov $0x13,%eax 35c: cd 40 int $0x40 35e: c3 ret 0000035f <mkdir>: SYSCALL(mkdir) 35f: b8 14 00 00 00 mov $0x14,%eax 364: cd 40 int $0x40 366: c3 ret 00000367 <chdir>: SYSCALL(chdir) 367: b8 09 00 00 00 mov $0x9,%eax 36c: cd 40 int $0x40 36e: c3 ret 0000036f <dup>: SYSCALL(dup) 36f: b8 0a 00 00 00 mov $0xa,%eax 374: cd 40 int $0x40 376: c3 ret 00000377 <getpid>: SYSCALL(getpid) 377: b8 0b 00 00 00 mov $0xb,%eax 37c: cd 40 int $0x40 37e: c3 ret 0000037f <sbrk>: SYSCALL(sbrk) 37f: b8 0c 00 00 00 mov $0xc,%eax 384: cd 40 int $0x40 386: c3 ret 00000387 <sleep>: SYSCALL(sleep) 387: b8 0d 00 00 00 mov $0xd,%eax 38c: cd 40 int $0x40 38e: c3 ret 0000038f <uptime>: SYSCALL(uptime) 38f: b8 0e 00 00 00 mov $0xe,%eax 394: cd 40 int $0x40 396: c3 ret 00000397 <date>: SYSCALL(date) 397: b8 16 00 00 00 mov $0x16,%eax 39c: cd 40 int $0x40 39e: c3 ret 0000039f <timem>: SYSCALL(timem) 39f: b8 17 00 00 00 mov $0x17,%eax 3a4: cd 40 int $0x40 3a6: c3 ret 000003a7 <getuid>: SYSCALL(getuid) 3a7: b8 18 00 00 00 mov $0x18,%eax 3ac: cd 40 int $0x40 3ae: c3 ret 000003af <getgid>: SYSCALL(getgid) 3af: b8 19 00 00 00 mov $0x19,%eax 3b4: cd 40 int $0x40 3b6: c3 ret 000003b7 <getppid>: SYSCALL(getppid) 3b7: b8 1a 00 00 00 mov $0x1a,%eax 3bc: cd 40 int $0x40 3be: c3 ret 000003bf <setuid>: SYSCALL(setuid) 3bf: b8 1b 00 00 00 mov $0x1b,%eax 3c4: cd 40 int $0x40 3c6: c3 ret 000003c7 <setgid>: SYSCALL(setgid) 3c7: b8 1c 00 00 00 mov $0x1c,%eax 3cc: cd 40 int $0x40 3ce: c3 ret 000003cf <getprocs>: SYSCALL(getprocs) 3cf: b8 1d 00 00 00 mov $0x1d,%eax 3d4: cd 40 int $0x40 3d6: c3 ret 000003d7 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 3d7: 55 push %ebp 3d8: 89 e5 mov %esp,%ebp 3da: 83 ec 18 sub $0x18,%esp 3dd: 8b 45 0c mov 0xc(%ebp),%eax 3e0: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 3e3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3ea: 00 3eb: 8d 45 f4 lea -0xc(%ebp),%eax 3ee: 89 44 24 04 mov %eax,0x4(%esp) 3f2: 8b 45 08 mov 0x8(%ebp),%eax 3f5: 89 04 24 mov %eax,(%esp) 3f8: e8 1a ff ff ff call 317 <write> } 3fd: c9 leave 3fe: c3 ret 000003ff <printint>: static void printint(int fd, int xx, int base, int sgn) { 3ff: 55 push %ebp 400: 89 e5 mov %esp,%ebp 402: 56 push %esi 403: 53 push %ebx 404: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 407: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 40e: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 412: 74 17 je 42b <printint+0x2c> 414: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 418: 79 11 jns 42b <printint+0x2c> neg = 1; 41a: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 421: 8b 45 0c mov 0xc(%ebp),%eax 424: f7 d8 neg %eax 426: 89 45 ec mov %eax,-0x14(%ebp) 429: eb 06 jmp 431 <printint+0x32> } else { x = xx; 42b: 8b 45 0c mov 0xc(%ebp),%eax 42e: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 431: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 438: 8b 4d f4 mov -0xc(%ebp),%ecx 43b: 8d 41 01 lea 0x1(%ecx),%eax 43e: 89 45 f4 mov %eax,-0xc(%ebp) 441: 8b 5d 10 mov 0x10(%ebp),%ebx 444: 8b 45 ec mov -0x14(%ebp),%eax 447: ba 00 00 00 00 mov $0x0,%edx 44c: f7 f3 div %ebx 44e: 89 d0 mov %edx,%eax 450: 0f b6 80 fc 0a 00 00 movzbl 0xafc(%eax),%eax 457: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 45b: 8b 75 10 mov 0x10(%ebp),%esi 45e: 8b 45 ec mov -0x14(%ebp),%eax 461: ba 00 00 00 00 mov $0x0,%edx 466: f7 f6 div %esi 468: 89 45 ec mov %eax,-0x14(%ebp) 46b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 46f: 75 c7 jne 438 <printint+0x39> if(neg) 471: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 475: 74 10 je 487 <printint+0x88> buf[i++] = '-'; 477: 8b 45 f4 mov -0xc(%ebp),%eax 47a: 8d 50 01 lea 0x1(%eax),%edx 47d: 89 55 f4 mov %edx,-0xc(%ebp) 480: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 485: eb 1f jmp 4a6 <printint+0xa7> 487: eb 1d jmp 4a6 <printint+0xa7> putc(fd, buf[i]); 489: 8d 55 dc lea -0x24(%ebp),%edx 48c: 8b 45 f4 mov -0xc(%ebp),%eax 48f: 01 d0 add %edx,%eax 491: 0f b6 00 movzbl (%eax),%eax 494: 0f be c0 movsbl %al,%eax 497: 89 44 24 04 mov %eax,0x4(%esp) 49b: 8b 45 08 mov 0x8(%ebp),%eax 49e: 89 04 24 mov %eax,(%esp) 4a1: e8 31 ff ff ff call 3d7 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4a6: 83 6d f4 01 subl $0x1,-0xc(%ebp) 4aa: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 4ae: 79 d9 jns 489 <printint+0x8a> putc(fd, buf[i]); } 4b0: 83 c4 30 add $0x30,%esp 4b3: 5b pop %ebx 4b4: 5e pop %esi 4b5: 5d pop %ebp 4b6: c3 ret 000004b7 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 4b7: 55 push %ebp 4b8: 89 e5 mov %esp,%ebp 4ba: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 4bd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 4c4: 8d 45 0c lea 0xc(%ebp),%eax 4c7: 83 c0 04 add $0x4,%eax 4ca: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 4cd: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 4d4: e9 7c 01 00 00 jmp 655 <printf+0x19e> c = fmt[i] & 0xff; 4d9: 8b 55 0c mov 0xc(%ebp),%edx 4dc: 8b 45 f0 mov -0x10(%ebp),%eax 4df: 01 d0 add %edx,%eax 4e1: 0f b6 00 movzbl (%eax),%eax 4e4: 0f be c0 movsbl %al,%eax 4e7: 25 ff 00 00 00 and $0xff,%eax 4ec: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 4ef: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 4f3: 75 2c jne 521 <printf+0x6a> if(c == '%'){ 4f5: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 4f9: 75 0c jne 507 <printf+0x50> state = '%'; 4fb: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 502: e9 4a 01 00 00 jmp 651 <printf+0x19a> } else { putc(fd, c); 507: 8b 45 e4 mov -0x1c(%ebp),%eax 50a: 0f be c0 movsbl %al,%eax 50d: 89 44 24 04 mov %eax,0x4(%esp) 511: 8b 45 08 mov 0x8(%ebp),%eax 514: 89 04 24 mov %eax,(%esp) 517: e8 bb fe ff ff call 3d7 <putc> 51c: e9 30 01 00 00 jmp 651 <printf+0x19a> } } else if(state == '%'){ 521: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 525: 0f 85 26 01 00 00 jne 651 <printf+0x19a> if(c == 'd'){ 52b: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 52f: 75 2d jne 55e <printf+0xa7> printint(fd, *ap, 10, 1); 531: 8b 45 e8 mov -0x18(%ebp),%eax 534: 8b 00 mov (%eax),%eax 536: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 53d: 00 53e: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 545: 00 546: 89 44 24 04 mov %eax,0x4(%esp) 54a: 8b 45 08 mov 0x8(%ebp),%eax 54d: 89 04 24 mov %eax,(%esp) 550: e8 aa fe ff ff call 3ff <printint> ap++; 555: 83 45 e8 04 addl $0x4,-0x18(%ebp) 559: e9 ec 00 00 00 jmp 64a <printf+0x193> } else if(c == 'x' || c == 'p'){ 55e: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 562: 74 06 je 56a <printf+0xb3> 564: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 568: 75 2d jne 597 <printf+0xe0> printint(fd, *ap, 16, 0); 56a: 8b 45 e8 mov -0x18(%ebp),%eax 56d: 8b 00 mov (%eax),%eax 56f: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 576: 00 577: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 57e: 00 57f: 89 44 24 04 mov %eax,0x4(%esp) 583: 8b 45 08 mov 0x8(%ebp),%eax 586: 89 04 24 mov %eax,(%esp) 589: e8 71 fe ff ff call 3ff <printint> ap++; 58e: 83 45 e8 04 addl $0x4,-0x18(%ebp) 592: e9 b3 00 00 00 jmp 64a <printf+0x193> } else if(c == 's'){ 597: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 59b: 75 45 jne 5e2 <printf+0x12b> s = (char*)*ap; 59d: 8b 45 e8 mov -0x18(%ebp),%eax 5a0: 8b 00 mov (%eax),%eax 5a2: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 5a5: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 5a9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 5ad: 75 09 jne 5b8 <printf+0x101> s = "(null)"; 5af: c7 45 f4 b0 08 00 00 movl $0x8b0,-0xc(%ebp) while(*s != 0){ 5b6: eb 1e jmp 5d6 <printf+0x11f> 5b8: eb 1c jmp 5d6 <printf+0x11f> putc(fd, *s); 5ba: 8b 45 f4 mov -0xc(%ebp),%eax 5bd: 0f b6 00 movzbl (%eax),%eax 5c0: 0f be c0 movsbl %al,%eax 5c3: 89 44 24 04 mov %eax,0x4(%esp) 5c7: 8b 45 08 mov 0x8(%ebp),%eax 5ca: 89 04 24 mov %eax,(%esp) 5cd: e8 05 fe ff ff call 3d7 <putc> s++; 5d2: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 5d6: 8b 45 f4 mov -0xc(%ebp),%eax 5d9: 0f b6 00 movzbl (%eax),%eax 5dc: 84 c0 test %al,%al 5de: 75 da jne 5ba <printf+0x103> 5e0: eb 68 jmp 64a <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 5e2: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 5e6: 75 1d jne 605 <printf+0x14e> putc(fd, *ap); 5e8: 8b 45 e8 mov -0x18(%ebp),%eax 5eb: 8b 00 mov (%eax),%eax 5ed: 0f be c0 movsbl %al,%eax 5f0: 89 44 24 04 mov %eax,0x4(%esp) 5f4: 8b 45 08 mov 0x8(%ebp),%eax 5f7: 89 04 24 mov %eax,(%esp) 5fa: e8 d8 fd ff ff call 3d7 <putc> ap++; 5ff: 83 45 e8 04 addl $0x4,-0x18(%ebp) 603: eb 45 jmp 64a <printf+0x193> } else if(c == '%'){ 605: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 609: 75 17 jne 622 <printf+0x16b> putc(fd, c); 60b: 8b 45 e4 mov -0x1c(%ebp),%eax 60e: 0f be c0 movsbl %al,%eax 611: 89 44 24 04 mov %eax,0x4(%esp) 615: 8b 45 08 mov 0x8(%ebp),%eax 618: 89 04 24 mov %eax,(%esp) 61b: e8 b7 fd ff ff call 3d7 <putc> 620: eb 28 jmp 64a <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 622: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 629: 00 62a: 8b 45 08 mov 0x8(%ebp),%eax 62d: 89 04 24 mov %eax,(%esp) 630: e8 a2 fd ff ff call 3d7 <putc> putc(fd, c); 635: 8b 45 e4 mov -0x1c(%ebp),%eax 638: 0f be c0 movsbl %al,%eax 63b: 89 44 24 04 mov %eax,0x4(%esp) 63f: 8b 45 08 mov 0x8(%ebp),%eax 642: 89 04 24 mov %eax,(%esp) 645: e8 8d fd ff ff call 3d7 <putc> } state = 0; 64a: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 651: 83 45 f0 01 addl $0x1,-0x10(%ebp) 655: 8b 55 0c mov 0xc(%ebp),%edx 658: 8b 45 f0 mov -0x10(%ebp),%eax 65b: 01 d0 add %edx,%eax 65d: 0f b6 00 movzbl (%eax),%eax 660: 84 c0 test %al,%al 662: 0f 85 71 fe ff ff jne 4d9 <printf+0x22> putc(fd, c); } state = 0; } } } 668: c9 leave 669: c3 ret 0000066a <free>: static Header base; static Header *freep; void free(void *ap) { 66a: 55 push %ebp 66b: 89 e5 mov %esp,%ebp 66d: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 670: 8b 45 08 mov 0x8(%ebp),%eax 673: 83 e8 08 sub $0x8,%eax 676: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 679: a1 18 0b 00 00 mov 0xb18,%eax 67e: 89 45 fc mov %eax,-0x4(%ebp) 681: eb 24 jmp 6a7 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 683: 8b 45 fc mov -0x4(%ebp),%eax 686: 8b 00 mov (%eax),%eax 688: 3b 45 fc cmp -0x4(%ebp),%eax 68b: 77 12 ja 69f <free+0x35> 68d: 8b 45 f8 mov -0x8(%ebp),%eax 690: 3b 45 fc cmp -0x4(%ebp),%eax 693: 77 24 ja 6b9 <free+0x4f> 695: 8b 45 fc mov -0x4(%ebp),%eax 698: 8b 00 mov (%eax),%eax 69a: 3b 45 f8 cmp -0x8(%ebp),%eax 69d: 77 1a ja 6b9 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 69f: 8b 45 fc mov -0x4(%ebp),%eax 6a2: 8b 00 mov (%eax),%eax 6a4: 89 45 fc mov %eax,-0x4(%ebp) 6a7: 8b 45 f8 mov -0x8(%ebp),%eax 6aa: 3b 45 fc cmp -0x4(%ebp),%eax 6ad: 76 d4 jbe 683 <free+0x19> 6af: 8b 45 fc mov -0x4(%ebp),%eax 6b2: 8b 00 mov (%eax),%eax 6b4: 3b 45 f8 cmp -0x8(%ebp),%eax 6b7: 76 ca jbe 683 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 6b9: 8b 45 f8 mov -0x8(%ebp),%eax 6bc: 8b 40 04 mov 0x4(%eax),%eax 6bf: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 6c6: 8b 45 f8 mov -0x8(%ebp),%eax 6c9: 01 c2 add %eax,%edx 6cb: 8b 45 fc mov -0x4(%ebp),%eax 6ce: 8b 00 mov (%eax),%eax 6d0: 39 c2 cmp %eax,%edx 6d2: 75 24 jne 6f8 <free+0x8e> bp->s.size += p->s.ptr->s.size; 6d4: 8b 45 f8 mov -0x8(%ebp),%eax 6d7: 8b 50 04 mov 0x4(%eax),%edx 6da: 8b 45 fc mov -0x4(%ebp),%eax 6dd: 8b 00 mov (%eax),%eax 6df: 8b 40 04 mov 0x4(%eax),%eax 6e2: 01 c2 add %eax,%edx 6e4: 8b 45 f8 mov -0x8(%ebp),%eax 6e7: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 6ea: 8b 45 fc mov -0x4(%ebp),%eax 6ed: 8b 00 mov (%eax),%eax 6ef: 8b 10 mov (%eax),%edx 6f1: 8b 45 f8 mov -0x8(%ebp),%eax 6f4: 89 10 mov %edx,(%eax) 6f6: eb 0a jmp 702 <free+0x98> } else bp->s.ptr = p->s.ptr; 6f8: 8b 45 fc mov -0x4(%ebp),%eax 6fb: 8b 10 mov (%eax),%edx 6fd: 8b 45 f8 mov -0x8(%ebp),%eax 700: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 702: 8b 45 fc mov -0x4(%ebp),%eax 705: 8b 40 04 mov 0x4(%eax),%eax 708: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 70f: 8b 45 fc mov -0x4(%ebp),%eax 712: 01 d0 add %edx,%eax 714: 3b 45 f8 cmp -0x8(%ebp),%eax 717: 75 20 jne 739 <free+0xcf> p->s.size += bp->s.size; 719: 8b 45 fc mov -0x4(%ebp),%eax 71c: 8b 50 04 mov 0x4(%eax),%edx 71f: 8b 45 f8 mov -0x8(%ebp),%eax 722: 8b 40 04 mov 0x4(%eax),%eax 725: 01 c2 add %eax,%edx 727: 8b 45 fc mov -0x4(%ebp),%eax 72a: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 72d: 8b 45 f8 mov -0x8(%ebp),%eax 730: 8b 10 mov (%eax),%edx 732: 8b 45 fc mov -0x4(%ebp),%eax 735: 89 10 mov %edx,(%eax) 737: eb 08 jmp 741 <free+0xd7> } else p->s.ptr = bp; 739: 8b 45 fc mov -0x4(%ebp),%eax 73c: 8b 55 f8 mov -0x8(%ebp),%edx 73f: 89 10 mov %edx,(%eax) freep = p; 741: 8b 45 fc mov -0x4(%ebp),%eax 744: a3 18 0b 00 00 mov %eax,0xb18 } 749: c9 leave 74a: c3 ret 0000074b <morecore>: static Header* morecore(uint nu) { 74b: 55 push %ebp 74c: 89 e5 mov %esp,%ebp 74e: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 751: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 758: 77 07 ja 761 <morecore+0x16> nu = 4096; 75a: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 761: 8b 45 08 mov 0x8(%ebp),%eax 764: c1 e0 03 shl $0x3,%eax 767: 89 04 24 mov %eax,(%esp) 76a: e8 10 fc ff ff call 37f <sbrk> 76f: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 772: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 776: 75 07 jne 77f <morecore+0x34> return 0; 778: b8 00 00 00 00 mov $0x0,%eax 77d: eb 22 jmp 7a1 <morecore+0x56> hp = (Header*)p; 77f: 8b 45 f4 mov -0xc(%ebp),%eax 782: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 785: 8b 45 f0 mov -0x10(%ebp),%eax 788: 8b 55 08 mov 0x8(%ebp),%edx 78b: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 78e: 8b 45 f0 mov -0x10(%ebp),%eax 791: 83 c0 08 add $0x8,%eax 794: 89 04 24 mov %eax,(%esp) 797: e8 ce fe ff ff call 66a <free> return freep; 79c: a1 18 0b 00 00 mov 0xb18,%eax } 7a1: c9 leave 7a2: c3 ret 000007a3 <malloc>: void* malloc(uint nbytes) { 7a3: 55 push %ebp 7a4: 89 e5 mov %esp,%ebp 7a6: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7a9: 8b 45 08 mov 0x8(%ebp),%eax 7ac: 83 c0 07 add $0x7,%eax 7af: c1 e8 03 shr $0x3,%eax 7b2: 83 c0 01 add $0x1,%eax 7b5: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 7b8: a1 18 0b 00 00 mov 0xb18,%eax 7bd: 89 45 f0 mov %eax,-0x10(%ebp) 7c0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 7c4: 75 23 jne 7e9 <malloc+0x46> base.s.ptr = freep = prevp = &base; 7c6: c7 45 f0 10 0b 00 00 movl $0xb10,-0x10(%ebp) 7cd: 8b 45 f0 mov -0x10(%ebp),%eax 7d0: a3 18 0b 00 00 mov %eax,0xb18 7d5: a1 18 0b 00 00 mov 0xb18,%eax 7da: a3 10 0b 00 00 mov %eax,0xb10 base.s.size = 0; 7df: c7 05 14 0b 00 00 00 movl $0x0,0xb14 7e6: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7e9: 8b 45 f0 mov -0x10(%ebp),%eax 7ec: 8b 00 mov (%eax),%eax 7ee: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 7f1: 8b 45 f4 mov -0xc(%ebp),%eax 7f4: 8b 40 04 mov 0x4(%eax),%eax 7f7: 3b 45 ec cmp -0x14(%ebp),%eax 7fa: 72 4d jb 849 <malloc+0xa6> if(p->s.size == nunits) 7fc: 8b 45 f4 mov -0xc(%ebp),%eax 7ff: 8b 40 04 mov 0x4(%eax),%eax 802: 3b 45 ec cmp -0x14(%ebp),%eax 805: 75 0c jne 813 <malloc+0x70> prevp->s.ptr = p->s.ptr; 807: 8b 45 f4 mov -0xc(%ebp),%eax 80a: 8b 10 mov (%eax),%edx 80c: 8b 45 f0 mov -0x10(%ebp),%eax 80f: 89 10 mov %edx,(%eax) 811: eb 26 jmp 839 <malloc+0x96> else { p->s.size -= nunits; 813: 8b 45 f4 mov -0xc(%ebp),%eax 816: 8b 40 04 mov 0x4(%eax),%eax 819: 2b 45 ec sub -0x14(%ebp),%eax 81c: 89 c2 mov %eax,%edx 81e: 8b 45 f4 mov -0xc(%ebp),%eax 821: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 824: 8b 45 f4 mov -0xc(%ebp),%eax 827: 8b 40 04 mov 0x4(%eax),%eax 82a: c1 e0 03 shl $0x3,%eax 82d: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 830: 8b 45 f4 mov -0xc(%ebp),%eax 833: 8b 55 ec mov -0x14(%ebp),%edx 836: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 839: 8b 45 f0 mov -0x10(%ebp),%eax 83c: a3 18 0b 00 00 mov %eax,0xb18 return (void*)(p + 1); 841: 8b 45 f4 mov -0xc(%ebp),%eax 844: 83 c0 08 add $0x8,%eax 847: eb 38 jmp 881 <malloc+0xde> } if(p == freep) 849: a1 18 0b 00 00 mov 0xb18,%eax 84e: 39 45 f4 cmp %eax,-0xc(%ebp) 851: 75 1b jne 86e <malloc+0xcb> if((p = morecore(nunits)) == 0) 853: 8b 45 ec mov -0x14(%ebp),%eax 856: 89 04 24 mov %eax,(%esp) 859: e8 ed fe ff ff call 74b <morecore> 85e: 89 45 f4 mov %eax,-0xc(%ebp) 861: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 865: 75 07 jne 86e <malloc+0xcb> return 0; 867: b8 00 00 00 00 mov $0x0,%eax 86c: eb 13 jmp 881 <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 86e: 8b 45 f4 mov -0xc(%ebp),%eax 871: 89 45 f0 mov %eax,-0x10(%ebp) 874: 8b 45 f4 mov -0xc(%ebp),%eax 877: 8b 00 mov (%eax),%eax 879: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 87c: e9 70 ff ff ff jmp 7f1 <malloc+0x4e> } 881: c9 leave 882: c3 ret
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/redshift/model/DataTransferProgress.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <utility> using namespace Aws::Utils::Xml; using namespace Aws::Utils; namespace Aws { namespace Redshift { namespace Model { DataTransferProgress::DataTransferProgress() : m_statusHasBeenSet(false), m_currentRateInMegaBytesPerSecond(0.0), m_currentRateInMegaBytesPerSecondHasBeenSet(false), m_totalDataInMegaBytes(0), m_totalDataInMegaBytesHasBeenSet(false), m_dataTransferredInMegaBytes(0), m_dataTransferredInMegaBytesHasBeenSet(false), m_estimatedTimeToCompletionInSeconds(0), m_estimatedTimeToCompletionInSecondsHasBeenSet(false), m_elapsedTimeInSeconds(0), m_elapsedTimeInSecondsHasBeenSet(false) { } DataTransferProgress::DataTransferProgress(const XmlNode& xmlNode) : m_statusHasBeenSet(false), m_currentRateInMegaBytesPerSecond(0.0), m_currentRateInMegaBytesPerSecondHasBeenSet(false), m_totalDataInMegaBytes(0), m_totalDataInMegaBytesHasBeenSet(false), m_dataTransferredInMegaBytes(0), m_dataTransferredInMegaBytesHasBeenSet(false), m_estimatedTimeToCompletionInSeconds(0), m_estimatedTimeToCompletionInSecondsHasBeenSet(false), m_elapsedTimeInSeconds(0), m_elapsedTimeInSecondsHasBeenSet(false) { *this = xmlNode; } DataTransferProgress& DataTransferProgress::operator =(const XmlNode& xmlNode) { XmlNode resultNode = xmlNode; if(!resultNode.IsNull()) { XmlNode statusNode = resultNode.FirstChild("Status"); if(!statusNode.IsNull()) { m_status = statusNode.GetText(); m_statusHasBeenSet = true; } XmlNode currentRateInMegaBytesPerSecondNode = resultNode.FirstChild("CurrentRateInMegaBytesPerSecond"); if(!currentRateInMegaBytesPerSecondNode.IsNull()) { m_currentRateInMegaBytesPerSecond = StringUtils::ConvertToDouble(StringUtils::Trim(currentRateInMegaBytesPerSecondNode.GetText().c_str()).c_str()); m_currentRateInMegaBytesPerSecondHasBeenSet = true; } XmlNode totalDataInMegaBytesNode = resultNode.FirstChild("TotalDataInMegaBytes"); if(!totalDataInMegaBytesNode.IsNull()) { m_totalDataInMegaBytes = StringUtils::ConvertToInt64(StringUtils::Trim(totalDataInMegaBytesNode.GetText().c_str()).c_str()); m_totalDataInMegaBytesHasBeenSet = true; } XmlNode dataTransferredInMegaBytesNode = resultNode.FirstChild("DataTransferredInMegaBytes"); if(!dataTransferredInMegaBytesNode.IsNull()) { m_dataTransferredInMegaBytes = StringUtils::ConvertToInt64(StringUtils::Trim(dataTransferredInMegaBytesNode.GetText().c_str()).c_str()); m_dataTransferredInMegaBytesHasBeenSet = true; } XmlNode estimatedTimeToCompletionInSecondsNode = resultNode.FirstChild("EstimatedTimeToCompletionInSeconds"); if(!estimatedTimeToCompletionInSecondsNode.IsNull()) { m_estimatedTimeToCompletionInSeconds = StringUtils::ConvertToInt64(StringUtils::Trim(estimatedTimeToCompletionInSecondsNode.GetText().c_str()).c_str()); m_estimatedTimeToCompletionInSecondsHasBeenSet = true; } XmlNode elapsedTimeInSecondsNode = resultNode.FirstChild("ElapsedTimeInSeconds"); if(!elapsedTimeInSecondsNode.IsNull()) { m_elapsedTimeInSeconds = StringUtils::ConvertToInt64(StringUtils::Trim(elapsedTimeInSecondsNode.GetText().c_str()).c_str()); m_elapsedTimeInSecondsHasBeenSet = true; } } return *this; } void DataTransferProgress::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const { if(m_statusHasBeenSet) { oStream << location << index << locationValue << ".Status=" << StringUtils::URLEncode(m_status.c_str()) << "&"; } if(m_currentRateInMegaBytesPerSecondHasBeenSet) { oStream << location << index << locationValue << ".CurrentRateInMegaBytesPerSecond=" << StringUtils::URLEncode(m_currentRateInMegaBytesPerSecond) << "&"; } if(m_totalDataInMegaBytesHasBeenSet) { oStream << location << index << locationValue << ".TotalDataInMegaBytes=" << m_totalDataInMegaBytes << "&"; } if(m_dataTransferredInMegaBytesHasBeenSet) { oStream << location << index << locationValue << ".DataTransferredInMegaBytes=" << m_dataTransferredInMegaBytes << "&"; } if(m_estimatedTimeToCompletionInSecondsHasBeenSet) { oStream << location << index << locationValue << ".EstimatedTimeToCompletionInSeconds=" << m_estimatedTimeToCompletionInSeconds << "&"; } if(m_elapsedTimeInSecondsHasBeenSet) { oStream << location << index << locationValue << ".ElapsedTimeInSeconds=" << m_elapsedTimeInSeconds << "&"; } } void DataTransferProgress::OutputToStream(Aws::OStream& oStream, const char* location) const { if(m_statusHasBeenSet) { oStream << location << ".Status=" << StringUtils::URLEncode(m_status.c_str()) << "&"; } if(m_currentRateInMegaBytesPerSecondHasBeenSet) { oStream << location << ".CurrentRateInMegaBytesPerSecond=" << StringUtils::URLEncode(m_currentRateInMegaBytesPerSecond) << "&"; } if(m_totalDataInMegaBytesHasBeenSet) { oStream << location << ".TotalDataInMegaBytes=" << m_totalDataInMegaBytes << "&"; } if(m_dataTransferredInMegaBytesHasBeenSet) { oStream << location << ".DataTransferredInMegaBytes=" << m_dataTransferredInMegaBytes << "&"; } if(m_estimatedTimeToCompletionInSecondsHasBeenSet) { oStream << location << ".EstimatedTimeToCompletionInSeconds=" << m_estimatedTimeToCompletionInSeconds << "&"; } if(m_elapsedTimeInSecondsHasBeenSet) { oStream << location << ".ElapsedTimeInSeconds=" << m_elapsedTimeInSeconds << "&"; } } } // namespace Model } // namespace Redshift } // namespace Aws
; Copyright Oliver Kowalke 2009. ; 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) ; ---------------------------------------------------------------------------------- ; | 0 | 1 | | ; ---------------------------------------------------------------------------------- ; | 0x0 | 0x4 | | ; ---------------------------------------------------------------------------------- ; | <indicator> | | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ; ---------------------------------------------------------------------------------- ; | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | 0x20 | 0x24 | ; ---------------------------------------------------------------------------------- ; | SEE registers (XMM6-XMM15) | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ; ---------------------------------------------------------------------------------- ; | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | 0x40 | 0x44 | ; ---------------------------------------------------------------------------------- ; | SEE registers (XMM6-XMM15) | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | ; ---------------------------------------------------------------------------------- ; | 0x48 | 0x4c | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | ; ---------------------------------------------------------------------------------- ; | SEE registers (XMM6-XMM15) | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ; ---------------------------------------------------------------------------------- ; | 0x68 | 0x6c | 0x70 | 0x74 | 0x78 | 0x7c | 0x80 | 0x84 | ; ---------------------------------------------------------------------------------- ; | SEE registers (XMM6-XMM15) | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | ; ---------------------------------------------------------------------------------- ; | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c | 0xa0 | 0xa4 | ; ---------------------------------------------------------------------------------- ; | SEE registers (XMM6-XMM15) | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ; ---------------------------------------------------------------------------------- ; | 0xa8 | 0xac | 0xb0 | 0xb4 | 0xb8 | 0xbc | 0xc0 | 0xc4 | ; ---------------------------------------------------------------------------------- ; | fc_mxcsr|fc_x87_cw| <alignment> | fbr_strg | fc_dealloc | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | ; ---------------------------------------------------------------------------------- ; | 0xc8 | 0xcc | 0xd0 | 0xd4 | 0xd8 | 0xdc | 0xe0 | 0xe4 | ; ---------------------------------------------------------------------------------- ; | limit | base | R12 | R13 | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | ; ---------------------------------------------------------------------------------- ; | 0xe8 | 0xec | 0xf0 | 0xf4 | 0xf8 | 0xfc | 0x100 | 0x104 | ; ---------------------------------------------------------------------------------- ; | R14 | R15 | RDI | RSI | ; ---------------------------------------------------------------------------------- ; ---------------------------------------------------------------------------------- ; | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ; ---------------------------------------------------------------------------------- ; | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c | 0x120 | 0x124 | ; ---------------------------------------------------------------------------------- ; | RBX | RBP | RIP | EXIT | ; ---------------------------------------------------------------------------------- ; standard C library function EXTERN _exit:PROC .code ; generate function table entry in .pdata and unwind information in make_fcontext_v1 PROC BOOST_CONTEXT_EXPORT FRAME ; .xdata for a function's structured exception handling unwind behavior .endprolog ; first arg of make_fcontext_v1() == top of context-stack mov rax, rcx ; reserve 32byte shadow-space for context-function sub rax, 028h ; shift address in RAX to lower 16 byte boundary ; == pointer to fcontext_t and address of context stack and rax, -16 ; reserve space for context-data on context-stack ; size for fc_mxcsr .. RIP + return-address for context-function ; on context-function entry: (RSP -0x8) % 16 == 0 sub rax, 0128h ; third arg of make_fcontext_v1() == address of context-function mov [rax+0118h], r8 ; first arg of make_fcontext_v1() == top of context-stack ; save top address of context stack as 'base' mov [rax+0d0h], rcx ; second arg of make_fcontext_v1() == size of context-stack ; negate stack size for LEA instruction (== substraction) neg rdx ; compute bottom address of context stack (limit) lea rcx, [rcx+rdx] ; save bottom address of context stack as 'limit' mov [rax+0c8h], rcx ; save address of context stack limit as 'dealloction stack' mov [rax+0c0h], rcx ; save MMX control- and status-word stmxcsr [rax+0a8h] ; save x87 control-word fnstcw [rax+0ach] ; compute abs address of label finish lea rcx, finish ; save address of finish as return-address for context-function ; will be entered after context-function returns mov [rax+0120h], rcx ; set indicator mov rcx, 1 mov [rax], rcx ret ; return pointer to context-data finish: ; 32byte shadow-space for _exit() are ; already reserved by make_fcontext_v1() ; exit code is zero xor rcx, rcx ; exit application call _exit hlt make_fcontext_v1 ENDP END
; ; Sharp OZ family functions ; ; ported from the OZ-7xx SDK by by Alexander R. Pruss ; by Stefano Bodrato - Oct. 2003 ; ; ; ; ------ ; $Id: ozexitto.asm,v 1.2 2003/10/27 16:56:57 stefano Exp $ ; XLIB ozexitto LIB ozkeyclear LIB ozungetch2 XREF cleanup ;exit ozexitto: call ozkeyclear pop bc ;; retval pop hl ;; key push hl ;; put two copies of key on stack push hl call ozungetch2 pop hl ;; use previous copy of key on stack as argument call ozungetch2 jp cleanup
//---------------------------------------------------------------------------- //Borland C++Builder //Copyright (c) 1987, 1998-2002 Borland International Inc. All Rights Reserved. //---------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "FontList.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TFormMain *FormMain; //--------------------------------------------------------------------------- __fastcall TFormMain::TFormMain(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFormMain::FormCreate(TObject *Sender) { ListBox1->Items = Screen->Fonts; } //--------------------------------------------------------------------- void __fastcall TFormMain::ListBox1Click(TObject *Sender) { FontLabel->Caption = ListBox1->Items->Strings[ListBox1->ItemIndex].c_str(); } //--------------------------------------------------------------------- void __fastcall TFormMain::DrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State) { ListBox1->Canvas->FillRect(Rect); ListBox1->Canvas->Font->Name =ListBox1->Items->Strings[Index].c_str(); ListBox1->Canvas->Font->Size = 0; ListBox1->Canvas->TextOut(Rect.Left+1, Rect.Top+1, ListBox1->Items->Strings[Index].c_str()); } //--------------------------------------------------------------------- void __fastcall TFormMain::ListBox1MeasureItem(TWinControl *Control, int Index, int &Height) { ListBox1->Canvas->Font->Name =ListBox1->Items->Strings[Index].c_str(); ListBox1->Canvas->Font->Size = 0; Height = ListBox1->Canvas->TextHeight("Wg") +2; } //---------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // Copyright (c) 2015-2019, Lawrence Livermore National Security, LLC. // // Produced at the Lawrence Livermore National Laboratory // // LLNL-CODE-716457 // // All rights reserved. // // This file is part of Ascent. // // For details, see: http://ascent.readthedocs.io/. // // Please also read ascent/LICENSE // // 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 disclaimer below. // // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the disclaimer (as noted below) in the // documentation and/or other materials provided with the distribution. // // * Neither the name of the LLNS/LLNL 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 LAWRENCE LIVERMORE NATIONAL SECURITY, // LLC, THE U.S. DEPARTMENT OF ENERGY 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. // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //----------------------------------------------------------------------------- /// /// file: t_ascent_cinema_a.cpp /// //----------------------------------------------------------------------------- #include "gtest/gtest.h" #include <ascent.hpp> #include <iostream> #include <math.h> #include <conduit_blueprint.hpp> #include "t_config.hpp" #include "t_utils.hpp" using namespace std; using namespace conduit; using namespace ascent; index_t EXAMPLE_MESH_SIDE_DIM = 32; //----------------------------------------------------------------------------- TEST(ascent_queries, max_query) { // the vtkm runtime is currently our only rendering runtime Node n; ascent::about(n); // // Create example mesh. // Node data, verify_info; conduit::blueprint::mesh::examples::braid("hexs", EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, data); EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info)); string output_path = prepare_output_dir(); string output_file = conduit::utils::join_file_path(output_path,"tout_max_query"); // remove old file if(conduit::utils::is_file(output_file)) { conduit::utils::remove_file(output_file); } // // Create the actions. // Node actions; conduit::Node queries; queries["q1/params/expression"] = "max(field(\"braid\"))"; queries["q1/params/name"] = "max_braid"; conduit::Node &add_queries = actions.append(); add_queries["action"] = "add_queries"; add_queries["queries"] = queries; actions.print(); // // Run Ascent // Ascent ascent; Node ascent_opts; // default is now ascent ascent_opts["runtime/type"] = "ascent"; ascent.open(ascent_opts); ascent.publish(data); ascent.execute(actions); conduit::Node info; ascent.info(info); EXPECT_TRUE(info.has_path("expressions/max_braid/100/attrs/value")); info["expressions"].save(output_file, "json"); ascent.close(); // check that we created an image EXPECT_TRUE(conduit::utils::is_file(output_file)); std::string msg = "An example of quiering the maximum value of a field."; ASCENT_ACTIONS_DUMP(actions,output_file,msg); } //----------------------------------------------------------------------------- TEST(ascent_queries, cycle_query) { // the vtkm runtime is currently our only rendering runtime Node n; ascent::about(n); // // Create example mesh. // Node data, verify_info; conduit::blueprint::mesh::examples::braid("hexs", EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, EXAMPLE_MESH_SIDE_DIM, data); EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info)); string output_path = prepare_output_dir(); string output_file = conduit::utils::join_file_path(output_path,"tout_cycle_query"); // remove old file if(conduit::utils::is_file(output_file)) { conduit::utils::remove_file(output_file); } // // Create the actions. // Node actions; conduit::Node queries; queries["q1/params/expression"] = "cycle()"; queries["q1/params/name"] = "cycle"; conduit::Node &add_queries = actions.append(); add_queries["action"] = "add_queries"; add_queries["queries"] = queries; actions.print(); // // Run Ascent // Ascent ascent; Node ascent_opts; // default is now ascent ascent_opts["runtime/type"] = "ascent"; ascent.open(ascent_opts); ascent.publish(data); ascent.execute(actions); conduit::Node info; ascent.info(info); EXPECT_TRUE(info.has_path("expressions/cycle/100/value")); EXPECT_TRUE(info["expressions/cycle/100/value"].to_int32() == 100); info["expressions"].save(output_file, "json"); ascent.close(); // check that we created an image EXPECT_TRUE(conduit::utils::is_file(output_file)); std::string msg = "An example of quiering the current cycle."; ASCENT_ACTIONS_DUMP(actions,output_file,msg); } //----------------------------------------------------------------------------- int main(int argc, char* argv[]) { int result = 0; ::testing::InitGoogleTest(&argc, argv); // allow override of the data size via the command line if(argc == 2) { EXAMPLE_MESH_SIDE_DIM = atoi(argv[1]); } result = RUN_ALL_TESTS(); return result; }
;=============================================================================== ; Constants PlayerIdleLeftAnim = 5 PlayerIdleRightAnim = 0 PlayerJumpLeftAnim = 9 PlayerJumpRightAnim = 4 PlayerFrame = 1 PlayerHorizontalSpeed = 2 PlayerXMinHigh = 0 ; 0*256 + 28 = 28 minX PlayerXMinLow = 28 PlayerXMaxHigh = 1 ; 1*256 + 60 = 316 maxX PlayerXMaxLow = 60 PlayerYMax = 205 PlayerXMinScrollHigh = 0 ; 0*256 + 150 = 150 minX PlayerXMinScrollLow = 150 PlayerXMaxScrollHigh = 0 ; 0*256 + 190 = 190 maxX PlayerXMaxScrollLow = 190 PlayerStateIdleLeft = 0 PlayerStateIdleRight = 1 PlayerStateRunLeft = 2 PlayerStateRunRight = 3 PlayerStateJumpLeft = 4 PlayerStateJumpRight = 5 PlayerJumpAmount = 28 PlayerYVelocityMax = 8 PlayerAnimDelay = 6 PlayerLeftCollX = 4 PlayerLeftCollY = 14 PlayerRightCollX = 20 PlayerRightCollY = 14 PlayerBottomLeftCollX = 7 PlayerBottomLeftCollY = 20 PlayerBottomRightCollX = 13 PlayerBottomRightCollY = 20 ;=============================================================================== ; Variables playerState byte PlayerStateIdleRight playerSprite byte 0 playerXVelocity byte 0 playerXVelocityAbs byte 0 playerXHigh byte 0 playerXLow byte 40 playerYVelocity byte 0 playerYVelocityAbs byte 0 playerYVelocityScaled byte 0 playerY byte PlayerYMax playerCollXHigh byte 0 playerCollXLow byte 0 playerCollY byte 0 playerXChar byte 0 playerXOffset byte 0 playerYChar byte 0 playerYOffset byte 0 playerOnGround byte True ;=============================================================================== ; Jump Tables gamePlayerJumpTableLow byte <gamePlayerUpdateIdleLeft byte <gamePlayerUpdateIdleRight byte <gamePlayerUpdateRunLeft byte <gamePlayerUpdateRunRight byte <gamePlayerUpdateJumpLeft byte <gamePlayerUpdateJumpRight gamePlayerJumpTableHigh byte >gamePlayerUpdateIdleLeft byte >gamePlayerUpdateIdleRight byte >gamePlayerUpdateRunLeft byte >gamePlayerUpdateRunRight byte >gamePlayerUpdateJumpLeft byte >gamePlayerUpdateJumpRight ;=============================================================================== ; Macros/Subroutines gamePlayerInit LIBSPRITE_ENABLE_AV playerSprite, True LIBSPRITE_SETFRAME_AV playerSprite, PlayerIdleRightAnim LIBSPRITE_SETCOLOR_AV playerSprite, Blue LIBSPRITE_MULTICOLORENABLE_AV playerSprite, True LIBSPRITE_SETPRIORITY_AV playerSprite, True rts ;=============================================================================== gamePlayerUpdate jsr gamePlayerUpdateState jsr gamePlayerUpdateVelocity jsr gamePlayerUpdatePosition jsr gamePlayerUpdateBackgroundCollisions rts ;=============================================================================== gamePlayerUpdateVelocity ; x velocity ----------------------------------------------- ; apply friction if on ground lda playerOnGround beq gPUVNoFriction lda #0 sta playerXVelocity gPUVNoFriction ; apply left/right velocity if left/right pressed LIBINPUT_GETHELD GameportLeftMask bne gPUVRight lda #-PlayerHorizontalSpeed sta playerXVelocity gPUVRight LIBINPUT_GETHELD GameportRightMask bne gPUVEnd lda #PlayerHorizontalSpeed sta playerXVelocity gPUVEnd ; get absolute x velocity LIBMATH_ABS_AA playerXVelocity, playerXVelocityAbs ; y velocity ----------------------------------------------- ; apply gravity inc playerYVelocity ; apply jump velocity if on ground & jump pressed lda playerOnGround beq gPUVNojump LIBINPUT_GETFIREPRESSED bne gPUVNoJump LIBMATH_SUB8BIT_AVA playerYVelocity, PlayerJumpAmount, playerYVelocity lda #False sta playerOnGround gPUVNoJump ; Clamp velocity if fire not held (Mario style variable height jump) lda playerYVelocity bpl gPUVYDone ; if velocity not negative we're done LIBINPUT_GETHELD GameportFireMask ; only do if fire released beq gPUVYDone LIBMATH_MAX8BIT_AV playerYVelocity, -PlayerYVelocityMax ; clamp gPUVYDone ; get absolute y velocity LIBMATH_ABS_AA playerYVelocity, playerYVelocityAbs ; scale abs velocity down to get speed (allows sub pixel precision) lda playerYVelocityAbs lsr A ; divided by 2 lsr A ; now by 4 sta playerYVelocityScaled ; clamp so collisions don't break if moving faster than 1 char per frame LIBMATH_MIN8BIT_AV playerYVelocityScaled, 6 rts ;============================================================================== gamePlayerCollideBottom ; Find the screen character at the player position LIBSCREEN_PIXELTOCHAR_AAVAVAAAA playerCollXHigh, playerCollXLow, 24, playerCollY, 50, playerXChar, playerXOffset, playerYChar, playerYOffset LIBSCREEN_SETCHARPOSITION_AA playerXChar, playerYChar LIBSCREEN_GETCHAR ZeroPageTemp ; Handle any pickups (char 0) jsr gamePickupsHandle ; Handle any collisions with character code > 32 lda #32 cmp ZeroPageTemp bcs gPCBNoCollision ; Collision response lda playerCollY and #%11111000 sta playerCollY ; extra adjustment for the 50 pixel y subtraction ; 50 / 8 leaves 2 pixels. adding 1 lines it back up inc playerCollY lda #0 sta playerYVelocity lda #True sta playerOnGround gPCBNoCollision rts ;============================================================================== gamePlayerCollideLeft ; Find the screen character at the player position LIBSCREEN_PIXELTOCHAR_AAVAVAAAA playerCollXHigh, playerCollXLow, 24, playerCollY, 50, playerXChar, playerXOffset, playerYChar, playerYOffset LIBSCREEN_SETCHARPOSITION_AA playerXChar, playerYChar LIBSCREEN_GETCHAR ZeroPageTemp ; Handle any pickups (char 0) jsr gamePickupsHandle ; Handle any collisions with character code > 32 lda #32 cmp ZeroPageTemp bcs gPCLNoCollision ; Collision response lda playerCollXLow and #%11111000 sta playerCollXLow LIBMATH_ADD16BIT_AAVVAA playerCollXHigh, playerCollXLow, 0, 8, playerCollXHigh, playerCollXLow gPCLNoCollision rts ;============================================================================== gamePlayerCollideRight ; Find the screen character at the player position LIBSCREEN_PIXELTOCHAR_AAVAVAAAA playerCollXHigh, playerCollXLow, 24, playerCollY, 50, playerXChar, playerXOffset, playerYChar, playerYOffset LIBSCREEN_SETCHARPOSITION_AA playerXChar, playerYChar LIBSCREEN_GETCHAR ZeroPageTemp ; Handle any pickups (char 0) jsr gamePickupsHandle ; Handle any collisions with character code > 32 lda #32 cmp ZeroPageTemp bcs gPCRNoCollision ; Collision response lda playerCollXLow and #%11111000 sta playerCollXLow gPCRNoCollision rts ;============================================================================== gamePlayerUpdateBackgroundCollisions ; adjust for the screen scroll value LIBMATH_SUB16BIT_AAVAAA playerXHigh, playerXLow, 0, screenScrollXValue, playerXHigh, playerXLow ; ---------------------------------------------- ; Transform left collision point LIBMATH_ADD16BIT_AAVVAA playerXHigh, playerXLow, 0, PlayerLeftCollX, playerCollXHigh, playerCollXLow LIBMATH_ADD8BIT_AVA playerY, PlayerLeftCollY, playerCollY ; Run collision check & response jsr gamePlayerCollideLeft ; Transform back to sprite space LIBMATH_SUB16BIT_AAVVAA playerCollXHigh, playerCollXLow, 0, PlayerLeftCollX, playerXHigh, playerXLow LIBMATH_SUB8BIT_AVA playerCollY, PlayerLeftCollY, playerY ; ---------------------------------------------- ; Transform right collision point LIBMATH_ADD16BIT_AAVVAA playerXHigh, playerXLow, 0, PlayerRightCollX, playerCollXHigh, playerCollXLow LIBMATH_ADD8BIT_AVA playerY, PlayerRightCollY, playerCollY ; Run collision check & response jsr gamePlayerCollideRight ; Transform back to sprite space LIBMATH_SUB16BIT_AAVVAA playerCollXHigh, playerCollXLow, 0, PlayerRightCollX, playerXHigh, playerXLow LIBMATH_SUB8BIT_AVA playerCollY, PlayerRightCollY, playerY ; ---------------------------------------------- ; Transform bottom left collision point LIBMATH_ADD16BIT_AAVVAA playerXHigh, playerXLow, 0, PlayerBottomLeftCollX, playerCollXHigh, playerCollXLow LIBMATH_ADD8BIT_AVA playerY, PlayerBottomLeftCollY, playerCollY ; Run collision check & response jsr gamePlayerCollideBottom ; Transform back to sprite space LIBMATH_SUB16BIT_AAVVAA playerCollXHigh, playerCollXLow, 0, PlayerBottomLeftCollX, playerXHigh, playerXLow LIBMATH_SUB8BIT_AVA playerCollY, PlayerBottomLeftCollY, playerY ; ---------------------------------------------- ; Transform bottom right collision point LIBMATH_ADD16BIT_AAVVAA playerXHigh, playerXLow, 0, PlayerBottomRightCollX, playerCollXHigh, playerCollXLow LIBMATH_ADD8BIT_AVA playerY, PlayerBottomRightCollY, playerCollY ; Run collision check & response jsr gamePlayerCollideBottom ; Transform back to sprite space LIBMATH_SUB16BIT_AAVVAA playerCollXHigh, playerCollXLow, 0, PlayerBottomRightCollX, playerXHigh, playerXLow LIBMATH_SUB8BIT_AVA playerCollY, PlayerBottomRightCollY, playerY ; ---------------------------------------------- ; revert the screen scroll value adjustment LIBMATH_ADD16BIT_AAVAAA playerXHigh, playerXLow, 0, screenScrollXValue, playerXHigh, playerXLow ; ---------------------------------------------- ; set the sprite position (moved from updateposition as this ; subroutine adjusts the position with collision response) LIBSPRITE_SETPOSITION_AAAA playerSprite, playerXHigh, PlayerXLow, PlayerY rts ;=============================================================================== gamePlayerUpdateState ; now run the state machine ldy playerState ; write the state's routine address to a zeropage temporary lda gamePlayerJumpTableLow,y sta ZeroPageLow lda gamePlayerJumpTableHigh,y sta ZeroPageHigh ; jump to the update routine that temp_address now points to jmp (ZeroPageLow) ;=============================================================================== gamePlayerUpdatePosition ; x position ----------------------------------------------- lda playerXVelocity beq gPUPXDone ; if zero velocity bpl gPUPXPositive ;gPUPXNegative ; subtract the x velocity abs from the x position LIBMATH_SUB16BIT_AAVAAA playerXHigh, PlayerXLow, 0, playerXVelocityAbs, playerXHigh, PlayerXLow jmp gPUPXDone gPUPXPositive ; add the x velocity abs to the x position LIBMATH_ADD16BIT_AAVAAA playerXHigh, PlayerXLow, 0, playerXVelocityAbs, playerXHigh, PlayerXLow gPUPXDone jsr gamePlayerClampXandScroll ; y position ----------------------------------------------- lda playerYVelocity beq gPUPYDone ; if zero velocity bpl gPUPYPositive ;gPUPYNegative ; subtract the y velocity scaled from the y position LIBMATH_SUB8BIT_AAA playerY, playerYVelocityScaled, playerY jmp gPUPYDone gPUPYPositive ; add the y velocity scaled to the x position LIBMATH_ADD8BIT_AAA playerY, playerYVelocityScaled, playerY gPUPYDone rts ;=============================================================================== gamePlayerClampXandScroll ; clamp the player x position ------------------------------ ; different min values based on first column or not lda screenColumn cmp #0 bne gPCXSNotFirstColumn LIBMATH_MAX16BIT_AAVV playerXHigh, playerXLow, PlayerXMinHigh, PLayerXMinLow jmp gPCXSFirstColumnEnd gPCXSNotFirstColumn LIBMATH_MAX16BIT_AAVV playerXHigh, playerXLow, PlayerXMinScrollHigh, PLayerXMinScrollLow gPCXSFirstColumnEnd ; different min values based on last column or not lda screenColumn cmp #MapLastColumn bcs gPCXSNotLastColumn LIBMATH_MIN16BIT_AAVV playerXHigh, playerXLow, PlayerXMaxScrollHigh, PLayerXMaxScrollLow jmp gPCXSLastColumnEnd gPCXSNotLastColumn LIBMATH_MIN16BIT_AAVV playerXHigh, playerXLow, PlayerXMaxHigh, PLayerXMaxLow gPCXSLastColumnEnd ; scroll the screen ---------------------------------------- lda playerXVelocity beq gPCXSDone ; if zero velocity bpl gPCXSPositive ;gPCXSNegative ; if negative velocity ; skip right scroll if at first column lda screenColumn cmp #0 beq gPCXSDone ; scroll the screen right if player X = min scrollX lda playerXHigh cmp #PlayerXMinScrollHigh bne gPCXSDone lda playerXLow cmp #PlayerXMinScrollLow bne gPCXSDone LIBSCREEN_SCROLLXRIGHT_A gameMapUpdate jmp gPCXSDone gPCXSPositive ; if positive velocity ; skip left scroll if at last column lda screenColumn cmp #MapLastColumn bcs gPCXSDone ; scroll the screen left if player X = max scrollX lda playerXHigh cmp #PLayerXMaxScrollHigh bne gPCXSDone lda playerXLow cmp #PLayerXMaxScrollLow bne gPCXSDone LIBSCREEN_SCROLLXLEFT_A gameMapUpdate gPCXSDone rts ;=============================================================================== gamePlayerUpdateIdleLeft lda playerXVelocity beq gPUILDone ; if zero velocity bpl gPUILPositive ;gPUILNegative ; if negative velocity jsr gamePlayerSetRunLeft jmp gPUILDone gPUILPositive ; if positive velocity jsr gamePlayerSetRunRight gPUILDone ; Switch to jump state if not on ground lda playerOnGround bne gPUILNoJump jsr gamePlayerSetJumpLeft gPUILNoJump rts ;=============================================================================== gamePlayerUpdateIdleRight lda playerXVelocity beq gPUIRDone ; if zero velocity bpl gPUIRPositive ;gPUIRNegative ; if negative velocity jsr gamePlayerSetRunLeft jmp gPUIRDone gPUIRPositive ; if positive velocity jsr gamePlayerSetRunRight gPUIRDone ; Switch to jump state if not on ground lda playerOnGround bne gPUIRNoJump jsr gamePlayerSetJumpRight gPUIRNoJump rts ;=============================================================================== gamePlayerUpdateRunLeft lda playerXVelocity beq gPURLZero ; if zero velocity bpl gPURLPositive ;gPURLNegative jmp gPURLDone gPURLPositive jsr gamePlayerSetRunRight jmp gPURLDone gPURLZero jsr gamePlayerSetIdleLeft gPURLDone ; Switch to jump state if not on ground lda playerOnGround bne gPURLNojump jsr gamePlayerSetJumpLeft gPURLNojump rts ;=============================================================================== gamePlayerUpdateRunRight lda playerXVelocity beq gPURRZero ; if zero velocity bpl gPURRPositive ;gPURRNegative jsr gamePlayerSetRunLeft jmp gPURRDone gPURRPositive jmp gPURRDone gPURRZero jsr gamePlayerSetIdleRight gPURRDone ; Switch to jump state if not on ground lda playerOnGround bne gPURRNojump jsr gamePlayerSetJumpRight gPURRNojump rts ;=============================================================================== gamePlayerUpdateJumpLeft lda playerXVelocity beq gPUJLDone ; if zero velocity bpl gPUJLPositive ;gPUJLNegative jmp gPUJLDone gPUJLPositive jsr gamePlayerSetJumpRight gPUJLDone lda playerOnGround beq gPUJLNotOnGround jsr gamePlayerSetIdleLeft gPUJLNotOnGround rts ;=============================================================================== gamePlayerUpdateJumpRight lda playerXVelocity beq gPUJRDone ; if zero velocity bpl gPUJRPositive ;gPUJRNegative jsr gamePlayerSetJumpLeft jmp gPUJRDone gPUJRPositive gPUJRDone lda playerOnGround beq gPUJRNotOnGround jsr gamePlayerSetIdleRight gPUJRNotOnGround rts ;=============================================================================== gamePlayerSetIdleLeft lda #PlayerStateIdleLeft sta playerState LIBSPRITE_STOPANIM_A playerSprite LIBSPRITE_SETFRAME_AV playerSprite, PlayerIdleLeftAnim rts ;====================================================2========================== gamePlayerSetIdleRight lda #PlayerStateIdleRight sta playerState LIBSPRITE_STOPANIM_A playerSprite LIBSPRITE_SETFRAME_AV playerSprite, PlayerIdleRightAnim rts ;=============================================================================== gamePlayerSetRunLeft lda #PlayerStateRunLeft sta playerState LIBSPRITE_PLAYANIM_AVVVV playerSprite, 6, 8, PlayerAnimDelay, True rts ;=============================================================================== gamePlayerSetRunRight lda #PlayerStateRunRight sta playerState LIBSPRITE_PLAYANIM_AVVVV playerSprite, 1, 3, PlayerAnimDelay, True rts ;=============================================================================== gamePlayerSetJumpLeft lda #PlayerStateJumpLeft sta playerState LIBSPRITE_STOPANIM_A playerSprite LIBSPRITE_SETFRAME_AV playerSprite, PlayerJumpLeftAnim rts ;=============================================================================== gamePlayerSetJumpRight lda #PlayerStateJumpRight sta playerState LIBSPRITE_STOPANIM_A playerSprite LIBSPRITE_SETFRAME_AV playerSprite, PlayerJumpRightAnim rts
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' EXTERN OPENSSL_ia32cap_P:NEAR PUBLIC sha256_block_data_order ALIGN 16 sha256_block_data_order PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order:: mov rdi,rcx mov rsi,rdx mov rdx,r8 lea r11,QWORD PTR[OPENSSL_ia32cap_P] mov r9d,DWORD PTR[r11] mov r10d,DWORD PTR[4+r11] mov r11d,DWORD PTR[8+r11] test r11d,536870912 jnz _shaext_shortcut test r10d,512 jnz $L$ssse3_shortcut mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 shl rdx,4 sub rsp,16*4+4*8 lea rdx,QWORD PTR[rdx*4+rsi] and rsp,-64 mov QWORD PTR[((64+0))+rsp],rdi mov QWORD PTR[((64+8))+rsp],rsi mov QWORD PTR[((64+16))+rsp],rdx mov QWORD PTR[88+rsp],rax $L$prologue:: mov eax,DWORD PTR[rdi] mov ebx,DWORD PTR[4+rdi] mov ecx,DWORD PTR[8+rdi] mov edx,DWORD PTR[12+rdi] mov r8d,DWORD PTR[16+rdi] mov r9d,DWORD PTR[20+rdi] mov r10d,DWORD PTR[24+rdi] mov r11d,DWORD PTR[28+rdi] jmp $L$loop ALIGN 16 $L$loop:: mov edi,ebx lea rbp,QWORD PTR[K256] xor edi,ecx mov r12d,DWORD PTR[rsi] mov r13d,r8d mov r14d,eax bswap r12d ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD PTR[rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD PTR[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,QWORD PTR[4+rbp] add r11d,r14d mov r12d,DWORD PTR[4+rsi] mov r13d,edx mov r14d,r11d bswap r12d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD PTR[4+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD PTR[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,QWORD PTR[4+rbp] add r10d,r14d mov r12d,DWORD PTR[8+rsi] mov r13d,ecx mov r14d,r10d bswap r12d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD PTR[8+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD PTR[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,QWORD PTR[4+rbp] add r9d,r14d mov r12d,DWORD PTR[12+rsi] mov r13d,ebx mov r14d,r9d bswap r12d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD PTR[12+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD PTR[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,QWORD PTR[20+rbp] add r8d,r14d mov r12d,DWORD PTR[16+rsi] mov r13d,eax mov r14d,r8d bswap r12d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD PTR[16+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD PTR[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,QWORD PTR[4+rbp] add edx,r14d mov r12d,DWORD PTR[20+rsi] mov r13d,r11d mov r14d,edx bswap r12d ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD PTR[20+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD PTR[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,QWORD PTR[4+rbp] add ecx,r14d mov r12d,DWORD PTR[24+rsi] mov r13d,r10d mov r14d,ecx bswap r12d ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD PTR[24+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD PTR[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,QWORD PTR[4+rbp] add ebx,r14d mov r12d,DWORD PTR[28+rsi] mov r13d,r9d mov r14d,ebx bswap r12d ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD PTR[28+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD PTR[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,QWORD PTR[20+rbp] add eax,r14d mov r12d,DWORD PTR[32+rsi] mov r13d,r8d mov r14d,eax bswap r12d ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD PTR[32+rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD PTR[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,QWORD PTR[4+rbp] add r11d,r14d mov r12d,DWORD PTR[36+rsi] mov r13d,edx mov r14d,r11d bswap r12d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD PTR[36+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD PTR[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,QWORD PTR[4+rbp] add r10d,r14d mov r12d,DWORD PTR[40+rsi] mov r13d,ecx mov r14d,r10d bswap r12d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD PTR[40+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD PTR[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,QWORD PTR[4+rbp] add r9d,r14d mov r12d,DWORD PTR[44+rsi] mov r13d,ebx mov r14d,r9d bswap r12d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD PTR[44+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD PTR[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,QWORD PTR[20+rbp] add r8d,r14d mov r12d,DWORD PTR[48+rsi] mov r13d,eax mov r14d,r8d bswap r12d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD PTR[48+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD PTR[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,QWORD PTR[4+rbp] add edx,r14d mov r12d,DWORD PTR[52+rsi] mov r13d,r11d mov r14d,edx bswap r12d ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD PTR[52+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD PTR[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,QWORD PTR[4+rbp] add ecx,r14d mov r12d,DWORD PTR[56+rsi] mov r13d,r10d mov r14d,ecx bswap r12d ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD PTR[56+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD PTR[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,QWORD PTR[4+rbp] add ebx,r14d mov r12d,DWORD PTR[60+rsi] mov r13d,r9d mov r14d,ebx bswap r12d ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD PTR[60+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD PTR[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,QWORD PTR[20+rbp] jmp $L$rounds_16_xx ALIGN 16 $L$rounds_16_xx:: mov r13d,DWORD PTR[4+rsp] mov r15d,DWORD PTR[56+rsp] mov r12d,r13d ror r13d,11 add eax,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[36+rsp] add r12d,DWORD PTR[rsp] mov r13d,r8d add r12d,r15d mov r14d,eax ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD PTR[rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD PTR[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[8+rsp] mov edi,DWORD PTR[60+rsp] mov r12d,r13d ror r13d,11 add r11d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[40+rsp] add r12d,DWORD PTR[4+rsp] mov r13d,edx add r12d,edi mov r14d,r11d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD PTR[4+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD PTR[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[12+rsp] mov r15d,DWORD PTR[rsp] mov r12d,r13d ror r13d,11 add r10d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[44+rsp] add r12d,DWORD PTR[8+rsp] mov r13d,ecx add r12d,r15d mov r14d,r10d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD PTR[8+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD PTR[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[16+rsp] mov edi,DWORD PTR[4+rsp] mov r12d,r13d ror r13d,11 add r9d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[48+rsp] add r12d,DWORD PTR[12+rsp] mov r13d,ebx add r12d,edi mov r14d,r9d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD PTR[12+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD PTR[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,QWORD PTR[20+rbp] mov r13d,DWORD PTR[20+rsp] mov r15d,DWORD PTR[8+rsp] mov r12d,r13d ror r13d,11 add r8d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[52+rsp] add r12d,DWORD PTR[16+rsp] mov r13d,eax add r12d,r15d mov r14d,r8d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD PTR[16+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD PTR[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[24+rsp] mov edi,DWORD PTR[12+rsp] mov r12d,r13d ror r13d,11 add edx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[56+rsp] add r12d,DWORD PTR[20+rsp] mov r13d,r11d add r12d,edi mov r14d,edx ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD PTR[20+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD PTR[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[28+rsp] mov r15d,DWORD PTR[16+rsp] mov r12d,r13d ror r13d,11 add ecx,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[60+rsp] add r12d,DWORD PTR[24+rsp] mov r13d,r10d add r12d,r15d mov r14d,ecx ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD PTR[24+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD PTR[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[32+rsp] mov edi,DWORD PTR[20+rsp] mov r12d,r13d ror r13d,11 add ebx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[rsp] add r12d,DWORD PTR[28+rsp] mov r13d,r9d add r12d,edi mov r14d,ebx ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD PTR[28+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD PTR[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,QWORD PTR[20+rbp] mov r13d,DWORD PTR[36+rsp] mov r15d,DWORD PTR[24+rsp] mov r12d,r13d ror r13d,11 add eax,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[4+rsp] add r12d,DWORD PTR[32+rsp] mov r13d,r8d add r12d,r15d mov r14d,eax ror r13d,14 mov r15d,r9d xor r13d,r8d ror r14d,9 xor r15d,r10d mov DWORD PTR[32+rsp],r12d xor r14d,eax and r15d,r8d ror r13d,5 add r12d,r11d xor r15d,r10d ror r14d,11 xor r13d,r8d add r12d,r15d mov r15d,eax add r12d,DWORD PTR[rbp] xor r14d,eax xor r15d,ebx ror r13d,6 mov r11d,ebx and edi,r15d ror r14d,2 add r12d,r13d xor r11d,edi add edx,r12d add r11d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[40+rsp] mov edi,DWORD PTR[28+rsp] mov r12d,r13d ror r13d,11 add r11d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[8+rsp] add r12d,DWORD PTR[36+rsp] mov r13d,edx add r12d,edi mov r14d,r11d ror r13d,14 mov edi,r8d xor r13d,edx ror r14d,9 xor edi,r9d mov DWORD PTR[36+rsp],r12d xor r14d,r11d and edi,edx ror r13d,5 add r12d,r10d xor edi,r9d ror r14d,11 xor r13d,edx add r12d,edi mov edi,r11d add r12d,DWORD PTR[rbp] xor r14d,r11d xor edi,eax ror r13d,6 mov r10d,eax and r15d,edi ror r14d,2 add r12d,r13d xor r10d,r15d add ecx,r12d add r10d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[44+rsp] mov r15d,DWORD PTR[32+rsp] mov r12d,r13d ror r13d,11 add r10d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[12+rsp] add r12d,DWORD PTR[40+rsp] mov r13d,ecx add r12d,r15d mov r14d,r10d ror r13d,14 mov r15d,edx xor r13d,ecx ror r14d,9 xor r15d,r8d mov DWORD PTR[40+rsp],r12d xor r14d,r10d and r15d,ecx ror r13d,5 add r12d,r9d xor r15d,r8d ror r14d,11 xor r13d,ecx add r12d,r15d mov r15d,r10d add r12d,DWORD PTR[rbp] xor r14d,r10d xor r15d,r11d ror r13d,6 mov r9d,r11d and edi,r15d ror r14d,2 add r12d,r13d xor r9d,edi add ebx,r12d add r9d,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[48+rsp] mov edi,DWORD PTR[36+rsp] mov r12d,r13d ror r13d,11 add r9d,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[16+rsp] add r12d,DWORD PTR[44+rsp] mov r13d,ebx add r12d,edi mov r14d,r9d ror r13d,14 mov edi,ecx xor r13d,ebx ror r14d,9 xor edi,edx mov DWORD PTR[44+rsp],r12d xor r14d,r9d and edi,ebx ror r13d,5 add r12d,r8d xor edi,edx ror r14d,11 xor r13d,ebx add r12d,edi mov edi,r9d add r12d,DWORD PTR[rbp] xor r14d,r9d xor edi,r10d ror r13d,6 mov r8d,r10d and r15d,edi ror r14d,2 add r12d,r13d xor r8d,r15d add eax,r12d add r8d,r12d lea rbp,QWORD PTR[20+rbp] mov r13d,DWORD PTR[52+rsp] mov r15d,DWORD PTR[40+rsp] mov r12d,r13d ror r13d,11 add r8d,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[20+rsp] add r12d,DWORD PTR[48+rsp] mov r13d,eax add r12d,r15d mov r14d,r8d ror r13d,14 mov r15d,ebx xor r13d,eax ror r14d,9 xor r15d,ecx mov DWORD PTR[48+rsp],r12d xor r14d,r8d and r15d,eax ror r13d,5 add r12d,edx xor r15d,ecx ror r14d,11 xor r13d,eax add r12d,r15d mov r15d,r8d add r12d,DWORD PTR[rbp] xor r14d,r8d xor r15d,r9d ror r13d,6 mov edx,r9d and edi,r15d ror r14d,2 add r12d,r13d xor edx,edi add r11d,r12d add edx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[56+rsp] mov edi,DWORD PTR[44+rsp] mov r12d,r13d ror r13d,11 add edx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[24+rsp] add r12d,DWORD PTR[52+rsp] mov r13d,r11d add r12d,edi mov r14d,edx ror r13d,14 mov edi,eax xor r13d,r11d ror r14d,9 xor edi,ebx mov DWORD PTR[52+rsp],r12d xor r14d,edx and edi,r11d ror r13d,5 add r12d,ecx xor edi,ebx ror r14d,11 xor r13d,r11d add r12d,edi mov edi,edx add r12d,DWORD PTR[rbp] xor r14d,edx xor edi,r8d ror r13d,6 mov ecx,r8d and r15d,edi ror r14d,2 add r12d,r13d xor ecx,r15d add r10d,r12d add ecx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[60+rsp] mov r15d,DWORD PTR[48+rsp] mov r12d,r13d ror r13d,11 add ecx,r14d mov r14d,r15d ror r15d,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor r15d,r14d shr r14d,10 ror r15d,17 xor r12d,r13d xor r15d,r14d add r12d,DWORD PTR[28+rsp] add r12d,DWORD PTR[56+rsp] mov r13d,r10d add r12d,r15d mov r14d,ecx ror r13d,14 mov r15d,r11d xor r13d,r10d ror r14d,9 xor r15d,eax mov DWORD PTR[56+rsp],r12d xor r14d,ecx and r15d,r10d ror r13d,5 add r12d,ebx xor r15d,eax ror r14d,11 xor r13d,r10d add r12d,r15d mov r15d,ecx add r12d,DWORD PTR[rbp] xor r14d,ecx xor r15d,edx ror r13d,6 mov ebx,edx and edi,r15d ror r14d,2 add r12d,r13d xor ebx,edi add r9d,r12d add ebx,r12d lea rbp,QWORD PTR[4+rbp] mov r13d,DWORD PTR[rsp] mov edi,DWORD PTR[52+rsp] mov r12d,r13d ror r13d,11 add ebx,r14d mov r14d,edi ror edi,2 xor r13d,r12d shr r12d,3 ror r13d,7 xor edi,r14d shr r14d,10 ror edi,17 xor r12d,r13d xor edi,r14d add r12d,DWORD PTR[32+rsp] add r12d,DWORD PTR[60+rsp] mov r13d,r9d add r12d,edi mov r14d,ebx ror r13d,14 mov edi,r10d xor r13d,r9d ror r14d,9 xor edi,r11d mov DWORD PTR[60+rsp],r12d xor r14d,ebx and edi,r9d ror r13d,5 add r12d,eax xor edi,r11d ror r14d,11 xor r13d,r9d add r12d,edi mov edi,ebx add r12d,DWORD PTR[rbp] xor r14d,ebx xor edi,ecx ror r13d,6 mov eax,ecx and r15d,edi ror r14d,2 add r12d,r13d xor eax,r15d add r8d,r12d add eax,r12d lea rbp,QWORD PTR[20+rbp] cmp BYTE PTR[3+rbp],0 jnz $L$rounds_16_xx mov rdi,QWORD PTR[((64+0))+rsp] add eax,r14d lea rsi,QWORD PTR[64+rsi] add eax,DWORD PTR[rdi] add ebx,DWORD PTR[4+rdi] add ecx,DWORD PTR[8+rdi] add edx,DWORD PTR[12+rdi] add r8d,DWORD PTR[16+rdi] add r9d,DWORD PTR[20+rdi] add r10d,DWORD PTR[24+rdi] add r11d,DWORD PTR[28+rdi] cmp rsi,QWORD PTR[((64+16))+rsp] mov DWORD PTR[rdi],eax mov DWORD PTR[4+rdi],ebx mov DWORD PTR[8+rdi],ecx mov DWORD PTR[12+rdi],edx mov DWORD PTR[16+rdi],r8d mov DWORD PTR[20+rdi],r9d mov DWORD PTR[24+rdi],r10d mov DWORD PTR[28+rdi],r11d jb $L$loop mov rsi,QWORD PTR[88+rsp] mov r15,QWORD PTR[((-48))+rsi] mov r14,QWORD PTR[((-40))+rsi] mov r13,QWORD PTR[((-32))+rsi] mov r12,QWORD PTR[((-24))+rsi] mov rbp,QWORD PTR[((-16))+rsi] mov rbx,QWORD PTR[((-8))+rsi] lea rsp,QWORD PTR[rsi] $L$epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order:: sha256_block_data_order ENDP ALIGN 64 K256:: DD 0428a2f98h,071374491h,0b5c0fbcfh,0e9b5dba5h DD 0428a2f98h,071374491h,0b5c0fbcfh,0e9b5dba5h DD 03956c25bh,059f111f1h,0923f82a4h,0ab1c5ed5h DD 03956c25bh,059f111f1h,0923f82a4h,0ab1c5ed5h DD 0d807aa98h,012835b01h,0243185beh,0550c7dc3h DD 0d807aa98h,012835b01h,0243185beh,0550c7dc3h DD 072be5d74h,080deb1feh,09bdc06a7h,0c19bf174h DD 072be5d74h,080deb1feh,09bdc06a7h,0c19bf174h DD 0e49b69c1h,0efbe4786h,00fc19dc6h,0240ca1cch DD 0e49b69c1h,0efbe4786h,00fc19dc6h,0240ca1cch DD 02de92c6fh,04a7484aah,05cb0a9dch,076f988dah DD 02de92c6fh,04a7484aah,05cb0a9dch,076f988dah DD 0983e5152h,0a831c66dh,0b00327c8h,0bf597fc7h DD 0983e5152h,0a831c66dh,0b00327c8h,0bf597fc7h DD 0c6e00bf3h,0d5a79147h,006ca6351h,014292967h DD 0c6e00bf3h,0d5a79147h,006ca6351h,014292967h DD 027b70a85h,02e1b2138h,04d2c6dfch,053380d13h DD 027b70a85h,02e1b2138h,04d2c6dfch,053380d13h DD 0650a7354h,0766a0abbh,081c2c92eh,092722c85h DD 0650a7354h,0766a0abbh,081c2c92eh,092722c85h DD 0a2bfe8a1h,0a81a664bh,0c24b8b70h,0c76c51a3h DD 0a2bfe8a1h,0a81a664bh,0c24b8b70h,0c76c51a3h DD 0d192e819h,0d6990624h,0f40e3585h,0106aa070h DD 0d192e819h,0d6990624h,0f40e3585h,0106aa070h DD 019a4c116h,01e376c08h,02748774ch,034b0bcb5h DD 019a4c116h,01e376c08h,02748774ch,034b0bcb5h DD 0391c0cb3h,04ed8aa4ah,05b9cca4fh,0682e6ff3h DD 0391c0cb3h,04ed8aa4ah,05b9cca4fh,0682e6ff3h DD 0748f82eeh,078a5636fh,084c87814h,08cc70208h DD 0748f82eeh,078a5636fh,084c87814h,08cc70208h DD 090befffah,0a4506cebh,0bef9a3f7h,0c67178f2h DD 090befffah,0a4506cebh,0bef9a3f7h,0c67178f2h DD 000010203h,004050607h,008090a0bh,00c0d0e0fh DD 000010203h,004050607h,008090a0bh,00c0d0e0fh DD 003020100h,00b0a0908h,0ffffffffh,0ffffffffh DD 003020100h,00b0a0908h,0ffffffffh,0ffffffffh DD 0ffffffffh,0ffffffffh,003020100h,00b0a0908h DD 0ffffffffh,0ffffffffh,003020100h,00b0a0908h DB 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97 DB 110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54 DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 DB 111,114,103,62,0 ALIGN 64 sha256_block_data_order_shaext PROC PRIVATE mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order_shaext:: mov rdi,rcx mov rsi,rdx mov rdx,r8 _shaext_shortcut:: lea rsp,QWORD PTR[((-88))+rsp] movaps XMMWORD PTR[(-8-80)+rax],xmm6 movaps XMMWORD PTR[(-8-64)+rax],xmm7 movaps XMMWORD PTR[(-8-48)+rax],xmm8 movaps XMMWORD PTR[(-8-32)+rax],xmm9 movaps XMMWORD PTR[(-8-16)+rax],xmm10 $L$prologue_shaext:: lea rcx,QWORD PTR[((K256+128))] movdqu xmm1,XMMWORD PTR[rdi] movdqu xmm2,XMMWORD PTR[16+rdi] movdqa xmm7,XMMWORD PTR[((512-128))+rcx] pshufd xmm0,xmm1,01bh pshufd xmm1,xmm1,0b1h pshufd xmm2,xmm2,01bh movdqa xmm8,xmm7 DB 102,15,58,15,202,8 punpcklqdq xmm2,xmm0 jmp $L$oop_shaext ALIGN 16 $L$oop_shaext:: movdqu xmm3,XMMWORD PTR[rsi] movdqu xmm4,XMMWORD PTR[16+rsi] movdqu xmm5,XMMWORD PTR[32+rsi] DB 102,15,56,0,223 movdqu xmm6,XMMWORD PTR[48+rsi] movdqa xmm0,XMMWORD PTR[((0-128))+rcx] paddd xmm0,xmm3 DB 102,15,56,0,231 movdqa xmm10,xmm2 DB 15,56,203,209 pshufd xmm0,xmm0,00eh nop movdqa xmm9,xmm1 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((32-128))+rcx] paddd xmm0,xmm4 DB 102,15,56,0,239 DB 15,56,203,209 pshufd xmm0,xmm0,00eh lea rsi,QWORD PTR[64+rsi] DB 15,56,204,220 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((64-128))+rcx] paddd xmm0,xmm5 DB 102,15,56,0,247 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm6 DB 102,15,58,15,253,4 nop paddd xmm3,xmm7 DB 15,56,204,229 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((96-128))+rcx] paddd xmm0,xmm6 DB 15,56,205,222 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm3 DB 102,15,58,15,254,4 nop paddd xmm4,xmm7 DB 15,56,204,238 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((128-128))+rcx] paddd xmm0,xmm3 DB 15,56,205,227 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm4 DB 102,15,58,15,251,4 nop paddd xmm5,xmm7 DB 15,56,204,243 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((160-128))+rcx] paddd xmm0,xmm4 DB 15,56,205,236 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm5 DB 102,15,58,15,252,4 nop paddd xmm6,xmm7 DB 15,56,204,220 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((192-128))+rcx] paddd xmm0,xmm5 DB 15,56,205,245 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm6 DB 102,15,58,15,253,4 nop paddd xmm3,xmm7 DB 15,56,204,229 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((224-128))+rcx] paddd xmm0,xmm6 DB 15,56,205,222 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm3 DB 102,15,58,15,254,4 nop paddd xmm4,xmm7 DB 15,56,204,238 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((256-128))+rcx] paddd xmm0,xmm3 DB 15,56,205,227 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm4 DB 102,15,58,15,251,4 nop paddd xmm5,xmm7 DB 15,56,204,243 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((288-128))+rcx] paddd xmm0,xmm4 DB 15,56,205,236 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm5 DB 102,15,58,15,252,4 nop paddd xmm6,xmm7 DB 15,56,204,220 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((320-128))+rcx] paddd xmm0,xmm5 DB 15,56,205,245 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm6 DB 102,15,58,15,253,4 nop paddd xmm3,xmm7 DB 15,56,204,229 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((352-128))+rcx] paddd xmm0,xmm6 DB 15,56,205,222 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm3 DB 102,15,58,15,254,4 nop paddd xmm4,xmm7 DB 15,56,204,238 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((384-128))+rcx] paddd xmm0,xmm3 DB 15,56,205,227 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm4 DB 102,15,58,15,251,4 nop paddd xmm5,xmm7 DB 15,56,204,243 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((416-128))+rcx] paddd xmm0,xmm4 DB 15,56,205,236 DB 15,56,203,209 pshufd xmm0,xmm0,00eh movdqa xmm7,xmm5 DB 102,15,58,15,252,4 DB 15,56,203,202 paddd xmm6,xmm7 movdqa xmm0,XMMWORD PTR[((448-128))+rcx] paddd xmm0,xmm5 DB 15,56,203,209 pshufd xmm0,xmm0,00eh DB 15,56,205,245 movdqa xmm7,xmm8 DB 15,56,203,202 movdqa xmm0,XMMWORD PTR[((480-128))+rcx] paddd xmm0,xmm6 nop DB 15,56,203,209 pshufd xmm0,xmm0,00eh dec rdx nop DB 15,56,203,202 paddd xmm2,xmm10 paddd xmm1,xmm9 jnz $L$oop_shaext pshufd xmm2,xmm2,0b1h pshufd xmm7,xmm1,01bh pshufd xmm1,xmm1,0b1h punpckhqdq xmm1,xmm2 DB 102,15,58,15,215,8 movdqu XMMWORD PTR[rdi],xmm1 movdqu XMMWORD PTR[16+rdi],xmm2 movaps xmm6,XMMWORD PTR[((-8-80))+rax] movaps xmm7,XMMWORD PTR[((-8-64))+rax] movaps xmm8,XMMWORD PTR[((-8-48))+rax] movaps xmm9,XMMWORD PTR[((-8-32))+rax] movaps xmm10,XMMWORD PTR[((-8-16))+rax] mov rsp,rax $L$epilogue_shaext:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order_shaext:: sha256_block_data_order_shaext ENDP ALIGN 64 sha256_block_data_order_ssse3 PROC PRIVATE mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_sha256_block_data_order_ssse3:: mov rdi,rcx mov rsi,rdx mov rdx,r8 $L$ssse3_shortcut:: mov rax,rsp push rbx push rbp push r12 push r13 push r14 push r15 shl rdx,4 sub rsp,160 lea rdx,QWORD PTR[rdx*4+rsi] and rsp,-64 mov QWORD PTR[((64+0))+rsp],rdi mov QWORD PTR[((64+8))+rsp],rsi mov QWORD PTR[((64+16))+rsp],rdx mov QWORD PTR[88+rsp],rax movaps XMMWORD PTR[(64+32)+rsp],xmm6 movaps XMMWORD PTR[(64+48)+rsp],xmm7 movaps XMMWORD PTR[(64+64)+rsp],xmm8 movaps XMMWORD PTR[(64+80)+rsp],xmm9 $L$prologue_ssse3:: mov eax,DWORD PTR[rdi] mov ebx,DWORD PTR[4+rdi] mov ecx,DWORD PTR[8+rdi] mov edx,DWORD PTR[12+rdi] mov r8d,DWORD PTR[16+rdi] mov r9d,DWORD PTR[20+rdi] mov r10d,DWORD PTR[24+rdi] mov r11d,DWORD PTR[28+rdi] jmp $L$loop_ssse3 ALIGN 16 $L$loop_ssse3:: movdqa xmm7,XMMWORD PTR[((K256+512))] movdqu xmm0,XMMWORD PTR[rsi] movdqu xmm1,XMMWORD PTR[16+rsi] movdqu xmm2,XMMWORD PTR[32+rsi] DB 102,15,56,0,199 movdqu xmm3,XMMWORD PTR[48+rsi] lea rbp,QWORD PTR[K256] DB 102,15,56,0,207 movdqa xmm4,XMMWORD PTR[rbp] movdqa xmm5,XMMWORD PTR[32+rbp] DB 102,15,56,0,215 paddd xmm4,xmm0 movdqa xmm6,XMMWORD PTR[64+rbp] DB 102,15,56,0,223 movdqa xmm7,XMMWORD PTR[96+rbp] paddd xmm5,xmm1 paddd xmm6,xmm2 paddd xmm7,xmm3 movdqa XMMWORD PTR[rsp],xmm4 mov r14d,eax movdqa XMMWORD PTR[16+rsp],xmm5 mov edi,ebx movdqa XMMWORD PTR[32+rsp],xmm6 xor edi,ecx movdqa XMMWORD PTR[48+rsp],xmm7 mov r13d,r8d jmp $L$ssse3_00_47 ALIGN 16 $L$ssse3_00_47:: sub rbp,-128 ror r13d,14 movdqa xmm4,xmm1 mov eax,r14d mov r12d,r9d movdqa xmm7,xmm3 ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax DB 102,15,58,15,224,4 and r12d,r8d xor r13d,r8d DB 102,15,58,15,250,4 add r11d,DWORD PTR[rsp] mov r15d,eax xor r12d,r10d ror r14d,11 movdqa xmm5,xmm4 xor r15d,ebx add r11d,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,eax add r11d,r13d xor edi,ebx paddd xmm0,xmm7 ror r14d,2 add edx,r11d psrld xmm6,7 add r11d,edi mov r13d,edx pshufd xmm7,xmm3,250 add r14d,r11d ror r13d,14 pslld xmm5,14 mov r11d,r14d mov r12d,r8d pxor xmm4,xmm6 ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 psrld xmm6,11 xor r14d,r11d pxor xmm4,xmm5 and r12d,edx xor r13d,edx pslld xmm5,11 add r10d,DWORD PTR[4+rsp] mov edi,r11d pxor xmm4,xmm6 xor r12d,r9d ror r14d,11 movdqa xmm6,xmm7 xor edi,eax add r10d,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,r11d psrld xmm7,10 add r10d,r13d xor r15d,eax paddd xmm0,xmm4 ror r14d,2 add ecx,r10d psrlq xmm6,17 add r10d,r15d mov r13d,ecx add r14d,r10d pxor xmm7,xmm6 ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 psrlq xmm6,2 xor r13d,ecx xor r12d,r8d pxor xmm7,xmm6 ror r13d,5 xor r14d,r10d and r12d,ecx pshufd xmm7,xmm7,128 xor r13d,ecx add r9d,DWORD PTR[8+rsp] mov r15d,r10d psrldq xmm7,8 xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 paddd xmm0,xmm7 and edi,r15d xor r14d,r10d add r9d,r13d pshufd xmm7,xmm0,80 xor edi,r11d ror r14d,2 add ebx,r9d movdqa xmm6,xmm7 add r9d,edi mov r13d,ebx psrld xmm7,10 add r14d,r9d ror r13d,14 psrlq xmm6,17 mov r9d,r14d mov r12d,ecx pxor xmm7,xmm6 ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d psrlq xmm6,2 and r12d,ebx xor r13d,ebx add r8d,DWORD PTR[12+rsp] pxor xmm7,xmm6 mov edi,r9d xor r12d,edx ror r14d,11 pshufd xmm7,xmm7,8 xor edi,r10d add r8d,r12d movdqa xmm6,XMMWORD PTR[rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,r9d add r8d,r13d xor r15d,r10d paddd xmm0,xmm7 ror r14d,2 add eax,r8d add r8d,r15d paddd xmm6,xmm0 mov r13d,eax add r14d,r8d movdqa XMMWORD PTR[rsp],xmm6 ror r13d,14 movdqa xmm4,xmm2 mov r8d,r14d mov r12d,ebx movdqa xmm7,xmm0 ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d DB 102,15,58,15,225,4 and r12d,eax xor r13d,eax DB 102,15,58,15,251,4 add edx,DWORD PTR[16+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 movdqa xmm5,xmm4 xor r15d,r9d add edx,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,r8d add edx,r13d xor edi,r9d paddd xmm1,xmm7 ror r14d,2 add r11d,edx psrld xmm6,7 add edx,edi mov r13d,r11d pshufd xmm7,xmm0,250 add r14d,edx ror r13d,14 pslld xmm5,14 mov edx,r14d mov r12d,eax pxor xmm4,xmm6 ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 psrld xmm6,11 xor r14d,edx pxor xmm4,xmm5 and r12d,r11d xor r13d,r11d pslld xmm5,11 add ecx,DWORD PTR[20+rsp] mov edi,edx pxor xmm4,xmm6 xor r12d,ebx ror r14d,11 movdqa xmm6,xmm7 xor edi,r8d add ecx,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,edx psrld xmm7,10 add ecx,r13d xor r15d,r8d paddd xmm1,xmm4 ror r14d,2 add r10d,ecx psrlq xmm6,17 add ecx,r15d mov r13d,r10d add r14d,ecx pxor xmm7,xmm6 ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 psrlq xmm6,2 xor r13d,r10d xor r12d,eax pxor xmm7,xmm6 ror r13d,5 xor r14d,ecx and r12d,r10d pshufd xmm7,xmm7,128 xor r13d,r10d add ebx,DWORD PTR[24+rsp] mov r15d,ecx psrldq xmm7,8 xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 paddd xmm1,xmm7 and edi,r15d xor r14d,ecx add ebx,r13d pshufd xmm7,xmm1,80 xor edi,edx ror r14d,2 add r9d,ebx movdqa xmm6,xmm7 add ebx,edi mov r13d,r9d psrld xmm7,10 add r14d,ebx ror r13d,14 psrlq xmm6,17 mov ebx,r14d mov r12d,r10d pxor xmm7,xmm6 ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx psrlq xmm6,2 and r12d,r9d xor r13d,r9d add eax,DWORD PTR[28+rsp] pxor xmm7,xmm6 mov edi,ebx xor r12d,r11d ror r14d,11 pshufd xmm7,xmm7,8 xor edi,ecx add eax,r12d movdqa xmm6,XMMWORD PTR[32+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,ebx add eax,r13d xor r15d,ecx paddd xmm1,xmm7 ror r14d,2 add r8d,eax add eax,r15d paddd xmm6,xmm1 mov r13d,r8d add r14d,eax movdqa XMMWORD PTR[16+rsp],xmm6 ror r13d,14 movdqa xmm4,xmm3 mov eax,r14d mov r12d,r9d movdqa xmm7,xmm1 ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax DB 102,15,58,15,226,4 and r12d,r8d xor r13d,r8d DB 102,15,58,15,248,4 add r11d,DWORD PTR[32+rsp] mov r15d,eax xor r12d,r10d ror r14d,11 movdqa xmm5,xmm4 xor r15d,ebx add r11d,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,eax add r11d,r13d xor edi,ebx paddd xmm2,xmm7 ror r14d,2 add edx,r11d psrld xmm6,7 add r11d,edi mov r13d,edx pshufd xmm7,xmm1,250 add r14d,r11d ror r13d,14 pslld xmm5,14 mov r11d,r14d mov r12d,r8d pxor xmm4,xmm6 ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 psrld xmm6,11 xor r14d,r11d pxor xmm4,xmm5 and r12d,edx xor r13d,edx pslld xmm5,11 add r10d,DWORD PTR[36+rsp] mov edi,r11d pxor xmm4,xmm6 xor r12d,r9d ror r14d,11 movdqa xmm6,xmm7 xor edi,eax add r10d,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,r11d psrld xmm7,10 add r10d,r13d xor r15d,eax paddd xmm2,xmm4 ror r14d,2 add ecx,r10d psrlq xmm6,17 add r10d,r15d mov r13d,ecx add r14d,r10d pxor xmm7,xmm6 ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 psrlq xmm6,2 xor r13d,ecx xor r12d,r8d pxor xmm7,xmm6 ror r13d,5 xor r14d,r10d and r12d,ecx pshufd xmm7,xmm7,128 xor r13d,ecx add r9d,DWORD PTR[40+rsp] mov r15d,r10d psrldq xmm7,8 xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 paddd xmm2,xmm7 and edi,r15d xor r14d,r10d add r9d,r13d pshufd xmm7,xmm2,80 xor edi,r11d ror r14d,2 add ebx,r9d movdqa xmm6,xmm7 add r9d,edi mov r13d,ebx psrld xmm7,10 add r14d,r9d ror r13d,14 psrlq xmm6,17 mov r9d,r14d mov r12d,ecx pxor xmm7,xmm6 ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d psrlq xmm6,2 and r12d,ebx xor r13d,ebx add r8d,DWORD PTR[44+rsp] pxor xmm7,xmm6 mov edi,r9d xor r12d,edx ror r14d,11 pshufd xmm7,xmm7,8 xor edi,r10d add r8d,r12d movdqa xmm6,XMMWORD PTR[64+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,r9d add r8d,r13d xor r15d,r10d paddd xmm2,xmm7 ror r14d,2 add eax,r8d add r8d,r15d paddd xmm6,xmm2 mov r13d,eax add r14d,r8d movdqa XMMWORD PTR[32+rsp],xmm6 ror r13d,14 movdqa xmm4,xmm0 mov r8d,r14d mov r12d,ebx movdqa xmm7,xmm2 ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d DB 102,15,58,15,227,4 and r12d,eax xor r13d,eax DB 102,15,58,15,249,4 add edx,DWORD PTR[48+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 movdqa xmm5,xmm4 xor r15d,r9d add edx,r12d movdqa xmm6,xmm4 ror r13d,6 and edi,r15d psrld xmm4,3 xor r14d,r8d add edx,r13d xor edi,r9d paddd xmm3,xmm7 ror r14d,2 add r11d,edx psrld xmm6,7 add edx,edi mov r13d,r11d pshufd xmm7,xmm2,250 add r14d,edx ror r13d,14 pslld xmm5,14 mov edx,r14d mov r12d,eax pxor xmm4,xmm6 ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 psrld xmm6,11 xor r14d,edx pxor xmm4,xmm5 and r12d,r11d xor r13d,r11d pslld xmm5,11 add ecx,DWORD PTR[52+rsp] mov edi,edx pxor xmm4,xmm6 xor r12d,ebx ror r14d,11 movdqa xmm6,xmm7 xor edi,r8d add ecx,r12d pxor xmm4,xmm5 ror r13d,6 and r15d,edi xor r14d,edx psrld xmm7,10 add ecx,r13d xor r15d,r8d paddd xmm3,xmm4 ror r14d,2 add r10d,ecx psrlq xmm6,17 add ecx,r15d mov r13d,r10d add r14d,ecx pxor xmm7,xmm6 ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 psrlq xmm6,2 xor r13d,r10d xor r12d,eax pxor xmm7,xmm6 ror r13d,5 xor r14d,ecx and r12d,r10d pshufd xmm7,xmm7,128 xor r13d,r10d add ebx,DWORD PTR[56+rsp] mov r15d,ecx psrldq xmm7,8 xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 paddd xmm3,xmm7 and edi,r15d xor r14d,ecx add ebx,r13d pshufd xmm7,xmm3,80 xor edi,edx ror r14d,2 add r9d,ebx movdqa xmm6,xmm7 add ebx,edi mov r13d,r9d psrld xmm7,10 add r14d,ebx ror r13d,14 psrlq xmm6,17 mov ebx,r14d mov r12d,r10d pxor xmm7,xmm6 ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx psrlq xmm6,2 and r12d,r9d xor r13d,r9d add eax,DWORD PTR[60+rsp] pxor xmm7,xmm6 mov edi,ebx xor r12d,r11d ror r14d,11 pshufd xmm7,xmm7,8 xor edi,ecx add eax,r12d movdqa xmm6,XMMWORD PTR[96+rbp] ror r13d,6 and r15d,edi pslldq xmm7,8 xor r14d,ebx add eax,r13d xor r15d,ecx paddd xmm3,xmm7 ror r14d,2 add r8d,eax add eax,r15d paddd xmm6,xmm3 mov r13d,r8d add r14d,eax movdqa XMMWORD PTR[48+rsp],xmm6 cmp BYTE PTR[131+rbp],0 jne $L$ssse3_00_47 ror r13d,14 mov eax,r14d mov r12d,r9d ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD PTR[rsp] mov r15d,eax xor r12d,r10d ror r14d,11 xor r15d,ebx add r11d,r12d ror r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx ror r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d ror r13d,14 mov r11d,r14d mov r12d,r8d ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD PTR[4+rsp] mov edi,r11d xor r12d,r9d ror r14d,11 xor edi,eax add r10d,r12d ror r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax ror r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 xor r13d,ecx xor r12d,r8d ror r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD PTR[8+rsp] mov r15d,r10d xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d ror r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d ror r13d,14 mov r9d,r14d mov r12d,ecx ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD PTR[12+rsp] mov edi,r9d xor r12d,edx ror r14d,11 xor edi,r10d add r8d,r12d ror r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d ror r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d ror r13d,14 mov r8d,r14d mov r12d,ebx ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD PTR[16+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 xor r15d,r9d add edx,r12d ror r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d ror r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx ror r13d,14 mov edx,r14d mov r12d,eax ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD PTR[20+rsp] mov edi,edx xor r12d,ebx ror r14d,11 xor edi,r8d add ecx,r12d ror r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d ror r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 xor r13d,r10d xor r12d,eax ror r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD PTR[24+rsp] mov r15d,ecx xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx ror r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx ror r13d,14 mov ebx,r14d mov r12d,r10d ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD PTR[28+rsp] mov edi,ebx xor r12d,r11d ror r14d,11 xor edi,ecx add eax,r12d ror r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx ror r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax ror r13d,14 mov eax,r14d mov r12d,r9d ror r14d,9 xor r13d,r8d xor r12d,r10d ror r13d,5 xor r14d,eax and r12d,r8d xor r13d,r8d add r11d,DWORD PTR[32+rsp] mov r15d,eax xor r12d,r10d ror r14d,11 xor r15d,ebx add r11d,r12d ror r13d,6 and edi,r15d xor r14d,eax add r11d,r13d xor edi,ebx ror r14d,2 add edx,r11d add r11d,edi mov r13d,edx add r14d,r11d ror r13d,14 mov r11d,r14d mov r12d,r8d ror r14d,9 xor r13d,edx xor r12d,r9d ror r13d,5 xor r14d,r11d and r12d,edx xor r13d,edx add r10d,DWORD PTR[36+rsp] mov edi,r11d xor r12d,r9d ror r14d,11 xor edi,eax add r10d,r12d ror r13d,6 and r15d,edi xor r14d,r11d add r10d,r13d xor r15d,eax ror r14d,2 add ecx,r10d add r10d,r15d mov r13d,ecx add r14d,r10d ror r13d,14 mov r10d,r14d mov r12d,edx ror r14d,9 xor r13d,ecx xor r12d,r8d ror r13d,5 xor r14d,r10d and r12d,ecx xor r13d,ecx add r9d,DWORD PTR[40+rsp] mov r15d,r10d xor r12d,r8d ror r14d,11 xor r15d,r11d add r9d,r12d ror r13d,6 and edi,r15d xor r14d,r10d add r9d,r13d xor edi,r11d ror r14d,2 add ebx,r9d add r9d,edi mov r13d,ebx add r14d,r9d ror r13d,14 mov r9d,r14d mov r12d,ecx ror r14d,9 xor r13d,ebx xor r12d,edx ror r13d,5 xor r14d,r9d and r12d,ebx xor r13d,ebx add r8d,DWORD PTR[44+rsp] mov edi,r9d xor r12d,edx ror r14d,11 xor edi,r10d add r8d,r12d ror r13d,6 and r15d,edi xor r14d,r9d add r8d,r13d xor r15d,r10d ror r14d,2 add eax,r8d add r8d,r15d mov r13d,eax add r14d,r8d ror r13d,14 mov r8d,r14d mov r12d,ebx ror r14d,9 xor r13d,eax xor r12d,ecx ror r13d,5 xor r14d,r8d and r12d,eax xor r13d,eax add edx,DWORD PTR[48+rsp] mov r15d,r8d xor r12d,ecx ror r14d,11 xor r15d,r9d add edx,r12d ror r13d,6 and edi,r15d xor r14d,r8d add edx,r13d xor edi,r9d ror r14d,2 add r11d,edx add edx,edi mov r13d,r11d add r14d,edx ror r13d,14 mov edx,r14d mov r12d,eax ror r14d,9 xor r13d,r11d xor r12d,ebx ror r13d,5 xor r14d,edx and r12d,r11d xor r13d,r11d add ecx,DWORD PTR[52+rsp] mov edi,edx xor r12d,ebx ror r14d,11 xor edi,r8d add ecx,r12d ror r13d,6 and r15d,edi xor r14d,edx add ecx,r13d xor r15d,r8d ror r14d,2 add r10d,ecx add ecx,r15d mov r13d,r10d add r14d,ecx ror r13d,14 mov ecx,r14d mov r12d,r11d ror r14d,9 xor r13d,r10d xor r12d,eax ror r13d,5 xor r14d,ecx and r12d,r10d xor r13d,r10d add ebx,DWORD PTR[56+rsp] mov r15d,ecx xor r12d,eax ror r14d,11 xor r15d,edx add ebx,r12d ror r13d,6 and edi,r15d xor r14d,ecx add ebx,r13d xor edi,edx ror r14d,2 add r9d,ebx add ebx,edi mov r13d,r9d add r14d,ebx ror r13d,14 mov ebx,r14d mov r12d,r10d ror r14d,9 xor r13d,r9d xor r12d,r11d ror r13d,5 xor r14d,ebx and r12d,r9d xor r13d,r9d add eax,DWORD PTR[60+rsp] mov edi,ebx xor r12d,r11d ror r14d,11 xor edi,ecx add eax,r12d ror r13d,6 and r15d,edi xor r14d,ebx add eax,r13d xor r15d,ecx ror r14d,2 add r8d,eax add eax,r15d mov r13d,r8d add r14d,eax mov rdi,QWORD PTR[((64+0))+rsp] mov eax,r14d add eax,DWORD PTR[rdi] lea rsi,QWORD PTR[64+rsi] add ebx,DWORD PTR[4+rdi] add ecx,DWORD PTR[8+rdi] add edx,DWORD PTR[12+rdi] add r8d,DWORD PTR[16+rdi] add r9d,DWORD PTR[20+rdi] add r10d,DWORD PTR[24+rdi] add r11d,DWORD PTR[28+rdi] cmp rsi,QWORD PTR[((64+16))+rsp] mov DWORD PTR[rdi],eax mov DWORD PTR[4+rdi],ebx mov DWORD PTR[8+rdi],ecx mov DWORD PTR[12+rdi],edx mov DWORD PTR[16+rdi],r8d mov DWORD PTR[20+rdi],r9d mov DWORD PTR[24+rdi],r10d mov DWORD PTR[28+rdi],r11d jb $L$loop_ssse3 mov rsi,QWORD PTR[88+rsp] movaps xmm6,XMMWORD PTR[((64+32))+rsp] movaps xmm7,XMMWORD PTR[((64+48))+rsp] movaps xmm8,XMMWORD PTR[((64+64))+rsp] movaps xmm9,XMMWORD PTR[((64+80))+rsp] mov r15,QWORD PTR[((-48))+rsi] mov r14,QWORD PTR[((-40))+rsi] mov r13,QWORD PTR[((-32))+rsi] mov r12,QWORD PTR[((-24))+rsi] mov rbp,QWORD PTR[((-16))+rsi] mov rbx,QWORD PTR[((-8))+rsi] lea rsp,QWORD PTR[rsi] $L$epilogue_ssse3:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order_ssse3:: sha256_block_data_order_ssse3 ENDP EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$in_prologue mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$in_prologue mov rsi,rax mov rax,QWORD PTR[((64+24))+rax] mov rbx,QWORD PTR[((-8))+rax] mov rbp,QWORD PTR[((-16))+rax] mov r12,QWORD PTR[((-24))+rax] mov r13,QWORD PTR[((-32))+rax] mov r14,QWORD PTR[((-40))+rax] mov r15,QWORD PTR[((-48))+rax] mov QWORD PTR[144+r8],rbx mov QWORD PTR[160+r8],rbp mov QWORD PTR[216+r8],r12 mov QWORD PTR[224+r8],r13 mov QWORD PTR[232+r8],r14 mov QWORD PTR[240+r8],r15 lea r10,QWORD PTR[$L$epilogue] cmp rbx,r10 jb $L$in_prologue lea rsi,QWORD PTR[((64+32))+rsi] lea rdi,QWORD PTR[512+r8] mov ecx,8 DD 0a548f3fch $L$in_prologue:: mov rdi,QWORD PTR[8+rax] mov rsi,QWORD PTR[16+rax] mov QWORD PTR[152+r8],rax mov QWORD PTR[168+r8],rsi mov QWORD PTR[176+r8],rdi mov rdi,QWORD PTR[40+r9] mov rsi,r8 mov ecx,154 DD 0a548f3fch mov rsi,r9 xor rcx,rcx mov rdx,QWORD PTR[8+rsi] mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[16+rsi] mov r10,QWORD PTR[40+rsi] lea r11,QWORD PTR[56+rsi] lea r12,QWORD PTR[24+rsi] mov QWORD PTR[32+rsp],r10 mov QWORD PTR[40+rsp],r11 mov QWORD PTR[48+rsp],r12 mov QWORD PTR[56+rsp],rcx call QWORD PTR[__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 se_handler ENDP ALIGN 16 shaext_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] lea r10,QWORD PTR[$L$prologue_shaext] cmp rbx,r10 jb $L$in_prologue lea r10,QWORD PTR[$L$epilogue_shaext] cmp rbx,r10 jae $L$in_prologue lea rsi,QWORD PTR[((-8-80))+rax] lea rdi,QWORD PTR[512+r8] mov ecx,10 DD 0a548f3fch jmp $L$in_prologue shaext_handler ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_sha256_block_data_order DD imagerel $L$SEH_end_sha256_block_data_order DD imagerel $L$SEH_info_sha256_block_data_order DD imagerel $L$SEH_begin_sha256_block_data_order_shaext DD imagerel $L$SEH_end_sha256_block_data_order_shaext DD imagerel $L$SEH_info_sha256_block_data_order_shaext DD imagerel $L$SEH_begin_sha256_block_data_order_ssse3 DD imagerel $L$SEH_end_sha256_block_data_order_ssse3 DD imagerel $L$SEH_info_sha256_block_data_order_ssse3 .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_sha256_block_data_order:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$prologue,imagerel $L$epilogue $L$SEH_info_sha256_block_data_order_shaext:: DB 9,0,0,0 DD imagerel shaext_handler $L$SEH_info_sha256_block_data_order_ssse3:: DB 9,0,0,0 DD imagerel se_handler DD imagerel $L$prologue_ssse3,imagerel $L$epilogue_ssse3 .xdata ENDS END
#include<iostream> using namespace std; int main() { string s; cin>>s; int counta, countb; counta = countb = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '-') { counta++; } else { countb++; } } if (countb <= 1) { cout << "YES" << endl; } else { cout <<(counta % countb == 0? "YES":"NO")<<endl; } }
x\0
SECTION code_driver PUBLIC asm_adv_curs GLOBAL __mode GLOBAL __console_x GLOBAL __console_y GLOBAL asm_scroll INCLUDE "target/gb/def/gb_globals.def" asm_adv_curs: PUSH HL LD HL,__console_x ; X coordinate LD A,MAXCURSPOSX CP (HL) JR Z,adv_curs_1 INC (HL) pop hl ret adv_curs_1: LD (HL),0x00 LD HL,__console_y ; Y coordinate LD A,MAXCURSPOSY CP (HL) JR Z,adv_curs_2 INC (HL) pop hl ret adv_curs_2: ;; See if scrolling is disabled LD A,(__mode) cp G_MODE ; In a graphics mode, we just reset to (0,0) jr z,reset_coords consider_text_mode: AND M_NO_SCROLL JR Z,adv_curs_3 ;; Nope - reset the cursor to (0,0) reset_coords: XOR A LD (__console_y),A LD (__console_x),A pop hl ret adv_curs_3: CALL asm_scroll POP HL RET
; --------------------------------------------------------------------------- ; Sprite mappings - SLZ platforms ; --------------------------------------------------------------------------- Map_Plat_SLZ_internal: dc.w @platform-Map_Plat_SLZ_internal @platform: dc.b 2 dc.b $F8, $F, 0, $21, $E0 dc.b $F8, $F, 0, $21, 0 even
; ; Z88 Small C+ Run Time Library ; Long library functions ; SECTION code_clib SECTION code_l_sccz80 PUBLIC l_long_ugt EXTERN l_long_ucmp l_long_ugt: ; PRIMARY > SECONDARY, carry set if true ; HL set to 0 (false) or 1 (true) ; dehl = secondary ; stack = primary, ret call l_long_ucmp jr z, false ccf ret c false: dec l ret
;************************************************************* ; ; TINY BASIC FOR ZILOG Z80 ; VERSION 2.5g ; ; ORIGINAL v2.0 ; BY LI-CHEN WANG ; ; MODIFIED AND TRANSLATED ; TO INTEL MNEMONICS ; BY ROGER RAUSKOLB ; 10 OCTOBER,1976 ; ; MODIFIED AND TRANSLATED ; TO ZILOG MNEMONICS ; BY DOUG GABBARD ; www.retrodepot.net ; ; RELEASED TO THE PUBLIC ; 10 OCTOBER,2017 ; YEAH, 41 YEARS LATER.... ; ; UPDATED TO V2.5g ; 9 DECEMBER, 2017 ; BY DOUG GABBARD ; www.retrodepot.net ; ; @COPYLEFT ; ALL WRONGS RESERVED ; ;************************************************************* ; This code is derived from the original 8080 Tiny Basic. ; It was first compiled in 8080 Mnemonics, then disassembled ; into Zilog Mnemonics. And then checked against the original ; to ensure accuracy. It was then partially enhanced with z80 ; specific code. And once done, it was then modified to work ; with the G80-S Micro Computer. However, that portion of the ; code has been left out in order to make this code a little ; more portable. There are only three routines that one needs ; to write, and specifing the serial port's I/O address, in ; order to make this version work with your own DIY computer. ; Those routines can be found at the end of the source code. ; ; I hope you find good use for this relic. However, I would ; ask that if you do find use for it, please put a reference ; to me in your work. And please, distribute freely. ;************************************************************* ;************************************************************* ; *** ROUTINES TO MODIFY *** ; ; The routines that need modified for this to work with your ; particular computer are at the bottom of this file. They ; are: SERIAL_INIT, RX_RDY, and TX_RDY. SERIAL_INIT is a ; routine to intialize the Serial Port that will be used. ; RX_RDY is a routine to check if the Serial Port has a ; character available. And TX_RDY checks to see if the Serial ; Port is ready to send a character, and then sends it. ; ; You will also need to define the location of your serial ; port. It's is the next line below this block of text. ;************************************************************* SerialPort EQU UART_DHR ;This is for your I/0 SPACE EQU 020H ; Space TAB EQU 09H ; HORIZONTAL TAB CTRLC EQU 03H ; Control "C" CTRLG EQU 07H ; Control "G" BKSP EQU 08H ; Back space LF EQU 0AH ; Line feed CS EQU 0CH ; Clear screen CR EQU 0DH ; Carriage return CTRLO EQU 0FH ; Control "O" CTRLQ EQU 011H ; Control "Q" CTRLR EQU 012H ; Control "R" CTRLS EQU 013H ; Control "S" CTRLU EQU 015H ; Control "U" ESC EQU 01BH ; Escape DEL EQU 07FH ; Delete STACK EQU 0FFFFH ; STACKB OCSW EQU 08000H ;SWITCH FOR OUTPUT CURRNT EQU OCSW+1 ;POINTS FOR OUTPUT STKGOS EQU OCSW+3 ;SAVES SP IN 'GOSUB' VARNXT EQU OCSW+5 ;TEMP STORAGE STKINP EQU OCSW+7 ;SAVES SP IN 'INPUT' LOPVAR EQU OCSW+9 ;'FOR' LOOP SAVE AREA LOPINC EQU OCSW+11 ;INCREMENT LOPLMT EQU OCSW+13 ;LIMIT LOPLN EQU OCSW+15 ;LINE NUMBER LOPPT EQU OCSW+17 ;TEXT POINTER RANPNT EQU OCSW+19 ;RANDOM NUMBER POINTER TXTUNF EQU OCSW+21 ;->UNFILLED TEXT AREA TXTBGN EQU OCSW+23 ;TEXT SAVE AREA BEGINS TXTEND EQU 0FF00H ;TEXT SAVE AREA ENDS ;************************************************************* ; *** ZERO PAGE SUBROUTINES *** ; ; THE Z80 INSTRUCTION SET ALLOWS FOR 8 ROUTINES IN LOW MEMORY ; THAT MAY BE CALLED BY RST 00H, 08H, 10H, 18H, 20H, 28H, 30H, ; AND 38H. THIS IS A ONE BYTE INSTRUCTION, AND IS FUNCTIONALLY ; SIMILAR TO THE THREE BYTE INSTRUCTION 'CALL XXXX'. TINY BASIC ; WILL USE THE RST INSTRUCTION FOR THE 7 MOST FREQUENTLY USED ; SUBROUTINES. TWO OTHER SUBROUTINES (CRLF & TSTNUM) ARE ALSO ; IN THIS SECTION. THEY CAN BE REACHED WITH 'CALL'. ;************************************************************* DWA MACRO WHERE DB (WHERE SHR 8) + 128 DB WHERE AND 0FFH ENDM ORG 0300H START: LD SP,STACK ;*** COLD START *** LD A,0FFH JP INIT RST08: EX (SP),HL ;*** TSTC OR RST 08H *** RST 28H ;IGNORE BLANKS AND CP (HL) ;TEST CHARACTER JP TC1 ;REST OF THIS IS AT TC1 CRLF: LD A,CR ;*** CRLF *** RST10: PUSH AF ;*** OUTC OR RST 10H *** LD A,(OCSW) ;PRINT CHARACTER ONLY OR A ;IF OCSW SWITCH IS ON JP OUTC ;REST OF THIS AT OUTC RST18: CALL EXPR2 ;*** EXPR OR RST 18H *** PUSH HL ;EVALUATE AN EXPRESSION JP EXPR1 ;REST OF IT AT EXPR1 DB 'W' RST20: LD A,H ;*** COMP OR RST 20H *** CP D ;COMPARE HL WITH DE RET NZ ;RETURN CORRECT C AND LD A,L ;Z FLAGS CP E ;BUT OLD A IS LOST RET DB 'AN' SS1: RST28: LD A,(DE) ;*** IGNBLK/RST 28H *** CP 20H ;IGNORE BLANKS RET NZ ;IN TEXT (WHERE DE->) INC DE ;AND RETURN THE FIRST JP SS1 ;NON-BLANK CHAR. IN A RST30: POP AF ;*** FINISH/RST 30H *** CALL FIN ;CHECK END OF COMMAND JP QWHAT ;PRINT "WHAT?" IF WRONG DB 'G' RST38: RST 28H ;*** TSTV OR RST 38H *** SUB 40H ;TEST VARIABLES RET C ;C:NOT A VARIABLE JR NZ,TV1 ;NOT "@" ARRAY INC DE ;IT IS THE "@" ARRAY CALL PARN ;@ SHOULD BE FOLLOWED ADD HL,HL ;BY (EXPR) AS ITS INDEX JR C,QHOW ;IS INDEX TOO BIG? PUSH DE ;WILL IT OVERWRITE EX DE,HL ;TEXT? CALL SIZE ;FIND SIZE OF FREE RST 20H ;AND CHECK THAT JP C,ASORRY ;IF SO, SAY "SORRY" LD HL,VARBGN ;IF NOT GET ADDRESS CALL SUBDE ;OF @(EXPR) AND PUT IT POP DE ;IN HL RET ;C FLAG IS CLEARED TV1: CP 1BH ;NOT @, IS IT A TO Z? CCF ;IF NOT RETURN C FLAG RET C INC DE ;IF A THROUGH Z LD HL,VARBGN ;COMPUTE ADDRESS OF RLCA ;THAT VARIABLE ADD A,L ;AND RETURN IT IN HL LD L,A ;WITH C FLAG CLEARED LD A,00H ADC A,H LD H,A RET TC1: INC HL ;COMPARE THE BYTE THAT JR Z,TC2 ;FOLLOWS THE RST INST. PUSH BC ;WITH THE TEXT (DE->) LD C,(HL) ;IF NOT =, ADD THE 2ND LD B,00H ;BYTE THAT FOLLOWS THE ADD HL,BC ;RST TO THE OLD PC POP BC ;I.E., DO A RELATIVE DEC DE ;JUMP IF NOT = TC2: INC DE ;IF =, SKIP THOSE BYTES INC HL ;AND CONTINUE EX (SP),HL RET TSTNUM: LD HL,0000H ;*** TSTNUM *** LD B,H ;TEST IF THE TEXT IS RST 28H ;A NUMBER TN1: CP 30H ;IF NOT, RETURN 0 IN RET C ;B AND HL CP 3AH ;IF NUMBERS, CONVERT RET NC ;TO BINARY IN HL AND LD A,0F0H ;SET B TO # OF DIGITS AND H ;IF H>255, THERE IS NO JR NZ,QHOW ;ROOM FOR NEXT DIGIT INC B ;B COUNTS # OF DIGITS PUSH BC LD B,H ;HL=10*HL+(NEW DIGIT) LD C,L ADD HL,HL ;WHERE 10* IS DONE BY ADD HL,HL ;SHIFT AND ADD ADD HL,BC ADD HL,HL LD A,(DE) ;AND (DIGIT) IS FROM INC DE ;STRIPPING THE ASCII AND 0FH ;CODE ADD A,L LD L,A LD A,00H ADC A,H LD H,A POP BC LD A,(DE) ;DO THIS DIGIT AFTER JP P,TN1 ;DIGIT. S SAYS OVERFLOW QHOW: PUSH DE ;*** ERROR "HOW?" *** AHOW: LD DE,HOW JP ERROR_ROUTINE HOW: DB "HOW?",CR OK: DB "OK",CR WHAT: DB "WHAT?",CR SORRY: DB "SORRY",CR ;************************************************************* ; ; *** MAIN *** ; ; THIS IS THE MAIN LOOP THAT COLLECTS THE TINY BASIC PROGRAM ; AND STORES IT IN THE MEMORY. ; ; AT START, IT PRINTS OUT "(CR)OK(CR)", AND INITIALIZES THE ; STACKB AND SOME OTHER INTERNAL VARIABLES. THEN IT PROMPTS ; ">" AND READS A LINE. IF THE LINE STARTS WITH A NON-ZERO ; NUMBER, THIS NUMBER IS THE LINE NUMBER. THE LINE NUMBER ; (IN 16 BIT BINARY) AND THE REST OF THE LINE (INCLUDING CR) ; IS STORED IN THE MEMORY. IF A LINE WITH THE SAME LINE ; NUMBER IS ALREADY THERE, IT IS REPLACED BY THE NEW ONE. IF ; THE REST OF THE LINE CONSISTS OF A CR ONLY, IT IS NOT STORED ; AND ANY EXISTING LINE WITH THE SAME LINE NUMBER IS DELETED. ; ; AFTER A LINE IS INSERTED, REPLACED, OR DELETED, THE PROGRAM ; LOOPS BACK AND ASKS FOR ANOTHER LINE. THIS LOOP WILL BE ; TERMINATED WHEN IT READS A LINE WITH ZERO OR NO LINE ; NUMBER; AND CONTROL IS TRANSFERED TO "DIRECT". ; ; TINY BASIC PROGRAM SAVE AREA STARTS AT THE MEMORY LOCATION ; LABELED "TXTBGN" AND ENDS AT "TXTEND". WE ALWAYS FILL THIS ; AREA STARTING AT "TXTBGN", THE UNFILLED PORTION IS POINTED ; BY THE CONTENT OF A MEMORY LOCATION LABELED "TXTUNF". ; ; THE MEMORY LOCATION "CURRNT" POINTS TO THE LINE NUMBER ; THAT IS CURRENTLY BEING INTERPRETED. WHILE WE ARE IN ; THIS LOOP OR WHILE WE ARE INTERPRETING A DIRECT COMMAND ; (SEE NEXT SECTION). "CURRNT" SHOULD POINT TO A 0. ;************************************************************* RSTART: LD SP,STACK ST1: CALL CRLF ;AND JUMP TO HERE LD DE,OK ;DE->STRING SUB A ;A=0 CALL PRTSTG ;PRINT STRING UNTIL CR LD HL,ST2+1 ;LITERAL 0 LD (CURRNT),HL ;CURRENT->LINE # = 0 ST2: LD HL,0000H LD (LOPVAR),HL LD (STKGOS),HL ST3: LD A,'>' ;PROMPT '>' AND CALL GETLN ;READ A LINE PUSH DE ;DE->END OF LINE LD DE,BUFFER ;DE->BEGINNING OF LINE CALL TSTNUM ;TEST IF IT IS A NUMBER RST 28H LD A,H ;HL=VALUE OF THE # OR OR L ;0 IF NO # WAS FOUND POP BC ;BC->END OF LINE JP Z,DIRECT DEC DE ;BACKUP DE AND SAVE LD A,H ;VALUE OF LINE # THERE LD (DE),A DEC DE LD A,L LD (DE),A PUSH BC ;BC,DE->BEGIN, END PUSH DE LD A,C SUB E PUSH AF ;A=# OF BYTES IN LINE CALL FNDLN ;FIND THIS LINE IN SAVE PUSH DE ;AREA, DE->SAVE AREA JR NZ,ST4 ;NZ:NOT FOUND, INSERT PUSH DE ;Z:FOUND, DELETE IT CALL FNDNXT ;FIND NEXT LINE ;DE->NEXT LINE POP BC ;BC->LINE TO BE DELETED LD HL,(TXTUNF) ;HL->UNFILLED SAVE AREA CALL MVUP ;MOVE UP TO DELETE LD H,B ;TXTUNF->UNFILLED ARA LD L,C LD (TXTUNF),HL ;UPDATE ST4: POP BC ;GET READY TO INSERT LD HL,(TXTUNF) ;BUT FIRST CHECK IF POP AF ;THE LENGTH OF NEW LINE PUSH HL ;IS 3 (LINE # AND CR) CP 03H ;THEN DO NOT INSERT JR Z,RSTART ;MUST CLEAR THE STACKB ADD A,L ;COMPUTE NEW TXTUNF LD L,A LD A,00H ADC A,H LD H,A ;HL->NEW UNFILLED AREA LD DE,TXTEND ;CHECK TO SEE IF THERE RST 20H ;IS ENOUGH SPACE JP NC,QSORRY ;SORRY, NO ROOM FOR IT LD (TXTUNF),HL ;OK, UPDATE TXTUNF POP DE ;DE->OLD UNFILLED AREA CALL MVDOWN POP DE ;DE->BEGIN, HL->END POP HL CALL MVUP ;MOVE NEW LINE TO SAVE JR ST3 ;AREA ;************************************************************* ; ; WHAT FOLLOWS IS THE CODE TO EXECUTE DIRECT AND STATEMENT ; COMMANDS. CONTROL IS TRANSFERED TO THESE POINTS VIA THE ; COMMAND TABLE LOOKUP CODE OF 'DIRECT' AND 'EXEC' IN LAST ; SECTION. AFTER THE COMMAND IS EXECUTED, CONTROL IS ; TRANSFERED TO OTHERS SECTIONS AS FOLLOWS: ; ; FOR 'LIST', 'NEW', AND 'STOP': GO BACK TO 'RSTART' ; FOR 'RUN': GO EXECUTE THE FIRST STORED LINE IF ANY, ELSE ; GO BACK TO 'RSTART'. ; FOR 'GOTO' AND 'GOSUB': GO EXECUTE THE TARGET LINE. ; FOR 'RETURN' AND 'NEXT': GO BACK TO SAVED RETURN LINE. ; FOR ALL OTHERS: IF 'CURRENT' -> 0, GO TO 'RSTART', ELSE ; GO EXECUTE NEXT COMMAND. (THIS IS DONE IN 'FINISH'.) ;************************************************************* ; ; *** NEW *** STOP *** RUN (& FRIENDS) *** & GOTO *** ; ; 'NEW(CR)' SETS 'TXTUNF' TO POINT TO 'TXTBGN' ; ; 'STOP(CR)' GOES BACK TO 'RSTART' ; ; 'RUN(CR)' FINDS THE FIRST STORED LINE, STORE ITS ADDRESS (IN ; 'CURRENT'), AND START EXECUTE IT. NOTE THAT ONLY THOSE ; COMMANDS IN TAB2 ARE LEGAL FOR STORED PROGRAM. ; ; THERE ARE 3 MORE ENTRIES IN 'RUN': ; 'RUNNXL' FINDS NEXT LINE, STORES ITS ADDR. AND EXECUTES IT. ; 'RUNTSL' STORES THE ADDRESS OF THIS LINE AND EXECUTES IT. ; 'RUNSML' CONTINUES THE EXECUTION ON SAME LINE. ; ; 'GOTO EXPR(CR)' EVALUATES THE EXPRESSION, FIND THE TARGET ; LINE, AND JUMP TO 'RUNTSL' TO DO IT. ;************************************************************* NEW: CALL ENDCHK ;*** NEW(CR) *** LD HL,TXTBGN LD (TXTUNF),HL STOP: CALL ENDCHK ;*** STOP(CR) *** JP RSTART RUN: CALL ENDCHK ;*** RUN(CR) *** LD DE,TXTBGN ;FIRST SAVED LINE RUNNXL: LD HL,00H ;*** RUNNXL *** CALL FNDLP ;FIND WHATEVER LINE # JP C,RSTART ;C:PASSED TXTUNF, QUIT RUNTSL: EX DE,HL ;*** RUNTSL *** LD (CURRNT),HL ;SET 'CURRENT'->LINE # EX DE,HL INC DE ;BUMP PASS LINE # INC DE RUNSML: CALL CHKIO ;*** RUNSML *** LD HL,TAB2-1 ;FIND COMMAND IN TAB2 JP EXEC ;AND EXECUTE IT GOTO: RST 18H ;*** GOTO EXPR *** PUSH DE ;SAVE FOR ERROR ROUTINE CALL ENDCHK ;MUST FIND A CR CALL FNDLN ;FIND THE TARGET LINE JP NZ,AHOW ;NO SUCH LINE # POP AF ;CLEAR THE PUSH DE JR RUNTSL ;GO DO IT ;************************************************************* ; ; *** LIST *** & PRINT *** ; ; LIST HAS TWO FORMS: ; 'LIST(CR)' LISTS ALL SAVED LINES ; 'LIST #(CR)' START LIST AT THIS LINE # ; YOU CAN STOP THE LISTING BY CONTROL C KEY ; ; PRINT COMMAND IS 'PRINT ....;' OR 'PRINT ....(CR)' ; WHERE '....' IS A LIST OF EXPRESIONS, FORMATS, BACK- ; ARROWS, AND STRINGS. THESE ITEMS ARE SEPERATED BY COMMAS. ; ; A FORMAT IS A POUND SIGN FOLLOWED BY A NUMBER. IT CONTROLS ; THE NUMBER OF SPACES THE VALUE OF A EXPRESION IS GOING TO ; BE PRINTED. IT STAYS EFFECTIVE FOR THE REST OF THE PRINT ; COMMAND UNLESS CHANGED BY ANOTHER FORMAT. IF NO FORMAT IS ; SPECIFIED, 6 POSITIONS WILL BE USED. ; ; A STRING IS QUOTED IN A PAIR OF SINGLE QUOTES OR A PAIR OF ; DOUBLE QUOTES. ; ; A BACK-ARROW MEANS GENERATE A (CR) WITHOUT (LF) ; ; A (CRLF) IS GENERATED AFTER THE ENTIRE LIST HAS BEEN ; PRINTED OR IF THE LIST IS A NULL LIST. HOWEVER IF THE LIST ; ENDED WITH A COMMA, NO (CRLF) IS GENERATED. ;************************************************************* LIST: CALL TSTNUM ;TEST IF THERE IS A # CALL ENDCHK ;IF NO # WE GET A 0 CALL FNDLN ;FIND THIS OR NEXT LINE LS1: JP C,RSTART ;C:PASSED TXTUNF CALL PRTLN ;PRINT THE LINE CALL CHKIO ;STOP IF HIT CONTROL-C CALL FNDLP ;FIND NEXT LINE JR LS1 ;AND LOOP BACK PRINT: LD C,06H ;C = # OF SPACES RST 08H ;F NULL LIST & ";" DB 3BH DB PR2-$-1 CALL CRLF ;GIVE CR-LF AND JR RUNSML ;CONTINUE SAME LINE PR2: RST 08H ;IF NULL LIST (CR) DB CR DB PR0-$-1 CALL CRLF ;ALSO GIVE CR-LF AND JR RUNNXL ;GO TO NEXT LINE PR0: RST 08H ;ELSE IS IT FORMAT? DB '#' DB PR1-$-1 RST 18H ;YES, EVALUATE EXPR. LD C,L ;AND SAVE IT IN C JR PR3 ;LOOK FOR MORE TO PRINT PR1: CALL QTSTG ;OR IS IT A STRING? JR PR8 ;IF NOT, MUST BE EXPR. PR3: RST 08H ;IF ",", GO FIND NEXT DB ',' DB PR6-$-1 CALL FIN ;IN THE LIST. JR PR0 ;LIST CONTINUES PR6: CALL CRLF ;LIST ENDS RST 30H PR8: RST 18H ;EVALUATE THE EXPR PUSH BC CALL PRTNUM ;PRINT THE VALUE POP BC JR PR3 ;MORE TO PRINT? ; ;************************************************************* ; ; *** GOSUB *** & RETURN *** ; ; 'GOSUB EXPR;' OR 'GOSUB EXPR (CR)' IS LIKE THE 'GOTO' ; COMMAND, EXCEPT THAT THE CURRENT TEXT POINTER, STACKB POINTER ; ETC. ARE SAVE SO THAT EXECUTION CAN BE CONTINUED AFTER THE ; SUBROUTINE 'RETURN'. IN ORDER THAT 'GOSUB' CAN BE NESTED ; (AND EVEN RECURSIVE), THE SAVE AREA MUST BE STACKBED. ; THE STACKB POINTER IS SAVED IN 'STKGOS', THE OLD 'STKGOS' IS ; SAVED IN THE STACKB. IF WE ARE IN THE MAIN ROUTINE, 'STKGOS' ; IS ZERO (THIS WAS DONE BY THE "MAIN" SECTION OF THE CODE), ; BUT WE STILL SAVE IT AS A FLAG FOR NO FURTHER 'RETURN'S. ; ; 'RETURN(CR)' UNDOS EVERYTHING THAT 'GOSUB' DID, AND THUS ; RETURN THE EXECUTION TO THE COMMAND AFTER THE MOST RECENT ; 'GOSUB'. IF 'STKGOS' IS ZERO, IT INDICATES THAT WE ; NEVER HAD A 'GOSUB' AND IS THUS AN ERROR. ;************************************************************* GOSUB: CALL PUSHA ;SAVE THE CURRENT "FOR" RST 18H ;PARAMETERS PUSH DE ;AND TEXT POINTER CALL FNDLN ;FIND THE TARGET LINE JP NZ,AHOW ;NOT THERE. SAY "HOW?" LD HL,(CURRNT) ;FOUND IT, SAVE OLD. PUSH HL ;'CURRNT' OLD 'STKGOS' LD HL,(STKGOS) PUSH HL LD HL,0000H ;AND LOAD NEW ONES LD (LOPVAR),HL ADD HL,SP LD (STKGOS),HL JP RUNTSL ;THEN RUN THAT LINE RETURN: CALL ENDCHK ;THERE MUST BE A CR LD HL,(STKGOS) ;OLD STACKB POINTER LD A,H ;0 MEANS NOT EXIST OR L JP Z,QWHAT ;SO, WE SAY: "WHAT?" LD SP,HL ;ELSE, RESTORE IT POP HL LD (STKGOS),HL ;AND THE OLD "STKGOS" POP HL LD (CURRNT),HL ;AND THE OLD 'CURRNT' POP DE ;OLD TEXT POINTER CALL POPA ;OLD "FOR" PARAMETERS RST 30H ;AND WE ARE BACK HOME ;************************************************************* ; ; *** FOR *** & NEXT *** ; ; 'FOR' HAS TWO FORMS: ; 'FOR VAR=EXP1 TO EXP2 STEP EXP3' AND 'FOR VAR=EXP1 TO EXP2' ; THE SECOND FORM MEANS THE SAME THING AS THE FIRST FORM WITH ; EXP3=1. (I.E., WITH A STEP OF +1.) ; TBI WILL FIND THE VARIABLE VAR, AND SET ITS VALUE TO THE ; CURRENT VALUE OF EXP1. IT ALSO EVALUATES EXP2 AND EXP3 ; AND SAVE ALL THESE TOGETHER WITH THE TEXT POINTER ETC. IN ; THE 'FOR' SAVE AREA, WHICH CONSISTS OF 'LOPVAR', 'LOPINC', ; 'LOPLMT', 'LOPLN', AND 'LOPPT'. IF THERE IS ALREADY SOME- ; THING IN THE SAVE AREA (THIS IS INDICATED BY A NON-ZERO ; 'LOPVAR'), THEN THE OLD SAVE AREA IS SAVED IN THE STACKB ; BEFORE THE NEW ONE OVERWRITES IT. ; TBI WILL THEN DIG IN THE STACKB AND FIND OUT IF THIS SAME ; VARIABLE WAS USED IN ANOTHER CURRENTLY ACTIVE 'FOR' LOOP. ; IF THAT IS THE CASE, THEN THE OLD 'FOR' LOOP IS DEACTIVATED. ; (PURGED FROM THE STACKB..) ; ; 'NEXT VAR' SERVES AS THE LOGICAL (NOT NECESSARILLY PHYSICAL) ; END OF THE 'FOR' LOOP. THE CONTROL VARIABLE VAR. IS CHECKED ; WITH THE 'LOPVAR'. IF THEY ARE NOT THE SAME, TBI DIGS IN ; THE STACKB TO FIND THE RIGHT ONE AND PURGES ALL THOSE THAT ; DID NOT MATCH. EITHER WAY, TBI THEN ADDS THE 'STEP' TO ; THAT VARIABLE AND CHECK THE RESULT WITH THE LIMIT. IF IT ; IS WITHIN THE LIMIT, CONTROL LOOPS BACK TO THE COMMAND ; FOLLOWING THE 'FOR'. IF OUTSIDE THE LIMIT, THE SAVE AREA ; IS PURGED AND EXECUTION CONTINUES. ;************************************************************* FOR: CALL PUSHA ;SAVE THE OLD SAVE AREA CALL SETVAL ;SET THE CONTROL VAR. DEC HL ;HL IS ITS ADDRESS LD (LOPVAR),HL ;SAVE THAT LD HL,TAB5-1 ;USE 'EXEC' TO LOOK JP EXEC ;FOR THE WORK 'TO' FR1: RST 18H ;EVALUATE THE LIMITE LD (LOPLMT),HL ;SAVE THAT LD HL,TAB6-1 ;USE 'EXEC' TO LOOK JP EXEC ;FOR THE WORD 'STEP' FR2: RST 18H ;FOUND IT, GET STEP JR FR4 FR3: LD HL,0001H ;NOT FOUND, SET TO 1 FR4: LD (LOPINC),HL ;SAVE THAT TOO FR5: LD HL,(CURRNT) ;SAVE CURRENT LINE # LD (LOPLN),HL EX DE,HL ;AND TEXT POINTER LD (LOPPT),HL LD BC,0AH ;DIG INTO STACKB TO LD HL,(LOPVAR) ;FIND 'LOPVAR' EX DE,HL LD H,B LD L,B ;HL=0 NOW ADD HL,SP ;HERE IS THE STACKB DB 3EH ;DISASSEMBLY SAID "ld a,09h" FR7: ADD HL,BC ;EACH LEVEL IS 10 DEEP - DIS = 09 LD A,(HL) ;GET THAT OLD 'LOPVAR' INC HL OR (HL) JR Z,FR8 ;0 SAYS NO MORE IN IT LD A,(HL) DEC HL CP D ;SAME AS THIS ONE? JR NZ,FR7 LD A,(HL) ;THE OTHER HALF? CP E JR NZ,FR7 EX DE,HL ;YES, FOUND ONE LD HL,0000H ADD HL,SP ;TRY TO MOVE SP LD B,H LD C,L LD HL,000AH ADD HL,DE CALL MVDOWN ;AND PURGE 10 WORDS LD SP,HL ;IN THE STACKB FR8: LD HL,(LOPPT) ;JOB DONE, RESTORE DE EX DE,HL RST 30H ;AND CONTINUE ; NEXT: RST 38H ;GET ADDRESS OF VAR. JP C,QWHAT ;NO VARIABLE, "WHAT?" LD (VARNXT),HL ;YES, SAVE IT NX0: PUSH DE ;SAVE TEXT POINTER EX DE,HL LD HL,(LOPVAR) ;GET VAR. IN 'FOR' LD A,H OR L ;0 SAYS NEVER HAD ONE JP Z,AWHAT ;SO WE ASK: "WHAT?" RST 20H ;ELSE WE CHECK THEM JR Z,NX3 ;OK, THEY AGREE POP DE ;NO, LET'S SEE CALL POPA ;PURGE CURRENT LOOP LD HL,(VARNXT) ;AND POP ONE LEVEL JR NX0 ;GO CHECK AGAIN NX3: LD E,(HL) ;COME HERE WHEN AGREED INC HL LD D,(HL) ;DE=VALUE OF VAR. LD HL,(LOPINC) PUSH HL LD A,H XOR D LD A,D ADD HL,DE ;ADD ONE STEP JP M,NX4 XOR H JP M,NX5 NX4: EX DE,HL LD HL,(LOPVAR) ;PUT IT BACK LD (HL),E INC HL LD (HL),D LD HL,(LOPLMT) ;HL->LIMIT POP AF ;OLD HL OR A JP P,NX1 ;STEP > 0 EX DE,HL ;STEP < 0 NX1: CALL CKHLDE ;COMPARE WITH LIMIT POP DE ;RESTORE TEXT POINTER JR C,NX2 ;OUTSIDE LIMIT LD HL,(LOPLN) ;WITHIN LIMIT, GO LD (CURRNT),HL ;BACK TO THE SAVED LD HL,(LOPPT) ;'CURRNT' AND TEXT EX DE,HL ;POINTER RST 30H NX5: POP HL POP DE NX2: CALL POPA ;PURGE THIS LOOP RST 30H ; ;************************************************************* ; ; *** REM *** IF *** INPUT *** & LET (& DEFLT) *** ; ; 'REM' CAN BE FOLLOWED BY ANYTHING AND IS IGNORED BY TBI. ; TBI TREATS IT LIKE AN 'IF' WITH A FALSE CONDITION. ; ; 'IF' IS FOLLOWED BY AN EXPR. AS A CONDITION AND ONE OR MORE ; COMMANDS (INCLUDING OTHER 'IF'S) SEPERATED BY SEMI-COLONS. ; NOTE THAT THE WORD 'THEN' IS NOT USED. TBI EVALUATES THE ; EXPR. IF IT IS NON-ZERO, EXECUTION CONTINUES. IF THE ; EXPR. IS ZERO, THE COMMANDS THAT FOLLOWS ARE IGNORED AND ; EXECUTION CONTINUES AT THE NEXT LINE. ; ; 'INPUT' COMMAND IS LIKE THE 'PRINT' COMMAND, AND IS FOLLOWED ; BY A LIST OF ITEMS. IF THE ITEM IS A STRING IN SINGLE OR ; DOUBLE QUOTES, OR IS A BACK-ARROW, IT HAS THE SAME EFFECT AS ; IN 'PRINT'. IF AN ITEM IS A VARIABLE, THIS VARIABLE NAME IS ; PRINTED OUT FOLLOWED BY A COLON. THEN TBI WAITS FOR AN ; EXPR. TO BE TYPED IN. THE VARIABLE IS THEN SET TO THE ; VALUE OF THIS EXPR. IF THE VARIABLE IS PROCEDED BY A STRING ; (AGAIN IN SINGLE OR DOUBLE QUOTES), THE STRING WILL BE ; PRINTED FOLLOWED BY A COLON. TBI THEN WAITS FOR INPUT EXPR. ; AND SET THE VARIABLE TO THE VALUE OF THE EXPR. ; ; IF THE INPUT EXPR. IS INVALID, TBI WILL PRINT "WHAT?", ; "HOW?" OR "SORRY" AND REPRINT THE PROMPT AND REDO THE INPUT. ; THE EXECUTION WILL NOT TERMINATE UNLESS YOU TYPE CONTROL-C. ; THIS IS HANDLED IN 'INPERR'. ; ; 'LET' IS FOLLOWED BY A LIST OF ITEMS SEPERATED BY COMMAS. ; EACH ITEM CONSISTS OF A VARIABLE, AN EQUAL SIGN, AND AN EXPR. ; TBI EVALUATES THE EXPR. AND SET THE VARIABLE TO THAT VALUE. ; TBI WILL ALSO HANDLE 'LET' COMMAND WITHOUT THE WORD 'LET'. ; THIS IS DONE BY 'DEFLT'. ;************************************************************* REM: LD HL,0000H ;*** REM *** DB 3EH ;THIS IS LIKE 'IF 0' IFF: RST 18H ;*** IF *** LD A,H ;IS THE EXPR.=0? OR L JP NZ,RUNSML ;NO, CONTINUE CALL FNDSKP ;YES, SKIP REST OF LINE JP NC,RUNTSL ;AND RUN THE NEXT LINE JP RSTART ;IF NO NEXT, RE-START INPERR: LD HL,(STKINP) ;*** INPERR *** LD SP,HL ;RESTORE OLD SP POP HL ;AND OLD 'CURRNT' LD (CURRNT),HL POP DE ;AND OLD TEXT POINTER POP DE ;REDO INPUT INPUT: ;*** INPUT *** IP1: PUSH DE ;SAVE IN CASE OF ERROR CALL QTSTG ;IS NEXT ITEM A STRING? JR IP2 ;NO RST 38H ;YES, BUT FOLLOWED BY A JR C,IP4 ;VARIABLE? NO. JR IP3 ;YES. INPUT VARIABLE IP2: PUSH DE ;SAVE FOR 'PRTSTG' RST 38H ;MUST BE VARIABLE NOW JP C,QWHAT ;"WHAT?" IT IS NOT? LD A,(DE) ;GET READY FOR 'PRTSTR' LD C,A SUB A LD (DE),A POP DE CALL PRTSTG ;PRINT STRING AS PROMPT LD A,C ;RESTORE TEXT DEC DE LD (DE),A IP3: PUSH DE ;SAVE TEXT POINTER EX DE,HL LD HL,(CURRNT) ;ALSO SAVE 'CURRNT' PUSH HL LD HL,IP1 ;A NEGATIVE NUMBER LD (CURRNT),HL ;AS A FLAG LD HL,0000H ;SAVE SP TOO ADD HL,SP LD (STKINP),HL PUSH DE ;OLD HL LD A,3AH ;PRINT THIS TOO CALL GETLN ;AND GET A LINE LD DE,BUFFER ;POINTS TO BUFFER RST 18H ;EVALUATE INPUT NOP ;CAN BE 'CALL ENDCHK' NOP NOP POP DE ;OK,GET OLD HL EX DE,HL LD (HL),E ;SAVE VALUE IN VAR. INC HL LD (HL),D POP HL ;GET OLD 'CURRNT' LD (CURRNT),HL POP DE ;AND OLD TEXT POINTER IP4: POP AF ;PURGE JUNK IN STACKB RST 08H ;IS NEXT CH. ','? DB ',' DB IP5-$-1 JR IP1 ;YES, MORE ITEMS. IP5: RST 30H DEFLT: LD A,(DE) ;*** DEFLT *** CP CR ;EMPTY LINE IS OK JR Z,LT1 ;ELSE IT IS 'LET' LET: CALL SETVAL ;*** LET *** RST 08H ;SET VALUE TO VAR DB ',' ;---DISASSEMBLE = INC L DB LT1-$-1 ;---DISASSEMBLE = INC BC JR LET ;ITEM BY ITEM LT1: RST 30H ;UNTIL FINISH ;************************************************************* ; ; *** EXPR *** ; ; 'EXPR' EVALUATES ARITHMETICAL OR LOGICAL EXPRESSIONS. ; <EXPR>::<EXPR2> ; <EXPR2><REL.OP.><EXPR2> ; WHERE <REL.OP.> IS ONE OF THE OPERATORS IN TAB8 AND THE ; RESULT OF THESE OPERATIONS IS 1 IF TRUE AND 0 IF FALSE. ; <EXPR2>::=(+ OR -)<EXPR3>(+ OR -<EXPR3>)(....) ; WHERE () ARE OPTIONAL AND (....) ARE OPTIONAL REPEATS. ; <EXPR3>::=<EXPR4>(* OR /><EXPR4>)(....) ; <EXPR4>::=<VARIABLE> ; <FUNCTION> ; (<EXPR>) ; <EXPR> IS RECURSIVE SO THAT VARIABLE '@' CAN HAVE AN <EXPR> ; AS INDEX, FUNCTIONS CAN HAVE AN <EXPR> AS ARGUMENTS, AND ; <EXPR4> CAN BE AN <EXPR> IN PARANTHESE. ;************************************************************* EXPR1: LD HL,TAB8-1 ;LOOKUP REL.OP. JP EXEC ;GO DO IT XP11: CALL XP18 ;REL.OP.">=" RET C ;NO, RETURN HL=0 LD L,A ;YES, RETURN HL=1 RET XP12: CALL XP18 ;REL.OP."#" RET Z ;FALSE, RETURN HL=0 LD L,A ;TRUE, RETURN HL=1 RET XP13: CALL XP18 ;REL.OP.">" RET Z ;FALSE RET C ;ALSO FALSE, HL=0 LD L,A ;TRUE, HL=1 RET XP14: CALL XP18 ;REL.OP."<=" LD L,A ;SET HL=1 RET Z ;REL. TRUE, RETURN RET C LD L,H ;ELSE SET HL=0 RET XP15: CALL XP18 ;REL.OP."=" RET NZ ;FALSE, RETURN HL=0 LD L,A ;ELSE SET HL=1 RET XP16: CALL XP18 ;REL.OP."<" RET NC ;FALSE, RETURN HL=0 LD L,A ;ELSE SET HL=1 RET XP17: POP HL ;NOT .REL.OP RET ;RETURN HL=<EXPR2> XP18: LD A,C ;SUBROUTINE FOR ALL POP HL ;REL.OP.'S POP BC PUSH HL ;REVERSE TOP OF STACKB PUSH BC LD C,A CALL EXPR2 ;GET 2ND <EXPR2> EX DE,HL ;VALUE IN DE NOW EX (SP),HL ;1ST <EXPR2> IN HL CALL CKHLDE ;COMPARE 1ST WITH 2ND POP DE ;RESTORE TEXT POINTER LD HL,0000H ;SET HL=0, A=1 LD A,01H RET EXPR2: RST 08H ;NEGATIVE SIGN? DB '-' DB XP21-$-1 LD HL,0000H ;YES, FAKE '0-' JR XP26 ;TREAT LIKE SUBTRACT XP21: RST 08H ;POSITIVE SIGN? IGNORE DB '+' DB XP22-$-1 XP22: CALL EXPR3 ;1ST <EXPR3> XP23: RST 08H ;ADD? DB '+' DB XP25-$-1 PUSH HL ;YES, SAVE VALUE CALL EXPR3 ;GET 2ND <EXPR3> XP24: EX DE,HL ;2ND IN DE EX (SP),HL ;1ST IN HL LD A,H ;COMPARE SIGN XOR D LD A,D ADD HL,DE POP DE ;RESTORE TEXT POINTER JP M,XP23 ;1ST AND 2ND SIGN DIFFER XOR H ;1ST AND 2ND SIGN EQUAL JP P,XP23 ;SO IS RESULT JP QHOW ;ELSE WE HAVE OVERFLOW XP25: RST 08H ;SUBTRACT? DB '-' DB XP42-$-1 XP26: PUSH HL ;YES, SAVE 1ST <EXPR3> CALL EXPR3 ;GET 2ND <EXPR3> CALL CHGSGN ;NEGATE JR XP24 ;AND ADD THEM ; EXPR3: CALL EXPR4 ;GET 1ST <EXPR4> XP31: RST 08H ;MULTIPLY? DB '*' DB XP34-$-1 PUSH HL ;YES, SAVE 1ST CALL EXPR4 ;AND GET 2ND <EXPR4> LD B,00H ;CLEAR B FOR SIGN CALL CHKSGN ;CHECK SIGN EX (SP),HL ;1ST IN HL CALL CHKSGN ;CHECK SIGN OF 1ST EX DE,HL EX (SP),HL LD A,H ;IS HL > 255 ? OR A JR Z,XP32 ;NO LD A,D ;YES, HOW ABOUT DE OR D EX DE,HL ;PUT SMALLER IN HL JP NZ,AHOW ;ALSO >, WILL OVERFLOW XP32: LD A,L ;THIS IS DUMB LD HL,0000H ;CLEAR RESULT OR A ;ADD AND COUNT JR Z,XP35 XP33: ADD HL,DE JP C,AHOW ;OVERFLOW DEC A JR NZ,XP33 JR XP35 ;FINISHED XP34: RST 08H ;DIVIDE? DB '/' DB XP42-$-1 PUSH HL ;YES, SAVE 1ST <EXPR4> CALL EXPR4 ;AND GET THE SECOND ONE LD B,00H ;CLEAR B FOR SIGN CALL CHKSGN ;CHECK SIGN OF 2ND EX (SP),HL ;GET 1ST IN HL CALL CHKSGN ;CHECK SIGN OF 1ST EX DE,HL EX (SP),HL EX DE,HL LD A,D ;DIVIDE BY 0? OR E JP Z,AHOW ;SAY "HOW?" PUSH BC ;ELSE SAVE SIGN CALL DIVIDE ;USE SUBROUTINE LD H,B ;RESULT IN HL NOW LD L,C POP BC ;GET SIGN BACK XP35: POP DE ;AND TEXT POINTER LD A,H ;HL MUST BE + OR A JP M,QHOW ;ELSE IT IS OVERFLOW LD A,B OR A CALL M,CHGSGN ;CHANGE SIGN IF NEEDED JR XP31 ;LOOK FOR MORE TERMS EXPR4: LD HL,TAB4-1 ;FIND FUNCTION IN TAB4 JP EXEC ;AND GO DO IT XP40: RST 38H ;NO, NOT A FUNCTION JR C,XP41 ;NOR A VARIABLE LD A,(HL) ;VARIABLE INC HL LD H,(HL) ;VALUE IN HL LD L,A RET XP41: CALL TSTNUM ;OR IS IT A NUMBER LD A,B ;# OF DIGIT OR A RET NZ ;OK PARN: RST 08H DB '(' DB XP43-$-1 RST 18H ;"(EXPR)" RST 08H DB ')' DB XP43-$-1 XP42: RET XP43: JP QWHAT ;ELSE SAY: "WHAT?" RND: CALL PARN ;*** RND(EXPR) *** LD A,H ;EXPR MUST BE + OR A JP M,QHOW OR L ;AND NON-ZERO JP Z,QHOW PUSH DE ;SAVE BOTH PUSH HL LD HL,(RANPNT) ;GET MEMORY AS RANDOM LD DE,LSTROM ;NUMBER RST 20H JR C,RA1 ;WRAP AROUND IF LAST LD HL,START RA1: LD E,(HL) INC HL LD D,(HL) LD (RANPNT),HL POP HL EX DE,HL PUSH BC CALL DIVIDE ;RND (N)=MOD(M,N)+1 POP BC POP DE INC HL RET ABS: CALL PARN ;*** ABS (EXPR) *** DEC DE CALL CHKSGN ;CHECK SIGN INC DE RET SIZE: LD HL,(TXTUNF) ;*** SIZE *** PUSH DE ;GET THE NUMBER OF FREE EX DE,HL ;BYTES BETWEEN 'TXTUNF' LD HL,VARBGN ;AND 'VARBGN' CALL SUBDE POP DE RET ;************************************************************* ; ; *** DIVIDE *** SUBDE *** CHKSGN *** CHGSGN *** & CKHLDE *** ; ; 'DIVIDE' DIVIDES HL BY DE, RESULT IN BC, REMAINDER IN HL ; ; 'SUBDE' SUBSTRACTS DE FROM HL ; ; 'CHKSGN' CHECKS SIGN OF HL. IF +, NO CHANGE. IF -, CHANGE ; SIGN AND FLIP SIGN OF B. ; ; 'CHGSGN' CHECKS SIGN N OF HL AND B UNCONDITIONALLY. ; ; 'CKHLDE' CHECKS SIGN OF HL AND DE. IF DIFFERENT, HL AND DE ; ARE INTERCHANGED. IF SAME SIGN, NOT INTERCHANGED. EITHER ; CASE, HL DE ARE THEN COMPARED TO SET THE FLAGS. ;************************************************************* DIVIDE: PUSH HL ;*** DIVIDE *** LD L,H ;DIVIDE H BY DE LD H,00H CALL DV1 LD B,C ;SAVE RESULT IN B LD A,L ;(REMAINDER+L)/DE POP HL LD H,A DV1: LD C,0FFH ;RESULT IN C DV2: INC C ;DUMB ROUTINE CALL SUBDE ;DIVIDE BY SUBTRACT JR NC,DV2 ;AND COUNT ADD HL,DE RET SUBDE: LD A,L ;*** SUBDE *** SUB E ;SUBSTRACT DE FROM LD L,A ;HL LD A,H SBC A,D LD H,A RET CHKSGN: LD A,H ;*** CHKSGN *** OR A ;CHECK SIGN OF HL RET P CHGSGN: LD A,H ;*** CHGSGN *** PUSH AF CPL ;CHANGE SIGN OF HL LD H,A LD A,L CPL LD L,A INC HL POP AF XOR H JP P,QHOW LD A,B ;AND ALSO FLIP B XOR 80H LD B,A RET CKHLDE: LD A,H ;SAME SIGN? XOR D ;YES, COMPARE JP P,CK1 ;NO, XCHANGE AND COMP EX DE,HL CK1: RST 20H RET ;************************************************************* ; ; *** SETVAL *** FIN *** ENDCHK *** & ERROR (& FRIENDS) *** ; ; "SETVAL" EXPECTS A VARIABLE, FOLLOWED BY AN EQUAL SIGN AND ; THEN AN EXPR. IT EVALUATES THE EXPR. AND SET THE VARIABLE ; TO THAT VALUE. ; ; "FIN" CHECKS THE END OF A COMMAND. IF IT ENDED WITH ";", ; EXECUTION CONTINUES. IF IT ENDED WITH A CR, IT FINDS THE ; NEXT LINE AND CONTINUE FROM THERE. ; ; "ENDCHK" CHECKS IF A COMMAND IS ENDED WITH CR. THIS IS ; REQUIRED IN CERTAIN COMMANDS. (GOTO, RETURN, AND STOP ETC.) ; ; "ERROR" PRINTS THE STRING POINTED BY DE (AND ENDS WITH CR). ; IT THEN PRINTS THE LINE POINTED BY 'CURRNT' WITH A "?" ; INSERTED AT WHERE THE OLD TEXT POINTER (SHOULD BE ON TOP ; OF THE STACKB) POINTS TO. EXECUTION OF TB IS STOPPED ; AND TBI IS RESTARTED. HOWEVER, IF 'CURRNT' -> ZERO ; (INDICATING A DIRECT COMMAND), THE DIRECT COMMAND IS NOT ; PRINTED. AND IF 'CURRNT' -> NEGATIVE # (INDICATING 'INPUT' ; COMMAND), THE INPUT LINE IS NOT PRINTED AND EXECUTION IS ; NOT TERMINATED BUT CONTINUED AT 'INPERR'. ; ; RELATED TO 'ERROR' ARE THE FOLLOWING: ; 'QWHAT' SAVES TEXT POINTER IN STACKB AND GET MESSAGE "WHAT?" ; 'AWHAT' JUST GET MESSAGE "WHAT?" AND JUMP TO 'ERROR'. ; 'QSORRY' AND 'ASORRY' DO SAME KIND OF THING. ; 'AHOW' AND 'AHOW' IN THE ZERO PAGE SECTION ALSO DO THIS. ;************************************************************* SETVAL: RST 38H ;*** SETVAL *** JP C,QWHAT ;"WHAT?" NO VARIABLE PUSH HL ;SAVE ADDRESS OF VAR. RST 08H ;PASS "=" SIGN DB '=' DB SV1-$-1 RST 18H ;EVALUATE EXPR. LD B,H ;VALUE IS IN BC NOW LD C,L POP HL ;GET ADDRESS LD (HL),C ;SAVE VALUE INC HL LD (HL),B RET SV1: JP QWHAT ;NO "=" SIGN FIN: RST 08H ;*** FIN *** DB 3BH DB FI1-$-1 POP AF ;";", PURGE RET. ADDR. JP RUNSML ;CONTINUE SAME LINE FI1: RST 08H ;NOT ";", IS IT CR? DB CR DB FI2-$-1 POP AF ;YES, PURGE RET. ADDR. JP RUNNXL ;RUN NEXT LINE FI2: RET ;ELSE RETURN TO CALLER ENDCHK: RST 28H ;*** ENDCHK *** CP CR ;END WITH CR? RET Z ;OK, ELSE SAY: "WHAT?" QWHAT: PUSH DE ;*** QWHAT *** AWHAT: LD DE,WHAT ;*** AWHAT *** ERROR_ROUTINE: SUB A ;*** ERROR *** CALL PRTSTG ;PRINT 'WHAT?', 'HOW?' POP DE ;OR 'SORRY' LD A,(DE) ;SAVE THE CHARACTER PUSH AF ;AT WHERE OLD DE -> SUB A ;AND PUT A 0 THERE LD (DE),A LD HL,(CURRNT) ;GET CURRENT LINE # PUSH HL LD A,(HL) ;CHECK THE VALUE INC HL OR (HL) POP DE JP Z,RSTART ;IF ZERO, JUST RESTART LD A,(HL) ;IF NEGATIVE, OR A JP M,INPERR ;REDO INPUT CALL PRTLN ;ELSE PRINT THE LINE DEC DE ;UPTO WHERE THE 0 IS POP AF ;RESTORE THE CHARACTER LD (DE),A LD A,3FH ;PRINT A "?" RST 10H SUB A ;AND THE REST OF THE CALL PRTSTG ;LINE JP RSTART ;THEN RESTART QSORRY: PUSH DE ;*** QSORRY *** ASORRY: LD DE,SORRY ;*** ASORRY *** JR ERROR_ROUTINE ;************************************************************* ; ; *** GETLN *** FNDLN (& FRIENDS) *** ; ; 'GETLN' READS A INPUT LINE INTO 'BUFFER'. IT FIRST PROMPT ; THE CHARACTER IN A (GIVEN BY THE CALLER), THEN IT FILLS ; THE BUFFER AND ECHOS. IT IGNORES LF'S AND NULLS, BUT STILL ; ECHOS THEM BACK. RUB-OUT IS USED TO CAUSE IT TO DELETE ; THE LAST CHARACTER (IF THERE IS ONE), AND ALT-MOD IS USED TO ; CAUSE IT TO DELETE THE WHOLE LINE AND START IT ALL OVER. ; CR SIGNALS THE END OF A LINE, AND CAUSE 'GETLN' TO RETURN. ; ; 'FNDLN' FINDS A LINE WITH A GIVEN LINE # (IN HL) IN THE ; TEXT SAVE AREA. DE IS USED AS THE TEXT POINTER. IF THE ; LINE IS FOUND, DE WILL POINT TO THE BEGINNING OF THAT LINE ; (I.E., THE LOW BYTE OF THE LINE #), AND FLAGS ARE NC & Z. ; IF THAT LINE IS NOT THERE AND A LINE WITH A HIGHER LINE # ; IS FOUND, DE POINTS TO THERE AND FLAGS ARE NC & NZ. IF ; WE REACHED THE END OF TEXT SAVE AREA AND CANNOT FIND THE ; LINE, FLAGS ARE C & NZ. ; 'FNDLN' WILL INITIALIZE DE TO THE BEGINNING OF THE TEXT SAVE ; AREA TO START THE SEARCH. SOME OTHER ENTRIES OF THIS ; ROUTINE WILL NOT INITIALIZE DE AND DO THE SEARCH. ; 'FNDLNP' WILL START WITH DE AND SEARCH FOR THE LINE #. ; 'FNDNXT' WILL BUMP DE BY 2, FIND A CR AND THEN START SEARCH. ; 'FNDSKP' USE DE TO FIND A CR, AND THEN START SEARCH. ;************************************************************* GETLN: RST 10H ;*** GETLN *** LD DE,BUFFER ;PROMPT AND INIT. GL1: CALL CHKIO ;CHECK KEYBOARD JR Z,GL1 ;NO INPUT, WAIT CP 7FH ;DELETE LAST CHARACTER? JR Z,GL3 ;YES RST 10H ;INPUT, ECHO BACK CP 0AH ;IGNORE LF JR Z,GL1 OR A ;IGNORE NULL JR Z,GL1 CP 7DH ;DELETE THE WHOLE LINE? JR Z,GL4 ;YES LD (DE),A ;ELSE SAVE INPUT INC DE ;AND BUMP POINTER CP 0DH ;WAS IT CR RET Z ;YES, END OF LINE LD A,E ;ELSE MORE FREE ROOM? CP BUFEND AND 0FFH JR NZ,GL1 ;YES, GET NEXT INPUT GL3: LD A,E ;DELETE LAST CHARACTER CP BUFFER AND 0FFH ;BUT DO WE HAVE ANY? JR Z,GL4 ;NO, REDO WHOLE LINE DEC DE ;YES, BACKUP POINTER LD A,5CH ;AND ECHO A BACK-SLASH RST 10H JR GL1 ;GO GET NEXT INPUT GL4: CALL CRLF ;REDO ENTIRE LINE LD A,05EH ;CR, LF AND UP-ARROW JR GETLN FNDLN: LD A,H ;*** FNDLN *** OR A ;CHECK SIGN OF HL JP M,QHOW ;IT CANNOT BE - LD DE,TXTBGN ;INIT TEXT POINTER FNDLP: ;*** FDLNP *** FL1: PUSH HL ;SAVE LINE # LD HL,(TXTUNF) ;CHECK IF WE PASSED END DEC HL RST 20H POP HL ;GET LINE # BACK RET C ;C,NZ PASSED END LD A,(DE) ;WE DID NOT, GET BYTE 1 SUB L ;IS THIS THE LINE? LD B,A ;COMPARE LOW ORDER INC DE LD A,(DE) ;GET BYTE 2 SBC A,H ;COMPARE HIGH ORDER JR C,FL2 ;NO, NOT THERE YET DEC DE ;ELSE WE EITHER FOUND OR B ;IT, OR IT IS NOT THERE RET ;NC,Z;FOUND, NC,NZ:NO FNDNXT: ;*** FNDNXT *** INC DE ;FIND NEXT LINE FL2: INC DE ;JUST PASSED BYTE 1 & 2 FNDSKP: LD A,(DE) ;*** FNDSKP *** CP CR ;TRY TO FIND CR JR NZ,FL2 ;KEEP LOOKING INC DE ;FOUND CR, SKIP OVER JR FL1 ;CHECK IF END OF TEXT ;************************************************************* ; ; *** PRTSTG *** QTSTG *** PRTNUM *** & PRTLN *** ; ; 'PRTSTG' PRINTS A STRING POINTED BY DE. IT STOPS PRINTING ; AND RETURNS TO CALLER WHEN EITHER A CR IS PRINTED OR WHEN ; THE NEXT BYTE IS THE SAME AS WHAT WAS IN A (GIVEN BY THE ; CALLER). OLD A IS STORED IN B, OLD B IS LOST. ; ; 'QTSTG' LOOKS FOR A BACK-ARROW, SINGLE QUOTE, OR DOUBLE ; QUOTE. IF NONE OF THESE, RETURN TO CALLER. IF BACK-ARROW, ; OUTPUT A CR WITHOUT A LF. IF SINGLE OR DOUBLE QUOTE, PRINT ; THE STRING IN THE QUOTE AND DEMANDS A MATCHING UNQUOTE. ; AFTER THE PRINTING THE NEXT 3 BYTES OF THE CALLER IS SKIPPED ; OVER (USUALLY A JUMP INSTRUCTION. ; ; 'PRTNUM' PRINTS THE NUMBER IN HL. LEADING BLANKS ARE ADDED ; IF NEEDED TO PAD THE NUMBER OF SPACES TO THE NUMBER IN C. ; HOWEVER, IF THE NUMBER OF DIGITS IS LARGER THAN THE # IN ; C, ALL DIGITS ARE PRINTED ANYWAY. NEGATIVE SIGN IS ALSO ; PRINTED AND COUNTED IN, POSITIVE SIGN IS NOT. ; ; 'PRTLN' PRINTS A SAVED TEXT LINE WITH LINE # AND ALL. ;************************************************************* PRTSTG: LD B,A ;*** PRTSTG *** PS1: LD A,(DE) ;GET A CHARACTER INC DE ;BUMP POINTER CP B ;SAME AS OLD A? RET Z ;YES, RETURN RST 10H ;NO, NEXT CP CR ;WAS IT A CR? JR NZ,PS1 ;NO, NEXT RET ;YES, RETURN QTSTG: RST 08H ;*** QTSTG *** DB '"' DB QT3-$-1 LD A,22H ;IT IS A " QT1: CALL PRTSTG ;PRINT UNTIL ANOTHER CP CR ;WAS LAST ONE A CR? POP HL ;RETURN ADDRESS JP Z,RUNNXL ;WAS CR, RUN NEXT LINE QT2: INC HL ;SKIP 3 BYTES ON RETURN INC HL ;INC HL ;skip due to relative jumps ;suggested by Nick Brok: Fixed JP (HL) ;RETURN QT3: RST 08H ;IS IT A '? DB 27H DB QT4-$-1 LD A,27H ;YES, DO THE SAME JR QT1 ;AS IN " QT4: RST 08H ;IS IT BACK-ARROW? DB 5FH DB QT5-$-1 LD A,8DH ;YES, CR WITHOUT LF RST 10H ;DO IT TWICE TO GIVE RST 10H ;TTY ENOUGH TIME POP HL ;RETURN ADDRESS JR QT2 QT5: RET ;NONE OF ABOVE ; PRTNUM: LD B,00H ;*** PRTNUM *** CALL CHKSGN ;CHECK SIGN JP P,PN1 ;NO SIGN LD B,'-' ;B=SIGN DEC C ;'-' TAKES SPACE PN1: PUSH DE ;SAVE LD DE,000AH ;DECIMAL PUSH DE ;SAVE AS FLAG DEC C ;C=SPACES PUSH BC ;SAVE SIGN & SPACE PN2: CALL DIVIDE ;DIVIDE HL BY 10 LD A,B ;RESULT 0? OR C JR Z,PN3 ;YES, WE GOT ALL EX (SP),HL ;NO, SAVE REMAINDER DEC L ;AND COUNT SPACE PUSH HL ;HL IS OLD BC LD H,B ;MOVE RESULT TO BC LD L,C JR PN2 ;AND DIVIDE BY 10 PN3: POP BC ;WE GOT ALL DIGITS IN PN4: DEC C ;THE STACKB LD A,C ;LOOK AT SPACE COUNT OR A JP M,PN5 ;NO LEADING BLANKS LD A,20H ;LEADING BLANKS RST 10H JR PN4 ;MORE? PN5: LD A,B ;PRINT SIGN OR A CALL NZ,0010H LD E,L ;LAST REMAINDER IN E PN6: LD A,E ;CHECK DIGIT IN E CP 0AH ;10 IS FLAG FOR NO MORE POP DE RET Z ;IF SO, RETURN ADD A,30H ;ELSE, CONVERT TO ASCII RST 10H ;PRINT THE DIGIT JR PN6 ;GO BACK FOR MORE PRTLN: LD A,(DE) ;*** PRTLN *** LD L,A ;LOW ORDER LINE # INC DE LD A,(DE) ;HIGH ORDER LD H,A INC DE LD C,04H ;PRINT 4 DIGIT LINE # CALL PRTNUM LD A,20H ;FOLLOWED BY A BLANK RST 10H SUB A ;AND THEN THE NEXT CALL PRTSTG RET ;************************************************************* ; ; *** MVUP *** MVDOWN *** POPA *** & PUSHA *** ; ; 'MVUP' MOVES A BLOCK UP FROM WHERE DE-> TO WHERE BC-> UNTIL ; DE = HL ; ; 'MVDOWN' MOVES A BLOCK DOWN FROM WHERE DE-> TO WHERE HL-> ; UNTIL DE = BC ; ; 'POPA' RESTORES THE 'FOR' LOOP VARIABLE SAVE AREA FROM THE ; STACKB ; ; 'PUSHA' STACKBS THE 'FOR' LOOP VARIABLE SAVE AREA INTO THE ; STACKB ;************************************************************* MVUP: RST 20H ;*** MVUP *** RET Z ;DE = HL, RETURN LD A,(DE) ;GET ONE BYTE LD (BC),A ;MOVE IT INC DE ;INCREASE BOTH POINTERS INC BC JR MVUP ;UNTIL DONE MVDOWN: LD A,B ;*** MVDOWN *** SUB D ;TEST IF DE = BC JP NZ,MD1 ;NO, GO MOVE LD A,C ;MAYBE, OTHER BYTE? SUB E RET Z ;YES, RETURN MD1: DEC DE ;ELSE MOVE A BYTE DEC HL ;BUT FIRST DECREASE LD A,(DE) ;BOTH POINTERS AND LD (HL),A ;THEN DO IT JR MVDOWN ;LOOP BACK POPA: POP BC ;BC = RETURN ADDR. POP HL ;RESTORE LOPVAR, BUT LD (LOPVAR),HL ;=0 MEANS NO MORE LD A,H OR L JR Z,PP1 ;YEP, GO RETURN POP HL ;NOP, RESTORE OTHERS LD (LOPINC),HL POP HL LD (LOPLMT),HL POP HL LD (LOPLN),HL POP HL LD (LOPPT),HL PP1: PUSH BC ;BC = RETURN ADDR. RET PUSHA: LD HL,STKLMT ;*** PUSHA *** CALL CHGSGN POP BC ;BC=RETURN ADDRESS ADD HL,SP ;IS STACKB NEAR THE TOP? JP NC,QSORRY ;YES, SORRY FOR THAT LD HL,(LOPVAR) ;ELSE SAVE LOOP VAR'S LD A,H ;BUT IF LOPVAR IS 0 OR L ;THAT WILL BE ALL JR Z,PU1 LD HL,(LOPPT) ;ELSE, MORE TO SAVE PUSH HL LD HL,(LOPLN) PUSH HL LD HL,(LOPLMT) PUSH HL LD HL,(LOPINC) PUSH HL LD HL,(LOPVAR) PU1: PUSH HL PUSH BC ;BC = RETURN ADDR. RET ;************************************************************* ; ; *** OUTC *** & CHKIO *** ; ; THESE ARE THE ONLY I/O ROUTINES IN TBI. ; 'OUTC' IS CONTROLLED BY A SOFTWARE SWITCH 'OCSW'. IF OCSW=0 ; 'OUTC' WILL JUST RETURN TO THE CALLER. IF OCSW IS NOT 0, ; IT WILL OUTPUT THE BYTE IN A. IF THAT IS A CR, A LF IS ALSO ; SEND OUT. ONLY THE FLAGS MAY BE CHANGED AT RETURN. ALL REG. ; ARE RESTORED. ; ; 'CHKIO' CHECKS THE INPUT. IF NO INPUT, IT WILL RETURN TO ; THE CALLER WITH THE Z FLAG SET. IF THERE IS INPUT, Z FLAG ; IS CLEARED AND THE INPUT BYTE IS IN A. HOWEVER, IF THE ; INPUT IS A CONTROL-O, THE 'OCSW' SWITCH IS COMPLIMENTED, AND ; Z FLAG IS RETURNED. IF A CONTROL-C IS READ, 'CHKIO' WILL ; RESTART TBI AND DO NOT RETURN TO THE CALLER. ;************************************************************* INIT: CALL SERIAL_INIT ;INITIALIZE THE SERIAL PORT LD D,03H ;3X LINE FEEDS PATLOP: CALL CRLF DEC D JR NZ,PATLOP SUB A LD DE,MSG1 CALL PRTSTG LD DE,MSG2 CALL PRTSTG LD DE,MSG3 CALL PRTSTG LD HL,START LD (RANPNT),HL LD HL,TXTBGN LD (TXTUNF),HL JP RSTART OUTC: JR NZ,OUTC2 ;IT IS ON POP AF ;IT IS OFF RET ;RESTORE AF AND RETURN OUTC2: CALL TX_RDY ;SEE IF TRANSMIT IS AVAILABLE POP AF ;RESTORE THE REGISTER OUT (SerialPort),A ;SEND THE BYTE CP CR RET NZ LD A,LF RST 10H LD A,CR RET CHKIO: CALL RX_RDY ;CHECK IF CHARACTER AVAILABLE RET Z ;RETURN IF NO CHARACTER AVAILABLE PUSH BC ;IF IT'S A LF, IGNORE AND RETURN LD B,A ; AS IF THERE WAS NO CHARACTER. SUB LF JR Z,CHKIO2 LD A,B ;OTHERWISE RESTORE 'A' AND 'BC' POP BC ; AND CONTINUE ON. CP 0FH ;IS IT CONTROL-0? JR NZ,CI1 ;NO, MORE CHECKING LD A,(OCSW) ;CONTROL-0 FLIPS OCSW CPL ;ON TO OFF, OFF TO ON LD (OCSW),A JR CHKIO ;GET ANOTHER INPUT CHKIO2: LD A,00H ;CLEAR A OR A ;ZET THE Z-FLAG POP BC ;RESTORE THE 'BC' PAIR RET ;RETURN WITH 'Z' SET. CI1: CP 03H ;IS IT CONTROL-C? RET NZ ;NO, RETURN "NZ" JP RSTART ;YES, RESTART TBI ; MSG1: DB ESC,"[2J",ESC,"[H" DB 'Z80 TinyBASIC 2.5g Patch 2',CR MSG2: DB 'Ported by Doug Gabbard, 2017',CR MSG3: DB LF,LF,'HELP - New Instructions',LF,LF,CR ;************************************************************* ; ; *** TABLES *** DIRECT *** & EXEC *** ; ; THIS SECTION OF THE CODE TESTS A STRING AGAINST A TABLE. ; WHEN A MATCH IS FOUND, CONTROL IS TRANSFERED TO THE SECTION ; OF CODE ACCORDING TO THE TABLE. ; ; AT 'EXEC', DE SHOULD POINT TO THE STRING AND HL SHOULD POINT ; TO THE TABLE-1. AT 'DIRECT', DE SHOULD POINT TO THE STRING. ; HL WILL BE SET UP TO POINT TO TAB1-1, WHICH IS THE TABLE OF ; ALL DIRECT AND STATEMENT COMMANDS. ; ; A '.' IN THE STRING WILL TERMINATE THE TEST AND THE PARTIAL ; MATCH WILL BE CONSIDERED AS A MATCH. E.G., 'P.', 'PR.', ; 'PRI.', 'PRIN.', OR 'PRINT' WILL ALL MATCH 'PRINT'. ; ; THE TABLE CONSISTS OF ANY NUMBER OF ITEMS. EACH ITEM ; IS A STRING OF CHARACTERS WITH BIT 7 SET TO 0 AND ; A JUMP ADDRESS STORED HI-LOW WITH BIT 7 OF THE HIGH ; BYTE SET TO 1. ; ; END OF TABLE IS AN ITEM WITH A JUMP ADDRESS ONLY. IF THE ; STRING DOES NOT MATCH ANY OF THE OTHER ITEMS, IT WILL ; MATCH THIS NULL ITEM AS DEFAULT. ;************************************************************* TAB1: ;DIRECT COMMANDS DB 'HELP' ;ADDED HELP MENU DWA HELP_CMDS DB 'LIST' DWA LIST DB 'NEW' DWA NEW DB 'RUN' DWA RUN TAB2: ;DIRECT/STATEMENT DB 'CALL' DWA CALL_MCODE DB 'CLS' ;ADDED CLS CMD DWA CLSB DB 'DELAY' ;ADDED DELAY CMD DWA DELAYB DB 'FOR' DWA FOR DB 'GOSUB' DWA GOSUB DB 'GOTO' DWA GOTO DB 'IF' DWA IFF DB 'INPUT' DWA INPUT DB 'IN' ;ADDED IN CMD DWA INB DB 'LET' DWA LET DB 'NEXT' DWA NEXT DB 'OUT' ;ADDED OUT CMD DWA OUTB DB 'PEEK' ;ADDED PEEK DWA PEEK DB 'POKE' ;ADDED POKE DWA POKE DB 'PRINT' DWA PRINT DB 'REM' DWA REM DB 'RETURN' DWA RETURN DB 'STOP' DWA STOP DWA DEFLT TAB4: ;FUNCTIONS DB 'ABS' DWA ABS DB 'RND' DWA RND DB 'SIZE' DWA SIZE DWA XP40 TAB5: ;"TO" IN "FOR" DB 'TO' DWA FR1 DWA QWHAT TAB6: ;"STEP" IN "FOR" DB 'STEP' DWA FR2 DWA FR3 TAB8: ;RELATION OPERATORS DB '>=' DWA XP11 DB '#' DWA XP12 DB '>' DWA XP13 DB '=' DWA XP15 DB '<=' DWA XP14 DB '<' DWA XP16 DWA XP17 DIRECT: LD HL,TAB1-1 ;*** DIRECT *** EXEC: ;*** EXEC *** EX0: RST 28H ;IGNORE LEADING BLANKS PUSH DE ;SAVE POINTER EX1: LD A,(DE) ;IF FOUND '.' IN STRING INC DE ;BEFORE ANY MISMATCH CP 23H ;WE DECLARE A MATCH JR Z,EX3 INC HL ;HL->TABLE CP (HL) ;IF MATCH, TEST NEXT JR Z,EX1 LD A,7FH ;ELSE SEE IF BIT 7 DEC DE ;OF TABLE IS SET, WHICH CP (HL) ;IS THE JUMP ADDR. (HI) JR C,EX5 ;C:YES, MATCHED EX2: INC HL ;NC:NO, FIND JUMP ADDR. CP (HL) JR NC,EX2 INC HL ;BUMP TO NEXT TAB. ITEM POP DE ;RESTORE STRING POINTER JR EX0 ;TEST AGAINST NEXT ITEM EX3: LD A,7FH ;PARTIAL MATCH, FIND EX4: INC HL ;JUMP ADDR., WHICH IS CP (HL) ;FLAGGED BY BIT 7 JR NC,EX4 EX5: LD A,(HL) ;LOAD HL WITH THE JUMP INC HL ;ADDRESS FROM THE TABLE LD L,(HL) AND 7FH ;MASK OFF BIT 7 LD H,A POP AF ;CLEAN UP THE GABAGE JP (HL) ;AND WE GO DO IT ;************************************************************* ; *** TinyBASIC Expansion *** ; ; *** QUIT *** INB *** OUTB *** CLSB *** ; *** DELAYB *** PEEK *** POKE *** ; ; INB IS THE ROUTINE FOR READING THE VALUE OF A PORT AND ; ASSIGNING IT TO A VARIABLE. ; ; OUTB IS THE ROUTINE FOR READIGN THE VALUE OF A VARIABLE AND ; WRITING IT TO A HARDWARE PORT. ; ; CLSB IS A ROUTINE TO CLEAR THE SCREEN. ; ; DELAYB IS A ROUTINE DESIGNED TO GIVE APPROXIMATELY 2ms DELAY ; AT 6MHZ. ; ; PEEK IS A ROUTINE TO READ THE VALUE OF A MEMORY LOCATION ; AND STORE THAT VALUE IN A VARIABLE. ; ; POKE IS A ROUTINE USED TO READ A VARIABLE, AND WRITE THE ; INFORMATION INTO A MEMORY LOCATION. ; ; CALL_MCODE IS A ROUTINE TO EXECUTE MACHINE CODE, AND CAN ; RETURN A TWO BYTE VARIABLE BACK TO 'HL'. ;************************************************************* INB: ;'IN' ROUTINE PUSH AF ;SAVE THE REGISTERS PUSH BC INB2: INC DE LD A,(DE) LD B,SPACE CP B JR Z,INB2 ;IF IT'S NOT A SPACE GET THE LOCATION INB3: CALL GET_HEX LD C,A ;PORT IS NOW IN 'C'. INB4: INC DE LD A,(DE) LD B,',' ; COMPARE COMA CP B JR Z,INB4 LD B,' ' ; COMPARE SPACE CP B JR Z,INB4 LD B,'=' CP B JR Z,INB4 LD B,40H ;IF NOT IT IS VARIABLE SUB B ;ADJUST FOR MEMORY LOCATION LD HL,VARBGN ;COMPUTE ADDRESS OF RLCA ;THAT VARIABLE ADD A,L ;AND RETURN IT IN HL LD L,A ;WITH C FLAG CLEARED LD A,00H ADC A,H LD H,A IN A,(C) ;GET BYTE LD (HL),A ;STORE IT IN THE VARIALBLE LOCATION INC HL ;PAD THE EXTRA MEMORY LOCATION LD (HL),00H INC DE POP BC ;RESTORE THE REGISTERS POP AF JP RUNSML ;NEXT LINE ;------------------------------------------------------------------------------- OUTB: ;'OUT' ROUTINE PUSH AF PUSH BC OUTB2: INC DE LD A,(DE) LD B,SPACE CP B JR Z,OUTB2 OUTB3: CALL GET_HEX PUSH AF ;PORT IS IN THE STACK OUTB4: INC DE LD A,(DE) LD B,',' ; COMPARE COMA CP B JR Z,OUTB4 LD B,' ' ; COMPARE SPACE CP B JR Z,OUTB4 LD B,'=' CP B JR Z,OUTB4 LD B,40H ;IF NOT IT IS VARIABLE SUB B ;ADJUST FOR MEMORY LOCATION LD HL,VARBGN ;COMPUTE ADDRESS OF RLCA ;THAT VARIABLE ADD A,L ;AND RETURN IT IN HL LD L,A ;WITH C FLAG CLEARED LD A,00H ADC A,H LD H,A ;VARIABLE LOCATION IN HL POP AF ;PORT BACK IN 'A' LD C,A ;PORT IS NOW IN C LD A,(HL) ;Load the value from memory into 'A' OUT (C),A ;WRITE THE BYTE TO THE PORT POP BC ;RESTORE REGISTERS POP AF INC DE JP RUNSML ;------------------------------------------------------------------------------- CLSB: ;CLS ROUTINE FOR BASIC PUSH AF PUSH BC PUSH DE LD DE,CLSB_MSG CALL PRTSTG POP DE POP BC POP AF INC DE JP RUNNXL CLSB_MSG: DB ESC,"[2J",ESC,"[H",CR ;------------------------------------------------------------------------------- DELAYB: PUSH AF PUSH BC PUSH DE PUSH HL CALL MILLI_DLY POP HL POP DE POP BC POP AF INC DE JP RUNNXL ;------------------------------------------------------------------------------- PEEK: PUSH AF ;SAVE THE REGISTERS PUSH BC PEEK2: INC DE LD A,(DE) LD B,SPACE CP B JR Z,PEEK2 ;IF IT'S NOT A SPACE GET THE LOCATION PEEK3: CALL GET_HEX LD H,A INC DE CALL GET_HEX LD L,A ;MEMORY LOCATION IN 'HL' NOW. LD A,(HL) ;GET THE BYTE FROM MEMORY. PUSH AF ;NOW STORE THE BYTE ON THE STACK. PEEK4: INC DE LD A,(DE) LD B,',' ; COMPARE COMA CP B JR Z,PEEK4 LD B,' ' ; COMPARE SPACE CP B JR Z,PEEK4 LD B,'=' CP B JR Z,PEEK4 LD B,40H ;IF NOT IT IS VARIABLE SUB B ;ADJUST FOR MEMORY LOCATION LD HL,VARBGN ;COMPUTE ADDRESS OF RLCA ;THAT VARIABLE ADD A,L ;AND RETURN IT IN HL LD L,A ;WITH C FLAG CLEARED LD A,00H ADC A,H LD H,A POP AF ;RESTORE THE BYTE FROM THE STACK LD (HL),A ;STORE IT IN THE VARIALBLE LOCATION INC HL ;PAD THE EXTRA MEMORY LOCATION LD (HL),00H INC DE POP BC ;RESTORE THE REGISTERS POP AF JP RUNSML ;NEXT LINE ;------------------------------------------------------------------------------- POKE: ;POKE ROUTINE PUSH AF PUSH BC POKE2: INC DE LD A,(DE) LD B,SPACE CP B JR Z,POKE2 POKE3: CALL GET_HEX LD H,A INC DE CALL GET_HEX LD L,A ;LOCATION NOW 'HL' PUSH HL ;STORE LOCATION IN STACK. POKE4: INC DE LD A,(DE) LD B,',' ; COMPARE COMA CP B JR Z,POKE4 LD B,' ' ; COMPARE SPACE CP B JR Z,POKE4 LD B,'=' CP B JR Z,POKE4 LD B,'(' ;IS IT HEX? CP B JR Z,POKE5 LD B,40H ;IF NOT IT IS VARIABLE SUB B ;ADJUST FOR MEMORY LOCATION LD HL,VARBGN ;COMPUTE ADDRESS OF RLCA ;THAT VARIABLE ADD A,L ;AND RETURN IT IN HL LD L,A ;WITH C FLAG CLEARED LD A,00H ADC A,H LD H,A ;VARIABLE LOCATION IN HL ;POP AF ;PORT BACK IN 'A' ;LD C,A ;PORT IS NOW IN C LD A,(HL) ;Load the value from memory into 'A' POP HL ;GET THE MEMORY LOCATION BACK LD (HL),A ;OUT (C),A ;WRITE THE BYTE TO THE PORT POP BC ;RESTORE REGISTERS POP AF INC DE JP RUNSML POKE5: INC DE ;NEXT CHARACTER LD A,(DE) LD B,')' ;IS IT THE END OF HEX? CP B JR Z,POKE6 ;IF SO, GO TO END CALL GET_HEX ;IF NOT, GET THE VALUE AND WRITE POP HL LD (HL),A INC HL ;NEXT LOCATION TO WRITE PUSH HL ;STORE THE LOCATION JR POKE5 ;NEXT BYTE. POKE6: POP BC POP AF INC DE JP RUNSML ;------------------------------------------------------------------------------- CALL_MCODE: PUSH AF PUSH BC PUSH HL CALL2: INC DE LD A,(DE) LD B,SPACE CP B JR Z,CALL2 CALL3: LD HL,CALL5 ;SET RETURN VECTOR - I THINK... PUSH HL ;PLACE IT ON THE STACK FOR RETURN... CALL GET_HEX LD H,A INC DE CALL GET_HEX LD L,A ;LOCATION NOW 'HL' CALL4: PUSH DE ;SAVE CURRENT DE LOCATION. JP (HL) CALL5: POP HL POP DE ;KEEPS RETURNING 'WHAT?' ERROR.... POP BC POP AF INC DE JP RUNSML ;------------------------------------------------------------------------------- GET_HEX: LD A,(DE) LD B,A INC DE LD A,(DE) LD C,A PUSH DE ;SAVE DE LOCATION LD D,B ;SEND THE ASCII TO CONVERT LD E,C CALL ASCIIHEX_TO_BYTE ;BYTE IS RETURNED IN 'A' POP DE RET ASCIIHEX_TO_BYTE: PUSH BC ;SAVE REGISTERS LD A,D ;LOAD UPPER CHARACTER CALL CONVERT_HEX_VAL ;CONVERT THE CHARACTER RLA RLA RLA RLA LD B,A ;STORE THE FIRST NIBBLE LD A,E ;GET SECOND CHARACTER CALL CONVERT_HEX_VAL ;CONVERT THE CHARACTER ADD A,B ;ADD THE TWO NIBBLES POP BC RET ; CONVERTS THE ASCII CHARACTER IN A TO IT'S HEX VALUE IN A, ERROR RETURNS 0FFH CONVERT_HEX_VAL: CP 'G' ;GREATER THAN "F" JP P,CONVERT_HEX_ERROR ;IF SO, ERROR. CP '0' ;LESS THAN "ZERO" JP M,CONVERT_HEX_ERROR ;IF SO, ERROR. CP 03AH ;LESS THAN OR EQUAL TO "9" JP M,CONVERT_MASK ;IF SO, CONVERT AND RETURN. CP 'A' ;LESS THAN "A" JP M,CONVERT_HEX_ERROR ;IF SO, ERROR. SUB 037H ;MUST BE "A" TO "F", CONVERT. RET CONVERT_MASK: AND 0FH RET CONVERT_HEX_ERROR: LD A,0FFH ;IF ERROR, RETURN 0FFH RET ;------------------------------------------------------------------------------- MILLI_DLY: ;DELAY 1 MILLISECOND @ 6MHZ (ESTIMATED) PUSH AF ; THERE IS NO WAY TO REALLY CALCULATE PUSH BC ; THIS, AS THE INTERPRETER TAKES TIME. LD BC,0073H ; 6006 INSTRUCTIONS MILLI_DLYL: DEC BC LD A,C OR B JR NZ,MILLI_DLYL POP BC POP AF RET ;------------------------------------------------------------------------------- HELP_CMDS: PUSH AF PUSH BC PUSH DE LD DE,HELP_CMD_MSG1 CALL PRTSTG LD DE,HELP_CMD_MSG2 CALL PRTSTG LD DE,HELP_CMD_MSG3 CALL PRTSTG LD DE,HELP_CMD_MSG4 CALL PRTSTG LD DE,HELP_CMD_MSG5 CALL PRTSTG LD DE,HELP_CMD_MSG6 CALL PRTSTG LD DE,HELP_CMD_MSG7 CALL PRTSTG LD DE,HELP_CMD_MSG8 CALL PRTSTG POP DE POP BC POP AF INC DE ;JP RUNSML JP RUNNXL HELP_CMD_MSG1: DB LF,LF,TAB,'TinyBASIC 2.5g Expanded Instructions',LF,LF,CR HELP_CMD_MSG2: DB TAB,'OUT PP,V',LF,CR HELP_CMD_MSG3: DB TAB,'IN PP,V',LF,CR HELP_CMD_MSG4: DB TAB,'POKE AAAA,V',LF,CR HELP_CMD_MSG5: DB TAB,'PEEK AAAA,V',LF,CR HELP_CMD_MSG6: DB TAB,'DELAY',LF,CR HELP_CMD_MSG7: DB TAB,'CLS',LF,LF,LF,CR HELP_CMD_MSG8: DB TAB,'PP=HEX PORT AAAA=HEX ADDR V=VARIABLE',LF,LF,CR ;------------------------------------------------------------------------------- ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------- ;COMPUTER SPECIFIC ROUTINES. UART_DHR EQU 0 ;UART Data R/W register UART_IER EQU 1 ;Interrupt Enable Register UART_IFR EQU 2 ;Interrupt ID Reg (READ), FIFO Control Reg (WRITE) UART_LCR EQU 3 ;Line Control Register UART_MCR EQU 4 ;Modem Control UART_LSR EQU 5 ;Line Status Register UART_MSR EQU 6 ;Modem Status (Unused) UART_SCR EQU 7 ;Arbitrary data can be stored here ;Baud Rate Divisor (115200) BAUD_DIV_HIGH equ 0 BAUD_DIV_LOW equ 8 ;------------------------------------------------------------------------------- SERIAL_INIT: PUSH AF CALL UART_CLEAR_DLAB CALL UART_DISABLE_FIFO CALL UART_SET_LINE_CONTROL CALL UART_TOGGLE_OUT1 CALL UART_TOGGLE_OUT2 CALL UART_CLEAR_LSR CALL UART_SET_DLAB CALL UART_SET_BAUD CALL UART_CLEAR_DLAB POP AF RET UART_CLEAR_DLAB: PUSH AF IN A, (UART_LCR) AND 7Fh OUT (UART_LCR), A POP AF RET UART_SET_DLAB: PUSH AF IN A, (UART_LCR) OR 80h OUT (UART_LCR), A POP AF RET UART_SET_LINE_CONTROL: PUSH AF LD A, 3h ;8 Bit word, 1 stop, no parity OUT (UART_LCR), A POP AF RET UART_DISABLE_FIFO: PUSH AF LD A, 6h OUT (UART_IFR), A POP AF RET UART_SET_BAUD: PUSH AF ;115200 LD A, BAUD_DIV_LOW OUT (UART_DHR), A LD A, BAUD_DIV_HIGH OUT (UART_IER), A POP AF RET UART_CLEAR_LSR: PUSH AF ;Clear Line Status Reg Errors (Page 21) IN A, (UART_LSR) POP AF RET UART_TOGGLE_OUT1: PUSH AF IN A, (UART_MCR) XOR 4h OUT (UART_MCR), A POP AF RET UART_TOGGLE_OUT2: PUSH AF IN A, (UART_MCR) XOR 8h OUT (UART_MCR), A POP AF RET ;------------------------------------------------------------------------------- TX_RDY: ; This routine is checking if the Serial Port is ready to send ; a character. PUSH AF CALL UART_TOGGLE_OUT1 CALL UART_CLEAR_DLAB PRINTCH_LOOP: ;Read transmit register status in line status register (LSR) See page 22 ;Wait if not empty IN A, (UART_LSR) AND 60H CP 60H JP NZ, PRINTCH_LOOP ;Write Char to UART POP AF RET ;------------------------------------------------------------------------------- RX_RDY: ; This routine is for checkif if a character is available over ; serial. If a character is available, it returns to the calling ; function with the character in 'A' and the Z-flag reset. ; However, if a character is not available, it returns with the ; Z-flag set. CALL UART_CLEAR_DLAB ;Read Line Status Reg IN A, (UART_LSR) ;If only bit 1 is set then FIFO has new data AND 1 CP 0 JP Z, RX_RDY_END CALL UART_TOGGLE_OUT2 XOR A CP 1 ;Get next char from data holding register IN A, (UART_DHR) RX_RDY_END: RET ;------------------------------------------------------------------------------- ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------------------------------------------- ; LSTROM: ;ALL ABOVE CAN BE ROM ; ORG 1000H ;HERE DOWN MUST BE RAM ORG 08000H ORG 0FF00H VARBGN: DS 55 ;VARIABLE @(0) BUFFER: DS 64 ;INPUT BUFFER BUFEND: DS 1 ;BUFFER ENDS STKLMT: DS 1 ;TOP LIMIT FOR STACKB
/*++ Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. Module Name: ConvSymKernelNeonDot.asm Abstract: This module implements the kernels for the symmetric quantized integer convolution operation. --*/ #include "kxarm64.h" #define MLAS_CONV_SYM_FLAG_INPUT_DIRECT 1 #define MLAS_CONV_SYM_FLAG_PER_CHANNEL_SCALE 2 // // Stack frame layout for the symmetric convolution kernel. // d8-d15, x19-x30 need to be preserved if used // #define ConvSymFrame_SavedNeonRegisters (8 * 8) #define ConvSymFrame_SavedRegisters ConvSymFrame_SavedNeonRegisters #define ConvSymFrame_PostProcessParams 0 + ConvSymFrame_SavedRegisters #define ConvSymFrame_KernelFlags 8 + ConvSymFrame_SavedRegisters #define ConvSymPostProcessParams_Bias 0 #define ConvSymPostProcessParams_Scale 8 #define ConvSymPostProcessParams_Min 16 #define ConvSymPostProcessParams_Max 20 #define ConvSymPostProcessParams_ZeroPoint 24 TEXTAREA /*++ Routine Description: This routine is the inner kernel to compute a convolution for the elements of an output row for a set of filter rows. Arguments: Input (x0) - Points to the input buffer. If MLAS_CONV_SYM_FLAG_INPUT_DIRECT is set, then the input buffer points directly at the input tensor. If MLAS_CONV_SYM_FLAG_INPUT_DIRECT is clear, then the input buffer is an indirection buffer. Every pointer in the indirection buffer points at a InputChannels length vector (either from the input tensor or a vector of padding values). These are grouped in batches of length KernelSize. These batches are then repeated OutputCount times. Filter (x1) - Points to the filter buffer. Output (x2) - Points the output buffer. KernelSize (x3/x9) - Size of the kernel (most commonly. 3x3=9, 5x5=25). If MLAS_CONV_SYM_FLAG_INPUT_DIRECT is set, then kernel size should be 1. InputChannels (x4/x7) - Number of input channels. OutputChannels (x5) - Number of output channels. ChannelCount (x6) - Number of output channels this iteration produces. OutputCount (x7) - Number of output elements this iteration produces. This implementation requires the count to be no larger than 4. PostProcessParams (x8) - Points to the post process parameter block. KernelFlags - (w10) Additional flags controlling the operation. Return Value: None. --*/ NESTED_ENTRY MlasConvSymU8KernelDot PROLOG_SAVE_REG_PAIR d8,d9,#-64! PROLOG_NOP ldr x8,[sp,#ConvSymFrame_PostProcessParams] PROLOG_NOP ldr w10,[sp,#ConvSymFrame_KernelFlags] PROLOG_SAVE_REG_PAIR d10,d11,#16 PROLOG_SAVE_REG_PAIR d12,d13,#32 PROLOG_SAVE_REG_PAIR x19,x20,#48 // compute C pointers: x2, x16, x17, x5 cmp x7,2 // OutputCount < 2 ? add x16,x2,x5 // x16 -> C1 lsl x3,x3,#3 // KernelSize * sizeof(int8_t*) csel x16,x2,x16,lo // if OutputCount < 2 x16/C1 -> C0 mov x20,x4 add x4,x4,3 // InputChannels align to 4 add x17,x16,x5 // x17 -> C2 ldr x11,[x8,#ConvSymPostProcessParams_Bias] csel x17,x16,x17,ls // if OutputCount <= 2 x17/C2 -> C1 bic x4,x4,3 cmp x7,4 // OutputCount < 4 ? add x5,x17,x5 // x5 -> C3 ldr x19,[x8,#ConvSymPostProcessParams_Scale] csel x5,x17,x5,lo // if OutputCount < 4 x5/C3 -> C2 movi v12.16b,128 // for top bit flipping OutputChannelLoop ldp q16,q20,[x11],32 // Init accumulators with biases mov v17.16b,v16.16b mov v18.16b,v16.16b ldp q24,q28,[x11],32 mov v19.16b,v16.16b mov v21.16b,v20.16b mov v22.16b,v20.16b mov v23.16b,v20.16b mov v25.16b,v24.16b mov v26.16b,v24.16b mov v27.16b,v24.16b mov v29.16b,v28.16b mov v30.16b,v28.16b mov v31.16b,v28.16b mov x9,x3 // restore KernelSize * sizeof(int8_t*) KernelSizeLoop tst w10,#MLAS_CONV_SYM_FLAG_INPUT_DIRECT beq InputIndirection InputDirect cmp x16,x2 mov x12,x0 // x12 -> A0 add x13,x0,x20 // x13 -> A1 = A0 + input channels csel x13,x0,x13,eq cmp x17,x16 add x14,x0,x20,lsl#1 // x14 -> A2 csel x14,x13,x14,eq cmp x5,x17 add x15,x13,x20,lsl#1 // x15 -> A3 csel x15,x14,x15,eq b FinishLoadAPtr InputIndirection ldr x12,[x0] // x12 -> A0 cmp x16,x2 b.eq SkipLoadA1 // C1==C0 -> A0=A1=A2=A3 cmp x17,x16 lsl x14,x3,#1 ldr x13,[x0,x3] // x13 -> A1 b.eq SkipLoadA2 // C2==C1 -> A1=A2=A3 cmp x5,x17 add x15,x3,x3,lsl#1 ldr x14,[x0,x14] // x14 -> A2 b.eq SkipLoadA3 // C3==C2 -> A2=A3 ldr x15,[x0,x15] // x15 -> A3 b FinishLoadAPtr SkipLoadA1 mov x13,x12 SkipLoadA2 mov x14,x13 SkipLoadA3 mov x15,x14 // Register Usage // B (x1) -> 4x16 // ---------------------------------------------------------------------------- // |v4.b[0]..v4.b[12] v5.b[0]..v5.b[12] v6.b[0]..v6.b[12] v7.b[0]..v7.b[12]| // | ... ... ... ... ... ... ... ... | // |v4.b[3]..v4.b[15] v5.b[3]..v5.b[15] v6.b[3]..v6.b[15] v7.b[3]..v7.b[15]| // A 4x4 ---------------------------------------------------------------------------- // ------------------ ---------------------------------------------------------------------------- // x12 |v0.b[0]..v0.b[3]| |v16.s[0]_v16.s[3] v20.s[0]_v20.s[3] v24.s[0]_v24.s[3] v28.s[0]_v28.s[3]| x2 // x13 |v1.b[0]..v1.b[3]| |v17.s[0]_v17.s[3] v21.s[0]_v21.s[3] v25.s[0]_v25.s[3] v29.s[0]_v29.s[3]| x16 // x14 |v2.b[0]..v2.b[3]| |v18.s[0]_v18.s[3] v22.s[0]_v23.s[3] v26.s[0]_v26.s[3] v30.s[0]_v31.s[3]| x17 // x15 |v3.b[0]..v3.b[3]| |v19.s[0]_v19.s[3] v23.s[0]_v23.s[3] v27.s[0]_v27.s[3] v31.s[0]_v31.s[3]| x5 // ------------------ ---------------------------------------------------------------------------- FinishLoadAPtr subs x7,x4,16 // Need 16 input channels for loop add x0,x0,8 // indirect A advance to next pointer, prepare for kernel size loop b.lo InChannels8 ldr d0,[x12],8 ldr q4,[x1],16 ldr d1,[x13],8 subs x7,x7,16 ldr d2,[x14],8 ldr d3,[x15],8 ldr q5,[x1],16 ldr q6,[x1],16 ldr q7,[x1],16 b.lo InChLoopEpilogue // Need 32 input channels for main loop InputChannelLoop eor v0.8b,v0.8b,v12.8b eor v1.8b,v1.8b,v12.8b sdot v16.4s,v4.16b,v0.4b[0] eor v2.8b,v2.8b,v12.8b sdot v17.4s,v4.16b,v1.4b[0] eor v3.8b,v3.8b,v12.8b ldr d8,[x12],8 sdot v18.4s,v4.16b,v2.4b[0] sdot v19.4s,v4.16b,v3.4b[0] ldr q4,[x1],16 sdot v20.4s,v5.16b,v0.4b[0] sdot v21.4s,v5.16b,v1.4b[0] ldr d9,[x13],8 sdot v22.4s,v5.16b,v2.4b[0] sdot v23.4s,v5.16b,v3.4b[0] ldr q5,[x1],16 sdot v24.4s,v6.16b,v0.4b[0] sdot v25.4s,v6.16b,v1.4b[0] ldr d10,[x14],8 sdot v26.4s,v6.16b,v2.4b[0] sdot v27.4s,v6.16b,v3.4b[0] ldr q6,[x1],16 sdot v28.4s,v7.16b,v0.4b[0] sdot v29.4s,v7.16b,v1.4b[0] ldr d11,[x15],8 sdot v30.4s,v7.16b,v2.4b[0] sdot v31.4s,v7.16b,v3.4b[0] ldr q7,[x1],16 sdot v16.4s,v4.16b,v0.4b[1] sdot v17.4s,v4.16b,v1.4b[1] sdot v18.4s,v4.16b,v2.4b[1] sdot v19.4s,v4.16b,v3.4b[1] ldr q4,[x1],16 sdot v20.4s,v5.16b,v0.4b[1] sdot v21.4s,v5.16b,v1.4b[1] sdot v22.4s,v5.16b,v2.4b[1] sdot v23.4s,v5.16b,v3.4b[1] ldr q5,[x1],16 sdot v24.4s,v6.16b,v0.4b[1] sdot v25.4s,v6.16b,v1.4b[1] sdot v26.4s,v6.16b,v2.4b[1] sdot v27.4s,v6.16b,v3.4b[1] ldr q6,[x1],16 sdot v28.4s,v7.16b,v0.4b[1] sdot v29.4s,v7.16b,v1.4b[1] sdot v30.4s,v7.16b,v2.4b[1] sdot v31.4s,v7.16b,v3.4b[1] eor v8.8b,v8.8b,v12.8b ldr q7,[x1],16 eor v9.8b,v9.8b,v12.8b sdot v16.4s,v4.16b,v8.4b[0] eor v10.8b,v10.8b,v12.8b sdot v17.4s,v4.16b,v9.4b[0] ldr d0,[x12],8 eor v11.8b,v11.8b,v12.8b sdot v18.4s,v4.16b,v10.4b[0] sdot v19.4s,v4.16b,v11.4b[0] ldr q4,[x1],16 sdot v20.4s,v5.16b,v8.4b[0] sdot v21.4s,v5.16b,v9.4b[0] ldr d1,[x13],8 sdot v22.4s,v5.16b,v10.4b[0] sdot v23.4s,v5.16b,v11.4b[0] ldr q5,[x1],16 sdot v24.4s,v6.16b,v8.4b[0] sdot v25.4s,v6.16b,v9.4b[0] ldr d2,[x14],8 sdot v26.4s,v6.16b,v10.4b[0] sdot v27.4s,v6.16b,v11.4b[0] ldr q6,[x1],16 sdot v28.4s,v7.16b,v8.4b[0] sdot v29.4s,v7.16b,v9.4b[0] ldr d3,[x15],8 sdot v30.4s,v7.16b,v10.4b[0] sdot v31.4s,v7.16b,v11.4b[0] ldr q7,[x1],16 sdot v16.4s,v4.16b,v8.4b[1] sdot v17.4s,v4.16b,v9.4b[1] sdot v18.4s,v4.16b,v10.4b[1] sdot v19.4s,v4.16b,v11.4b[1] ldr q4,[x1],16 sdot v20.4s,v5.16b,v8.4b[1] sdot v21.4s,v5.16b,v9.4b[1] sdot v22.4s,v5.16b,v10.4b[1] sdot v23.4s,v5.16b,v11.4b[1] ldr q5,[x1],16 sdot v24.4s,v6.16b,v8.4b[1] sdot v25.4s,v6.16b,v9.4b[1] sdot v26.4s,v6.16b,v10.4b[1] sdot v27.4s,v6.16b,v11.4b[1] ldr q6,[x1],16 sdot v28.4s,v7.16b,v8.4b[1] sdot v29.4s,v7.16b,v9.4b[1] subs x7,x7,16 // InputChannels -= 16 sdot v30.4s,v7.16b,v10.4b[1] sdot v31.4s,v7.16b,v11.4b[1] ldr q7,[x1],16 b.hs InputChannelLoop InChLoopEpilogue eor v0.8b,v0.8b,v12.8b eor v1.8b,v1.8b,v12.8b sdot v16.4s,v4.16b,v0.4b[0] eor v2.8b,v2.8b,v12.8b sdot v17.4s,v4.16b,v1.4b[0] eor v3.8b,v3.8b,v12.8b ldr d8,[x12],8 sdot v18.4s,v4.16b,v2.4b[0] sdot v19.4s,v4.16b,v3.4b[0] ldr q4,[x1],16 sdot v20.4s,v5.16b,v0.4b[0] sdot v21.4s,v5.16b,v1.4b[0] ldr d9,[x13],8 sdot v22.4s,v5.16b,v2.4b[0] sdot v23.4s,v5.16b,v3.4b[0] ldr q5,[x1],16 sdot v24.4s,v6.16b,v0.4b[0] sdot v25.4s,v6.16b,v1.4b[0] ldr d10,[x14],8 sdot v26.4s,v6.16b,v2.4b[0] sdot v27.4s,v6.16b,v3.4b[0] ldr q6,[x1],16 sdot v28.4s,v7.16b,v0.4b[0] sdot v29.4s,v7.16b,v1.4b[0] ldr d11,[x15],8 sdot v30.4s,v7.16b,v2.4b[0] sdot v31.4s,v7.16b,v3.4b[0] ldr q7,[x1],16 sdot v16.4s,v4.16b,v0.4b[1] sdot v17.4s,v4.16b,v1.4b[1] sdot v18.4s,v4.16b,v2.4b[1] sdot v19.4s,v4.16b,v3.4b[1] ldr q4,[x1],16 sdot v20.4s,v5.16b,v0.4b[1] sdot v21.4s,v5.16b,v1.4b[1] sdot v22.4s,v5.16b,v2.4b[1] sdot v23.4s,v5.16b,v3.4b[1] ldr q5,[x1],16 sdot v24.4s,v6.16b,v0.4b[1] sdot v25.4s,v6.16b,v1.4b[1] sdot v26.4s,v6.16b,v2.4b[1] sdot v27.4s,v6.16b,v3.4b[1] ldr q6,[x1],16 sdot v28.4s,v7.16b,v0.4b[1] sdot v29.4s,v7.16b,v1.4b[1] sdot v30.4s,v7.16b,v2.4b[1] sdot v31.4s,v7.16b,v3.4b[1] eor v8.8b,v8.8b,v12.8b ldr q7,[x1],16 eor v9.8b,v9.8b,v12.8b sdot v16.4s,v4.16b,v8.4b[0] eor v10.8b,v10.8b,v12.8b sdot v17.4s,v4.16b,v9.4b[0] eor v11.8b,v11.8b,v12.8b sdot v18.4s,v4.16b,v10.4b[0] sdot v19.4s,v4.16b,v11.4b[0] ldr q4,[x1],16 sdot v20.4s,v5.16b,v8.4b[0] sdot v21.4s,v5.16b,v9.4b[0] sdot v22.4s,v5.16b,v10.4b[0] sdot v23.4s,v5.16b,v11.4b[0] ldr q5,[x1],16 sdot v24.4s,v6.16b,v8.4b[0] sdot v25.4s,v6.16b,v9.4b[0] sdot v26.4s,v6.16b,v10.4b[0] sdot v27.4s,v6.16b,v11.4b[0] ldr q6,[x1],16 sdot v28.4s,v7.16b,v8.4b[0] sdot v29.4s,v7.16b,v9.4b[0] sdot v30.4s,v7.16b,v10.4b[0] sdot v31.4s,v7.16b,v11.4b[0] ldr q7,[x1],16 sdot v16.4s,v4.16b,v8.4b[1] sdot v17.4s,v4.16b,v9.4b[1] sdot v18.4s,v4.16b,v10.4b[1] sdot v19.4s,v4.16b,v11.4b[1] sdot v20.4s,v5.16b,v8.4b[1] sdot v21.4s,v5.16b,v9.4b[1] sdot v22.4s,v5.16b,v10.4b[1] sdot v23.4s,v5.16b,v11.4b[1] sdot v24.4s,v6.16b,v8.4b[1] sdot v25.4s,v6.16b,v9.4b[1] sdot v26.4s,v6.16b,v10.4b[1] sdot v27.4s,v6.16b,v11.4b[1] sdot v28.4s,v7.16b,v8.4b[1] sdot v29.4s,v7.16b,v9.4b[1] sdot v30.4s,v7.16b,v10.4b[1] sdot v31.4s,v7.16b,v11.4b[1] TST x7,15 B.NE InChannels8 // 4 ~ 12 InputChannels subs x9,x9,8 // KernelSize-=1 b.hi KernelSizeLoop Requantize tst w10,#MLAS_CONV_SYM_FLAG_PER_CHANNEL_SCALE ldr w13,[x8,#ConvSymPostProcessParams_ZeroPoint] beq BroadcastScaleValue ldp q0,q1,[x19],32 // load scale vector ldp q2,q3,[x19],32 b AccumulatorsToFloat BroadcastScaleValue ld1r {v0.4s},[x19] // load scale Value mov v1.16b, v0.16b mov v2.16b, v0.16b mov v3.16b, v0.16b AccumulatorsToFloat scvtf v16.4s,v16.4s // convert to float scvtf v17.4s,v17.4s scvtf v18.4s,v18.4s scvtf v19.4s,v19.4s scvtf v20.4s,v20.4s scvtf v21.4s,v21.4s scvtf v22.4s,v22.4s scvtf v23.4s,v23.4s scvtf v24.4s,v24.4s scvtf v25.4s,v25.4s scvtf v26.4s,v26.4s scvtf v27.4s,v27.4s scvtf v28.4s,v28.4s scvtf v29.4s,v29.4s scvtf v30.4s,v30.4s scvtf v31.4s,v31.4s fmul v16.4s,v16.4s,v0.4s // multiply by scale fmul v17.4s,v17.4s,v0.4s fmul v18.4s,v18.4s,v0.4s fmul v19.4s,v19.4s,v0.4s fmul v20.4s,v20.4s,v1.4s fmul v21.4s,v21.4s,v1.4s fmul v22.4s,v22.4s,v1.4s fmul v23.4s,v23.4s,v1.4s fmul v24.4s,v24.4s,v2.4s fmul v25.4s,v25.4s,v2.4s fmul v26.4s,v26.4s,v2.4s fmul v27.4s,v27.4s,v2.4s fmul v28.4s,v28.4s,v3.4s fmul v29.4s,v29.4s,v3.4s fmul v30.4s,v30.4s,v3.4s fmul v31.4s,v31.4s,v3.4s fcvtns v16.4s,v16.4s // convert to int fcvtns v17.4s,v17.4s fcvtns v18.4s,v18.4s fcvtns v19.4s,v19.4s fcvtns v20.4s,v20.4s fcvtns v21.4s,v21.4s fcvtns v22.4s,v22.4s fcvtns v23.4s,v23.4s fcvtns v24.4s,v24.4s fcvtns v25.4s,v25.4s fcvtns v26.4s,v26.4s fcvtns v27.4s,v27.4s fcvtns v28.4s,v28.4s fcvtns v29.4s,v29.4s fcvtns v30.4s,v30.4s fcvtns v31.4s,v31.4s sqxtn v16.4h,v16.4s sqxtn v17.4h,v17.4s sqxtn v18.4h,v18.4s sqxtn v19.4h,v19.4s sqxtn v24.4h,v24.4s sqxtn v25.4h,v25.4s sqxtn v26.4h,v26.4s sqxtn v27.4h,v27.4s dup v4.8h,w13 // zero point sqxtn2 v16.8h,v20.4s sqxtn2 v17.8h,v21.4s sqxtn2 v18.8h,v22.4s sqxtn2 v19.8h,v23.4s sqxtn2 v24.8h,v28.4s sqxtn2 v25.8h,v29.4s sqxtn2 v26.8h,v30.4s sqxtn2 v27.8h,v31.4s sqadd v16.8h,v16.8h,v4.8h sqadd v17.8h,v17.8h,v4.8h sqadd v18.8h,v18.8h,v4.8h sqadd v19.8h,v19.8h,v4.8h sqadd v24.8h,v24.8h,v4.8h sqadd v25.8h,v25.8h,v4.8h sqadd v26.8h,v26.8h,v4.8h sqadd v27.8h,v27.8h,v4.8h sqxtun v0.8b,v16.8h sqxtun v1.8b,v17.8h sqxtun v2.8b,v18.8h sqxtun v3.8b,v19.8h sqxtun2 v0.16b,v24.8h sqxtun2 v1.16b,v25.8h subs x6,x6,16 // processed 16 output channels sqxtun2 v2.16b,v26.8h sqxtun2 v3.16b,v27.8h b.lo PartialStore st1 {v3.16b},[x5],16 // Store full 4 x 16 st1 {v2.16b},[x17],16 sub x0,x0,x3 // Restore pointer to A: a -= ks st1 {v1.16b},[x16],16 st1 {v0.16b},[x2],16 b.hi OutputChannelLoop ExitKernel EPILOG_RESTORE_REG_PAIR x19,x20,#48 EPILOG_RESTORE_REG_PAIR d12,d13,#32 EPILOG_RESTORE_REG_PAIR d10,d11,#16 EPILOG_RESTORE_REG_PAIR d8,d9,#64! EPILOG_RETURN InChannels8 tbz x7,3,InChannels4 ldr d0,[x12],8 ldr q4,[x1],16 ldr d1,[x13],8 ldr d2,[x14],8 ldr d3,[x15],8 eor v0.8b,v0.8b,v12.8b ldr q5,[x1],16 eor v1.8b,v1.8b,v12.8b sdot v16.4s,v4.16b,v0.4b[0] sdot v17.4s,v4.16b,v1.4b[0] eor v2.8b,v2.8b,v12.8b ldp q6,q7,[x1],32 eor v3.8b,v3.8b,v12.8b sdot v18.4s,v4.16b,v2.4b[0] sdot v19.4s,v4.16b,v3.4b[0] sdot v20.4s,v5.16b,v0.4b[0] sdot v21.4s,v5.16b,v1.4b[0] sdot v22.4s,v5.16b,v2.4b[0] sdot v23.4s,v5.16b,v3.4b[0] sdot v24.4s,v6.16b,v0.4b[0] sdot v25.4s,v6.16b,v1.4b[0] ldp q4,q5,[x1],32 sdot v26.4s,v6.16b,v2.4b[0] sdot v27.4s,v6.16b,v3.4b[0] sdot v28.4s,v7.16b,v0.4b[0] sdot v29.4s,v7.16b,v1.4b[0] sdot v30.4s,v7.16b,v2.4b[0] sdot v31.4s,v7.16b,v3.4b[0] sdot v16.4s,v4.16b,v0.4b[1] sdot v17.4s,v4.16b,v1.4b[1] ldp q6,q7,[x1],32 sdot v18.4s,v4.16b,v2.4b[1] sdot v19.4s,v4.16b,v3.4b[1] sdot v20.4s,v5.16b,v0.4b[1] sdot v21.4s,v5.16b,v1.4b[1] sdot v22.4s,v5.16b,v2.4b[1] sdot v23.4s,v5.16b,v3.4b[1] sdot v24.4s,v6.16b,v0.4b[1] sdot v25.4s,v6.16b,v1.4b[1] sdot v26.4s,v6.16b,v2.4b[1] sdot v27.4s,v6.16b,v3.4b[1] sdot v28.4s,v7.16b,v0.4b[1] sdot v29.4s,v7.16b,v1.4b[1] sdot v30.4s,v7.16b,v2.4b[1] sdot v31.4s,v7.16b,v3.4b[1] tbz x7,2,SkipInCh4 InChannels4 ldr s0,[x12],4 ldr q4,[x1],16 ldr s1,[x13],4 ldr s2,[x14],4 ldr s3,[x15],4 eor v0.8b,v0.8b,v12.8b ldr q5,[x1],16 eor v1.8b,v1.8b,v12.8b sdot v16.4s,v4.16b,v0.4b[0] sdot v17.4s,v4.16b,v1.4b[0] eor v2.8b,v2.8b,v12.8b ldp q6,q7,[x1],32 eor v3.8b,v3.8b,v12.8b sdot v18.4s,v4.16b,v2.4b[0] sdot v19.4s,v4.16b,v3.4b[0] sdot v20.4s,v5.16b,v0.4b[0] sdot v21.4s,v5.16b,v1.4b[0] sdot v22.4s,v5.16b,v2.4b[0] sdot v23.4s,v5.16b,v3.4b[0] sdot v24.4s,v6.16b,v0.4b[0] sdot v25.4s,v6.16b,v1.4b[0] sdot v26.4s,v6.16b,v2.4b[0] sdot v27.4s,v6.16b,v3.4b[0] sdot v28.4s,v7.16b,v0.4b[0] sdot v29.4s,v7.16b,v1.4b[0] sdot v30.4s,v7.16b,v2.4b[0] sdot v31.4s,v7.16b,v3.4b[0] SkipInCh4 subs x9,x9,8 // ks -= 1 b.hi KernelSizeLoop b Requantize PartialStore tbz x6,3,LT8Store str d3,[x5],8 // no less than 8 channels str d2,[x17],8 dup d3,v3.d[1] dup d2,v2.d[1] str d1,[x16],8 str d0,[x2],8 dup d1,v1.d[1] dup d0,v0.d[1] LT8Store tbz x6,2,LT4Store str s3,[x5],4 str s2,[x17],4 dup s3,v3.s[1] dup s2,v2.s[1] str s1,[x16],4 str s0,[x2],4 dup s1,v1.s[1] dup s0,v0.s[1] LT4Store tbz x6,1, LT2Store str h3,[x5],2 str h2,[x17],2 dup h3,v3.h[1] dup h2,v2.h[1] str h1,[x16],2 str h0,[x2],2 dup h1,v1.h[1] dup h0,v0.h[1] LT2Store tbz x6,0,ExitKernel str b3,[x5] str b2,[x17] str b1,[x16] str b0,[x2] b ExitKernel NESTED_END MlasConvSymU8KernelDot END
LMDiamondK label byte word C_BLACK Bitmap <71,100,0,BMF_MONO> db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 db 0xbc, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0 db 0xbc, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60 db 0x98, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xb0 db 0x99, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x50 db 0x9b, 0x80, 0x00, 0x08, 0x42, 0x10, 0x80, 0x0a, 0xa8 db 0x9f, 0x00, 0x00, 0x09, 0xad, 0x6a, 0x80, 0x05, 0x50 db 0x9e, 0x00, 0x00, 0x0f, 0x5e, 0xf7, 0x86, 0x66, 0xb0 db 0x9c, 0x00, 0x00, 0x0b, 0xad, 0x6a, 0x8a, 0xbb, 0x60 db 0x9e, 0x0f, 0xff, 0xf9, 0x18, 0xc4, 0xf2, 0x9d, 0xc0 db 0x9f, 0x08, 0x00, 0x05, 0x08, 0x85, 0x23, 0xbc, 0x80 db 0x9b, 0x88, 0x08, 0x06, 0x22, 0x23, 0x25, 0x9c, 0x00 db 0x99, 0xc8, 0x1c, 0x03, 0x55, 0x56, 0x44, 0xbc, 0x00 db 0x98, 0xe8, 0x36, 0x02, 0xaa, 0xaa, 0x58, 0x9b, 0x00 db 0xbc, 0xf8, 0x6b, 0x03, 0xff, 0xfe, 0x60, 0xb1, 0x80 db 0xbc, 0xf8, 0xd5, 0x82, 0x02, 0xaa, 0x58, 0x9b, 0xc0 db 0x80, 0x09, 0xaa, 0xc2, 0xc1, 0x55, 0x44, 0xbf, 0x80 db 0x80, 0x09, 0x55, 0x42, 0xb1, 0x55, 0x25, 0x9d, 0x00 db 0x80, 0x0a, 0xaa, 0xa4, 0x01, 0x55, 0x23, 0xbc, 0x00 db 0x80, 0x09, 0x55, 0x48, 0x00, 0xaa, 0x92, 0x9c, 0x00 db 0x80, 0x09, 0xaa, 0xce, 0x00, 0xaa, 0x8a, 0xbc, 0x00 db 0x80, 0x08, 0xd5, 0x83, 0x20, 0xaa, 0x86, 0x9c, 0x00 db 0x80, 0x08, 0x6b, 0x02, 0xc0, 0xaa, 0x80, 0xbc, 0x00 db 0x80, 0x08, 0x36, 0x01, 0x00, 0xaa, 0x80, 0x9c, 0x00 db 0x80, 0x08, 0x1c, 0x02, 0x00, 0xaa, 0x80, 0xbc, 0x00 db 0x80, 0x08, 0x08, 0x02, 0x0b, 0x55, 0x80, 0x9c, 0x00 db 0x80, 0x08, 0x00, 0x03, 0x56, 0xaa, 0x80, 0xbc, 0x00 db 0x80, 0x08, 0x00, 0x12, 0xaa, 0x2a, 0x80, 0x9c, 0x00 db 0x80, 0x08, 0x00, 0x35, 0x55, 0xdf, 0x78, 0xbc, 0x00 db 0x80, 0x28, 0x00, 0x1a, 0xa8, 0x00, 0x1e, 0x9c, 0x00 db 0x80, 0x54, 0x00, 0x6f, 0x15, 0x55, 0x27, 0xbc, 0x00 db 0x80, 0x2a, 0x83, 0x90, 0x2c, 0xaa, 0xa5, 0x9c, 0x00 db 0x80, 0x55, 0x4d, 0x08, 0x40, 0x01, 0x50, 0xfc, 0x00 db 0x80, 0x2a, 0xbd, 0x29, 0xb7, 0xf2, 0x62, 0x7c, 0x00 db 0x80, 0x54, 0x76, 0x86, 0xaf, 0xf4, 0xf8, 0xbc, 0x00 db 0x80, 0x28, 0xda, 0x95, 0x9e, 0xf2, 0xfc, 0x3c, 0x00 db 0x80, 0x11, 0xdd, 0x84, 0x3d, 0x65, 0xfe, 0x9c, 0x00 db 0x80, 0x0b, 0x5b, 0x52, 0xee, 0xe9, 0x3f, 0x18, 0x00 db 0x80, 0x0f, 0xdd, 0x43, 0xd7, 0xe5, 0xcf, 0xb8, 0x00 db 0x80, 0x0d, 0x1b, 0x4b, 0xef, 0xca, 0xf7, 0x98, 0x00 db 0x80, 0x0f, 0x35, 0x43, 0xff, 0xd6, 0x97, 0xd0, 0x00 db 0x80, 0x08, 0x7a, 0x53, 0xff, 0xce, 0xfb, 0xd0, 0x00 db 0x80, 0x0f, 0xf6, 0x46, 0xaa, 0xde, 0x85, 0xe0, 0x00 db 0x80, 0x0f, 0xac, 0x4f, 0xff, 0xba, 0xfd, 0xe0, 0x00 db 0x80, 0x0d, 0x58, 0x5f, 0xff, 0xf4, 0x8d, 0xe0, 0x00 db 0x80, 0x0a, 0xb2, 0x7a, 0x00, 0xe4, 0xf5, 0xe0, 0x00 db 0x80, 0x0f, 0xc2, 0x73, 0x55, 0xcc, 0xc5, 0xe0, 0x00 db 0x80, 0x0f, 0x46, 0x66, 0xaa, 0x9c, 0x87, 0xe0, 0x00 db 0x80, 0x0f, 0x5e, 0x4e, 0x00, 0xbc, 0x9a, 0xa0, 0x00 db 0x80, 0x0f, 0x62, 0x5f, 0xff, 0xf4, 0x35, 0x60, 0x00 db 0x80, 0x0f, 0x7e, 0xbb, 0xff, 0xe4, 0x6b, 0xe0, 0x00 db 0x80, 0x0f, 0x42, 0xf6, 0xaa, 0xc4, 0xdf, 0xe0, 0x00 db 0x80, 0x17, 0xbe, 0xe7, 0xff, 0x94, 0xbc, 0x20, 0x00 db 0x80, 0x17, 0xd2, 0xd7, 0xff, 0x85, 0x59, 0xe0, 0x00 db 0x80, 0x33, 0xde, 0xa7, 0xef, 0xa5, 0xb1, 0x60, 0x00 db 0x80, 0x3b, 0xe7, 0x4f, 0xd7, 0x85, 0x77, 0xe0, 0x00 db 0x80, 0x31, 0xf9, 0x2e, 0xee, 0x95, 0xb5, 0xa0, 0x00 db 0x80, 0x32, 0xff, 0x4d, 0x78, 0x43, 0x77, 0x10, 0x00 db 0x80, 0x18, 0x7e, 0x9e, 0xf3, 0x52, 0xb6, 0x2c, 0x00 db 0x80, 0x1a, 0x3e, 0x5f, 0xea, 0xc2, 0xdc, 0x56, 0x00 db 0x80, 0x18, 0x8c, 0x9f, 0xdb, 0x29, 0x7a, 0xaf, 0x00 db 0x80, 0x16, 0x15, 0x00, 0x04, 0x21, 0x65, 0x56, 0x00 db 0x80, 0x17, 0x4a, 0xaa, 0x68, 0x13, 0x82, 0xaf, 0x00 db 0x80, 0x13, 0xc9, 0x55, 0x51, 0xec, 0x00, 0x56, 0x00 db 0x80, 0x16, 0xf0, 0x00, 0x2a, 0xb0, 0x00, 0x2e, 0x00 db 0x80, 0x12, 0x3d, 0xf7, 0x55, 0x48, 0x00, 0x2c, 0x00 db 0x80, 0x16, 0x02, 0xa8, 0xaa, 0x90, 0x00, 0x20, 0x00 db 0x80, 0x12, 0x02, 0xaa, 0xd5, 0x80, 0x00, 0x20, 0x00 db 0x80, 0x16, 0x03, 0x55, 0xa0, 0x80, 0x20, 0x20, 0x00 db 0x80, 0x12, 0x02, 0xaa, 0x00, 0x80, 0x70, 0x20, 0x00 db 0x80, 0x16, 0x02, 0xaa, 0x01, 0x00, 0xd8, 0x20, 0x00 db 0x80, 0x12, 0x02, 0xaa, 0x06, 0x81, 0xac, 0x20, 0x00 db 0x80, 0x16, 0xc2, 0xaa, 0x09, 0x83, 0x56, 0x20, 0x00 db 0x80, 0x12, 0xa2, 0xaa, 0x00, 0xe6, 0xab, 0x20, 0x00 db 0x80, 0x16, 0x92, 0xaa, 0x00, 0x25, 0x55, 0x20, 0x00 db 0x80, 0x13, 0x89, 0x55, 0x00, 0x4a, 0xaa, 0xa0, 0x00 db 0x80, 0x17, 0x49, 0x55, 0x1a, 0x85, 0x55, 0x20, 0x00 db 0x80, 0x52, 0x45, 0x55, 0x06, 0x86, 0xab, 0x20, 0x00 db 0x80, 0xb6, 0x34, 0xaa, 0x80, 0x83, 0x56, 0x3e, 0x78 db 0x81, 0x12, 0x0c, 0xff, 0xff, 0x81, 0xac, 0x3e, 0x78 db 0x80, 0xb6, 0x34, 0xa2, 0x22, 0x80, 0xd8, 0x2e, 0x30 db 0x80, 0x52, 0x44, 0xd5, 0x55, 0x80, 0x70, 0x27, 0x30 db 0x80, 0x17, 0x49, 0x88, 0x88, 0xc0, 0x20, 0x23, 0xb0 db 0x82, 0x13, 0x89, 0x42, 0x21, 0x40, 0x00, 0x21, 0xf0 db 0x87, 0x17, 0xde, 0x46, 0x31, 0x3f, 0xff, 0xe0, 0xf0 db 0x8d, 0x93, 0xbe, 0xef, 0x7b, 0xf8, 0x00, 0x00, 0x70 db 0x9a, 0xcf, 0xfb, 0xff, 0xff, 0xfe, 0x00, 0x00, 0xf0 db 0x95, 0x43, 0x32, 0x7f, 0xff, 0xe4, 0x00, 0x01, 0xf0 db 0xaa, 0xa0, 0x02, 0x72, 0x94, 0xac, 0x00, 0x03, 0xb0 db 0x95, 0x40, 0x00, 0xc7, 0x39, 0xc6, 0x00, 0x07, 0x30 db 0x9a, 0xc0, 0x00, 0x42, 0x10, 0x84, 0x00, 0x0e, 0x30 db 0x8d, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x78 db 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x78 db 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
//================================================================================================= /*! // \file src/mathtest/operations/smatsmatmult/UCaUCb.cpp // \brief Source file for the UCaUCb sparse matrix/sparse matrix multiplication math test // // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/CompressedMatrix.h> #include <blaze/math/UpperMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/operations/smatsmatmult/OperationTest.h> #include <blazetest/system/MathTest.h> #ifdef BLAZE_USE_HPX_THREADS # include <hpx/hpx_main.hpp> #endif //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'UCaUCb'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions using UCa = blaze::UpperMatrix< blaze::CompressedMatrix<TypeA> >; using UCb = blaze::UpperMatrix< blaze::CompressedMatrix<TypeB> >; // Creator type definitions using CUCa = blazetest::Creator<UCa>; using CUCb = blazetest::Creator<UCb>; // Running tests with small matrices for( size_t i=0UL; i<=6UL; ++i ) { RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0UL ), CUCb( i, 0UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0UL ), CUCb( i, 0.2*i*i ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0UL ), CUCb( i, 0.5*i*i ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.2*i*i ), CUCb( i, 0UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.2*i*i ), CUCb( i, 0.2*i*i ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.2*i*i ), CUCb( i, 0.5*i*i ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.5*i*i ), CUCb( i, 0UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.5*i*i ), CUCb( i, 0.2*i*i ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( i, 0.5*i*i ), CUCb( i, 0.5*i*i ) ); } // Running tests with large matrices RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 15UL, 7UL ), CUCb( 15UL, 7UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 37UL, 7UL ), CUCb( 37UL, 7UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 63UL, 7UL ), CUCb( 63UL, 7UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 16UL, 8UL ), CUCb( 16UL, 8UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 32UL, 8UL ), CUCb( 32UL, 8UL ) ); RUN_SMATSMATMULT_OPERATION_TEST( CUCa( 64UL, 16UL ), CUCb( 64UL, 16UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during sparse matrix/sparse matrix multiplication:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
// RH_RF95.cpp // // Copyright (C) 2011 Mike McCauley // $Id: RH_RF95.cpp,v 1.19 2018/09/23 23:54:01 mikem Exp $ #include <RH_RF95.h> // Interrupt vectors for the 3 Arduino interrupt pins // Each interrupt can be handled by a different instance of RH_RF95, allowing you to have // 2 or more LORAs per Arduino RH_RF95* RH_RF95::_deviceForInterrupt[RH_RF95_NUM_INTERRUPTS] = {0, 0, 0}; uint8_t RH_RF95::_interruptCount = 0; // Index into _deviceForInterrupt for next device // These are indexed by the values of ModemConfigChoice // Stored in flash (program) memory to save SRAM PROGMEM static const RH_RF95::ModemConfig MODEM_CONFIG_TABLE[] = { // 1d, 1e, 26 { 0x72, 0x74, 0x04}, // Bw125Cr45Sf128 (the chip default), AGC enabled { 0x92, 0x74, 0x04}, // Bw500Cr45Sf128, AGC enabled { 0x48, 0x94, 0x04}, // Bw31_25Cr48Sf512, AGC enabled { 0x78, 0xc4, 0x0c}, // Bw125Cr48Sf4096, AGC enabled }; RH_RF95::RH_RF95(uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI& spi) : RHSPIDriver(slaveSelectPin, spi), _rxBufValid(0) { _interruptPin = interruptPin; _myInterruptIndex = 0xff; // Not allocated yet } bool RH_RF95::init() { if (!RHSPIDriver::init()) return false; // Determine the interrupt number that corresponds to the interruptPin int interruptNumber = digitalPinToInterrupt(_interruptPin); if (interruptNumber == NOT_AN_INTERRUPT) return false; #ifdef RH_ATTACHINTERRUPT_TAKES_PIN_NUMBER interruptNumber = _interruptPin; #endif // Tell the low level SPI interface we will use SPI within this interrupt spiUsingInterrupt(interruptNumber); // No way to check the device type :-( // Set sleep mode, so we can also set LORA mode: spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE); delay(10); // Wait for sleep mode to take over from say, CAD // Check we are in sleep mode, with LORA set if (spiRead(RH_RF95_REG_01_OP_MODE) != (RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE)) { // Serial.println(spiRead(RH_RF95_REG_01_OP_MODE), HEX); return false; // No device present? } // Add by Adrien van den Bossche <vandenbo@univ-tlse2.fr> for Teensy // ARM M4 requires the below. else pin interrupt doesn't work properly. // On all other platforms, its innocuous, belt and braces pinMode(_interruptPin, INPUT); // Set up interrupt handler // Since there are a limited number of interrupt glue functions isr*() available, // we can only support a limited number of devices simultaneously // ON some devices, notably most Arduinos, the interrupt pin passed in is actuallt the // interrupt number. You have to figure out the interruptnumber-to-interruptpin mapping // yourself based on knwledge of what Arduino board you are running on. if (_myInterruptIndex == 0xff) { // First run, no interrupt allocated yet if (_interruptCount <= RH_RF95_NUM_INTERRUPTS) _myInterruptIndex = _interruptCount++; else return false; // Too many devices, not enough interrupt vectors } _deviceForInterrupt[_myInterruptIndex] = this; if (_myInterruptIndex == 0) attachInterrupt(interruptNumber, isr0, RISING); else if (_myInterruptIndex == 1) attachInterrupt(interruptNumber, isr1, RISING); else if (_myInterruptIndex == 2) attachInterrupt(interruptNumber, isr2, RISING); else return false; // Too many devices, not enough interrupt vectors // Set up FIFO // We configure so that we can use the entire 256 byte FIFO for either receive // or transmit, but not both at the same time spiWrite(RH_RF95_REG_0E_FIFO_TX_BASE_ADDR, 0); spiWrite(RH_RF95_REG_0F_FIFO_RX_BASE_ADDR, 0); // Packet format is preamble + explicit-header + payload + crc // Explicit Header Mode // payload is TO + FROM + ID + FLAGS + message data // RX mode is implmented with RXCONTINUOUS // max message data length is 255 - 4 = 251 octets setModeIdle(); // Set up default configuration // No Sync Words in LORA mode. setModemConfig(Bw125Cr45Sf128); // Radio default // setModemConfig(Bw125Cr48Sf4096); // slow and reliable? setPreambleLength(8); // Default is 8 // An innocuous ISM frequency, same as RF22's setFrequency(434.0); // Lowish power setTxPower(13); return true; } // C++ level interrupt handler for this instance // LORA is unusual in that it has several interrupt lines, and not a single, combined one. // On MiniWirelessLoRa, only one of the several interrupt lines (DI0) from the RFM95 is usefuly // connnected to the processor. // We use this to get RxDone and TxDone interrupts void RH_RF95::handleInterrupt() { // Read the interrupt register uint8_t irq_flags = spiRead(RH_RF95_REG_12_IRQ_FLAGS); // Read the RegHopChannel register to check if CRC presence is signalled // in the header. If not it might be a stray (noise) packet.* uint8_t crc_present = spiRead(RH_RF95_REG_1C_HOP_CHANNEL); if (_mode == RHModeRx && ((irq_flags & (RH_RF95_RX_TIMEOUT | RH_RF95_PAYLOAD_CRC_ERROR)) | !(crc_present & RH_RF95_RX_PAYLOAD_CRC_IS_ON))) // if (_mode == RHModeRx && irq_flags & (RH_RF95_RX_TIMEOUT | RH_RF95_PAYLOAD_CRC_ERROR)) { _rxBad++; } else if (_mode == RHModeRx && irq_flags & RH_RF95_RX_DONE) { // Have received a packet uint8_t len = spiRead(RH_RF95_REG_13_RX_NB_BYTES); // Reset the fifo read ptr to the beginning of the packet spiWrite(RH_RF95_REG_0D_FIFO_ADDR_PTR, spiRead(RH_RF95_REG_10_FIFO_RX_CURRENT_ADDR)); spiBurstRead(RH_RF95_REG_00_FIFO, _buf, len); _bufLen = len; spiWrite(RH_RF95_REG_12_IRQ_FLAGS, 0xff); // Clear all IRQ flags // Remember the last signal to noise ratio, LORA mode // Per page 111, SX1276/77/78/79 datasheet _lastSNR = (int8_t)spiRead(RH_RF95_REG_19_PKT_SNR_VALUE) / 4; // Remember the RSSI of this packet, LORA mode // this is according to the doc, but is it really correct? // weakest receiveable signals are reported RSSI at about -66 _lastRssi = spiRead(RH_RF95_REG_1A_PKT_RSSI_VALUE); // Adjust the RSSI, datasheet page 87 if (_lastSNR < 0) _lastRssi = _lastRssi + _lastSNR; else _lastRssi = (int)_lastRssi * 16 / 15; if (_usingHFport) _lastRssi -= 157; else _lastRssi -= 164; // We have received a message. validateRxBuf(); if (_rxBufValid) setModeIdle(); // Got one } else if (_mode == RHModeTx && irq_flags & RH_RF95_TX_DONE) { _txGood++; setModeIdle(); } else if (_mode == RHModeCad && irq_flags & RH_RF95_CAD_DONE) { _cad = irq_flags & RH_RF95_CAD_DETECTED; setModeIdle(); } // Sigh: on some processors, for some unknown reason, doing this only once does not actually // clear the radio's interrupt flag. So we do it twice. Why? spiWrite(RH_RF95_REG_12_IRQ_FLAGS, 0xff); // Clear all IRQ flags spiWrite(RH_RF95_REG_12_IRQ_FLAGS, 0xff); // Clear all IRQ flags } // These are low level functions that call the interrupt handler for the correct // instance of RH_RF95. // 3 interrupts allows us to have 3 different devices void RH_RF95::isr0() { if (_deviceForInterrupt[0]) _deviceForInterrupt[0]->handleInterrupt(); } void RH_RF95::isr1() { if (_deviceForInterrupt[1]) _deviceForInterrupt[1]->handleInterrupt(); } void RH_RF95::isr2() { if (_deviceForInterrupt[2]) _deviceForInterrupt[2]->handleInterrupt(); } // Check whether the latest received message is complete and uncorrupted void RH_RF95::validateRxBuf() { if (_bufLen < 4) return; // Too short to be a real message // Extract the 4 headers _rxHeaderTo = _buf[0]; _rxHeaderFrom = _buf[1]; _rxHeaderId = _buf[2]; _rxHeaderFlags = _buf[3]; if (_promiscuous || _rxHeaderTo == _thisAddress || _rxHeaderTo == RH_BROADCAST_ADDRESS) { _rxGood++; _rxBufValid = true; } } bool RH_RF95::available() { if (_mode == RHModeTx) return false; setModeRx(); return _rxBufValid; // Will be set by the interrupt handler when a good message is received } void RH_RF95::clearRxBuf() { ATOMIC_BLOCK_START; _rxBufValid = false; _bufLen = 0; ATOMIC_BLOCK_END; } bool RH_RF95::recv(uint8_t* buf, uint8_t* len) { if (!available()) return false; if (buf && len) { ATOMIC_BLOCK_START; // Skip the 4 headers that are at the beginning of the rxBuf if (*len > _bufLen-RH_RF95_HEADER_LEN) *len = _bufLen-RH_RF95_HEADER_LEN; memcpy(buf, _buf+RH_RF95_HEADER_LEN, *len); ATOMIC_BLOCK_END; } clearRxBuf(); // This message accepted and cleared return true; } bool RH_RF95::send(const uint8_t* data, uint8_t len) { if (len > RH_RF95_MAX_MESSAGE_LEN) return false; waitPacketSent(); // Make sure we dont interrupt an outgoing message setModeIdle(); if (!waitCAD()) return false; // Check channel activity // Position at the beginning of the FIFO spiWrite(RH_RF95_REG_0D_FIFO_ADDR_PTR, 0); // The headers spiWrite(RH_RF95_REG_00_FIFO, _txHeaderTo); spiWrite(RH_RF95_REG_00_FIFO, _txHeaderFrom); spiWrite(RH_RF95_REG_00_FIFO, _txHeaderId); spiWrite(RH_RF95_REG_00_FIFO, _txHeaderFlags); // The message data spiBurstWrite(RH_RF95_REG_00_FIFO, data, len); spiWrite(RH_RF95_REG_22_PAYLOAD_LENGTH, len + RH_RF95_HEADER_LEN); setModeTx(); // Start the transmitter // when Tx is done, interruptHandler will fire and radio mode will return to STANDBY return true; } bool RH_RF95::printRegisters() { #ifdef RH_HAVE_SERIAL uint8_t registers[] = { 0x01, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x014, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27}; uint8_t i; for (i = 0; i < sizeof(registers); i++) { Serial.print(registers[i], HEX); Serial.print(": "); Serial.println(spiRead(registers[i]), HEX); } #endif return true; } uint8_t RH_RF95::maxMessageLength() { return RH_RF95_MAX_MESSAGE_LEN; } bool RH_RF95::setFrequency(float centre) { // Frf = FRF / FSTEP uint32_t frf = (centre * 1000000.0) / RH_RF95_FSTEP; spiWrite(RH_RF95_REG_06_FRF_MSB, (frf >> 16) & 0xff); spiWrite(RH_RF95_REG_07_FRF_MID, (frf >> 8) & 0xff); spiWrite(RH_RF95_REG_08_FRF_LSB, frf & 0xff); _usingHFport = (centre >= 779.0); return true; } void RH_RF95::setModeIdle() { if (_mode != RHModeIdle) { spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_STDBY); _mode = RHModeIdle; } } bool RH_RF95::sleep() { if (_mode != RHModeSleep) { spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP); _mode = RHModeSleep; } return true; } void RH_RF95::setModeRx() { if (_mode != RHModeRx) { spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_RXCONTINUOUS); spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x00); // Interrupt on RxDone _mode = RHModeRx; } } void RH_RF95::setModeTx() { if (_mode != RHModeTx) { spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_TX); spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x40); // Interrupt on TxDone _mode = RHModeTx; } } void RH_RF95::setTxPower(int8_t power, bool useRFO) { // Sigh, different behaviours depending on whther the module use PA_BOOST or the RFO pin // for the transmitter output if (useRFO) { if (power > 14) power = 14; if (power < -1) power = -1; spiWrite(RH_RF95_REG_09_PA_CONFIG, RH_RF95_MAX_POWER | (power + 1)); } else { if (power > 23) power = 23; if (power < 5) power = 5; // For RH_RF95_PA_DAC_ENABLE, manual says '+20dBm on PA_BOOST when OutputPower=0xf' // RH_RF95_PA_DAC_ENABLE actually adds about 3dBm to all power levels. We will us it // for 21, 22 and 23dBm if (power > 20) { spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_ENABLE); power -= 3; } else { spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_DISABLE); } // RFM95/96/97/98 does not have RFO pins connected to anything. Only PA_BOOST // pin is connected, so must use PA_BOOST // Pout = 2 + OutputPower. // The documentation is pretty confusing on this topic: PaSelect says the max power is 20dBm, // but OutputPower claims it would be 17dBm. // My measurements show 20dBm is correct spiWrite(RH_RF95_REG_09_PA_CONFIG, RH_RF95_PA_SELECT | (power-5)); } } // Sets registers from a canned modem configuration structure void RH_RF95::setModemRegisters(const ModemConfig* config) { spiWrite(RH_RF95_REG_1D_MODEM_CONFIG1, config->reg_1d); spiWrite(RH_RF95_REG_1E_MODEM_CONFIG2, config->reg_1e); spiWrite(RH_RF95_REG_26_MODEM_CONFIG3, config->reg_26); } // Set one of the canned FSK Modem configs // Returns true if its a valid choice bool RH_RF95::setModemConfig(ModemConfigChoice index) { if (index > (signed int)(sizeof(MODEM_CONFIG_TABLE) / sizeof(ModemConfig))) return false; ModemConfig cfg; memcpy_P(&cfg, &MODEM_CONFIG_TABLE[index], sizeof(RH_RF95::ModemConfig)); setModemRegisters(&cfg); return true; } void RH_RF95::setPreambleLength(uint16_t bytes) { spiWrite(RH_RF95_REG_20_PREAMBLE_MSB, bytes >> 8); spiWrite(RH_RF95_REG_21_PREAMBLE_LSB, bytes & 0xff); } bool RH_RF95::isChannelActive() { // Set mode RHModeCad if (_mode != RHModeCad) { spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_CAD); spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x80); // Interrupt on CadDone _mode = RHModeCad; } while (_mode == RHModeCad) YIELD; return _cad; } void RH_RF95::enableTCXO() { while ((spiRead(RH_RF95_REG_4B_TCXO) & RH_RF95_TCXO_TCXO_INPUT_ON) != RH_RF95_TCXO_TCXO_INPUT_ON) { sleep(); spiWrite(RH_RF95_REG_4B_TCXO, (spiRead(RH_RF95_REG_4B_TCXO) | RH_RF95_TCXO_TCXO_INPUT_ON)); } } // From section 4.1.5 of SX1276/77/78/79 // Ferror = FreqError * 2**24 * BW / Fxtal / 500 int RH_RF95::frequencyError() { int32_t freqerror = 0; // Convert 2.5 bytes (5 nibbles, 20 bits) to 32 bit signed int // Caution: some C compilers make errors with eg: // freqerror = spiRead(RH_RF95_REG_28_FEI_MSB) << 16 // so we go more carefully. freqerror = spiRead(RH_RF95_REG_28_FEI_MSB); freqerror <<= 8; freqerror |= spiRead(RH_RF95_REG_29_FEI_MID); freqerror <<= 8; freqerror |= spiRead(RH_RF95_REG_2A_FEI_LSB); // Sign extension into top 3 nibbles if (freqerror & 0x80000) freqerror |= 0xfff00000; int error = 0; // In hertz float bw_tab[] = {7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500}; uint8_t bwindex = spiRead(RH_RF95_REG_1D_MODEM_CONFIG1) >> 4; if (bwindex < (sizeof(bw_tab) / sizeof(float))) error = (float)freqerror * bw_tab[bwindex] * ((float)(1L << 24) / (float)RH_RF95_FXOSC / 500.0); // else not defined return error; } int RH_RF95::lastSNR() { return _lastSNR; } /////////////////////////////////////////////////// // // additions below by Brian Norman 9th Nov 2018 // brian.n.norman@gmail.com // // Routines intended to make changing BW, SF and CR // a bit more intuitive // /////////////////////////////////////////////////// void RH_RF95::setSpreadingFactor(uint8_t sf) { if (sf <= 6) sf = RH_RF95_SPREADING_FACTOR_64CPS; else if (sf == 7) sf = RH_RF95_SPREADING_FACTOR_128CPS; else if (sf == 8) sf = RH_RF95_SPREADING_FACTOR_256CPS; else if (sf == 9) sf = RH_RF95_SPREADING_FACTOR_512CPS; else if (sf == 10) sf = RH_RF95_SPREADING_FACTOR_1024CPS; else if (sf == 11) sf = RH_RF95_SPREADING_FACTOR_2048CPS; else if (sf >= 12) sf = RH_RF95_SPREADING_FACTOR_4096CPS; // set the new spreading factor spiWrite(RH_RF95_REG_1E_MODEM_CONFIG2, (spiRead(RH_RF95_REG_1E_MODEM_CONFIG2) & ~RH_RF95_SPREADING_FACTOR) | sf); // check if Low data Rate bit should be set or cleared setLowDatarate(); } void RH_RF95::setSignalBandwidth(long sbw) { uint8_t bw; //register bit pattern if (sbw <= 7800) bw = RH_RF95_BW_7_8KHZ; else if (sbw <= 10400) bw = RH_RF95_BW_10_4KHZ; else if (sbw <= 15600) bw = RH_RF95_BW_15_6KHZ ; else if (sbw <= 20800) bw = RH_RF95_BW_20_8KHZ; else if (sbw <= 31250) bw = RH_RF95_BW_31_25KHZ; else if (sbw <= 41700) bw = RH_RF95_BW_41_7KHZ; else if (sbw <= 62500) bw = RH_RF95_BW_62_5KHZ; else if (sbw <= 125000) bw = RH_RF95_BW_125KHZ; else if (sbw <= 250000) bw = RH_RF95_BW_250KHZ; else bw = RH_RF95_BW_500KHZ; // top 4 bits of reg 1D control bandwidth spiWrite(RH_RF95_REG_1D_MODEM_CONFIG1, (spiRead(RH_RF95_REG_1D_MODEM_CONFIG1) & ~RH_RF95_BW) | bw); // check if low data rate bit should be set or cleared setLowDatarate(); } void RH_RF95::setCodingRate4(uint8_t denominator) { int cr; if (denominator <= 5) cr=RH_RF95_CODING_RATE_4_5; else if (denominator == 6) cr = RH_RF95_CODING_RATE_4_6; else if (denominator == 7) cr = RH_RF95_CODING_RATE_4_7; else if (denominator >= 8) cr = RH_RF95_CODING_RATE_4_8; // CR is bits 3..1 of RH_RF95_REG_1D_MODEM_CONFIG1 spiWrite(RH_RF95_REG_1D_MODEM_CONFIG1, (spiRead(RH_RF95_REG_1D_MODEM_CONFIG1) & ~RH_RF95_CODING_RATE) | cr); } void RH_RF95::setLowDatarate() { // called after changing bandwidth and/or spreading factor // Semtech modem design guide AN1200.13 says // "To avoid issues surrounding drift of the crystal reference oscillator due to either temperature change // or motion,the low data rate optimization bit is used. Specifically for 125 kHz bandwidth and SF = 11 and 12, // this adds a small overhead to increase robustness to reference frequency variations over the timescale of the LoRa packet." // read current value for BW and SF uint8_t BW = spiRead(RH_RF95_REG_1D_MODEM_CONFIG1) >> 4; // bw is in bits 7..4 uint8_t SF = spiRead(RH_RF95_REG_1E_MODEM_CONFIG2) >> 4; // sf is in bits 7..4 // calculate symbol time (see Semtech AN1200.22 section 4) float bw_tab[] = {7800, 10400, 15600, 20800, 31250, 41700, 62500, 125000, 250000, 500000}; float bandwidth = bw_tab[BW]; float symbolTime = 1000.0 * pow(2, SF) / bandwidth; // ms // the symbolTime for SF 11 BW 125 is 16.384ms. // and, according to this :- // https://www.thethingsnetwork.org/forum/t/a-point-to-note-lora-low-data-rate-optimisation-flag/12007 // the LDR bit should be set if the Symbol Time is > 16ms // So the threshold used here is 16.0ms // the LDR is bit 3 of RH_RF95_REG_26_MODEM_CONFIG3 uint8_t current = spiRead(RH_RF95_REG_26_MODEM_CONFIG3) & ~RH_RF95_LOW_DATA_RATE_OPTIMIZE; // mask off the LDR bit if (symbolTime > 16.0) spiWrite(RH_RF95_REG_26_MODEM_CONFIG3, current | RH_RF95_LOW_DATA_RATE_OPTIMIZE); else spiWrite(RH_RF95_REG_26_MODEM_CONFIG3, current); } void RH_RF95::setPayloadCRC(bool on) { // Payload CRC is bit 2 of register 1E uint8_t current = spiRead(RH_RF95_REG_1E_MODEM_CONFIG2) & ~RH_RF95_PAYLOAD_CRC_ON; // mask off the CRC if (on) spiWrite(RH_RF95_REG_1E_MODEM_CONFIG2, current | RH_RF95_PAYLOAD_CRC_ON); else spiWrite(RH_RF95_REG_1E_MODEM_CONFIG2, current); }
Name: Pause-p.asm Type: file Size: 45691 Last-Modified: '1992-07-29T15:00:00Z' SHA-1: 2551DE977DA0715564E8835295DB1CAA14AB56E6 Description: null
; A108679: a(n) = (n+1)*(n+2)^2*(n+3)^2*(n+4)^2*(n+5)^2*(n+6)/86400. ; 1,21,196,1176,5292,19404,60984,169884,429429,1002001,2186184,4504864,8836464,16604784,30046752,52581816,89311761,147685461,238369516,376372920,582481900,885069900,1322357400,1945206900,2820550005,4035556161,5702666256,7965629056,11006694336,15055133632,20397277824,27388280304,36465835329,48166103349,63142118676,82184979864,106248149644,136475219244,174231521464,221140008012,279121839381,350442170001,437761647576,544194183456,673371590640,829515727600,1017518829600,1243032754600,1512567918225 mov $1,4 mov $2,$0 add $2,6 sub $1,$2 bin $1,4 bin $2,$0 mul $1,$2 mov $0,$1 div $0,5
#include <PCP/Curvature/GlobalEstimationData.h> #include <PCP/Common/Log.h> #include <fstream> namespace pcp { GlobalEstimationData::GlobalEstimationData(int size) : m_data(size) { } bool GlobalEstimationData::load(const std::string& filename) { this->clear(); std::ifstream ifs(filename); if(!ifs.is_open()) { warning() << "Failed to open input file " << filename; return false; } Scalar k1; Scalar k2; Scalar H; Scalar nx; Scalar ny; Scalar nz; Scalar dir1x; Scalar dir1y; Scalar dir1z; Scalar dir2x; Scalar dir2y; Scalar dir2z; int nei_count; Scalar time_ms; std::string str_k1; std::string str_k2; std::string str_H; std::string str_nx; std::string str_ny; std::string str_nz; std::string str_dir1x; std::string str_dir1y; std::string str_dir1z; std::string str_dir2x; std::string str_dir2y; std::string str_dir2z; std::string str_nei_count; std::string str_time_ms; std::string line; int line_count = 0; int cmt_count = 0; while(std::getline(ifs, line)) { std::stringstream str(line); bool ok = str >> str_k1 && str >> str_k2 && str >> str_H && str >> str_nx && str >> str_ny && str >> str_nz && str >> str_dir1x && str >> str_dir1y && str >> str_dir1z && str >> str_dir2x && str >> str_dir2y && str >> str_dir2z && str >> str_nei_count && str >> str_time_ms; if(!ok) { error() << "Failed to read line " << line_count+1 << " from file " << filename; } else { if (str_k1 != "#") { k1 = std::stof(str_k1 ); k2 = std::stof(str_k2 ); H = std::stof(str_H ); nx = std::stof(str_nx ); ny = std::stof(str_ny ); nz = std::stof(str_nz ); dir1x = std::stof(str_dir1x); dir1y = std::stof(str_dir1y); dir1z = std::stof(str_dir1z); dir2x = std::stof(str_dir2x); dir2y = std::stof(str_dir2y); dir2z = std::stof(str_dir2z); nei_count = std::stoi(str_nei_count); time_ms = std::stof(str_time_ms); if(std::isnan(k1 ) || std::isinf(k1 ) || std::isnan(k2 ) || std::isinf(k2 ) || std::isnan(H ) || std::isinf(H ) || std::isnan(nx ) || std::isinf(nx ) || std::isnan(ny ) || std::isinf(ny ) || std::isnan(nz ) || std::isinf(nz ) || std::isnan(dir1x) || std::isinf(dir1x) || std::isnan(dir1y) || std::isinf(dir1y) || std::isnan(dir1z) || std::isinf(dir1z) || std::isnan(dir2x) || std::isinf(dir2x) || std::isnan(dir2y) || std::isinf(dir2y) || std::isnan(dir2z) || std::isinf(dir2z) || std::isnan(nei_count) || std::isinf(nei_count) || std::isnan(time_ms) || std::isinf(time_ms) ) { warning() << "Nan/Inf values read at " << filename << ":" << line_count+1; } this->push_back(k1, k2, H, Vector3(dir1x, dir1y, dir1z), Vector3(dir2x, dir2y, dir2z), Vector3(nx, ny, nz), nei_count, time_ms); } else ++cmt_count; } ++line_count; } info() << this->size() << " estimations data loaded from " << filename; return true; } bool GlobalEstimationData::save(const std::string& filename) const { std::ofstream ofs(filename); if(!ofs.is_open()) { warning() << "Failed to open output file " << filename; return false; } ofs << "# k1 k2 Mean_Curvature nx ny nz d1x d1y d1z d2x d2y d2z nei time\n"; for(int i=0; i<this->size(); ++i) { ofs << m_data[i].m_k1 << " " << m_data[i].m_k2 << " " << m_data[i].m_H << " " << m_data[i].m_N.x() << " " << m_data[i].m_N.y() << " " << m_data[i].m_N.z() << " " << m_data[i].m_dir1.x() << " " << m_data[i].m_dir1.y() << " " << m_data[i].m_dir1.z() << " " << m_data[i].m_dir2.x() << " " << m_data[i].m_dir2.y() << " " << m_data[i].m_dir2.z() << " " << m_data[i].m_nei_count << " " << m_data[i].m_time_ms << "\n"; } info() << this->size() << " estimations data saved to " << filename; return true; } void GlobalEstimationData::clear() { m_data.clear(); } void GlobalEstimationData::resize(int size) { m_data.resize(size); } void GlobalEstimationData::push_back(Scalar k1, Scalar k2, Scalar H, const Vector3& dir1, const Vector3& dir2, const Vector3& normal, int nei_count, Scalar time_ms) { m_data.push_back(PointWiseEstimationData(k1, k2, H, normal, dir1, dir2, nei_count, time_ms)); } int GlobalEstimationData::size() const { return m_data.size(); } const PointWiseEstimationData& GlobalEstimationData::operator[](int i) const { return m_data[i]; } PointWiseEstimationData& GlobalEstimationData::operator[](int i) { return m_data[i]; } Scalar GlobalEstimationData::k1(int i) const { return m_data[i].m_k1; } Scalar GlobalEstimationData::k2(int i) const { return m_data[i].m_k2; } const Vector3& GlobalEstimationData::dir1(int i) const { return m_data[i].m_dir1; } const Vector3& GlobalEstimationData::dir2(int i) const { return m_data[i].m_dir2; } const Vector3& GlobalEstimationData::normal(int i) const { return m_data[i].m_N; } int GlobalEstimationData::nei_count(int i) const { return m_data[i].m_nei_count; } Scalar GlobalEstimationData::time_ms(int i) const { return m_data[i].m_time_ms; } Scalar& GlobalEstimationData::k1(int i) { return m_data[i].m_k1; } Scalar& GlobalEstimationData::k2(int i) { return m_data[i].m_k2; } Vector3& GlobalEstimationData::dir1(int i) { return m_data[i].m_dir1; } Vector3& GlobalEstimationData::dir2(int i) { return m_data[i].m_dir2; } Vector3& GlobalEstimationData::normal(int i) { return m_data[i].m_N; } int& GlobalEstimationData::nei_count(int i) { return m_data[i].m_nei_count; } Scalar& GlobalEstimationData::time_ms(int i) { return m_data[i].m_time_ms; } int GlobalEstimationData::average_nei_count() const { Scalar sum_nei_count = 0; Scalar sum = 0; for(const auto& it : m_data) { if(it.valid()) { sum_nei_count += it.nei_count(); ++sum; } } return sum > 0 ? int(sum_nei_count/sum) : 0; } int GlobalEstimationData::valid_count() const { int sum = 0; for(const auto& it : m_data) { if(it.valid()) { ++sum; } } return sum; } } // namespace pcp
; A060605: a(n) = sum of lengths of the iteration sequences of Euler totient function from 1 to n. ; 1,3,6,9,13,16,20,24,28,32,37,41,46,50,55,60,66,70,75,80,85,90,96,101,107,112,117,122,128,133,139,145,151,157,163,168,174,179,185,191,198,203,209,215,221,227,234,240,246,252,259,265,272,277,284,290,296,302 mov $27,$0 mov $29,$0 add $29,1 lpb $29 clr $0,27 mov $0,$27 sub $29,1 sub $0,$29 lpb $0 mov $1,$0 cal $1,10 ; Euler totient function phi(n): count numbers <= n and prime to n. mov $0,$1 sub $0,1 add $5,153793 mov $3,$5 lpe mov $1,$3 div $1,153793 add $1,1 add $28,$1 lpe mov $1,$28
#include <iostream> #include <sstream> #include <utility> #include <vector> class TablePrinter { private: static void output(std::ostream& out, std::string str); static void output_repeat(std::ostream& out, std::string str, int count); static void output_cell(std::ostream& out, std::string str, int width); static void output_row(std::ostream& out, std::string str1, std::string str2, int col_width); public: static void print_table(std::ostream& out, const std::vector<std::string>& vec); };
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__placement_new_82_goodG2B.cpp Label Definition File: CWE122_Heap_Based_Buffer_Overflow__placement_new.label.xml Template File: sources-sinks-82_goodG2B.tmpl.cpp */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: Initialize data to a small buffer * GoodSource: Initialize data to a buffer large enough to hold a TwoIntsClass * Sinks: * GoodSink: Allocate a new class using placement new and a buffer that is large enough to hold the class * BadSink : Allocate a new class using placement new and a buffer that is too small * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #ifndef OMITGOOD #include "std_testcase.h" #include "CWE122_Heap_Based_Buffer_Overflow__placement_new_82.h" namespace CWE122_Heap_Based_Buffer_Overflow__placement_new_82 { void CWE122_Heap_Based_Buffer_Overflow__placement_new_82_goodG2B::action(char * data) { { /* The Visual C++ compiler generates a warning if you initialize the class with (). * This will cause the compile to default-initialize the object. * See http://msdn.microsoft.com/en-us/library/wewb47ee%28v=VS.100%29.aspx */ /* POTENTIAL FLAW: data may not be large enough to hold a TwoIntsClass */ TwoIntsClass * classTwo = new(data) TwoIntsClass; /* Initialize and make use of the class */ classTwo->intOne = 5; classTwo->intTwo = 10; /* POTENTIAL FLAW: If sizeof(data) < sizeof(TwoIntsClass) then this line will be a buffer overflow */ printIntLine(classTwo->intOne); /* skip printing classTwo->intTwo since that could be a buffer overread */ free(data); } } } #endif /* OMITGOOD */
/* * Copyright 2014-2021 Real Logic Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <array> #include <thread> #include <atomic> #include <limits> #include <gtest/gtest.h> extern "C" { #include "concurrent/aeron_spsc_rb.h" } #undef max #define CAPACITY (1024) #define BUFFER_SZ (CAPACITY + AERON_RB_TRAILER_LENGTH) #define ODD_BUFFER_SZ ((CAPACITY - 1) + AERON_RB_TRAILER_LENGTH) #define MSG_TYPE_ID (101) typedef std::array<std::uint8_t, BUFFER_SZ> buffer_t; typedef std::array<std::uint8_t, ODD_BUFFER_SZ> odd_sized_buffer_t; class SpscRbTest : public testing::Test { public: SpscRbTest() { m_buffer.fill(0); m_srcBuffer.fill(0); } protected: buffer_t m_buffer = {}; buffer_t m_srcBuffer = {}; }; TEST_F(SpscRbTest, shouldCalculateCapacityForBuffer) { aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); EXPECT_EQ(rb.capacity, BUFFER_SZ - AERON_RB_TRAILER_LENGTH); } TEST_F(SpscRbTest, shouldErrorForCapacityNotPowerOfTwo) { aeron_spsc_rb_t rb; EXPECT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size() - 1), -1); } TEST_F(SpscRbTest, shouldErrorWhenMaxMessageSizeExceeded) { aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); EXPECT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), rb.max_message_length + 1), AERON_RB_ERROR); } TEST_F(SpscRbTest, shouldErrorWhenMessageTypeIsNegative) { aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); EXPECT_EQ(aeron_spsc_rb_write(&rb, AERON_RB_PADDING_MSG_TYPE_ID, m_srcBuffer.data(), 5), AERON_RB_ERROR); } TEST_F(SpscRbTest, shouldErrorWhenMessageTypeIsZero) { aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); EXPECT_EQ(aeron_spsc_rb_write(&rb, 0, m_srcBuffer.data(), 5), AERON_RB_ERROR); } TEST_F(SpscRbTest, shouldWriteToEmptyBuffer) { aeron_spsc_rb_t rb; size_t tail = 0; size_t tailIndex = 0; size_t length = 8; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); ASSERT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), length), AERON_RB_SUCCESS); auto *record = (aeron_rb_record_descriptor_t *)(m_buffer.data() + tailIndex); EXPECT_EQ(record->length, (int32_t)recordLength); EXPECT_EQ(record->msg_type_id, (int32_t)MSG_TYPE_ID); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)(tail + alignedRecordLength)); } TEST_F(SpscRbTest, shouldWriteVectorToEmptyBuffer) { aeron_spsc_rb_t rb; size_t tail = 0; size_t tailIndex = 0; const int vec_len = 3; struct iovec vec[vec_len]; vec[0].iov_base = m_srcBuffer.data(); vec[0].iov_len = 8; vec[1].iov_base = m_srcBuffer.data() + (vec[0].iov_len); vec[1].iov_len = 7; vec[2].iov_base = m_srcBuffer.data() + (vec[0].iov_len + vec[1].iov_len); vec[2].iov_len = 11; size_t length = vec[0].iov_len + vec[1].iov_len + vec[2].iov_len; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); ASSERT_EQ(aeron_spsc_rb_writev(&rb, MSG_TYPE_ID, vec, vec_len), AERON_RB_SUCCESS); auto *record = (aeron_rb_record_descriptor_t *)(m_buffer.data() + tailIndex); EXPECT_EQ(record->length, (int32_t)recordLength); EXPECT_EQ(record->msg_type_id, (int32_t)MSG_TYPE_ID); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)(tail + alignedRecordLength)); } TEST_F(SpscRbTest, shouldRejectWriteWhenInsufficientSpace) { aeron_spsc_rb_t rb; size_t length = 100; size_t head = 0; size_t tail = head + (CAPACITY - AERON_ALIGN(length - AERON_RB_ALIGNMENT, AERON_RB_ALIGNMENT)); ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; ASSERT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), length), AERON_RB_FULL); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)tail); } TEST_F(SpscRbTest, shouldRejectWriteVectorWhenInsufficientSpace) { aeron_spsc_rb_t rb; const int vec_len = 3; struct iovec vec[vec_len]; vec[0].iov_base = m_srcBuffer.data(); vec[0].iov_len = 1; vec[1].iov_base = m_srcBuffer.data() + (vec[0].iov_len); vec[1].iov_len = 1; vec[2].iov_base = m_srcBuffer.data() + (vec[0].iov_len + vec[1].iov_len); vec[2].iov_len = 98; size_t length = vec[0].iov_len + vec[1].iov_len + vec[2].iov_len; size_t head = 0; size_t tail = head + (CAPACITY - AERON_ALIGN(length - AERON_RB_ALIGNMENT, AERON_RB_ALIGNMENT)); ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; ASSERT_EQ(aeron_spsc_rb_writev(&rb, MSG_TYPE_ID, vec, vec_len), AERON_RB_FULL); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)tail); } TEST_F(SpscRbTest, shouldRejectWriteWhenBufferFull) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t tail = head + CAPACITY; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; ASSERT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), length), AERON_RB_FULL); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)tail); } TEST_F(SpscRbTest, shouldInsertPaddingRecordPlusMessageOnBufferWrap) { aeron_spsc_rb_t rb; size_t length = 100; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t tail = CAPACITY - AERON_RB_ALIGNMENT; size_t head = tail - (AERON_RB_ALIGNMENT * 4); ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; ASSERT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), length), AERON_RB_SUCCESS); auto *record = (aeron_rb_record_descriptor_t *)(rb.buffer + tail); EXPECT_EQ(record->msg_type_id, (int32_t)AERON_RB_PADDING_MSG_TYPE_ID); EXPECT_EQ(record->length, (int32_t)AERON_RB_ALIGNMENT); record = (aeron_rb_record_descriptor_t *)(rb.buffer); EXPECT_EQ(record->msg_type_id, (int32_t)MSG_TYPE_ID); EXPECT_EQ(record->length, (int32_t)recordLength); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)(tail + alignedRecordLength + AERON_RB_ALIGNMENT)); } TEST_F(SpscRbTest, shouldInsertPaddingRecordPlusMessageOnBufferWrapWithHeadEqualToTail) { aeron_spsc_rb_t rb; size_t length = 100; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t tail = CAPACITY - AERON_RB_ALIGNMENT; size_t head = tail; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; ASSERT_EQ(aeron_spsc_rb_write(&rb, MSG_TYPE_ID, m_srcBuffer.data(), length), AERON_RB_SUCCESS); auto *record = (aeron_rb_record_descriptor_t *)(rb.buffer + tail); EXPECT_EQ(record->msg_type_id, (int32_t)AERON_RB_PADDING_MSG_TYPE_ID); EXPECT_EQ(record->length, (int32_t)AERON_RB_ALIGNMENT); record = (aeron_rb_record_descriptor_t *)(rb.buffer); EXPECT_EQ(record->msg_type_id, (int32_t)MSG_TYPE_ID); EXPECT_EQ(record->length, (int32_t)recordLength); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)(tail + alignedRecordLength + AERON_RB_ALIGNMENT)); } static void countTimesAsSizeT(int32_t msg_type_id, const void *msg, size_t length, void *clientd) { auto *count = (size_t *)clientd; (*count)++; /* unused */ } TEST_F(SpscRbTest, shouldReadNothingFromEmptyBuffer) { aeron_spsc_rb_t rb; size_t tail = 0; size_t head = 0; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; size_t timesCalled = 0; const size_t messagesRead = aeron_spsc_rb_read(&rb, countTimesAsSizeT, &timesCalled, 10); EXPECT_EQ(messagesRead, (size_t)0); EXPECT_EQ(timesCalled, (size_t)0); } TEST_F(SpscRbTest, shouldReadSingleMessage) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t tail = alignedRecordLength; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; auto *record = (aeron_rb_record_descriptor_t *)(rb.buffer); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = (int32_t)recordLength; size_t timesCalled = 0; const size_t messagesRead = aeron_spsc_rb_read(&rb, countTimesAsSizeT, &timesCalled, 10); EXPECT_EQ(messagesRead, (size_t)1); EXPECT_EQ(timesCalled, (size_t)1); EXPECT_EQ(rb.descriptor->head_position, (int64_t)(head + alignedRecordLength)); } TEST_F(SpscRbTest, shouldNotReadSingleMessagePartWayThroughWriting) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t endTail = alignedRecordLength; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)endTail; auto *record = (aeron_rb_record_descriptor_t *)(rb.buffer); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = -((int32_t)recordLength); size_t timesCalled = 0; const size_t messagesRead = aeron_spsc_rb_read(&rb, countTimesAsSizeT, &timesCalled, 10); EXPECT_EQ(messagesRead, (size_t)0); EXPECT_EQ(timesCalled, (size_t)0); EXPECT_EQ(rb.descriptor->head_position, (int64_t)head); } TEST_F(SpscRbTest, shouldReadTwoMessages) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t tail = alignedRecordLength * 2; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; aeron_rb_record_descriptor_t *record; record = (aeron_rb_record_descriptor_t *)(rb.buffer); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = (int32_t)recordLength; record = (aeron_rb_record_descriptor_t *)(rb.buffer + alignedRecordLength); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = (int32_t)recordLength; size_t timesCalled = 0; const size_t messagesRead = aeron_spsc_rb_read(&rb, countTimesAsSizeT, &timesCalled, 10); EXPECT_EQ(messagesRead, (size_t)2); EXPECT_EQ(timesCalled, (size_t)2); EXPECT_EQ(rb.descriptor->head_position, (int64_t)(head + (alignedRecordLength * 2))); } TEST_F(SpscRbTest, shouldLimitReadOfMessages) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t recordLength = length + AERON_RB_RECORD_HEADER_LENGTH; size_t alignedRecordLength = AERON_ALIGN(recordLength, AERON_RB_ALIGNMENT); size_t tail = alignedRecordLength * 2; ASSERT_EQ(aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size()), 0); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; aeron_rb_record_descriptor_t *record; record = (aeron_rb_record_descriptor_t *)(rb.buffer); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = (int32_t)recordLength; record = (aeron_rb_record_descriptor_t *)(rb.buffer + alignedRecordLength); record->msg_type_id = (int32_t)MSG_TYPE_ID; record->length = (int32_t)recordLength; size_t timesCalled = 0; const size_t messagesRead = aeron_spsc_rb_read(&rb, countTimesAsSizeT, &timesCalled, 1); EXPECT_EQ(messagesRead, (size_t)1); EXPECT_EQ(timesCalled, (size_t)1); EXPECT_EQ(rb.descriptor->head_position, (int64_t)(head + alignedRecordLength)); } TEST_F(SpscRbTest, tryClaimShouldErrorWhenMessageTypeIsZero) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(AERON_RB_ERROR, aeron_spsc_rb_try_claim(&rb, 0, 5)); } TEST_F(SpscRbTest, tryClaimShouldErrorWhenMessageTypeIsNegative) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(AERON_RB_ERROR, aeron_spsc_rb_try_claim(&rb, -3, 5)); } TEST_F(SpscRbTest, tryClaimShouldErrorWhenLengthExceedMaxMessageSize) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(AERON_RB_ERROR, aeron_spsc_rb_try_claim(&rb, 6, rb.max_message_length + 1)); } TEST_F(SpscRbTest, tryClaimShouldErrorBufferIsFull) { aeron_spsc_rb_t rb; size_t length = 8; size_t head = 0; size_t tail = head + CAPACITY; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); rb.descriptor->head_position = (int64_t)head; rb.descriptor->tail_position = (int64_t)tail; EXPECT_EQ(AERON_RB_FULL, aeron_spsc_rb_try_claim(&rb, MSG_TYPE_ID, length)); EXPECT_EQ(rb.descriptor->tail_position, (int64_t)tail); } TEST_F(SpscRbTest, tryClaimShouldReturnMessageOffsetUponSuccess) { int msg_type_id = 17; size_t length = 100; aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ((int32_t)AERON_RB_RECORD_HEADER_LENGTH, aeron_spsc_rb_try_claim(&rb, msg_type_id, length)); auto *record_header = (aeron_rb_record_descriptor_t *)(rb.buffer); EXPECT_EQ(msg_type_id, record_header->msg_type_id); EXPECT_EQ(-(int32_t)(length + AERON_RB_RECORD_HEADER_LENGTH), record_header->length); } TEST_F(SpscRbTest, commitShouldReturnErrorIfOffsetIsNegative) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_commit(&rb, -2)); } TEST_F(SpscRbTest, commitShouldReturnErrorIfOffsetIsExceedsBufferCapacity) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_commit(&rb, (int32_t)(m_buffer.size() + 1))); } TEST_F(SpscRbTest, commitShouldReturnErrorIfOffsetIsSmallerThanRecordHeader) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_commit(&rb, (int32_t)(m_buffer.size() - AERON_RB_RECORD_HEADER_LENGTH + 1))); } TEST_F(SpscRbTest, commitShouldReturnZeroUponSuccess) { size_t tail = 200; size_t length = 50; aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); rb.descriptor->tail_position = (int64_t)tail; int32_t offset = aeron_spsc_rb_try_claim(&rb, MSG_TYPE_ID, length); EXPECT_EQ((int32_t)AERON_RB_MESSAGE_OFFSET(tail), offset); EXPECT_EQ(0, aeron_spsc_rb_commit(&rb, offset)); auto *record_header = (aeron_rb_record_descriptor_t *)(rb.buffer + (offset - AERON_RB_RECORD_HEADER_LENGTH)); EXPECT_EQ(MSG_TYPE_ID, record_header->msg_type_id); EXPECT_EQ((int32_t)(length + AERON_RB_RECORD_HEADER_LENGTH), record_header->length); } TEST_F(SpscRbTest, abortShouldReturnErrorIfOffsetIsNegative) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_abort(&rb, -10)); } TEST_F(SpscRbTest, abortShouldReturnErrorIfOffsetIsExceedsBufferCapacity) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_abort(&rb, (int32_t)(m_buffer.size() + 8))); } TEST_F(SpscRbTest, abortShouldReturnErrorIfOffsetIsSmallerThanRecordHeader) { aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); EXPECT_EQ(-1, aeron_spsc_rb_abort(&rb, (int32_t)(m_buffer.size() - 1))); } TEST_F(SpscRbTest, abortShouldReturnZeroUponSuccess) { size_t length = 32; aeron_spsc_rb_t rb; ASSERT_EQ(0, aeron_spsc_rb_init(&rb, m_buffer.data(), m_buffer.size())); int32_t offset = aeron_spsc_rb_try_claim(&rb, MSG_TYPE_ID, length); EXPECT_EQ((int32_t)AERON_RB_MESSAGE_OFFSET(0), offset); EXPECT_EQ(0, aeron_spsc_rb_abort(&rb, offset)); auto *record_header = (aeron_rb_record_descriptor_t *)(rb.buffer + (offset - AERON_RB_RECORD_HEADER_LENGTH)); EXPECT_EQ(AERON_RB_PADDING_MSG_TYPE_ID, record_header->msg_type_id); EXPECT_EQ((int32_t)(length + AERON_RB_RECORD_HEADER_LENGTH), record_header->length); } #define NUM_MESSAGES (10 * 1000 * 1000) #define NUM_IDS_PER_THREAD (10 * 1000 * 1000) TEST(SpscRbConcurrentTest, shouldProvideCorrelationIds) { AERON_DECL_ALIGNED(buffer_t buffer, 16) = {}; buffer.fill(0); aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, buffer.data(), buffer.size()), 0); std::atomic<int> countDown(2); std::vector<std::thread> threads; for (int i = 0; i < 2; i++) { threads.push_back(std::thread( [&]() { countDown--; while (countDown > 0) { std::this_thread::yield(); } for (int m = 0; m < NUM_IDS_PER_THREAD; m++) { aeron_spsc_rb_next_correlation_id(&rb); } })); } for (std::thread &t: threads) { if (t.joinable()) { t.join(); } } ASSERT_EQ(aeron_spsc_rb_next_correlation_id(&rb), NUM_IDS_PER_THREAD * 2); } static void spsc_rb_concurrent_handler(int32_t msg_type_id, const void *buffer, size_t length, void *clientd) { auto *counts = (size_t *)clientd; const int32_t messageNumber = *((int32_t *)(buffer)); EXPECT_EQ(length, (size_t)4); ASSERT_EQ(msg_type_id, MSG_TYPE_ID); EXPECT_EQ((*counts)++, (size_t)messageNumber); } TEST(SpscRbConcurrentTest, shouldExchangeMessages) { AERON_DECL_ALIGNED(buffer_t spsc_buffer, 16) = {}; spsc_buffer.fill(0); aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, spsc_buffer.data(), spsc_buffer.size()), 0); std::atomic<int> countDown(1); std::vector<std::thread> threads; size_t msgCount = 0; size_t counts = 0; threads.push_back(std::thread( [&]() { AERON_DECL_ALIGNED(buffer_t buffer, 16); buffer.fill(0); countDown--; while (countDown > 0) { std::this_thread::yield(); } for (int m = 0; m < NUM_MESSAGES; m++) { auto *payload = (int32_t *)(buffer.data()); *payload = m; while (AERON_RB_SUCCESS != aeron_spsc_rb_write(&rb, MSG_TYPE_ID, buffer.data(), 4)) { std::this_thread::yield(); } } })); while (msgCount < NUM_MESSAGES) { const size_t readCount = aeron_spsc_rb_read( &rb, spsc_rb_concurrent_handler, &counts, std::numeric_limits<size_t>::max()); if (0 == readCount) { std::this_thread::yield(); } msgCount += readCount; } for (std::thread &t: threads) { if (t.joinable()) { t.join(); } } } TEST(SpscRbConcurrentTest, shouldExchangeVectorMessages) { AERON_DECL_ALIGNED(buffer_t spsc_buffer, 16) = {}; spsc_buffer.fill(0); aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, spsc_buffer.data(), spsc_buffer.size()), 0); std::atomic<int> countDown(1); std::vector<std::thread> threads; size_t msgCount = 0; size_t counts = 0; threads.push_back(std::thread( [&]() { struct iovec vec[2]; AERON_DECL_ALIGNED(buffer_t buffer, 16); buffer.fill(0); countDown--; while (countDown > 0) { std::this_thread::yield(); } for (int m = 0; m < NUM_MESSAGES; m++) { auto *payload = (int32_t *)(buffer.data()); *payload = m; vec[0].iov_len = 2; vec[0].iov_base = payload; vec[1].iov_len = 2; vec[1].iov_base = ((uint8_t *)payload) + 2; while (AERON_RB_SUCCESS != aeron_spsc_rb_writev(&rb, MSG_TYPE_ID, vec, 2)) { std::this_thread::yield(); } } })); while (msgCount < NUM_MESSAGES) { const size_t readCount = aeron_spsc_rb_read( &rb, spsc_rb_concurrent_handler, &counts, std::numeric_limits<size_t>::max()); if (0 == readCount) { std::this_thread::yield(); } msgCount += readCount; } for (std::thread &t: threads) { if (t.joinable()) { t.join(); } } } TEST(SpscRbConcurrentTest, shouldExchangeMessagesViaTryClaim) { AERON_DECL_ALIGNED(buffer_t spsc_buffer, 16) = {}; spsc_buffer.fill(0); aeron_spsc_rb_t rb; ASSERT_EQ(aeron_spsc_rb_init(&rb, spsc_buffer.data(), spsc_buffer.size()), 0); std::atomic<int> countDown(1); std::vector<std::thread> threads; size_t msgCount = 0; size_t counts = 0; threads.push_back(std::thread( [&]() { countDown--; while (countDown > 0) { std::this_thread::yield(); } for (int m = 0; m < NUM_MESSAGES; m++) { int32_t offset; int32_t length = 4; while ((offset = aeron_spsc_rb_try_claim(&rb, MSG_TYPE_ID, length)) < 0) { std::this_thread::yield(); } auto *payload = (int32_t *)(rb.buffer + offset); *payload = m; aeron_spsc_rb_commit(&rb, offset); } })); while (msgCount < NUM_MESSAGES) { const size_t readCount = aeron_spsc_rb_read( &rb, spsc_rb_concurrent_handler, &counts, std::numeric_limits<size_t>::max()); if (0 == readCount) { std::this_thread::yield(); } msgCount += readCount; } for (std::thread &t: threads) { if (t.joinable()) { t.join(); } } }
; ; Getsprite - Picks up a sprite from display with the given size ; by Stefano Bodrato - Jan 2001 ; Apr 2002 - Fixed. (Long time, I know...) ; ; The original putsprite code is by Patrick Davidson (TI 85) ; ; Generic version (just a bit slow) ; ; ; $Id: getsprite.asm,v 1.9 2016-07-02 09:01:35 dom Exp $ ; SECTION code_clib PUBLIC getsprite PUBLIC _getsprite EXTERN pixeladdress EXTERN swapgfxbk EXTERN __graphics_end INCLUDE "graphics/grafix.inc" ; __gfx_coords: d,e (vert-horz) ; sprite: (ix) .getsprite ._getsprite push ix ld hl,2 add hl,sp ld e,(hl) inc hl ld d,(hl) ; sprite address push de pop ix inc hl ld e,(hl) inc hl inc hl ld d,(hl) ; x and y __gfx_coords ld h,d ld l,e ld (actcoord),hl ; save current coordinates call swapgfxbk call pixeladdress xor 7 ld (_smc+1),a ld h,d ld l,e ld e,(ix+0) ld b,(ix+1) dec e srl e srl e srl e inc e ; INT ((width-1)/8+1) ._oloop push bc ;Save # of rows push de ;Save # of bytes per row ._iloop2 ld a,(hl) inc hl ld d,(hl) ._smc ld b,1 ;Load pixel position inc b dec b jr z,zpos ._iloop rl d rl a djnz _iloop .zpos ld (ix+2),a inc ix dec e jr nz,_iloop2 ; --------- push de ld hl,(actcoord) inc l ld (actcoord),hl call pixeladdress ld h,d ld l,e pop de ; --------- pop de pop bc ;Restore data djnz _oloop jp __graphics_end SECTION bss_clib .actcoord defw 0
; A250754: Number of (n+1) X (7+1) 0..2 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing x(i,j)+x(i-1,j) in the j direction. ; 527,1707,5471,17211,53327,163467,497471,1506651,4548527,13702827,41223071,123898491,372154127,1117379787,3353974271,10065592731,30204118127,90627034347,271910463071,815790109371,2447487768527,7342698186507,22028564321471,66086632488411,198261776513327,594789087636267,1784374779101471,5353139369689851 add $0,3 mov $2,4 lpb $0,1 add $3,$2 mov $4,$0 sub $0,1 mov $1,1 mul $2,2 add $2,3 sub $3,1 mul $3,3 add $3,9 add $4,7 mul $1,$4 mov $5,$4 lpe mul $3,2 add $3,$5 add $1,$3 sub $1,731 div $1,6 mul $1,4 add $1,527
; A090809: Coefficient of the irreducible character of S_m indexed by (m-2n+2,2n-2) in the n-th Kronecker power of the representation indexed by (m-2,2). ; 0,0,2,10,31,75,155,287,490,786,1200,1760,2497,3445,4641,6125,7940,10132,12750,15846,19475,23695,28567,34155,40526,47750,55900,65052,75285,86681,99325,113305,128712,145640,164186,184450,206535,230547 lpb $0,1 sub $0,1 add $1,$2 add $1,$0 add $3,$0 add $2,$3 lpe
dnl AMD K7 mpn_add_n/mpn_sub_n -- mpn add or subtract. dnl Copyright 1999-2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C K7: 1.64 cycles/limb (at 16 limbs/loop). dnl K7: UNROLL_COUNT cycles/limb dnl 8 1.9 dnl 16 1.64 dnl 32 1.7 dnl 64 2.0 dnl Maximum possible with the current code is 64. deflit(UNROLL_COUNT, 16) ifdef(`OPERATION_add_n', ` define(M4_inst, adcl) define(M4_function_n, mpn_add_n) define(M4_function_nc, mpn_add_nc) define(M4_description, add) ',`ifdef(`OPERATION_sub_n', ` define(M4_inst, sbbl) define(M4_function_n, mpn_sub_n) define(M4_function_nc, mpn_sub_nc) define(M4_description, subtract) ',`m4_error(`Need OPERATION_add_n or OPERATION_sub_n ')')') MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc) C mp_limb_t M4_function_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2, C mp_size_t size); C mp_limb_t M4_function_nc (mp_ptr dst, mp_srcptr src1, mp_srcptr src2, C mp_size_t size, mp_limb_t carry); C C Calculate src1,size M4_description src2,size, and store the result in C dst,size. The return value is the carry bit from the top of the result (1 C or 0). C C The _nc version accepts 1 or 0 for an initial carry into the low limb of C the calculation. Note values other than 1 or 0 here will lead to garbage C results. C C This code runs at 1.64 cycles/limb, which might be the best possible with C plain integer operations. Each limb is 2 loads and 1 store, any 2 of C which can be done each cycle, leading to 1.5 c/l. dnl Must have UNROLL_THRESHOLD >= 2, since the unrolled loop can't handle 1. ifdef(`PIC',` deflit(UNROLL_THRESHOLD, 8) ',` deflit(UNROLL_THRESHOLD, 8) ') defframe(PARAM_CARRY,20) defframe(PARAM_SIZE, 16) defframe(PARAM_SRC2, 12) defframe(PARAM_SRC1, 8) defframe(PARAM_DST, 4) defframe(SAVE_EBP, -4) defframe(SAVE_ESI, -8) defframe(SAVE_EBX, -12) defframe(SAVE_EDI, -16) deflit(STACK_SPACE, 16) TEXT ALIGN(32) deflit(`FRAME',0) PROLOGUE(M4_function_nc) movl PARAM_CARRY, %eax jmp L(start) EPILOGUE() PROLOGUE(M4_function_n) xorl %eax, %eax C carry L(start): movl PARAM_SIZE, %ecx subl $STACK_SPACE, %esp deflit(`FRAME',STACK_SPACE) movl %edi, SAVE_EDI movl %ebx, SAVE_EBX cmpl $UNROLL_THRESHOLD, %ecx movl PARAM_SRC2, %edx movl PARAM_SRC1, %ebx jae L(unroll) movl PARAM_DST, %edi leal (%ebx,%ecx,4), %ebx leal (%edx,%ecx,4), %edx leal (%edi,%ecx,4), %edi negl %ecx shrl %eax C This loop in in a single 16 byte code block already, so no C alignment necessary. L(simple): C eax scratch C ebx src1 C ecx counter C edx src2 C esi C edi dst C ebp movl (%ebx,%ecx,4), %eax M4_inst (%edx,%ecx,4), %eax movl %eax, (%edi,%ecx,4) incl %ecx jnz L(simple) movl $0, %eax movl SAVE_EDI, %edi movl SAVE_EBX, %ebx setc %al addl $STACK_SPACE, %esp ret C ----------------------------------------------------------------------------- C This is at 0x55, close enough to aligned. L(unroll): deflit(`FRAME',STACK_SPACE) movl %ebp, SAVE_EBP andl $-2, %ecx C size low bit masked out andl $1, PARAM_SIZE C size low bit kept movl %ecx, %edi decl %ecx movl PARAM_DST, %ebp shrl $UNROLL_LOG2, %ecx negl %edi movl %esi, SAVE_ESI andl $UNROLL_MASK, %edi ifdef(`PIC',` call L(pic_calc) L(here): ',` leal L(entry) (%edi,%edi,8), %esi C 9 bytes per ') negl %edi shrl %eax leal ifelse(UNROLL_BYTES,256,128) (%ebx,%edi,4), %ebx leal ifelse(UNROLL_BYTES,256,128) (%edx,%edi,4), %edx leal ifelse(UNROLL_BYTES,256,128) (%ebp,%edi,4), %edi jmp *%esi ifdef(`PIC',` L(pic_calc): C See mpn/x86/README about old gas bugs leal (%edi,%edi,8), %esi addl $L(entry)-L(here), %esi addl (%esp), %esi ret_internal ') C ----------------------------------------------------------------------------- ALIGN(32) L(top): C eax zero C ebx src1 C ecx counter C edx src2 C esi scratch (was computed jump) C edi dst C ebp scratch leal UNROLL_BYTES(%edx), %edx L(entry): deflit(CHUNK_COUNT, 2) forloop(i, 0, UNROLL_COUNT/CHUNK_COUNT-1, ` deflit(`disp0', eval(i*CHUNK_COUNT*4 ifelse(UNROLL_BYTES,256,-128))) deflit(`disp1', eval(disp0 + 4)) Zdisp( movl, disp0,(%ebx), %esi) movl disp1(%ebx), %ebp Zdisp( M4_inst,disp0,(%edx), %esi) Zdisp( movl, %esi, disp0,(%edi)) M4_inst disp1(%edx), %ebp movl %ebp, disp1(%edi) ') decl %ecx leal UNROLL_BYTES(%ebx), %ebx leal UNROLL_BYTES(%edi), %edi jns L(top) mov PARAM_SIZE, %esi movl SAVE_EBP, %ebp movl $0, %eax decl %esi js L(even) movl (%ebx), %ecx M4_inst UNROLL_BYTES(%edx), %ecx movl %ecx, (%edi) L(even): movl SAVE_EDI, %edi movl SAVE_EBX, %ebx setc %al movl SAVE_ESI, %esi addl $STACK_SPACE, %esp ret EPILOGUE()
; ; ANSI Video handling for the Commodore 128 (Z80 mode) ; By Stefano Bodrato - 22/08/2001 ; ; CLS - Clear the screen ; ; ; $Id: f_ansi_cls.asm,v 1.4 2015/01/19 01:33:18 pauloscustodio Exp $ ; PUBLIC ansi_cls .ansi_cls ld hl,$2000 ; Text ld d,h ld e,l inc de ld bc,1023 ld (hl),32 ldir ld hl,$1000 ; Color attributes ld d,h ld e,l inc de ld bc,1023 ld (hl),1 ldir ret
// Generated by Haxe 3.4.7 #include <hxcpp.h> #ifndef INCLUDED_95f339a1d026d52c #define INCLUDED_95f339a1d026d52c #include "hxMath.h" #endif #ifndef INCLUDED_flixel_FlxG #include <flixel/FlxG.h> #endif #ifndef INCLUDED_flixel_math_FlxPoint #include <flixel/math/FlxPoint.h> #endif #ifndef INCLUDED_flixel_system_scaleModes_BaseScaleMode #include <flixel/system/scaleModes/BaseScaleMode.h> #endif #ifndef INCLUDED_flixel_system_scaleModes_RatioScaleMode #include <flixel/system/scaleModes/RatioScaleMode.h> #endif #ifndef INCLUDED_flixel_util_IFlxDestroyable #include <flixel/util/IFlxDestroyable.h> #endif #ifndef INCLUDED_flixel_util_IFlxPooled #include <flixel/util/IFlxPooled.h> #endif HX_DEFINE_STACK_FRAME(_hx_pos_35d034ea7d537e63_14_new,"flixel.system.scaleModes.RatioScaleMode","new",0x00d4d0cf,"flixel.system.scaleModes.RatioScaleMode.new","flixel/system/scaleModes/RatioScaleMode.hx",14,0x35e4ce80) HX_LOCAL_STACK_FRAME(_hx_pos_35d034ea7d537e63_20_updateGameSize,"flixel.system.scaleModes.RatioScaleMode","updateGameSize",0xacc31ced,"flixel.system.scaleModes.RatioScaleMode.updateGameSize","flixel/system/scaleModes/RatioScaleMode.hx",20,0x35e4ce80) namespace flixel{ namespace _hx_system{ namespace scaleModes{ void RatioScaleMode_obj::__construct(hx::Null< bool > __o_fillScreen){ bool fillScreen = __o_fillScreen.Default(false); HX_STACKFRAME(&_hx_pos_35d034ea7d537e63_14_new) HXLINE( 15) super::__construct(); HXLINE( 16) this->fillScreen = fillScreen; } Dynamic RatioScaleMode_obj::__CreateEmpty() { return new RatioScaleMode_obj; } void *RatioScaleMode_obj::_hx_vtable = 0; Dynamic RatioScaleMode_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< RatioScaleMode_obj > _hx_result = new RatioScaleMode_obj(); _hx_result->__construct(inArgs[0]); return _hx_result; } bool RatioScaleMode_obj::_hx_isInstanceOf(int inClassId) { if (inClassId<=(int)0x2a5138eb) { return inClassId==(int)0x00000001 || inClassId==(int)0x2a5138eb; } else { return inClassId==(int)0x5682c573; } } void RatioScaleMode_obj::updateGameSize(int Width,int Height){ HX_STACKFRAME(&_hx_pos_35d034ea7d537e63_20_updateGameSize) HXLINE( 21) Float ratio = ((Float)::flixel::FlxG_obj::width / (Float)::flixel::FlxG_obj::height); HXLINE( 22) Float realRatio = ((Float)Width / (Float)Height); HXLINE( 24) bool scaleY = (realRatio < ratio); HXLINE( 25) if (this->fillScreen) { HXLINE( 27) scaleY = !(scaleY); } HXLINE( 30) if (scaleY) { HXLINE( 32) this->gameSize->set_x(Width); HXLINE( 33) ::flixel::math::FlxPoint _hx_tmp = this->gameSize; HXDLIN( 33) _hx_tmp->set_y(::Math_obj::floor(((Float)this->gameSize->x / (Float)ratio))); } else { HXLINE( 37) this->gameSize->set_y(Height); HXLINE( 38) ::flixel::math::FlxPoint _hx_tmp1 = this->gameSize; HXDLIN( 38) _hx_tmp1->set_x(::Math_obj::floor((this->gameSize->y * ratio))); } } hx::ObjectPtr< RatioScaleMode_obj > RatioScaleMode_obj::__new(hx::Null< bool > __o_fillScreen) { hx::ObjectPtr< RatioScaleMode_obj > __this = new RatioScaleMode_obj(); __this->__construct(__o_fillScreen); return __this; } hx::ObjectPtr< RatioScaleMode_obj > RatioScaleMode_obj::__alloc(hx::Ctx *_hx_ctx,hx::Null< bool > __o_fillScreen) { RatioScaleMode_obj *__this = (RatioScaleMode_obj*)(hx::Ctx::alloc(_hx_ctx, sizeof(RatioScaleMode_obj), true, "flixel.system.scaleModes.RatioScaleMode")); *(void **)__this = RatioScaleMode_obj::_hx_vtable; __this->__construct(__o_fillScreen); return __this; } RatioScaleMode_obj::RatioScaleMode_obj() { } hx::Val RatioScaleMode_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp) { switch(inName.length) { case 10: if (HX_FIELD_EQ(inName,"fillScreen") ) { return hx::Val( fillScreen ); } break; case 14: if (HX_FIELD_EQ(inName,"updateGameSize") ) { return hx::Val( updateGameSize_dyn() ); } } return super::__Field(inName,inCallProp); } hx::Val RatioScaleMode_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 10: if (HX_FIELD_EQ(inName,"fillScreen") ) { fillScreen=inValue.Cast< bool >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } void RatioScaleMode_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_HCSTRING("fillScreen","\x4f","\xc2","\xf7","\x4a")); super::__GetFields(outFields); }; #if HXCPP_SCRIPTABLE static hx::StorageInfo RatioScaleMode_obj_sMemberStorageInfo[] = { {hx::fsBool,(int)offsetof(RatioScaleMode_obj,fillScreen),HX_HCSTRING("fillScreen","\x4f","\xc2","\xf7","\x4a")}, { hx::fsUnknown, 0, null()} }; static hx::StaticInfo *RatioScaleMode_obj_sStaticStorageInfo = 0; #endif static ::String RatioScaleMode_obj_sMemberFields[] = { HX_HCSTRING("fillScreen","\x4f","\xc2","\xf7","\x4a"), HX_HCSTRING("updateGameSize","\xfc","\x94","\xa3","\xed"), ::String(null()) }; static void RatioScaleMode_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(RatioScaleMode_obj::__mClass,"__mClass"); }; #ifdef HXCPP_VISIT_ALLOCS static void RatioScaleMode_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(RatioScaleMode_obj::__mClass,"__mClass"); }; #endif hx::Class RatioScaleMode_obj::__mClass; void RatioScaleMode_obj::__register() { hx::Object *dummy = new RatioScaleMode_obj; RatioScaleMode_obj::_hx_vtable = *(void **)dummy; hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("flixel.system.scaleModes.RatioScaleMode","\x5d","\xbd","\x32","\x19"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField; __mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField; __mClass->mMarkFunc = RatioScaleMode_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */); __mClass->mMembers = hx::Class_obj::dupFunctions(RatioScaleMode_obj_sMemberFields); __mClass->mCanCast = hx::TCanCast< RatioScaleMode_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = RatioScaleMode_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = RatioScaleMode_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = RatioScaleMode_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } } // end namespace flixel } // end namespace system } // end namespace scaleModes
0D00 06 05 0D02 DD 21 00 0E 0D06 97 0D07 DD 86 00 0D0A EA 20 0D 0D0D DD 23 0D0F 05 0D10 C2 07 0D 0D13 DF 5B 0D20 DF 6B 0D22 DF 5B 0E00 38 0E01 F9 0E02 4B 0E03 05 0E04 10
; ; Amstrad CPC library ; ; void __LIB__ __CALLEE__ cpc_SetInkGphStr(char *color, char *valor); ; ; $Id: cpc_SetInkGphStrM1_callee.asm $ ; SECTION code_clib PUBLIC cpc_SetInkGphStrM1_callee PUBLIC _cpc_SetInkGphStrM1_callee PUBLIC asm_cpc_SetInkGphStrM1 EXTERN colores_cambM1 .cpc_SetInkGphStrM1_callee ._cpc_SetInkGphStrM1_callee pop hl pop bc ;valor ex (sp),hl ; valor ld a,c ld c,l .asm_cpc_SetInkGphStrM1 ld hl,colores_cambM1 ld b,0 add hl,bc ld (hl),a ret
// Fill out your copyright notice in the Description page of Project Settings. #include "ShooterGame.h" #include "EnvironmentQuery/Contexts/EnvQueryContext_Querier.h" #include "EnvironmentQuery/Items/EnvQueryItemType_VectorBase.h" #include "EnvironmentQuery/Tests/EnvQueryTest_Trace.h" #include "Bots/ShooterAIController.h" #include "Public/Others/HelperMethods.h" #include "Public/EQS/MinDotProductChosenPositions.h" UMinDotProductChosenPositions::UMinDotProductChosenPositions(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { Cost = EEnvTestCost::Low; ValidItemType = UEnvQueryItemType_VectorBase::StaticClass(); } void UMinDotProductChosenPositions::RunTest(FEnvQueryInstance& QueryInstance) const { //UE_LOG(LogTemp, Log, TEXT("F:RunTest")); UObject* QueryOwner = QueryInstance.Owner.Get(); if (QueryOwner == nullptr) { return; } FloatValueMin.BindData(QueryOwner, QueryInstance.QueryID); float MinThresholdValue = FloatValueMin.GetValue(); FloatValueMax.BindData(QueryOwner, QueryInstance.QueryID); float MaxThresholdValue = FloatValueMax.GetValue(); // Get all covers annotations within radius UWorld * World = GEngine->GetWorldFromContextObject(QueryOwner); APawn * Pawn = Cast<APawn>(QueryOwner); if (!Pawn) { return; } AShooterAIController * AIController = Cast<AShooterAIController>(Pawn->GetController()); if (!AIController) { return; } const TMap<FString, FVector> * AlreadyChosenAttackPositions = AIController->GetAI_fAttackLocations(); const FVector PlayerPosition = HelperMethods::GetPlayerPositionFromAI(World); for (FEnvQueryInstance::ItemIterator It(this, QueryInstance); It; ++It) { const FVector ItemLocation = GetItemLocation(QueryInstance, *It); FVector ItemToPlayer = PlayerPosition - ItemLocation; ItemToPlayer.Normalize(); float MinAngle = 360; for (auto& Elem : *AlreadyChosenAttackPositions) { const FString BotName = *Elem.Key; const FVector BotAttackPosition = Elem.Value; //UE_LOG(LogTemp, Warning, TEXT("EQS Bot in the map %s"), *BotName); if (BotName != Pawn->GetName()) { // Dont compare with MY old position FVector AttackToPlayer = PlayerPosition - BotAttackPosition; AttackToPlayer.Normalize(); const float Angle = FMath::RadiansToDegrees(acosf(ItemToPlayer.CosineAngle2D(AttackToPlayer))); MinAngle = (Angle > MinAngle) ? MinAngle : Angle; } } It.SetScore(TestPurpose, FilterType, MinAngle, MinThresholdValue, MaxThresholdValue); } }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r15 push %r8 push %r9 push %rdi lea addresses_normal_ht+0x189b4, %r9 nop nop nop nop nop xor $8800, %rdi movw $0x6162, (%r9) nop nop nop nop nop add %r11, %r11 lea addresses_D_ht+0xd360, %r15 and %r13, %r13 movl $0x61626364, (%r15) nop sub $25369, %r8 pop %rdi pop %r9 pop %r8 pop %r15 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r9 push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0x16ebe, %rsi lea addresses_D+0xeb28, %rdi nop nop nop nop nop dec %r9 mov $95, %rcx rep movsl nop nop nop sub %r9, %r9 // Store lea addresses_A+0x18688, %r11 clflush (%r11) nop nop nop cmp %r14, %r14 movl $0x51525354, (%r11) nop nop nop nop nop cmp $39105, %rsi // Load lea addresses_WT+0x4928, %rsi nop add $19483, %r14 mov (%rsi), %ecx nop nop xor $16515, %rbx // Store lea addresses_WC+0xf028, %r11 nop nop nop xor %rbx, %rbx mov $0x5152535455565758, %rcx movq %rcx, %xmm6 movups %xmm6, (%r11) nop nop nop nop nop add $57523, %rdi // Store lea addresses_UC+0x17148, %rdi nop nop nop nop dec %r11 movb $0x51, (%rdi) nop nop nop nop and %r9, %r9 // Faulty Load lea addresses_normal+0x1ac28, %rcx clflush (%rcx) nop nop nop and $35726, %rdi mov (%rcx), %si lea oracles, %r9 and $0xff, %rsi shlq $12, %rsi mov (%r9,%rsi,1), %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
Route1_Script: jp EnableAutoTextBoxDrawing Route1_TextPointers: dw Route1Text1 dw Route1Text2 dw Route1Text3 Route1Text1: TX_ASM CheckAndSetEvent EVENT_GOT_POTION_SAMPLE jr nz, .asm_1cada ld hl, Route1ViridianMartSampleText call PrintText lb bc, POTION, 1 call GiveItem jr nc, .BagFull ld hl, Route1Text_1cae8 jr .asm_1cadd .BagFull ld hl, Route1Text_1caf3 jr .asm_1cadd .asm_1cada ld hl, Route1Text_1caee .asm_1cadd call PrintText jp TextScriptEnd Route1ViridianMartSampleText: TX_FAR _Route1ViridianMartSampleText db "@" Route1Text_1cae8: TX_FAR _Route1Text_1cae8 TX_SFX_ITEM_1 db "@" Route1Text_1caee: TX_FAR _Route1Text_1caee db "@" Route1Text_1caf3: TX_FAR _Route1Text_1caf3 db "@" Route1Text2: TX_FAR _Route1Text2 db "@" Route1Text3: TX_FAR _Route1Text3 db "@"
/* @flow */ // Copyright (c) 2012-2013 The PPCoin developers // Copyright (c) 2015-2019 The PIVX developers // Copyright (c) 2018-2019 The ZENZO developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/assign/list_of.hpp> #include <boost/lexical_cast.hpp> #include "db.h" #include "kernel.h" #include "script/interpreter.h" #include "timedata.h" #include "util.h" using namespace std; bool fTestNet = false; //Params().NetworkID() == CBaseChainParams::TESTNET; // Modifier interval: time to elapse before new modifier is computed // Set to 3-hour for production network and 20-minute for test network unsigned int nModifierInterval; int nStakeTargetSpacing = 60; unsigned int getIntervalVersion(bool fTestNet) { if (fTestNet) return MODIFIER_INTERVAL_TESTNET; else return MODIFIER_INTERVAL; } // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map<int, unsigned int> mapStakeModifierCheckpoints = boost::assign::map_list_of(0, 0xfd11f4e7u); // Get time weight int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd) { return nIntervalEnd - nIntervalBeginning - nStakeMinAge; } // Get the last stake modifier and its generation time from a given block static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64_t& nStakeModifier, int64_t& nModifierTime) { if (!pindex) return error("GetLastStakeModifier: null pindex"); while (pindex && pindex->pprev && !pindex->GeneratedStakeModifier()) pindex = pindex->pprev; if (!pindex->GeneratedStakeModifier()) return error("GetLastStakeModifier: no generation at genesis block"); nStakeModifier = pindex->nStakeModifier; nModifierTime = pindex->GetBlockTime(); return true; } // Get selection interval section (in seconds) static int64_t GetStakeModifierSelectionIntervalSection(int nSection) { assert(nSection >= 0 && nSection < 64); int64_t a = getIntervalVersion(fTestNet) * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))); return a; } // Get stake modifier selection interval (in seconds) static int64_t GetStakeModifierSelectionInterval() { int64_t nSelectionInterval = 0; for (int nSection = 0; nSection < 64; nSection++) { nSelectionInterval += GetStakeModifierSelectionIntervalSection(nSection); } return nSelectionInterval; } // select a block from the candidate blocks in vSortedByTimestamp, excluding // already selected blocks in vSelectedBlocks, and with timestamp up to // nSelectionIntervalStop. static bool SelectBlockFromCandidates( vector<pair<int64_t, uint256> >& vSortedByTimestamp, map<uint256, const CBlockIndex*>& mapSelectedBlocks, int64_t nSelectionIntervalStop, uint64_t nStakeModifierPrev, const CBlockIndex** pindexSelected) { bool fModifierV2 = false; bool fFirstRun = true; bool fSelected = false; uint256 hashBest = 0; *pindexSelected = (const CBlockIndex*)0; BOOST_FOREACH (const PAIRTYPE(int64_t, uint256) & item, vSortedByTimestamp) { if (!mapBlockIndex.count(item.second)) return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str()); const CBlockIndex* pindex = mapBlockIndex[item.second]; if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop) break; //if the lowest block height (vSortedByTimestamp[0]) is >= switch height, use new modifier calc if (fFirstRun){ fModifierV2 = pindex->nHeight >= Params().ModifierUpgradeBlock(); fFirstRun = false; } if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0) continue; // compute the selection hash by hashing an input that is unique to that block uint256 hashProof; if(fModifierV2) hashProof = pindex->GetBlockHash(); else hashProof = pindex->IsProofOfStake() ? 0 : pindex->GetBlockHash(); CDataStream ss(SER_GETHASH, 0); ss << hashProof << nStakeModifierPrev; uint256 hashSelection = Hash(ss.begin(), ss.end()); // the selection hash is divided by 2**32 so that proof-of-stake block // is always favored over proof-of-work block. this is to preserve // the energy efficiency property if (pindex->IsProofOfStake()) hashSelection >>= 32; if (fSelected && hashSelection < hashBest) { hashBest = hashSelection; *pindexSelected = (const CBlockIndex*)pindex; } else if (!fSelected) { fSelected = true; hashBest = hashSelection; *pindexSelected = (const CBlockIndex*)pindex; } } if (GetBoolArg("-printstakemodifier", false)) LogPrintf("SelectBlockFromCandidates: selection hash=%s\n", hashBest.ToString().c_str()); return fSelected; } // Stake Modifier (hash modifier of proof-of-stake): // The purpose of stake modifier is to prevent a txout (coin) owner from // computing future proof-of-stake generated by this txout at the time // of transaction confirmation. To meet kernel protocol, the txout // must hash with a future stake modifier to generate the proof. // Stake modifier consists of bits each of which is contributed from a // selected block of a given block group in the past. // The selection of a block is based on a hash of the block's proof-hash and // the previous stake modifier. // Stake modifier is recomputed at a fixed time interval instead of every // block. This is to make it difficult for an attacker to gain control of // additional bits in the stake modifier, even after generating a chain of // blocks. bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier) { nStakeModifier = 0; fGeneratedStakeModifier = false; if (!pindexPrev) { fGeneratedStakeModifier = true; return true; // genesis block's modifier is 0 } if (pindexPrev->nHeight == 0) { //Give a stake modifier to the first block fGeneratedStakeModifier = true; nStakeModifier = uint64_t("stakemodifier"); return true; } // First find current stake modifier and its generation block time // if it's not old enough, return the same stake modifier int64_t nModifierTime = 0; if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime)) return error("ComputeNextStakeModifier: unable to get last modifier"); if (GetBoolArg("-printstakemodifier", false)) LogPrintf("ComputeNextStakeModifier: prev modifier= %s time=%s\n", boost::lexical_cast<std::string>(nStakeModifier).c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nModifierTime).c_str()); if (nModifierTime / getIntervalVersion(fTestNet) >= pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) return true; // Sort candidate blocks by timestamp vector<pair<int64_t, uint256> > vSortedByTimestamp; vSortedByTimestamp.reserve(64 * getIntervalVersion(fTestNet) / nStakeTargetSpacing); int64_t nSelectionInterval = GetStakeModifierSelectionInterval(); int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) * getIntervalVersion(fTestNet) - nSelectionInterval; const CBlockIndex* pindex = pindexPrev; while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart) { vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash())); pindex = pindex->pprev; } int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0; reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); // Select 64 blocks from candidate blocks to generate stake modifier uint64_t nStakeModifierNew = 0; int64_t nSelectionIntervalStop = nSelectionIntervalStart; map<uint256, const CBlockIndex*> mapSelectedBlocks; for (int nRound = 0; nRound < min(64, (int)vSortedByTimestamp.size()); nRound++) { // add an interval section to the current selection round nSelectionIntervalStop += GetStakeModifierSelectionIntervalSection(nRound); // select a block from the candidates of current round if (!SelectBlockFromCandidates(vSortedByTimestamp, mapSelectedBlocks, nSelectionIntervalStop, nStakeModifier, &pindex)) return error("ComputeNextStakeModifier: unable to select block at round %d", nRound); // write the entropy bit of the selected block nStakeModifierNew |= (((uint64_t)pindex->GetStakeEntropyBit()) << nRound); // add the selected block from candidates to selected list mapSelectedBlocks.insert(make_pair(pindex->GetBlockHash(), pindex)); if (fDebug || GetBoolArg("-printstakemodifier", false)) LogPrintf("ComputeNextStakeModifier: selected round %d stop=%s height=%d bit=%d\n", nRound, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nSelectionIntervalStop).c_str(), pindex->nHeight, pindex->GetStakeEntropyBit()); } // Print selection map for visualization of the selected blocks if (fDebug || GetBoolArg("-printstakemodifier", false)) { string strSelectionMap = ""; // '-' indicates proof-of-work blocks not selected strSelectionMap.insert(0, pindexPrev->nHeight - nHeightFirstCandidate + 1, '-'); pindex = pindexPrev; while (pindex && pindex->nHeight >= nHeightFirstCandidate) { // '=' indicates proof-of-stake blocks not selected if (pindex->IsProofOfStake()) strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "="); pindex = pindex->pprev; } BOOST_FOREACH (const PAIRTYPE(uint256, const CBlockIndex*) & item, mapSelectedBlocks) { // 'S' indicates selected proof-of-stake blocks // 'W' indicates selected proof-of-work blocks strSelectionMap.replace(item.second->nHeight - nHeightFirstCandidate, 1, item.second->IsProofOfStake() ? "S" : "W"); } LogPrintf("ComputeNextStakeModifier: selection height [%d, %d] map %s\n", nHeightFirstCandidate, pindexPrev->nHeight, strSelectionMap.c_str()); } if (fDebug || GetBoolArg("-printstakemodifier", false)) { LogPrintf("ComputeNextStakeModifier: new modifier=%s time=%s\n", boost::lexical_cast<std::string>(nStakeModifierNew).c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexPrev->GetBlockTime()).c_str()); } nStakeModifier = nStakeModifierNew; fGeneratedStakeModifier = true; return true; } // The stake modifier used to hash for a stake kernel is chosen as the stake // modifier about a selection interval later than the coin generating the kernel bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake) { nStakeModifier = 0; if (!mapBlockIndex.count(hashBlockFrom)) return error("GetKernelStakeModifier() : block not indexed"); const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom]; nStakeModifierHeight = pindexFrom->nHeight; nStakeModifierTime = pindexFrom->GetBlockTime(); int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval(); const CBlockIndex* pindex = pindexFrom; CBlockIndex* pindexNext = chainActive[pindexFrom->nHeight + 1]; // loop to find the stake modifier later by a selection interval while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval) { if (!pindexNext) { // Should never happen return error("Null pindexNext\n"); } pindex = pindexNext; pindexNext = chainActive[pindexNext->nHeight + 1]; if (pindex->GeneratedStakeModifier()) { nStakeModifierHeight = pindex->nHeight; nStakeModifierTime = pindex->GetBlockTime(); } } nStakeModifier = pindex->nStakeModifier; return true; } uint256 stakeHash(unsigned int nTimeTx, CDataStream ss, unsigned int prevoutIndex, uint256 prevoutHash, unsigned int nTimeBlockFrom) { //ZENZO will hash in the transaction hash and the index number in order to make sure each hash is unique ss << nTimeBlockFrom << prevoutIndex << prevoutHash << nTimeTx; return Hash(ss.begin(), ss.end()); } //test hash vs target bool stakeTargetHit(uint256 hashProofOfStake, int64_t nValueIn, uint256 bnTargetPerCoinDay) { //get the stake weight - weight is equal to coin amount uint256 bnCoinDayWeight = uint256(nValueIn) / 100; // Now check if proof-of-stake hash meets target protocol return (uint256(hashProofOfStake) < bnCoinDayWeight * bnTargetPerCoinDay); } //instead of looping outside and reinitializing variables many times, we will give a nTimeTx and also search interval so that we can do all the hashing here bool CheckStakeKernelHash(unsigned int nBits, const CBlock blockFrom, const CTransaction txPrev, const COutPoint prevout, unsigned int& nTimeTx, unsigned int nHashDrift, bool fCheck, uint256& hashProofOfStake, bool fPrintProofOfStake) { //assign new variables to make it easier to read int64_t nValueIn = txPrev.vout[prevout.n].nValue; unsigned int nTimeBlockFrom = blockFrom.GetBlockTime(); if (nTimeTx < nTimeBlockFrom) // Transaction timestamp violation return error("CheckStakeKernelHash() : nTime violation"); if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement return error("CheckStakeKernelHash() : min age violation - nTimeBlockFrom=%d nStakeMinAge=%d nTimeTx=%d", nTimeBlockFrom, nStakeMinAge, nTimeTx); //grab difficulty uint256 bnTargetPerCoinDay; bnTargetPerCoinDay.SetCompact(nBits); //grab stake modifier uint64_t nStakeModifier = 0; int nStakeModifierHeight = 0; int64_t nStakeModifierTime = 0; if (!GetKernelStakeModifier(blockFrom.GetHash(), nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake)) { LogPrintf("CheckStakeKernelHash(): failed to get kernel stake modifier \n"); return false; } //create data stream once instead of repeating it in the loop CDataStream ss(SER_GETHASH, 0); ss << nStakeModifier; //if wallet is simply checking to make sure a hash is valid if (fCheck) { hashProofOfStake = stakeHash(nTimeTx, ss, prevout.n, prevout.hash, nTimeBlockFrom); return stakeTargetHit(hashProofOfStake, nValueIn, bnTargetPerCoinDay); } bool fSuccess = false; unsigned int nTryTime = 0; unsigned int i; int nHeightStart = chainActive.Height(); for (i = 0; i < (nHashDrift); i++) //iterate the hashing { //new block came in, move on if (chainActive.Height() != nHeightStart) break; //hash this iteration nTryTime = nTimeTx + nHashDrift - i; hashProofOfStake = stakeHash(nTryTime, ss, prevout.n, prevout.hash, nTimeBlockFrom); // if stake hash does not meet the target then continue to next iteration if (!stakeTargetHit(hashProofOfStake, nValueIn, bnTargetPerCoinDay)) continue; fSuccess = true; // if we make it this far then we have successfully created a stake hash nTimeTx = nTryTime; if (fDebug || fPrintProofOfStake) { LogPrintf("CheckStakeKernelHash() : using modifier %s at height=%d timestamp=%s for block from height=%d timestamp=%s\n", boost::lexical_cast<std::string>(nStakeModifier).c_str(), nStakeModifierHeight, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", nStakeModifierTime).c_str(), mapBlockIndex[blockFrom.GetHash()]->nHeight, DateTimeStrFormat("%Y-%m-%d %H:%M:%S", blockFrom.GetBlockTime()).c_str()); LogPrintf("CheckStakeKernelHash() : pass protocol=%s modifier=%s nTimeBlockFrom=%u prevoutHash=%s nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", "0.3", boost::lexical_cast<std::string>(nStakeModifier).c_str(), nTimeBlockFrom, prevout.hash.ToString().c_str(), nTimeBlockFrom, prevout.n, nTryTime, hashProofOfStake.ToString().c_str()); } break; } mapHashedBlocks.clear(); mapHashedBlocks[chainActive.Tip()->nHeight] = GetTime(); //store a time stamp of when we last hashed on this block return fSuccess; } // Check kernel hash target and coinstake signature bool CheckProofOfStake(const CBlock block, uint256& hashProofOfStake) { const CTransaction tx = block.vtx[1]; if (!tx.IsCoinStake()) return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString().c_str()); // Kernel (input 0) must match the stake hash target per coin age (nBits) const CTxIn& txin = tx.vin[0]; // First try finding the previous transaction in database uint256 hashBlock; CTransaction txPrev; if (!GetTransaction(txin.prevout.hash, txPrev, hashBlock, true)) return error("CheckProofOfStake() : INFO: read txPrev failed"); //verify signature and script if (!VerifyScript(txin.scriptSig, txPrev.vout[txin.prevout.n].scriptPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&tx, 0))) return error("CheckProofOfStake() : VerifySignature failed on coinstake %s", tx.GetHash().ToString().c_str()); CBlockIndex* pindex = NULL; BlockMap::iterator it = mapBlockIndex.find(hashBlock); if (it != mapBlockIndex.end()) pindex = it->second; else return error("CheckProofOfStake() : read block failed"); // Read block header CBlock blockprev; if (!ReadBlockFromDisk(blockprev, pindex->GetBlockPos())) return error("CheckProofOfStake(): INFO: failed to find block"); unsigned int nInterval = 0; unsigned int nTime = block.nTime; if (!CheckStakeKernelHash(block.nBits, blockprev, txPrev, txin.prevout, nTime, nInterval, true, hashProofOfStake, fDebug)) return error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s, hashProof=%s \n", tx.GetHash().ToString().c_str(), hashProofOfStake.ToString().c_str()); // may occur during initial download or if behind on blockchain sync return true; } // Check whether the coinstake timestamp meets protocol bool CheckCoinStakeTimestamp(int64_t nTimeBlock, int64_t nTimeTx) { // v0.3 protocol return (nTimeBlock == nTimeTx); } // Get stake modifier checksum unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex) { assert(pindex->pprev || pindex->GetBlockHash() == Params().HashGenesisBlock()); // Hash previous checksum with flags, hashProofOfStake and nStakeModifier CDataStream ss(SER_GETHASH, 0); if (pindex->pprev) ss << pindex->pprev->nStakeModifierChecksum; ss << pindex->nFlags << pindex->hashProofOfStake << pindex->nStakeModifier; uint256 hashChecksum = Hash(ss.begin(), ss.end()); hashChecksum >>= (256 - 32); return hashChecksum.Get64(); } // Check stake modifier hard checkpoints bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum) { if (fTestNet) return true; // Testnet has no checkpoints if (mapStakeModifierCheckpoints.count(nHeight)) { return nStakeModifierChecksum == mapStakeModifierCheckpoints[nHeight]; } return true; }
; int ilogb(float x) SECTION code_clib SECTION code_fp_math48 PUBLIC cm48_sdccix_ilogb EXTERN cm48_sdccix_ilogb_fastcall cm48_sdccix_ilogb: pop af pop hl pop de push de push hl push af jp cm48_sdccix_ilogb_fastcall
; A037951: binomial(n,[ (n-3)/2 ]). ; 0,0,0,1,1,5,6,21,28,84,120,330,495,1287,2002,5005,8008,19448,31824,75582,125970,293930,497420,1144066,1961256,4457400,7726160,17383860,30421755,67863915,119759850,265182525 mov $1,$0 div $0,2 add $0,2 bin $1,$0
;/******************************************************************************** ; File:boot.asm ; Description:Bootloader ; ;********************************************************************************/ [BITS 16] ORG 0x7C00 ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; BOOT ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ BOOT: CLI HLT TIMES 510 - ($ - $$) DB 0 DW 0xAA55