snq
Experienced Member
I'm not sure when MEM was introduced but my DOS 3.3 doesn't have it and I've actually missed it a bit.. So I baked my own version and figured I may as well share it here
It turned out to be 41 bytes, if anyone can see a way to make it smaller please post!
Download below, and here is the source too.
It turned out to be 41 bytes, if anyone can see a way to make it smaller please post!
Download below, and here is the source too.
Code:
;nasm -fbin -omem.com mem.asm
cpu 8086
bits 16
org 100h
; Try to resize our current block to 0FFxxh paragraphs
; This will fail and report max paragraphs available in BX
mov bh, 0FFh
mov ah, 4Ah
int 21h
; Divide by (1024/16)
; On 286+ we can shr ax,6 directly and save 1 byte
xchg ax, bx
mov cl, 6
shr ax, cl
; Convert to string, starting with the last digit
; Overwrites code we don't need any more, to save space
jmp short skipString
digitsGoHere:
db 'k$'
skipString:
mov bl, 10
mov di, digitsGoHere
convertLoop:
dec di
div bl
add ah, '0'
mov [di], ah
xor ah, ah
test al, al
jnz short convertLoop
; Output string, we have our pointer in DI
mov ah, 9
mov dx, di
int 21h
ret