Skip to content

Instantly share code, notes, and snippets.

@angch
Created November 21, 2022 08:20
Embed
What would you like to do?
format mz
mov ax, 3h
int 10h ; cls
mov ah, 2
mov bh, 0
mov dx, 1700h
int 10h
mov cx, [0080h]
mov ch , 0
mov di, 81h
xor ax, ax
mov bl, 10
again:
mov dl, [di]
cmp dl, '0'
jb skip
cmp dl, '9'
ja skip
imul bl
sub dl, '0'
add al, dl
skip:
inc di
dec cx
jnz again
; AX has the input
cmp ax, 12
jbe ok
mov ax, 12
ok:
push 0B800h
pop ds
mov cx, ax
inc cx
push cx
shl ax, 1
mov bx, ax
jmp loop2a
loop2:
mov di, ax
mov byte [di], 4
mov di, bx
mov byte [di], 4
add ax, 162
add bx, 158
loop2a:
dec cx
jnz loop2
pop cx
; jmp loop3a
loop3:
mov di, ax
mov byte [di], 4
mov di, bx
mov byte [di], 4
loop3a:
add ax, 158
add bx, 162
dec cx
jnz loop3
mov ax,4C00h
int 21h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment