; TEST03.ASM study of random schrages
; Author: oni[at]sdf[dot] org
; TASM.EXE borland international inc. turbo assemmbler 4.0
; COMMAND: TASM TEST03.ASM
;          TLINK TEST03.OBJ
; DATE: 16th of November 2021

.MODEL small
.STACK 0100H
.DATA
prompt DB 'random; enter any ascii seed:','$'
buffer DB 120
output DB 12
constA equ 21845
constC equ 43691

.CODE

start:
    mov ax, @data
    mov ds, ax
    mov ax, @stack
    mov ss, ax
    ; boilerplate do not edit

    mov ah, 09H
    mov dx, OFFSET prompt
    int 21H


    mov ah, 0AH
    mov dx, OFFSET buffer
    int 21H

    mov ax, 00H

    mov bx, 0FFH
    lea di, buffer
collector:
    inc di

    add ax, [di]
    add cx, ax
    add cx, ax
    dec bx
    cmp bx, 00H
    jne collector

    mov di, 00004H
columns:
    mov ax, cx

    mov cx, OFFSET constA
multiply:
    add dx, ax
    dec cx
    cmp cx, 00H
    jnz multiply

    mov cx, dx
    mov ax, cx

    add ax, OFFSET constC
    mov cx, ax
    mov ah, 02H
    mov dl, 13
    int 21H
    mov ah, 02H
    mov dl, 10
    int 21H
    mov ax, cx
modulo:
    sub ax, 0AH
    dec bx
    cmp ax, 0AH
    ja modulo
    add ax, 030H
    mov ah, 02H
    mov dl, al
    int 21H
    dec di
    cmp di, 0000H
    jnz columns

    ;boilerplate do not edit
    mov ah, 4CH
    mov al, 00H
    int 21H


END start







