CPU 8086 ORG 0x3000 ;Load a file and print it ;Set the stack cli mov sp, stack + 0x100 sti ;Check for an empty tail ;Check cmp byte [si], 0x0 jne start ;Print an error message and abort if the tail is empty mov si, errormsg mov ah, 0x2 int 0x21 je done start: ;Find the end of the filename and add a null if needed ;Set DI at the tail mov di, si findend: ;Check for the string end cmp byte [di], 0x0 je load ;Check for a space cmp byte [di], 0x20 je addnull inc di jmp findend addnull: mov al, 0x0 stosb ;Load the file load: ;Load mov bx, stack + 0x100 mov ah, 0x0 int 0x22 ;Check for errors cmp al, 0x0 jne done ;Print the file ;Setup mov bh, 0x0 mov bl, 0x18 mov dl, 0x50 mov si, stack + 0x100 print: ;Decrease the character counter dec dl ;Load the current character lodsb ;Print the character mov ah, 0xe int 0x10 ;Check for a hard line end cmp al, 0xa je linecount ;Check for a soft line end cmp dl, 0x0 je linecount contprint: ;Check paging cmp bl, 0x0 jz page ;Repeat for the next character loop print jmp done ;Decrease the line counter and reset the character one linecount: dec bl mov dl, 0x50 jmp contprint ;Page page: push ax mov ah, 0x0 int 0x16 pop ax mov bl, 0x18 mov dl, 0x50 loop print done: int 0x20 ;Data errormsg db "File not found", 0x0 stack: