Search code examples
assemblydosx86-16tasm

Can I push al onto a stack in TASM?


I am a beginner in assembly and any help would be appreciated. Here is my code:

.MODEL SMALL

.DATA  
Textstring db "I'm a string$"
.CODE
START:

mov dx, Textstring
push dx
getche:
    mov ah, 06h
    int 21h
    push al



 END START

I keep getting the errors that operand types do not match on line 8 and argument to operation or instruction has illegal size on line 13.
I am guessing the problem is I am trying to push AL onto the stack. Is there anyway I could push the contents of AL onto the stack? I am trying to make a code where I prompt the user for a character and return that character back to the program that called it.


Solution

  • You cannot push AL into the stack because every element of the stack is a word and AL's size is a byte.

    What you can do, is reset AH's value and push AX into the stack so AL will contain the value you want and AH will just be 0 which will not affect the data in AL.