Nawpe
Nawpe

Reputation: 11

How to use PUSH properly?

PILE SEGMENT STACK
DW 256 DUP(?)
base:
PILE ENDS

DATA SEGMENT

N1 DB 1
N2 DB 2
N3 DB 3


DATA ENDS

CODE SEGMENT

ASSUME CS:CODE, DS:DATA, SS:PILE

main:

MOV AX,DATA
MOV DS,AX
MOV AX,PILE
MOV SS,AX
MOV SP,Base

MOV AH,N1
PUSH AH

fin:

MOV AH,4CH
INT 21H
CODE ENDS
END main

Hello everyone,

I'm currently learning how to code in Assembly Language, and after a very long reading of several lessons on the internet, it was time to get started. Now, the practice isn't as easy as the reading, without any surprise. Everything was fine until the stack...yup. You can see my (really basic) code above, I would like to understand why Emu8086 doesn't understand the instruction "PUSH AH" knowing that the register isn't empty and the stack is initialised.

Thanks

Upvotes: 1

Views: 674

Answers (1)

Sep Roland
Sep Roland

Reputation: 39676

MOV AH,N1
PUSH AH

The push instruction does not allow a byte sized register operand.
What you need to do is write push ax. This works because the 8-bit AH register is (together with the 8-bit AL register) part of the 16-bit AX register. You are not required to put any value in the AL register beforehand for this to work.

MOV AH,N1
PUSH AX

All the above applies to the pop instruction also!

Upvotes: 1

Related Questions