- Homework Statement
- Please i need to do this in 8086 NASM assembly:
Read lines of text from the terminal. Write to the terminal the first half of the read lines and from each line only the first half of the read bytes.
You count half as a whole number. Half of eg 5 are 2. Then the first half will contain 2 lines or bytes and the second half 3 lines or bytes.
There can be up to 600 lines in the input, each line can be up to 100 bytes long.
Even empty lines must be passed to the output.
On the output, each line must be terminated with CR LF characters, regardless of which line separator it was terminated on the input.
For simplicity, only letters without diacritics, numbers and spaces appear in the loaded data.
- Relevant Equations
- Need help
cpu 8086 segment code ..start mov ax,data mov ds,ax mov ax,stack mov ss,ax mov sp,dno mov es, ax start_2 mov ah, 0x0a mov dx, buffer int 21h cmp al, 0 je print_lines inc word [count] mov si, buffer mov di, line mov cx, 100 rep movsb jmp print_lines print_lines mov ax, [count] shr ax, 1 mov [half], ax mov bx, [half] mov cx, [half] print_line mov dx, line mov ah, 9 int 21h mov si, line mov di, line_end mov cx, 2 rep movsb mov ax, 100 shr ax, 1 mov [half_byte], ax add si, [half_byte] mov cx, 100 rep movsb dec bx jz end jmp print_line empty_line mov ah, 9 mov dx, empty_string int 21h jmp print_line end hlt segment data buffer db 100 half dw 0 count dw 0 half_byte dw 0 line_end db 0Ah, 0Dh line db 100 empty_string db 0Ah, 0Dh segment stack resb 100 dno: db ?
Last edited by a moderator: