home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
20 Miles North of Nowhere BBS
/
20miles_north_of_nowhere_1996_05_10.zip
/
20miles_north_of_nowhere_1996_05_10
/
EMULATOR
/
8080.ZIP
/
8080.INC
< prev
next >
Wrap
Text File
|
1985-11-21
|
6KB
|
436 lines
IF1 ;;only need envolve pass1
;
; Macros to Define 8080 Instruction Set to MASM (Intel mnemonics)
; (Allows development of 8080/V20 emulation code user PC-DOS)
;
; STEPHEN R DAVIS '85 (214-)454-2426
;
; (Note that the IN and OUT instructions were left out
; since the I/O configuration of a V20/30 system is not the
; same as an 8080, the di and ei instructions were renamed id and
; ie to avoid conflict with the DI register and the SP was renamed
; STKP to avoid conflict with the 8086/88 SP register). The two
; NEC instructions CALLN (call native mode) and RETEM (return from
; emulation have been added to allow 8080 code interaction with the
; native mode code.)
;
; When used in a program, these macros "generate" instructions by building
; the opcodes up. You may want to suppress this instruction generation
; from appearing in your listings with a .SALL statement at the beginning
; of your program.
;
; DEFINE THE 8080 REGISTERS
;
.Y = 0
IRPC X,BCDEHLMA
X = .Y
.Y = .Y + 1
ENDM
STKP = 6 ;;some instructions use sp
PSW = 6 ;;and push/pop uses psw
; SOME INSTRUCTIONS ACT ON REGISTER PAIRS (BC,DE,HL)
; THE FOLLOWING MACRO GENERATES AN ERROR IF THE
; SPECIFIED ARGUMENT IS NOT A LEGAL REGISTER PAIR
PAIR MACRO ARG
.OK = 1
IF (ARG MOD 2)
ARG ;NOT A REGISTER PAIR
.OK = 0
ENDIF
ENDM
; MANY OF THE SINGLE ARGUMENT INSTRUCTIONS
; WHICH USE DOUBLE REGISTERS FOLLOW A PATTERN
DOUBLE MACRO OPCODE,ARG
PAIR ARG
IF .OK
DB OPCODE+(ARG SHL 3)
ENDIF
ENDM
; STAX AND LDAX HAVE THE SAME RESTRICTIONS AS
; THE OTHER DOUBLES WITH THE ADDED RESTRICTION
; THAT ONLY REGISTERS B AND D ARE LEGAL ARGUMENTS
STXLDX MACRO OPCODE,ARG
.OK = 1
IRPC .X,HM
IFE .X-ARG
.OK = 0
ARG ;ILLEGAL ARGUMENT
ENDIF
ENDM
IF .OK
DOUBLE OPCODE,ARG
ENDIF
ENDM
; THE CALL AND JUMP GROUP HAVE THEIR OWN FORMAT
CJ MACRO OPCODE,ADDR
DB OPCODE
DW ADDR
ENDM
; NOW THE ACTUAL INSTRUCTION DEFINITIONS
; INSTRUCTIONS WITHOUT ARGUMENTS
NOP MACRO
DB 0H
ENDM
RLC MACRO
DB 7H
ENDM
RRC MACRO
DB 0FH
ENDM
RAL MACRO
DB 17H
ENDM
RAR MACRO
DB 1FH
ENDM
DAA MACRO
DB 27H
ENDM
CMA MACRO
DB 2FH
ENDM
STC MACRO
DB 37H
ENDM
CMC MACRO
DB 3FH
ENDM
HLT MACRO
DB 76H
ENDM
RNZ MACRO
DB 0C0H
ENDM
RZ MACRO
DB 0C8H
ENDM
RET MACRO
DB 0C9H
ENDM
RNC MACRO
DB 0D0H
ENDM
RC MACRO
DB 0D8H
ENDM
RPO MACRO
DB 0E0H
ENDM
RPE MACRO
DB 0E8H
ENDM
PCHL MACRO
DB 0E9H
ENDM
XTHL MACRO
DB 0E3H
ENDM
XCHG MACRO
DB 0EBH
ENDM
RP MACRO
DB 0F0H
ENDM
ID MACRO
DB 0F3H
ENDM
RM MACRO
DB 0F8H
ENDM
SPHL MACRO
DB 0F9H
ENDM
IE MACRO
DB 0FBH
ENDM
;THE SIMPLE SINGLE ARGUMENT INSTRUCTIONS
ADD MACRO ARG
DB 80H+ARG
ENDM
ADC MACRO ARG
DB 88H+ARG
ENDM
SUB MACRO ARG
DB 90H+ARG
ENDM
SBB MACRO ARG
DB 98H+ARG
ENDM
ANA MACRO ARG
DB 0A0H+ARG
ENDM
XRA MACRO ARG
DB 0A8H+ARG
ENDM
ORA MACRO ARG
DB 0B0H+ARG
ENDM
CMP MACRO ARG
DB 0B8H+ARG
ENDM
ADI MACRO ARG
DB 0C6H
DB ARG
ENDM
ACI MACRO ARG
DB 0CEH
DB ARG
ENDM
SUI MACRO ARG
DB 0D6H
DB ARG
ENDM
SBI MACRO ARG
DB 0DEH
DB ARG
ENDM
ANI MACRO ARG
DB 0E6H
DB ARG
ENDM
XRI MACRO ARG
DB 0EEH
DB ARG
ENDM
ORI MACRO ARG
DB 0F6H
DB ARG
ENDM
CPI MACRO ARG
DB 0FEH
DB ARG
ENDM
INR MACRO ARG
DB 04H+(ARG * 8)
ENDM
DCR MACRO ARG
DOUBLE 05H,ARG
ENDM
;THE DOUBLE REGISTER SINGLE ARGUMENT
STAX MACRO ARG
STXLDX 02H,ARG
ENDM
INX MACRO ARG
DOUBLE 03H,ARG
ENDM
DAD MACRO ARG
DOUBLE 09H,ARG
ENDM
LDAX MACRO ARG
STXLDX 0AH,ARG
ENDM
DCX MACRO ARG
DOUBLE 0BH,ARG
ENDM
SHLD MACRO ARG1,ARG2
DB 22H
DW ARG1 ARG2
ENDM
LHLD MACRO ARG1,ARG2
DB 2AH
DW ARG1 ARG2
ENDM
STA MACRO ARG1,ARG2
DB 32H
DW ARG1 ARG2
ENDM
LDA MACRO ARG1,ARG2
DB 3AH
DW ARG1 ARG2
ENDM
POP MACRO ARG
DOUBLE 0C1H,ARG
ENDM
PUSH MACRO ARG
DOUBLE 0C5H,ARG
ENDM
;HERE ARE THE CALL, INTERRUPT, JUMP & RETURN GROUP
RST MACRO NUM ;;ONLY RST 0 THRU RST 7 ALLOWED
.OK = 0 ;;ASSUME ILLEGAL
IRPC .X,01234567
IFE .X-NUM ;;OH - WE HAVE A MATCH
.OK = 1 ;;MEANS ITS OK
ENDIF
ENDM
IFE .OK
NUM ;ILLEGAL ARGUMENT -- MUST BE 0 THRU 7
ELSE
DB 0C7H+(NUM * 8)
ENDIF
ENDM
JNZ MACRO ADDR
CJ 0C2H,ADDR
ENDM
JMP MACRO ADDR
CJ 0C3H,ADDR
ENDM
JZ MACRO ADDR
CJ 0CAH,ADDR
ENDM
JNC MACRO ADDR
CJ 0D2H,ADDR
ENDM
JC MACRO ADDR
CJ 0DAH,ADDR
ENDM
JPO MACRO ADDR
CJ 0E2H,ADDR
ENDM
JPE MACRO ADDR
CJ 0EAH,ADDR
ENDM
JP MACRO ADDR
CJ 0F2H,ADDR
ENDM
JM MACRO ADDR
CJ 0FAH,ADDR
ENDM
CNZ MACRO ADDR
CJ 0C4H,ADDR
ENDM
CZ MACRO ADDR
CJ 0CCH,ADDR
ENDM
CALL MACRO ADDR
CJ 0CDH,ADDR
ENDM
CNC MACRO ADDR
CJ 0D4,ADDR
ENDM
CC MACRO ADDR
CJ 0DCH,ADDR
ENDM
CPO MACRO ADDR
CJ 0E4H,ADDR
ENDM
CPE MACRO ADDR
CJ 0ECH,ADDR
ENDM
CP MACRO ADDR
CJ 0F4H,ADDR
ENDM
CM MACRO ADDR
CJ 0FCH,ADDR
ENDM
;NOW THE 2 ARGUMENT GROUP
MOV MACRO ARG1,ARG2
DB 40H+(ARG1 SHL 3)+ARG2
ENDM
LXI MACRO ARG1,ARG2
DOUBLE 01H,ARG1
DW ARG2
ENDM
MVI MACRO ARG1,ARG2
DB 06H+(ARG1 SHL 3)
DB ARG2
ENDM
;FINALLY WE ADD THE NEC UNIQUE INSTRUCTIONS
INTEM MACRO ARG ;;BREAK INTO 8080 EMULATION
DB 0FH,0FFH
DB ARG
ENDM
CALLN MACRO ARG ;;CALL NATIVE 8086 CODE FROM EMULATION
DB 0EDH,0EDH
DB ARG
ENDM
RETEM MACRO ;;RETURN TO NATIVE MODE FROM EMULATION
DB 0EDH,0FDH
ENDM
ENDIF