im using
Mov AH, 0
INT 0x16

For getting characters pressed
and character data is in AL

i Display the character data on the screen using
Mov AH, 0x0E
INT 0x10

i Want to push characters as its displaying on the screen and be able to pop them when enter is pressed.

How do i Push and Pop the character i mentioned in AL?

Here is the piece of the code im useing

;Tells the assembler that its a 16 bit code

Loop:
XOR CL, CL
MOV AH, 0
INT 0x16

CMP AL, 0x08 ;backspace
JE Bspace

CMP AL, 0x0D ; enter
JE Xcute

;Need to have it Push the character in AL
MOV AH, 0x0E
INT 0x10

;add letter to current line data
JMP Loop
JMP $

Xcute:
;Need to have it pop the character data and use
;MOV AL, (charater)
;CALL PrintCharacter
call Nline

JMP Loop


Bspace:
MOV AL, 0x08
MOV AH, 0x0E
INT 10h
MOV AL, 0x20
MOV AH, 0x0E
INT 10h
MOV AL, 0x08
MOV AH, 0x0E
INT 10h
;remove last character from screen and current line data (if the cursor
; isnt already leftmost)
JMP Loop

Nline:
MOV AL, 0Ah  ;line feed
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07
INT 0x10
MOV AL, 0Dh  ;backspace carrige
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07
INT 0x10
RET


PrintCharacter: ;Procedure to print character on screen
;Assume that ASCII value is in register AL
MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
MOV BH, 0x00 ;Page no.
MOV BL, 0x07 ;Text attribute 0x07 is lightgrey font on black background

INT 0x10 ;Call video interrupt
RET ;Return to calling procedure

TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with 0
DW 0xAA55
Posted on 2012-11-27 07:18:36 by gotatrust
Well, you can't push/pop al, of course. ASSuming you set up a sane stack, you can push/pop ax, and only pay attention to al (make sure it doesn't overwrite the 0xE you want in ah). I question whether that's really what you want to do - it'll reverse your string, won't it? You could set up a stack frame, and put your buffer on the stack, if you really wanted to. In any case, you probably want to limit the number of characters the user can enter to the space you've got in the buffer (whether on the stack or not) - no need to re-invent "gets()"!

Best,
Frank

Posted on 2012-11-27 14:04:20 by fbkotler