Yeah, I just saw your latest question on SO. Thought I remembered it from before that. Earlier version, maybe. No matter, between us we'll get it working!
;NASM-IDE ASM Assistant Assembler Project File
BITS 16 ;Set code generation to 16 bit mode
ORG 0x0100 ;Set code start address to 0100h
SEGMENT .text ;Main code segment
MAIN:
MOV DI, array
Call GETSTRING
MOV SI, array
Call PUTSTRING
JMP EXIT ; don't really need to jump there - won't hurt
EXIT:
MOV AX, 4C00H
INT 21H
PUTCH:
PUSH AX
MOV AH, 02H
MOV DL, DL ; ??? is this what you meant to do?
INT 21H
POP AX
ret
GETCH:
PUSH BX
MOV BH, AH
MOV AH, 08H
INT 21H
MOV AH, BH
POP BX
ret
PUTLINE:
; what's this intended to do?
; doesn't matter 'cause we're not calling it anymore
; should just exit
PUSH AX
PUSH BX
MOV AH, 0004CH
INT 21H
POP AX
POP BX
ret
GETSTRING:
Call GETCH
; character's in al
; you're going to want it in both places anyway
mov dl, al
CMP DL, 0DH
JE END
Call PUTCH
STOSB
JMP GETSTRING
END:
MOV AL, 00H
STOSB
ret
PUTSTRING:
CLD
LODSB
CMP AL, 00H
JZ END1
MOV DL, AL
Call PUTCH
JMP PUTSTRING
END1:
ret
SEGMENT .data ;Initialised data segment
mesg db 'assembly', 0DH, 0AH, '$'
CR equ 0DH
LF equ 0AH
SEGMENT .bss ;Uninitialised data segment
array resb 256 ; reserves 256 bytes of space
I think that might work. It isn't too great, you've reinvented "gets()" - allowed the user to enter more than will fit in your buffer. Probably not a real target for "attackerz", but we can discuss how to fix it. Get it working first.
Best,
Frank