Category : Assembly Language Source Code
Archive   : SLOWDOWN.ZIP

Output of file : SLOWDOWN.ASM contained in archive : SLOWDOWN.ZIP
page 66,132
title slowdown.asm - reduce processor speed

code segment
assume cs:code

org 0100h

jmp init

; ----- DATA -----

ms_slowing db "Processor being slowed down...",0dh,0ah
db '$'
ms_badvalue db "Incorrect value for SlowDown:",0dh,0ah
db "Specify a number between 1 and 95 inclusive!",0dh,0ah
db '$'

tim_adr label dword ; address of original user timer rtn
tim_off dw ?
tim_seg dw ?

k_ten dw 10 ; constant 10
k_100 dw 100 ; 100

tick_cnt dw 0 ; tick counter

loop_cnt label dword ; loop counter
loop_low dw 0
loop_high dw 0

pct_idle dw 50 ; default: 50% idle

loop_max dw ?


; This first timer interrupt routine is just used to calibrate the timer
; so that the user can enter a percentage rather than an absolute count.

inc tick_cnt
jmp tim_adr

; This timer routine loads a loop counter with the desired number of
; iterations and counts down to zero before returning.

push ax
mov ax,loop_max
mov loop_low,ax
pop ax
push ax
mov ax,loop_low
dec ax
mov loop_low,ax
pop ax
cmp loop_low,0
jge tim_lp
jmp tim_adr

; ----- INITIALIZATION -----


; establish addressability

push cs
pop ds
assume ds:code

; Check for parameters

mov cl,byte ptr ds:[80h]
xor ch,ch
jcxz got_factor

; Parameter present - scan for digits.

mov si,81h
xor bx,bx
sub al,'0'
jb next_digit
cmp al,10
jae next_digit
xchg ax,bx
mul k_ten
add al,bl
adc ah,0
xchg ax,bx
loop scan_lp

cmp bx,1
jb bad_value
cmp bx,96
jae bad_value
mov pct_idle,bx
jmp short got_factor

mov dx,offset ms_badvalue
mov ah,9
int 21h

mov al,1
mov ah,4ch
int 21h

; Get current timer interrupt vector

mov al,1ch
mov ah,35h
int 21h
mov tim_seg,es
mov tim_off,bx

; Set timer interrupt vector to routine 1

mov dx,offset tim_rtn_1
mov al,1ch
mov ah,25h
int 21h

; Loop 1: Wait for first tick to happen.

cmp tick_cnt,0
jz l1

; Loop 2: Increment loop counter until second tick happens.

push ax
mov ax,loop_low
inc ax
mov loop_low,ax
pop ax
cmp tick_cnt,2
jb l2

; Now the number of loop iterations per tick is known. Multiply by the
; user-supplied percentage to get the number he wants to diddle away.

mov ax,loop_low
mul pct_idle
div k_100
mov loop_max,ax

; Set up the second interrupt routine.

mov dx,offset tim_rtn_2
mov al,1ch
mov ah,25h
int 21h

; Print friendly message

mov dx,offset ms_slowing
mov ah,09h
int 21h

; Exit (keep program resident)

mov al,0
mov dx,offset init+100h
mov cl,4
shr dx,cl
mov ah,31h
int 21h

code ends
end start

  3 Responses to “Category : Assembly Language Source Code
Archive   : SLOWDOWN.ZIP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: