This worked in simulation. Might try in real 1802 with slowish stepping.
C:\Users\Dell\Documents\1802_Data\a18\WorkingApril282020\intsPractice1.lst
0000 START ORG 0
0000 7b seq
0001 f8 03 ldi $03 ;careful, we have some nops up there.
0003 b2 phi 2 ;R2 is stack pointer
0004 f8 45 ldi $45
0006 a2 plo 2 ;R2=stack pointer now points to $00ff
0007 e2 sex 2 ;X now pnts to R2, the stack pointer. 00ff
0008 f8 00 ldi HIGH(ISR)
000a b1 phi 1
000b f8 55 ldi LOW(ISR)
000d a1 plo 1
000e loop0
000e f8 2d ldi $2d ;want output this byte on channel 1
0010 73 stxd
0011 12 inc 2
;here P=0 and X=2
; enableinterrupts
; sex 0 ;P=0 currently
; ret ;
; DB $20 ;ret will use this. Now P=0,X=2. Interrupts enabled
; disableinterrupts
; sex 0 ;P=0 currently
; dis ;
; DB $20 ;dis will use this.Now P=0,X=2 and interrupts disabled
0012 loop1
0012 61 out 1
0013 30 12 br loop1
0053 ORG $0053
0053 exit ;leave ISR here
0053 42 lda 2 ;put back DB
0054 71 dis ;same as ret but disable interrupts
;ret ;X,P get old values. Enable interrupts
0055 ORG $0055
0055 ISR ;get R1 to point here for interrupts. T = XP
0055 22 dec 2 ;R=2 is stack ptr. Point to free space
0056 78 sav ;T goes to MR(X)
0057 22 dec 2 ;fresh slot on stack
0058 52 str 2 ;D goes on stack
0059 c4 nop ;do other stuff
005a 30 53 br exit ;leave main part of ISR
0345 ORG $345
0345 11 22 33 0f DB $11,$22,$33,$0f,$55
0349 55
03fb ORG $3fb
03fb c4 nop
03fc c4 nop
03fd c4 nop
03fe c4 nop
03ff c4 nop
0400 END
0055 ISR 0000 START 0053 exit 000e loop0
0012 loop1
Tuesday, April 28, 2020
Now writing to virtual RAM
Actually, date wrong. Got out of sequence.
Note change in virtual RAM.0000 START ORG 0
0000 7b seq
0001 7a req
0002 7b seq
0003 f8 00 ldi $00
0005 b7 phi 7
0006 f8 98 ldi 98H
0008 a7 plo 7
0009 f8 a5 write ldi $A5 ;MADE CHANGE to $5b in above
000b 57 str 7
000c 30 09 br write
0064 ORG 100
0064 c4 nop
0065 END
0000 START 0009 write
COSMACuino 0.1 going.
Now have ability to send programs to Mega which the 1802 "thinks" is ROM. Status information continuously sent to Bray term. Two "commands"used du=dump contents of virtual RAM to serial terminal, gf=get file, a .bin file from the a18 assembler. When a new file is received, the 1802 stops and resets and starts using new 1802 instructions just received.
See below:
See below:
Enable and disable interrupts on 1802.
Relies on a trick where X is set to P so that after a RET x is pointing to the byte beyond the RET and this is the pretend T that is usually on the stack at the end of a internet service routine.
0000 START ORG 0
0000 7b seq
0001 f8 03 ldi $03 ;careful, we have some nops up there.
0003 b2 phi 2 ;R2 is stack pointer
0004 f8 45 ldi $45
0006 a2 plo 2 ;R2=stack pointer now points to $00ff
0007 e2 sex 2 ;X now pnts to R2, the stack pointer. 00ff
0008 loop0
0008 f8 2d ldi $2d ;want output this byte on channel 1
000a 73 stxd
000b 12 inc 2
;here P=0 and X=2
000c enableinterrupts
000c e0 sex 0 ;P=0 currently. Now X is too.
000d 70 ret ;goes and gets T from stack, but stackptr is now R0
000e 20 DB $20 ;ret will use this. Now P=0,X=2. Interrupts enabled
000f disableinterrupts
000f e0 sex 0 ;P=0 currently.Now X is too.
0010 71 dis ;
0011 20 DB $20 ;dis will use this.Now P=0,X=2 and interrupts disabled
0012 loop1
0012 61 out 1
0013 30 12 br loop1
0345 ORG $345
0345 11 22 33 0f DB $11,$22,$33,$0f,$55
0349 55
03fb ORG $3fb
03fb c4 nop
03fc c4 nop
03fd c4 nop
03fe c4 nop
03ff c4 nop
0400 END
0000 START 000f disableinterrupts 000c enableinterrupts 0008 loop0
0012 loop1
0000 START ORG 0
0000 7b seq
0001 f8 03 ldi $03 ;careful, we have some nops up there.
0003 b2 phi 2 ;R2 is stack pointer
0004 f8 45 ldi $45
0006 a2 plo 2 ;R2=stack pointer now points to $00ff
0007 e2 sex 2 ;X now pnts to R2, the stack pointer. 00ff
0008 loop0
0008 f8 2d ldi $2d ;want output this byte on channel 1
000a 73 stxd
000b 12 inc 2
;here P=0 and X=2
000c enableinterrupts
000c e0 sex 0 ;P=0 currently. Now X is too.
000d 70 ret ;goes and gets T from stack, but stackptr is now R0
000e 20 DB $20 ;ret will use this. Now P=0,X=2. Interrupts enabled
000f disableinterrupts
000f e0 sex 0 ;P=0 currently.Now X is too.
0010 71 dis ;
0011 20 DB $20 ;dis will use this.Now P=0,X=2 and interrupts disabled
0012 loop1
0012 61 out 1
0013 30 12 br loop1
0345 ORG $345
0345 11 22 33 0f DB $11,$22,$33,$0f,$55
0349 55
03fb ORG $3fb
03fb c4 nop
03fc c4 nop
03fd c4 nop
03fe c4 nop
03ff c4 nop
0400 END
0000 START 000f disableinterrupts 000c enableinterrupts 0008 loop0
0012 loop1
Monday, April 27, 2020
OUT instruction proves tricky but perhaps OK now.
Think I've got it. On 1802 I/O is almost like DMA.
For OUT 1 (0x61) the byte cycle after instruction fetch puts the address in R(x) on address bus, does a read, ie. pulls MRD* low. This causes the memory byte M(R(X)) to go onto the data bus. Here it can be read by an I/O device like 8255 PORT. This is possible because the 1802 also decodes the LSNibble of the 0x6X instruction and puts X (1,2,..7) on the bus.The nBus. In this case above, we enter the )x61= OUT 1 instruction with X=2 and R2 = 0345. The byte at 0345 is 0x0f. So during the cycle after reading OUT 1=0x61 instruction, R(X) = 0345 is put on address bus, MRD* is brought low, N=1 put on nBus and the byte 0x0f is read onto the data bus. Also, R(X) is incremented so is pointing to the next byte in increasing-address string.
Note that to put 0x0f on stack with ldi 0x0f, stxd, we have to increment stack pointer R2 so R2 points to the 0x0f (0345) not (0344). We have to undo the decrementing of R2 during stxd.
All this took me a while to get right on real 1802 as the issues were compounded be having stack starting at 03ff and increasing into variable RAM territory above there as well as power supply batteries for 1802 getting around 3.5 volts and causing intermittent errors. Each issue confused solving surrounding issues.
For OUT 1 (0x61) the byte cycle after instruction fetch puts the address in R(x) on address bus, does a read, ie. pulls MRD* low. This causes the memory byte M(R(X)) to go onto the data bus. Here it can be read by an I/O device like 8255 PORT. This is possible because the 1802 also decodes the LSNibble of the 0x6X instruction and puts X (1,2,..7) on the bus.The nBus. In this case above, we enter the )x61= OUT 1 instruction with X=2 and R2 = 0345. The byte at 0345 is 0x0f. So during the cycle after reading OUT 1=0x61 instruction, R(X) = 0345 is put on address bus, MRD* is brought low, N=1 put on nBus and the byte 0x0f is read onto the data bus. Also, R(X) is incremented so is pointing to the next byte in increasing-address string.
Note that to put 0x0f on stack with ldi 0x0f, stxd, we have to increment stack pointer R2 so R2 points to the 0x0f (0345) not (0344). We have to undo the decrementing of R2 during stxd.
All this took me a while to get right on real 1802 as the issues were compounded be having stack starting at 03ff and increasing into variable RAM territory above there as well as power supply batteries for 1802 getting around 3.5 volts and causing intermittent errors. Each issue confused solving surrounding issues.
Saturday, April 25, 2020
Cosmacuino has disassembler
Cosmacuino has disassembler but getting too big for nano.WIP
Note in serial terminal screen getting 20KHz clock cycle. Fastest yet but still slowed down by all that Arduino loop code. Get a big jump going from delay =02,01 then zero.Maybe compiler just misses out delay(0) and doesn't even visit delay() code.
Arduino code is in pasetbin: https://pastebin.com/a8HFscTC
Terminal shortcuts are here: https://pastebin.com/FhA4MMX0
Note in serial terminal screen getting 20KHz clock cycle. Fastest yet but still slowed down by all that Arduino loop code. Get a big jump going from delay =02,01 then zero.Maybe compiler just misses out delay(0) and doesn't even visit delay() code.
Arduino code is in pasetbin: https://pastebin.com/a8HFscTC
Terminal shortcuts are here: https://pastebin.com/FhA4MMX0
Friday, April 17, 2020
Cosmacuino 0.2, but no disassembler yet.
cadsPasted latest version C:\Users\Dell\Documents\Arduino\PB_SketchApril12\CDP1802e1\CDP1802e1.ino to Pastebin, in background. Also you can see serial terminal work in Bray terminal as well as list of terminal commands that can be sent to Arduino. There is an interpretb funcition that acts of command like singlestep etc. Viz:
--------------------------------------------------------------------------------------
void interpretCommand() {
String Command(receivedChars); //**important
if(Command.equals("gf")){
Serial.print("Getting File");
getFile();
serialFlush();
Serial.println("**done gf flush** Now resetting");
doReset();
}
if(Command.equals("dk")){
dumpVariableVert(1024);
serialFlush();
Serial.println("**done dkflush**");
}
if(Command.equals("du")){
dumpVariableVert(256);
serialFlush();
Serial.println("**done duflush**");
}
if(Command.equals("re")){
doReset();
TPBCtr=0; clkCtr = 0;
serialFlush();
Serial.println("**did reset flush**");
}
if((receivedBytes[0]==0x62)&&(receivedBytes[1]==0x70)) doBreakPoint2(); //<bpxxxx>
if((receivedBytes[0]==0x6f)&&(receivedBytes[1]==0x70)) doOpStop2();
......etc.......
---------------------------------------------------------------------------------------------
Subscribe to:
Posts (Atom)
Pi Pico and other Boards
Got a new Pi Pico and it looks very promising. Want to use Oled display with it.
-
1802 talks to Arduino Mega. If a constant $c4 = nop is output from PORTC of mega to BUS of 1802 it always fetches a nop, just as it did i...
-
The breadboard version of the CDP1802 2 Nano system is starting. And the schematic for the breadboard is below. But only some of the brea...
-
This worked in simulation. Might try in real 1802 with slowish stepping. C:\Users\Dell\Documents\1802_Data\a18\WorkingApril282020\intsPrac...



