From 4b5993cfa9da930738c26e61d300b87c996d5f8e Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Tue, 15 Sep 2020 20:38:34 +0200 Subject: [PATCH] WIP of asm86 --- com/a86.asm | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/com/a86.asm b/com/a86.asm index a194729..2c00ad7 100644 --- a/com/a86.asm +++ b/com/a86.asm @@ -7,16 +7,23 @@ mov [fd], ax -loop: call getc - jc end - cmp dl, 26 - je end + call getline + + mov dx, [line_length] + call dumpdx + + mov si, line_buffer + mov cx, [line_length] mov ah, 2 +l03: lodsb + mov dl, al int 0x21 - jmp loop + loop l03 end: ret +line_num: dw 1 + err: mov dx, ax dumpdx: ; setup bx and ah for int 10h call @@ -53,6 +60,29 @@ getc: mov dl, 26 pop dx ret +getline: mov word [line_length], 0 + mov di, line_buffer + mov cx, line_buflen +l02: push cx + call getc + pop cx + mov al, dl + cmp al, 0x0A + je l01 + cmp al, 0x0D + je l01 + cmp al, 0x1A + je l01 + inc word [line_length] + loop l02 + +l01: ret + infile: db "com/a86.asm", 0 +line_buflen: equ 0x100 +line_length: dw 0 ; valid bytes in buffer +line_prefix: times 16 db " " +line_buffer: times line_buflen db 0 + fd: dw 0