URL
https://opencores.org/ocsvn/light8080/light8080/trunk
Subversion Repositories light8080
[/] [light8080/] [trunk/] [sw/] [tb/] [tb0/] [tb0.asm] - Rev 74
Compare with Previous | Blame | View Log
;***********************************************************************; MICROCOSM ASSOCIATES 8080/8085 CPU DIAGNOSTIC VERSION 1.0 (C) 1980;***********************************************************************;;DONATED TO THE "SIG/M" CP/M USER'S GROUP BY:;KELLY SMITH, MICROCOSM ASSOCIATES;3055 WACO AVENUE;SIMI VALLEY, CALIFORNIA, 93065;(805) 527-9321 (MODEM, CP/M-NET (TM));(805) 527-0518 (VERBAL);;***********************************************************************; Modified 2001/02/28 by Richard Cini for use in the Altair32 Emulator; Project;; Need to somehow connect this code to Windows so that failure messages; can be posted to Windows. Maybe just store error code in; Mem[0xffff]. Maybe trap NOP in the emulator code?;;***********************************************************************; Modified 2006/11/16 by Scott Moore to work on CPU8080 FPGA core;;***********************************************************************; Modified 2007/09/24 by Jose Ruiz for use in light8080 FPGA core;; 1.- Changed formatting for compatibility to CP/M's ASM; 2.- Commented out all Altair / MITS hardware related stuff; 3.- Set origin at 0H;; Modified again in 2008 to make it compatible with TASM assembler.;; Modified 2012/02/12 to add a few CY checks.; Flags go almost completely unchecked in this test.;***********************************************************************; DS pseudo-directive; reserve space in bytes, without initializing it; (TASM does not have a DS directive)#define ds(n) \.org $+n;; Select controller defines;;selmain: equ 00H ; offset of main control register;sel1msk: equ 02H ; offset of select 1 mask;sel1cmp: equ 03H ; offset of select 1 compare;sel2msk: equ 04H ; offset of select 1 mask;sel2cmp: equ 05H ; offset of select 1 compare;sel3msk: equ 06H ; offset of select 1 mask;sel3cmp: equ 07H ; offset of select 1 compare;sel4msk: equ 08H ; offset of select 1 mask;sel4cmp: equ 09H ; offset of select 1 compare;; bits;;selenb: equ 01H ; enable select;selio: equ 02H ; I/O address or memory;; Note: select 1 is ROM, 2, is RAM, 3 is interrupt controller, 4 is serial I/O.;;; Where to place ROM and RAM for this test;;rombas: equ 0000H;rambas: equ rombas+4*1024;; Interrupt controller defines;;intbas: equ 10H;intmsk: equ intbas+00H ; mask;intsts: equ intbas+01H ; status;intact: equ intbas+02H ; active interrupt;intpol: equ intbas+03H ; polarity select;intedg: equ intbas+04H ; edge/level select;intvec: equ intbas+05H ; vector base page;; Mits Serial I/O card;;siobas: equ 20H;sioctl: equ siobas+00H ; control register;siodat: equ siobas+01H ; data;; Set up selectors;;; ROM;; mvi a,rombas shr 8 ; enable select 1 to 4kb at base; out sel1cmp; mvi a,(0f000H shr 8) or selenb; out sel1msk;; RAM;; mvi a,rambas shr 8 ; enable select 2 to 1kb at base; out sel2cmp; mvi a,(0fc00H shr 8) or selenb; out sel2msk;; ROM and RAM set up, exit bootstrap mode;; mvi a,00H ; exit bootstrap mode; out selmain;; Serial I/O;; mvi a,siobas ; enable serial controller for 4 addresses; out sel4cmp; mvi a,0fcH or selio or selenb; out sel4msk;************************************************************; 8080/8085 CPU TEST/DIAGNOSTIC;************************************************************;;note: (1) program assumes "call",and "lxi sp" instructions work;;; (2) instructions not tested are "hlt","di","ei",; and "rst 0" thru "rst 7";;;;test jump instructions and flags;.org 0Hcpu: lxi sp,stack ;set the stack pointermvi a,077H ;@ initialize A to remove X values from simulationani 0 ;initialize a reg. and clear all flagsjz j010 ;test "jz"call cpuerj010: jnc j020 ;test "jnc"call cpuerj020: jpe j030 ;test "jpe"call cpuerj030: jp j040 ;test "jp"call cpuerj040: jnz j050 ;test "jnz"jc j050 ;test "jc"jpo j050 ;test "jpo"jm j050 ;test "jm"jmp j060 ;test "jmp" (it's a little late,but what the hell;j050: call cpuerj060: adi 6 ;a=6,c=0,p=1,s=0,z=0jnz j070 ;test "jnz"call cpuerj070: jc j080 ;test "jc"jpo j080 ;test "jpo"jp j090 ;test "jp"j080: call cpuerj090: adi 70H ;a=76h,c=0,p=0,s=0,z=0jpo j100 ;test "jpo"call cpuerj100: jm j110 ;test "jm"jz j110 ;test "jz"jnc j120 ;test "jnc"j110: call cpuerj120: adi 81H ;a=f7h,c=0,p=0,s=1,z=0jm j130 ;test "jm"call cpuerj130: jz j140 ;test "jz"jc j140 ;test "jc"jpo j150 ;test "jpo"j140: call cpuerj150: adi 0feH ;a=f5h,c=1,p=1,s=1,z=0jc j160 ;test "jc"call cpuerj160: jz j170 ;test "jz"jpo j170 ;test "jpo"jm aimm ;test "jm"j170: call cpuer;;;;test accumulator immediate instructions;aimm: cpi 0 ;a=f5h,c=0,z=0jc cpie ;test "cpi" for re-set carryjz cpie ;test "cpi" for re-set zerocpi 0f5H ;a=f5h,c=0,z=1jc cpie ;test "cpi" for re-set carry ("adi")jnz cpie ;test "cpi" for re-set zerocpi 0ffH ;a=f5h,c=1,z=0jz cpie ;test "cpi" for re-set zerojc acii ;test "cpi" for set carrycpie: call cpueracii: aci 00aH ;a=f5h+0ah+carry(1)=0,c=1aci 00aH ;a=0+0ah+carry(0)=0bh,c=0cpi 00bHjz suii ;test "aci"call cpuersuii: sui 00cH ;a=ffh,c=0sui 00fH ;a=f0h,c=1cpi 0f0Hjz sbii ;test "sui"call cpuersbii: sbi 0f1H ;a=f0h-0f1h-carry(0)=ffh,c=1sbi 0eH ;a=ffh-oeh-carry(1)=f0h,c=0cpi 0f0Hjz anii ;test "sbi"call cpueranii: ani 055H ;a=f0h<and>55h=50h,c=0,p=1,s=0,z=0cc cpuercz cpuercpi 050Hjz orii ;test "ani"call cpuerorii: ori 03aH ;a=50h<or>3ah=7ah,c=0,p=0,s=0,z=0cc cpuercz cpuercpi 07aHjz xrii ;test "ori"call cpuerxrii: xri 00fH ;a=7ah<xor>0fh=75h,c=0,p=0,s=0,z=0cc cpuercz cpuercpi 075Hjz c010 ;test "xri"call cpuer;;;;test calls and returns;c010: ani 0H ;a=0,c=0,p=1,s=0,z=1cc cpuer ;test "cc"cpo cpuer ;test "cpo"cm cpuer ;test "cm"cnz cpuer ;test "cnz"cpi 0Hjz c020 ;a=0,c=0,p=0,s=0,z=1call cpuerc020: sui 077H ;a=89h,c=1,p=0,s=1,z=0cnc cpuer ;test "cnc"cpe cpuer ;test "cpe"cp cpuer ;test "cp"cz cpuer ;test "cz"cpi 089Hjz c030 ;test for "calls" taking branchcall cpuerc030: ani 0ffH ;set flags back;cpo cpoi ;test "cpo"cpi 0d9Hjz movi ;test "call" sequence successcall cpuercpoi: rpe ;test "rpe"adi 010H ;a=99h,c=0,p=0,s=1,z=0cpe cpei ;test "cpe"adi 002H ;a=d9h,c=0,p=0,s=1,z=0rpo ;test "rpo"call cpuercpei: rpo ;test "rpo"adi 020H ;a=b9h,c=0,p=0,s=1,z=0cm cmi ;test "cm"adi 004H ;a=d7h,c=0,p=1,s=1,z=0rpe ;test "rpe"call cpuercmi: rp ;test "rp"adi 080H ;a=39h,c=1,p=1,s=0,z=0cp tcpi ;test "cp"adi 080H ;a=d3h,c=0,p=0,s=1,z=0rm ;test "rm"call cpuertcpi: rm ;test "rm"adi 040H ;a=79h,c=0,p=0,s=0,z=0cnc cnci ;test "cnc"adi 040H ;a=53h,c=0,p=1,s=0,z=0rp ;test "rp"call cpuercnci: rc ;test "rc"adi 08fH ;a=08h,c=1,p=0,s=0,z=0cc cci ;test "cc"sui 002H ;a=13h,c=0,p=0,s=0,z=0rnc ;test "rnc"call cpuercci: rnc ;test "rnc"adi 0f7H ;a=ffh,c=0,p=1,s=1,z=0cnz cnzi ;test "cnz"adi 0feH ;a=15h,c=1,p=0,s=0,z=0rc ;test "rc"call cpuercnzi: rz ;test "rz"adi 001H ;a=00h,c=1,p=1,s=0,z=1cz czi ;test "cz"adi 0d0H ;a=17h,c=1,p=1,s=0,z=0rnz ;test "rnz"call cpuerczi: rnz ;test "rnz"adi 047H ;a=47h,c=0,p=1,s=0,z=0cpi 047H ;a=47h,c=0,p=1,s=0,z=1rz ;test "rz"call cpuer;;;;test "mov","inr",and "dcr" instructions;movi: mvi a,077Hinr amov b,ainr bmov c,bdcr cmov d,cmov e,dmov h,emov l,hmov a,l ;test "mov" a,l,h,e,d,c,b,adcr amov c,amov e,cmov l,emov b,lmov d,bmov h,dmov a,h ;test "mov" a,h,d,b,l,e,c,amov d,ainr dmov l,dmov c,linr cmov h,cmov b,hdcr bmov e,bmov a,e ;test "mov" a,e,b,h,c,l,d,amov e,ainr emov b,emov h,binr hmov c,hmov l,cmov d,ldcr dmov a,d ;test "mov" a,d,l,c,h,b,e,amov h,adcr hmov d,hmov b,dmov l,binr lmov e,ldcr emov c,emov a,c ;test "mov" a,c,e,l,b,d,h,amov l,adcr lmov h,lmov e,hmov d,emov c,dmov b,cmov a,bcpi 077Hcnz cpuer ;test "mov" a,b,c,d,e,h,l,a;;;;test arithmetic and logic instructions;xra amvi b,001Hmvi c,003Hmvi d,007Hmvi e,00fHmvi h,01fHmvi l,03fHadd badd cadd dadd eadd hadd ladd acpi 0f0Hcnz cpuer ;test "add" b,c,d,e,h,l,asub bsub csub dsub esub hsub lcpi 078Hcnz cpuer ;test "sub" b,c,d,e,h,lsub acnz cpuer ;test "sub" amvi a,080Hadd amvi b,001Hmvi c,002Hmvi d,003Hmvi e,004Hmvi h,005Hmvi l,006Hadc bmvi b,080Hadd badd badc cadd badd badc dadd badd badc eadd badd badc hadd badd badc ladd badd badc acpi 037Hcnz cpuer ;test "adc" b,c,d,e,h,l,amvi a,080Hadd amvi b,001Hsbb bmvi b,0ffHadd bsbb cadd bsbb dadd bsbb eadd bsbb hadd bsbb lcpi 0e0Hcnz cpuer ;test "sbb" b,c,d,e,h,lmvi a,080Hadd asbb acpi 0ffHcnz cpuer ;test "sbb" amvi a,0ffHmvi b,0feHmvi c,0fcHmvi d,0efHmvi e,07fHmvi h,0f4Hmvi l,0bfHstcana acc cpuerana cana dana eana hana lana acpi 024Hcnz cpuer ;test "ana" b,c,d,e,h,l,axra amvi b,001Hmvi c,002Hmvi d,004Hmvi e,008Hmvi h,010Hmvi l,020Hstcora bcc cpuerora cora dora eora hora lora acpi 03fHcnz cpuer ;test "ora" b,c,d,e,h,l,amvi a,0Hmvi h,08fHmvi l,04fHstcxra bcc cpuerxra cxra dxra exra hxra lcpi 0cfHcnz cpuer ;test "xra" b,c,d,e,h,lxra acnz cpuer ;test "xra" amvi b,044Hmvi c,045Hmvi d,046Hmvi e,047Hmvi h,temp0 / 0ffH ;high byte of test memory locationmvi l,temp0 & 0ffH ;low byte of test memory locationmov m,bmvi b,0Hmov b,mmvi a,044Hcmp bcnz cpuer ;test "mov" m,b and b,mmov m,dmvi d,0Hmov d,mmvi a,046Hcmp dcnz cpuer ;test "mov" m,d and d,mmov m,emvi e,0Hmov e,mmvi a,047Hcmp ecnz cpuer ;test "mov" m,e and e,mmov m,hmvi h,temp0 / 0ffHmvi l,temp0 & 0ffHmov h,mmvi a,temp0 / 0ffHcmp hcnz cpuer ;test "mov" m,h and h,mmov m,lmvi h,temp0 / 0ffHmvi l,temp0 & 0ffHmov l,mmvi a,temp0 & 0ffHcmp lcnz cpuer ;test "mov" m,l and l,mmvi h,temp0 / 0ffHmvi l,temp0 & 0ffHmvi a,032Hmov m,acmp mcnz cpuer ;test "mov" m,aadd mcpi 064Hcnz cpuer ;test "add" mxra amov a,mcpi 032Hcnz cpuer ;test "mov" a,mmvi h,temp0 / 0ffHmvi l,temp0 & 0ffHmov a,msub mcnz cpuer ;test "sub" mmvi a,080Hadd aadc mcpi 033Hcnz cpuer ;test "adc" mmvi a,080Hadd asbb mcpi 0cdHcnz cpuer ;test "sbb" mstcana mcc cpuercnz cpuer ;test "ana" mmvi a,025Hstcora mcc cpuercpi 37Hcnz cpuer ;test "ora" mstcxra mcc cpuercpi 005Hcnz cpuer ;test "xra" mmvi m,055Hinr mdcr madd mcpi 05aHcnz cpuer ;test "inr","dcr",and "mvi" mlxi b,12ffHlxi d,12ffHlxi h,12ffHinx binx dinx hmvi a,013Hcmp bcnz cpuer ;test "lxi" and "inx" bcmp dcnz cpuer ;test "lxi" and "inx" dcmp hcnz cpuer ;test "lxi" and "inx" hmvi a,0Hcmp ccnz cpuer ;test "lxi" and "inx" bcmp ecnz cpuer ;test "lxi" and "inx" dcmp lcnz cpuer ;test "lxi" and "inx" hdcx bdcx ddcx hmvi a,012Hcmp bcnz cpuer ;test "dcx" bcmp dcnz cpuer ;test "dcx" dcmp hcnz cpuer ;test "dcx" hmvi a,0ffHcmp ccnz cpuer ;test "dcx" bcmp ecnz cpuer ;test "dcx" dcmp lcnz cpuer ;test "dcx" hsta temp0xra alda temp0cpi 0ffHcnz cpuer ;test "lda" and "sta"lhld temppshld temp0lda temppmov b,alda temp0cmp bcnz cpuer ;test "lhld" and "shld"lda tempp+1mov b,alda temp0+1cmp bcnz cpuer ;test "lhld" and "shld"mvi a,0aaHsta temp0mov b,hmov c,lxra aldax bcpi 0aaHcnz cpuer ;test "ldax" binr astax blda temp0cpi 0abHcnz cpuer ;test "stax" bmvi a,077Hsta temp0lhld tempplxi d,00000Hxchgxra aldax dcpi 077Hcnz cpuer ;test "ldax" d and "xchg"xra aadd hadd lcnz cpuer ;test "xchg"mvi a,0ccHstax dlda temp0cpi 0ccHstax dlda temp0cpi 0ccHcnz cpuer ;test "stax" dlxi h,07777Hdad hmvi a,0eeHcmp hcnz cpuer ;test "dad" hcmp lcnz cpuer ;test "dad" hlxi h,05555Hlxi b,0ffffHdad bmvi a,055Hcnc cpuer ;test "dad" bcmp hcnz cpuer ;test "dad" bmvi a,054Hcmp lcnz cpuer ;test "dad" blxi h,0aaaaHlxi d,03333Hdad dmvi a,0ddHcmp hcnz cpuer ;test "dad" dcmp lcnz cpuer ;test "dad" bstccnc cpuer ;test "stc"cmccc cpuer ;test "cmcmvi a,0aaHcmacpi 055Hcnz cpuer ;test "cma"ora a ;re-set auxiliary carrydaacpi 055Hcnz cpuer ;test "daa"mvi a,088Hadd adaacpi 076Hcnz cpuer ;test "daa"xra amvi a,0aaHdaacnc cpuer ;test "daa"cpi 010Hcnz cpuer ;test "daa"xra amvi a,09aHdaacnc cpuer ;test "daa"cnz cpuer ;test "daa"stcmvi a,042Hrlccc cpuer ;test "rlc" for re-set carryrlccnc cpuer ;test "rlc" for set carrycpi 009Hcnz cpuer ;test "rlc" for rotationrrccnc cpuer ;test "rrc" for set carryrrccpi 042Hcnz cpuer ;test "rrc" for rotationralralcnc cpuer ;test "ral" for set carrycpi 008Hcnz cpuer ;test "ral" for rotationrarrarcc cpuer ;test "rar" for re-set carrycpi 002Hcnz cpuer ;test "rar" for rotationlxi b,01234Hlxi d,0aaaaHlxi h,05555Hxra apush bpush dpush hpush pswlxi b,00000Hlxi d,00000Hlxi h,00000Hmvi a,0c0Hadi 0f0Hpop pswpop hpop dpop bcc cpuer ;test "push psw" and "pop psw"cnz cpuer ;test "push psw" and "pop psw"cpo cpuer ;test "push psw" and "pop psw"cm cpuer ;test "push psw" and "pop psw"mvi a,012Hcmp bcnz cpuer ;test "push b" and "pop b"mvi a,034Hcmp ccnz cpuer ;test "push b" and "pop b"mvi a,0aaHcmp dcnz cpuer ;test "push d" and "pop d"cmp ecnz cpuer ;test "push d" and "pop d"mvi a,055Hcmp hcnz cpuer ;test "push h" and "pop h"cmp lcnz cpuer ;test "push h" and "pop h"lxi h,00000Hdad spshld savstk ;save the "old" stack-pointer;lxi sp,temp4dcx spdcx spinx spdcx spmvi a,055Hsta temp2cmasta temp3pop bcmp bcnz cpuer ;test "lxi","dad","inx",and "dcx" spcmacmp ccnz cpuer ;test "lxi","dad","inx", and "dcx" splxi h,temp4sphllxi h,07733Hdcx spdcx spxthllda temp3cpi 077Hcnz cpuer ;test "sphl" and "xthl"lda temp2cpi 033Hcnz cpuer ;test "sphl" and "xthl"mvi a,055Hcmp lcnz cpuer ;test "sphl" and "xthl"cmacmp hcnz cpuer ;test "sphl" and "xthl"lhld savstk ;restore the "old" stack-pointersphllxi h,cpuokpchl ;test "pchl"cpuer: mvi a, 0aaH ; set exit code (failure)out 20hhlt ; stop herecpuok: mvi a, 55H ;out 20hhlt ; stop here - no trap;; Data area in program space;tempp: .dw temp0 ;pointer used to test "lhld","shld",; and "ldax" instructions;; Data area in variable space;temp0: ds(1) ;temporary storage for cpu test memory locationstemp1: ds(1) ;temporary storage for cpu test memory locationstemp2: ds(1) ;temporary storage for cpu test memory locationstemp3: ds(1) ;temporary storage for cpu test memory locationstemp4: ds(1) ;temporary storage for cpu test memory locationssavstk: ds(2) ;temporary stack-pointer storage locationds(256) ;de-bug stack pointer storage areastack: .dw 0.end
