Shop OBEX P1 Docs P2 Docs Learn Events
qZ80 - the third shot - Page 9 — Parallax Forums

qZ80 - the third shot

12345679»

Comments

  • heaterheater Posts: 3,370
    edited 2010-07-29 06:44
    That's looks more like it.

    Now Chris you know where to get Zog from and the ZPU C compiler is here opensource.zylin.com/zpu.htm [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Chris MicroChris Micro Posts: 160
    edited 2010-07-29 08:29
    Yes, I know, someone should do it.
    But ... my time is a little bit limited. My next project will be running the propeller code on an XMEGA wink.gif
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-07-29 14:42
    Success!

    It is midnight (a good time for vampires to be working) and I need to record this before I forget how it is done.

    1) Get the a.dsk off the first page of this thread
    2) Run the qz80 and xmodem three files off the disk - LDRBIOS.MAC, MPMXIOS.MAC AND MPMD.LIB
    3) rename them LDRBIOSJ.MAC, MPMXIOSJ.MAC AND MPMDJ.LIB
    4) Find the reference to MPMD.LIB in both the mac files and change it to MPMDJ.LIB
    5) Copy them using R into the SIMH
    6) Use PIP to copy SYSMPM.SUB to SYSMPMJ.SUB
    7) Use wordstar to edit SYSMPMJ.SUB to this
    [code]

    ; build MP/M system
    ; needs to be executed under CP/M 2
    ; required sources: LDRBIOS.MAC, MPMXIOS.MAC, MPMD.LIB
    ; required programs: M80.COM, L80.COM, DDTZ.COM, LINK.COM, XSUB.COM
    XSUB
    M80 =LDRBIOSJ/M
    L80 LDRBIOSJ,LDRBIOSJ/N/E
    DDTZ MPMLDR.COM
    FLDRBIOSJ.COM
    R1600
    G0
    SAVE 26 MPMJ.COM
    ERA LDRBIOSJ.REL
    ERA LDRBIOSJ.COM
    M80 =MPMXIOSJ/M
    LINK BNKXIOS[noparse][[/noparse]OS]=MPMXIOSJ
    GENSYS $$A
    ERA BNKXIOS.SYM
    ERA MPMXIOSJ.REL
    PI
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-07-31 11:25
    This is a quick post in case I accidentally delete a day's worth of coding.

    This is an autoexec for MPM. I have tried many different solutions - the big problem with MPM is that you can't start feeding bytes straight away. You have to wait till the A0> prompt has been stable for a while. And polling can't take too many CPU cycles.

    This is the main code for the autoexec. It is called from within the keyboard scan routine
    autoexec:
        ld    a,(autofin)
        cp    0FFH
        ret    z        ; return if has run once
        ld    a,(cnt50)    ; counter decremented by mpm
        cp    1        ; is it 1?
        jp    z,autores    ; reset the flag (cnt50 decrements)
        cp    2        ; is it 2
        ret    nz        ; return if not 2
        ld    a,(autolet)    ; have we sent a letter out yet?
        cp    0FFH        ; FF if yes
        ret    z        ; return
        ld    hl,autodat    ; pointer to text string
        ld    a,(autocnt)    ; get the letter counter    
        ld    d,0
        ld    e,a        ; set up to add the two together
        add    hl,de        ; add them
        ld    a,(hl)        ; get the letter
        cp    0
        jp    z,autoend    ; if zero then end of string, finish up
        out    (21H),a        ; send it out - port 11H for testing, port 21H or 22H on propeller
        ld    a,(autocnt)
        inc    a
        ld     (autocnt),a    ; increment the pointer
        ld    a,0FFH
        ld    (autolet),a    ; flag pointer to say sent out a letter
        ret
    
    autores:ld    a,0        ; reset the flag so ready for next letter
        ld    (autolet),a
        ret            ; and return
    
    autoend:ld    a,0FFH        ; flag to say has finished
        ld    (autofin),a    ; store flag o say all bytes sent, do nothing from now on
        ret            ; return
    
    
    autofin:    db    0    ; 0 =running, FF=finished
    autolet:    db    0    ; 0=not sent a letter, FF=sent
    autocnt:    db    0    ; letter counter
    autodat:    db    'SUBMIT AUTOEXEC',cr,0
    
    



    called from here
    ptsti    macro    ?num
    ; Console #&?num input status routine, retuns 0ffh if ready, 00h if not
    ptsti&?num    equ    $
    
        call    autoexec        ; run autoexec on user 0 1 or 2 (port 20H 21H or 22H)
    
        in    a, (sts&?num)        ; get status
        and    m_in            ; check with input mask
        ret    z            ; zero means that bit is not set meaning no input available
        ld    a, 0ffh            ; otherwise indicate that input is available
        ret
        endm
    
        ptsti    0
        ptsti    1
        ptsti    2
    
    



    I've got a similar program working on the SIMH.

    Many traps along the way. For some reason you can only run this on the machine you compiled it on. (it must write more files out than I can see).

    What this means is a board can autoboot into the network program on user 2, and this can start directing packets automatically.

    This has been a huge coding challenge - the final code is very simple but there were a huge number of dead ends along the way. And I'm sure it can be simplified - eg by calling autoexec from somewhere related to the clock tick/interrupt rather than the console input routine.

    I'm still fixing a few minor things - eg just changed it from AUTOEXEC.SUB to AUTOMPM.SUB as CP/M is using the name AUTOEXEC.SUB

    and GENSYS is defaulting to not using a Z80 so I need to change that.

    I must say, it is very cool for the propeller to be able to recompile its own operating system. Soon, with the network, it will be possible to also transmit a new operating system wirelessly.

    Attached is a zip of the 4 disks needed. Disk A has the fixed GENSYS file with Z80 enabled, ticks = 5 per second.

    Note to myself - the attached disk may also not work. Somehow errors seem to sometimes creep into the gensys settings. So for posterity this is a record of settings that work:
    A>gensysm 
    
    
    MP/M II V2.1 System Generation
    Copyright (C) 1981, Digital Research
    
    Default entries are shown in (parens).
    Default base is Hex, precede entry with # for decimal
    Use SYSTEM.DAT for defaults (Y) ? 
    
    Top page of operating system (FE) ? 
    
    Number of TMPs (system consoles) (#3) ? 
    
    Number of Printers (#1) ? 
    
    Breakpoint RST (06) ? 
    
    Enable Compatibility Attributes (Y) ? 
    
    Add system call user stacks (N) ? y
    
    Z80 CPU (Y) ? 
    
    Number of ticks/second (#5) ? 
    
    System Drive (A:) ? 
    
    Temporary file drive (A:) ? 
    
    Maximum locked records/process (#16) ? 
    
    Total locked records/system (#32) ? 
    
    Maximum open files/process (#16) ? 
    
    Total open files/system (#32) ? 
    
    Bank switched memory (Y) ? 
    
    Number of user memory segments (#7) ? 
    
    Common memory base page (C0) ? 
    
    Dayfile logging at console (N) ? 
    
    
     RESERVED     FF00H  0100H
     SYSTEM  DAT  FE00H  0100H
     TMPD    DAT  FD00H  0100H
     USERSYS STK  FB00H  0200H
     XIOSJMP TBL  FA00H  0100H
    Accept new system data page entries (Y) ? 
    
    
     RESBDOS SPR  EE00H  0C00H
     XDOS    SPR  CC00H  2200H
    Select Resident and Banked System Processes:
     ABORT   RSP (N) ? 
    
     SCHED   RSP (N) ? 
    
     SPOOL   RSP (N) ? 
    
     MPMSTAT RSP (N) ? 
    
    
     BNKXIOS SPR  C400H  0800H
     BNKBDOS SPR  A100H  2300H
     BNKXDOS SPR  9F00H  0200H
     TMP     SPR  9B00H  0400H
     LCKLSTS DAT  9800H  0300H
     CONSOLE DAT  9500H  0300H
    Enter memory segment table:
     Base,size,attrib,bank (95,6B,80,00) ? 
    
     Base,size,attrib,bank (00,C0,00,01) ? 
    
     Base,size,attrib,bank (00,C0,00,02) ? 
    
     Base,size,attrib,bank (00,C0,00,03) ? 
    
     Base,size,attrib,bank (00,C0,00,04) ? 
    
     Base,size,attrib,bank (00,C0,00,05) ? 
    
     Base,size,attrib,bank (00,C0,00,06) ? 
    
     Base,size,attrib,bank (00,C0,00,07) ? 
    
    
     MP/M II Sys  9500H  6B00H  Bank 00
     Memseg  Usr  0000H  C000H  Bank 01
     Memseg  Usr  0000H  C000H  Bank 02
     Memseg  Usr  0000H  C000H  Bank 03
     Memseg  Usr  0000H  C000H  Bank 04
     Memseg  Usr  0000H  C000H  Bank 05
     Memseg  Usr  0000H  C000H  Bank 06
     Memseg  Usr  0000H  C000H  Bank 07
    
    Accept new memory segment table entries (Y) ? 
    
    ** GENSYS DONE **
    
    



    More notes - recompiling MPM is proving an extremely difficult task. Many restarts from a clean disk. Gensys problem solved
    ; build MP/M system
    ; needs to be executed under CP/M 2
    ; required sources: LDRBIOS.MAC, MPMXIOS.MAC, MPMD.LIB
    ; required programs: M80.COM, L80.COM, DDTZ.COM, LINK.COM, XSUB.COM MPMD.LIB
    ; gensys sometimes corrupts files so don't run gensys
    ; settings Y, FE, #3, #1, 06, Y, Y, Y, #5, A, A, #16, #32, #16, Y, #7, C0, N
    ; and N to adding RSPs
    XSUB
    M80 =LDRBIOS/M
    L80 LDRBIOS,LDRBIOS/N/E
    DDTZ MPMLDR.COM
    FLDRBIOS.COM
    R1600
    G0
    SAVE 26 MPM.COM
    ERA LDRBIOS.REL
    ERA LDRBIOS.COM
    M80 =MPMXIOS/M
    LINK BNKXIOS[noparse][[/noparse]OS]=MPMXIOS
    ERA BNKXIOS.SYM
    ERA MPMXIOS.REL
    ; start MP/M with MPM
    
    


    and I have sometimes found it works better without these two lines comment out in spin
    '#define USER0_PS2_VGA
    
    #define USER0_TO_PUNCH
    
    



    but I'm still not 100% sure about this.

    Next experiment - is the
    #define TIMED_FLUSH

    a factor.

    Still only have about a 10% chance of a compilation working.

    I might try compiling on the SIMH too.

    ...many false starts, but I seem to have a stable A disk. Need timed flush to be on (otherwise misses the last packet on an xmodem transfer), user0_to_punch must be commented (slows things down too much and sysmpm errors occ) and it does not matter if user0 is the serial port or the vga monitor.

    Strangely, on this test, the ticks at 50x a second seems to be working. I even pushed it right to the limit by starting mbasic at the same time on two users and it worked.

    I've attached this (a.dsk)

    I'm learning a lot about mpm. For instance - one tiny error in gensys, and it still compiles, but you get the previous version. So you can have a mistake and it can creep in for many versions because gensys is failing, and it makes debugging very hard. Almost worth changing the version number on mpmxios.mac every time it is recompiled.

    Accurate time delays are possible:
    procedure doevents(milliseconds=integer)
        rem pass control to other users for n ticks
        var hl, de, bc, a_psw = integer
           de = milliseconds/20     rem number of ticks eg 50 per second on the propeller emulation
        bc=141                rem function call 141
           call (0005H,hl,de,bc,a_psw)
    end
    
    rem ************ MAIN **************
    
        print "One second delay"
        doevents 1000
        print "one second delay over"
    end
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 8/3/2010 3:30:18 AM GMT
  • pullmollpullmoll Posts: 817
    edited 2010-08-09 19:48
    Is it just me, or is the quoting and code-blocks insertion pretty much screwed up in the new forum?
    Trying myself:
    pullmoll wrote:
    Pullmoll's quote
    int pullmoll(int question) { return 42; }
    

    And what about tab stops?
    CON
    	CMD_AES_SET_ENCRYPTION_KEY	=	1
    	CMD_AES_SET_DECRYPTION_KEY	=	2
    
    	KEY_ROUNDS			=	10
    
    	EPARAM				=	1
    
    VAR
    	long	cog
    	long	command
    	long	params[8]
    
    PUB start : okay
    	stop
    	tbl_e0_ptr := @tbl_e0
    	tbl_e1_ptr := @tbl_e1
    	tbl_e2_ptr := @tbl_e2
    	tbl_e3_ptr := @tbl_e3
    	tbl_e4_ptr := @tbl_e4
    	tbl_d0_ptr := @tbl_d0
    	tbl_d1_ptr := @tbl_d1
    	tbl_d2_ptr := @tbl_d2
    	tbl_d3_ptr := @tbl_d3
    	tbl_d4_ptr := @tbl_d4
    	rcon_ptr := @rcon
    	params[0] := @command
    	okay := cog := COGNEW(@entry, @params) + 1
    
    PUB stop
    	if cog
    		COGSTOP(cog~~)
    
    PUB set_encryption_key(key_ptr)
    	bytemove(@params, key_ptr, 128/8)
    	command := CMD_AES_SET_ENCRYPTION_KEY
    	repeat while command == CMD_AES_SET_ENCRYPTION_KEY
    
    PUB set_decryption_key(key_ptr)
    	bytemove(@params, key_ptr, 128/8)
    	command := CMD_AES_SET_DECRYPTION_KEY
    	repeat while command == CMD_AES_SET_DECRYPTION_KEY
    
    DAT
    			org	0
    entry
    			mov	t1, PAR
    			rdlong	command_ptr, t1
    command_loop
    			rdlong	cmd, command_ptr	wz
    		if_z	jmp	#command_loop
    
    			cmp	cmd, #CMD_AES_SET_ENCRYPTION_KEY wz	' set encryption key?
    		if_z	movs	aes_set_encryption_key_ret, #command_done
    		if_z	jmp	#aes_set_encryption_key
    			cmp	cmd, #CMD_AES_SET_DECRYPTION_KEY wz	' set decryption key?
    		if_z	movs	aes_set_decryption_key_ret, #command_done
    		if_z	jmp	#aes_set_decryption_key
    
    command_done
    			mov	cmd, #0
    			wrlong	cmd, command_ptr
    			jmp	#command_loop
    
    param_error
    			neg	cmd, #EPARAM
    			wrlong	cmd, command_ptr
    			jmp	#command_loop
    
    

    Now, that looks ok! So I guess it's the posts that got screwed somehow?

    Anyway: Hello everyone on the new forum.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-08-09 20:03
    It is the previous code that has been damaged when porting to this forum (still ok on the archived old forum)

    [ /code ] is ok but

    [ code ] got replaced with [ quote ]


    BTW - today I got an MPM version with 8 users working on the SIMH. Also autoexec in MPM. Big buffers inside the xios - big enough to handle an xmodem packet. Am working on the interface code but hopefully soon will be able to have something that looks like windows for the simh. Then will look at porting it over to the propeller.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-09 21:47
    pullmoll: All your quote/code tests in that last post work fine.

    As Dr_A says it's all the code blocks, images and large attachments moved from the old forum that are mangled and chopped.

    Apparently no one thought any of that data might be important.

    Oh, and I have to say again I hate to have code blocks in scrollable little windows. Why for God sake? The page is scrollable already. It's annoying and it does not work in all browsers, like on mu Android phone.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-08-29 04:58
    A simple text version of windows is now running on the qZ80. Screenshot here http://www.smarthome.viviti.com/mp-m The second program is perhaps not as exciting to look at, but it is doing more in terms of being able to route data around the place. We can do a remote login now and run programs on a remote propeller board. Next step is more reliable file transfer - xmodem is fine for a phone line that stays connected all the time, but for wireless, with the really possibility of corrupted packets, something better than x/y/z modem is needed. I'm thinking about the bittorrent protocol, where you can disconnect for a day in the middle of a download and resume when a connection is reestablished. Hopefully soon it will be possible to demonstrate something practical, like sending a jpeg picture via a noisy wireless data link that has interference and disconnects at random times.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-05 05:57
    Hi Juergen, I hope you are not too busy with work!

    I have a strange bug - I am not sure if it is with MPM or the qZ80. The keyboard occasionally will not read a character properly. This is my test code. The bug showed up in the middle of a huge 1000 line program, but I have narrowed it down to this
    	$lines
    
    procedure ReadKeyboard
    	var c=byte
    	while inp(10H)=3 do
    		begin
    			c=inp(11H)			rem get the byte
    			print asc(c);			rem print the ascii value
    		end
    end
    rem *************** Main **********************
    	var a=integer
    	var b=integer
    	a=0
    	repeat
    		begin
    			readkeyboard			rem read the keyboard
    			print ".";			rem print a dot on the screen
    			for b=1 to 2000		rem delay loop
    			next b
    		end
    	until a=1
    end
    

    If I run this and type a character then about once every 15 characters it will not read the correct character. The character it does read is repeatable - eg typing zero (ascii 48) will occasionally return 69. Ascii a (97) occasionally returns 28.

    This does not happen when running the same program in the SIMH.

    Another intriguing clue - take out the lines "for b = 1 to 2000 next" and the error is not there. (These lines emulate the rest of the program).

    So I am thinking that when a character arrives in the middle of that delay loop maybe it gets corrupted somehow.

    I've tried looking in the qZ80 code but I can't see why it would do this. Any help would be most appreciated!
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-09-21 06:33
    Further to the post above, the missing character bug has been fixed. It proved impossible to find in the end, though it seems to be in the keyboard.spin object (now modified to be only pasm). The workaround was to create a new buffer and to bypass the existing one. I have no idea why this works but I suspect something is overwriting the data somewhere (it corrupted bytes in the middle of the buffer, byte 8 and 9 of 16)

    Further to this, I've been working on some major rewrite of the keyboard driver code so that the insert/home/pageup/delete/end/pagedown/arrowkeys/escape all work properly. The practical upshot of all this is a text editor for the propeller that is easy to use and is actually practical, in that it is quicker to open a file on the propeller, edit, and save/close, than it is to edit the file on a PC and download the new file.

    The story behind this took a week of coding to find and fix (thanks ++ to Mike Green and Toby on another thread)

    This major revision started because I wanted to run Wordstar on MPM. (Via wireless!) I kept getting "out of memory" errors, and changing the memory settings in WSCHANGE did not seem to help.

    So I checked out an alternative text editor, VEDIT which is available over at the Altair SIMH. Check out Vedit http://www.vedit.com/ they are still going strong today, with modern software for many platforms. And buried in their website is a disclaimer saying that the legacy versions are available as freeware. This works on MPM and is quicker than Wordstar. But I could never remember the keycodes, and they are a little different to Wordstar (^X and ^C are swapped for instance)

    I wanted to get the arrow keys and the home/end/insert/delete/pageup/pagedown keys working, as then you don't need to remember control characters (vedit does not have them at the top of the screen).

    Indeed, the only command that is a bit strange that you have to remember is to hit escape twice, then up comes a command prompt, and you use EQ to quit without saving, or EX to save.

    And this is where all the problems started, because the escape key would not work. After many tries, I found a solution that sent ascii 27 straight from the keyboard.spin object, rather than decoding CB in the io.spin object (which was receiving 02, not CB).

    And the bonus is that this saved two longs in code.

    So I tried Insert, and this failed too, so I changed keyboard.spin to send ^N and that worked, and saved another two longs in io.spin.

    And so eventually I've changed all the wordprocessing characters so the keyboard object sends them as control codes, and saved about 20 longs overall.

    Vedit is a pleasure to work with. It is the first word processor that is, in my opinion, not a toy, and is an entirely practical thing to use on a propeller. I'm using it to change some .INI files to alter the behaviour of a program, and this is proving quicker than recompiling code all the time.

    Plus - I've got a new board being made that has a standard D25 serial port, and so it should be possible to configure this as a printer and so have a word processor and printer package all on the propeller.

    Also, I made some minor changes to the vt100 object so it keeps the foreground and background colours.

    As an aside I'm still selling about 3 boards a week. These work out at cost neutral but I get a real buzz with each sale. Hopefully some of the people buying these boards will post their projects here and maybe contribute something as well.

    I love the Propeller chip!
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-09-21 06:52
    Drac: I used Vedit - old memories here :lol:

    Nice to see your progress. Unfortunately I have not had much time for actual prop code lately - I am hoping this will change shortly.
Sign In or Register to comment.