; Program to print out the next 10 numbers after a number. ; Written in x86 Assembly Language. Compiled with A86 v3.22, 1990 ; VERSION 1 - screws up on 99,999,9999, etc. ; check out my registers - make sure that nothing screws up by overwriting ; something. Make sure that you know what variable is in each register all ; the time. ; SI = copy of message pointer for manipulating ; DX = message pointer: initally it has length of line, etc as first two ; bytes. We then make it just point to message start. ; The DX pointer initally has output string, then it gets the numeric ; input (with 2 leader characters). We overwrite the numeric input with ; the numbers that we want (since we are not doing any other I/O). ; CX = string length ; BX BH=0; BL = file handle ; AH = interrupts, passing values to subroutines, scratch register ; AL = loop counter -- GETS OVERWRITTEN BY INT 21 !! ; note: the number is stored as a character, never converted to binary. ; 1: print message MOV DX,MYTEXT ; DS:DX message pointer MOV CX,TXT_SIZE ; CX number of bytes to write MOV BX,1 CALL MSG_OUT ; WHAT IS INT 33 ??? mouse or DOS ??? ; 2: get input MOV AH,0A INT 21H ; 3: set up variables MOV SI,DX ; store pointer in SI where it can be manipulated MOV CH,0 ; zero out CH MOV CL,[SI+1] ; put string length into CL MOV AL,0 ; AL will be the loop counter INC SI ; increment pointer twice INC SI MOV DX,SI ; now DX (and SI) pointer actually points to start of string. CMP CL,1 ; check for only 1 digit JNE CONT1 MOV AH,[SI] ; copy digit to AH MOV [SI+1],AH ; move to next position MOV B[SI],30H ; insert a zero character INC CX ;(INT 21,40 strings do not have to be zero truncated) CONT1: ADD SI,CX DEC SI ; now SI points to the last digit ; 4: loop start MAIN_LOOP: INC AL CMP AL,10 ; do loop 10 times JA EXIT ; safer than just exiting when AL=10 ; -- any big number will exit MOV AH,[SI] ; put byte in AH INC AH ; increment MOV [SI],AH ; put back into data string CMP AH,3AH ; have we gone past the digit 9 ? JNE CONT2 MOV B[SI],30H ; set digit back to zero MOV AH,[SI-1] ; get tens digit INC AH MOV [SI-1],AH ; store incremented tens digit CONT2: ;print string out again, but first print a CRLF MOV AH,13 CALL STD_OUT MOV AH,10 CALL STD_OUT CALL MSG_OUT JMP MAIN_LOOP EXIT: ;MOV AX,04C00 ; sucessful program termination ;INT 33 ; back to DOS RET ; Return to DOS MSG_OUT PROC ; DX has message, null terminated, CX=string length PUSH AX ; BX=file handle (1=console) ; none of these are ever changed (except for AX) MOV AH,040H ; INT 21 code for write to device BX INT 21H POP AX RET MSG_OUT ENDP STD_OUT PROC ; AH has character to output PUSH AX,DX ; Save registers MOV DL,AH ; In DL for DOS call MOV AH,2 ; Standard output INT 21H ; DOS call POP DX,AX ; Restore registers RET ; Return STD_OUT ENDP MYTEXT: DB 'Enter a number (integer) ',0 TXT_SIZE EQU $ - MYTEXT