my problem is that I need to number lines according to the following assignment among some other tasks. I managed to do all the others, but I don't know how to do this one. Number the non-empty lines passed to the output with sequential numbers in the decimal system starting with the number 1. There will never be more than 99 lines to number. You always place two digits from the beginning of the line followed by a period and a space. If the line number is in the range 1-9, you place a space before the number. example: _1._text 10._text
this is the part where I tried to do it, but without success. I thought about using stack, but I wanted to ask for advice first.
...
nums inc cx
; mov bx, tens
; cmp bx, 50
; ja lower
;both mov dx, ones
; mov ah, 9
; int 21h
; inc dx
mov dx, bfrtxt
mov ah, 9
int 21h
; mov dx, ones
; cmp dx, 59
; je reset
fork test cx,1
jz oddw1
jnz evenw1
;lower mov dx, ' '
; mov ah, 9
; int 21h
; jmp both
;
;higher mov dx, tens
; mov ah, 9
; int 21h
; cmp dx, 9
; jmp both
;reset mov dx, 49
; jmp fork
...
segment data
resb 1024
ones db 50
tens db 49
line db 0
bfrtxt db '. ','$'
This code only generates line numbers from 1 to 23 just to fit the screen. Change
max_linesto 99.Line number is stored in
line_num. Code modifies only bytes at offsetline_numandline_num + 1.How to combine text with line number is up to You. ;)