Add first steps of another assembler attempt

This commit is contained in:
Nero 2020-07-19 12:07:03 +02:00
parent 5382edc2ae
commit a90ca60422
1 changed files with 58 additions and 0 deletions

58
com/a86.asm Normal file
View File

@ -0,0 +1,58 @@
org 0x100
mov ax, 0x3D00
mov dx, infile
int 0x21
jc err
mov [fd], ax
loop: call getc
jc end
cmp dl, 26
je end
mov ah, 2
int 0x21
jmp loop
end: ret
err: mov dx, ax
dumpdx: ; setup bx and ah for int 10h call
xor bx, bx
mov ah, 0x0e
mov cl, 4
; this double-call is essentially a 4 times repeating loop
call dmpdx1
dmpdx1: call dmpdx2
dmpdx2: ; grab highest nibble from dx
mov al, dh
; remove highest nibble from dx
shl dx, cl
; shift away second-highest nibble that we accidentally copied
shr al, cl
; map 0-9 to ascii codes for '0' to '9'
add al, 0x30
; if result is larger than '9', ...
cmp al, 0x3a
jl dmpdx3
; ... add 7 so we continue at 'A'
add al, 7
dmpdx3: int 0x10
ret
; read a character from the input file into DL
getc: mov dl, 26
push dx
mov ah, 0x3f
mov bx, [fd]
mov cx, 1
mov dx, sp
int 0x21
pop dx
ret
infile: db "com/a86.asm", 0
fd: dw 0