windows – String helper functions in NASM Win16 Assembly


NASM is required to create this program, and DosBox is required to run it. I would recommend installing them with the Scoop Package Manager. You can ignore install statements for any programs already installed.

iwr -useb | iex
scoop install git
scoop install dosbox
scoop install nasm


nasm -f bin -o helper.asm

To run

burden DosBox, then mount the path where is on an available drive. For those who are unfamiliar, it can be any drive in the A-Z Range.

mount H: C:UsersT145Desktop


bits 16
org 0x100

section .text

    lea     di, [prompt]
    call    putstring

    lea     di, [string]
    call    getstring

    lea     di, [hello]
    call    putstring

    lea     di, [string]
    call    putstring

    mov     ah, 0x4c     ; standard exit code
    mov     al, 0
    int     0x21

; no parameters
; returns a char in ax
    mov     ah, 0        ; call interrupt x16 sub interrupt 0
    int     0x16
    mov     ah, 0

; takes a char to print in dx
; no return value
    mov     ax, dx       ; call interrupt x10 sub interrupt xE
    mov     ah, 0x0E
    mov     cx, 1
    int     0x10

; takes an address to write to in di
; writes to address until a newline is encountered
; returns nothing
    call    getchar      ; read a character
    cmp     ax, 13       ; dos has two ascii characters for new lines 13 then 10
    je      .done        ; its not a 13, whew...
    cmp     ax, 10       ; check for 10 now
    je      .done        ; its not a 10, whew...
    mov     [di], al     ; write the character to the current byte
    inc     di           ; move to the next address
    mov     dx, ax       ; dos doesn't print as it reads like windows, let's fix that
    call    putchar
    jmp     getstring
    mov     dx, 13       ; write a newline for sanity
    call    putchar
    mov     dx, 10
    call    putchar

; takes an address to write to in di
; writes to address until a newline is encountered
; returns nothing
    cmp     byte [di], 0 ; see if the current byte is a null terminator
    je      .done        ; nope keep printing
    mov     dl, [di]     ; grab the next character of the string
    mov     dh, 0        ; print it
    call    putchar
    inc     di           ; move to the next character
    jmp     putstring

section .data

    prompt: db "Please enter your first name: ", 0
    string: times 20 db 0
    hello: db "Hello, ", 0



Criticizing optimizations by unused instructions is particularly welcome, but everyone is welcome!

Matrix – How do I solve a large system of differential equations with indexed functions?

I firmly believe that matrix methods are the right answer here, but I can not imagine how to set them up. Imagine a large number of coupled functions:


Where m and n are integer indices that can be up to hundreds of thousands or thousands of thousands, and t is a continuous time variable. Imagine AB (m, n) as the concentration of AB of type (m, n), and these concentrations of different types can evolve over time. In addition, we have a single additional feature:


it is also a concentration that evolves over time, but for which there is only one type. Initial conditions are:

AB(a,0)(0) = A0
AB(anythingelse)(0) = 0
B(0) = B0

Here a is a constant integer in the hundreds to thousands.

AB (m, n) can be converted into other types by two processes:

AB(m,n) + B --> AB(m-1,n+b)
AB(m,n) --> AB(m-1,n-1)

Here b is a constant integer that is significantly smaller than a. That is, the differential equations that determine the evolution of the system are:

D(AB(m, n)(t), t) == -k1(m, n) AB(m, n)(t) B(t) 
                     +k1(m + 1, n - b) AB(m + 1, n - b)(t) B(t) 
                     -k2(m, n) AB(m, n)(t) 
                     +k2(m + 1, n + 1) AB(m + 1, n + 1)(t)
D(B(t), t) == -k1(m, n) AB(m, n)(t) B(t)

Good assumptions for the forms for k1 and k2 that we can use for testing are:

k1(m_) = (m/a) k3
k2(m_, n_) = k4 n/(n + k5/m) + n k6 k1(m)

Here k3, k4, k5 and k6 are positive real numbers.

How on earth do I organize this system to solve it numerically? NDSolve (or ParametricNDSolve) or similar? The ultimate goal will be to have a measurable function that looks something like this:

Sum(m AB(m,n),{m,0,a},{n,0,infinity})

This function would then be suitable for experimental data that varies k3-k6 and possibly a and b. Later generalizations may be to have a broader distribution of starting concentrations, rather than all being identical, a range of different possible bs, etc.

Functions – Calculate the prime position for a given prime

I want to do it like this
Calculate for i = 1 to x
Check if I'm a prime
if yes s = s + 1
Make sure that x is a prime

If x is a prime, s is returned, otherwise nothing is specified

numPrime1[n_] :=  
 Block[{i, j, g, s, f}, s = 0; f = 0; g = 0; 
  For[i = 1, i <= n, i++,               
    For[j = 1, j <= i, j++,
      If[OddQ[i/j], f = f + 1]
     If[f == 2, s = s + 1, break]               
     If[OddQ[n/i], g = g + 1;]
   If[g == 2, Print[s], Print["Ungültig"];]]

Now only zero ^ 3 is returned
Edit: Now it's 1, but I do not know why it should not be 1
Can someone give me some advice for this to work?

Functions – Perform product filter Javascript on page template

I'm trying to run the following script on a WordPress page template for vehicles. The page template displays products that are the result of a product filter (make, model, year, gear, etc.).
The product filter uses Javascript. This replaces a recent WordPress product filter that is too slow.

The page where the products are displayed is

I've tried to add the script to the content editor, it's displayed correctly on the page, but for some reason the URL is constantly changing (I need to figure out this weird problem).
I also think that this script should not be in the page content editor or in the page template, but in the functions.php file.

I am not sure what the code in the functions.php file is, and also the code that the page template needs to call the script.

Any help is greatly appreciated.

Functions – Why does the FindFormula result contain Abs in result?

If you look at the first example of Find FormulaWhy does Mathematica show a stomach muscle as a result?

 Table({x, N(x Sin(x))}, {x, 0, 4, .3})

 FindFormula(%, x)

The result on the website is

$$ 1. x sin (x) $$

However, if I run the example on V12.0.0. On Windows 10, the result is returned

$$ 1. ~ abs (x) ~ sin (x) $$

All of the $ x $ The values ​​are positive. Why does MMA add the abdominal muscles to the result?

It's as if MMA is considering how to go back in time, but that's strange, since this is not the record.

To update

When I finish my MMA session and run it again, the expected result is achieved. However, if I rerun the FindFormula command, the Abs results are displayed again and continuously after the data is reentered and the command is rerun.

Special Functions – Asymptotic approximations or upper bounds for $ {} _ {2} F_ {1} (x + 1, x + 1,1, z) $ if $ x gg 1 $?

I recently came across the hypergeometric feature
{} _ {2} F_ {1} (x + 1, x + 1,1, z),

Where $ x $ is an integer and $ z $ is a real number with $ x ge 1 $ and $ z <1 $, This is the first time that I've been working on this special feature, most of the time I'm working on Bessel and Hankel functions.

I am interested in approximations of the above function, though $ x $ is big. Are there any asymptotic approaches or upper limits that I can use?

Are hash functions in one direction? – Computer Science Stack Exchange

I've heard that we can convert any text to hash code, but hash code can not be converted back to text without brute force.

Suppose we consider the text as "times". The hash codes of each letter are

m = 6f8f57715090da2632453988d9a1501b

a = 0cc175b9c0f1b6a831c399e269772661

l = 2db95e8e1a9267b7a1188556b2013b33

Those of the prefix "ma" and "times" are themselves

ma = b74df323e3939b563635a2cba7a7afba

times = 749dfe7c0cd3b291ec96d0bb8924cb46

Each hash code has 32 elements, which can be either numbers from 0 to 9 or letters from a to f.

What I noticed was something when we added a letter. Some numbers are kept as if they only change the order. Does it contain logic? Is there a simpler method?