Image Map Image Map
Page 4 of 4 FirstFirst 1234
Results 31 to 38 of 38

Thread: Z80 Hello World example in hex

  1. #31
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,790

    Default

    +1.

    Yep, that’s the mystery solved. Two pages of 512 bytes.

    One page from 0xC00 to 0xDFF and the other page from 0xE00 to 0xFFF.

    So we should now be able to write “hello world!” on one page and “goodbye world!” on the other page...

    Dave

  2. #32
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,896
    Blog Entries
    3

    Default

    Cool! I'll try to reverse engineer that Hello World program and see if I can get it to do that.

    I wonder why you'd set up your display that way? Seems kind of unusual for a computer.

  3. #33
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,896
    Blog Entries
    3

    Default

    Okay so I tried changing the program to send data to the other page, 0E00 .. but nothing came up on the second page. I changed it to 0D00 and got a half screen of HELLO WORLD. I tried 0F00 too but same thing.. the other page was totally blank. So it's not able to access there for some reason.

  4. Default

    Quote Originally Posted by falter View Post
    Okay so I tried changing the program to send data to the other page, 0E00 .. but nothing came up on the second page. I changed it to 0D00 and got a half screen of HELLO WORLD. I tried 0F00 too but same thing.. the other page was totally blank. So it's not able to access there for some reason.
    Did you change this instruction to compare with 10H?

    Code:
    0808 FE 0E       CP   0E      ;compare with end
    I wonder why you'd set up your display that way? Seems kind of unusual for a computer.
    Perhaps so that your program output doesn't get overwritten by the monitor when you press the interrupt button.

  5. #35
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,790

    Default

    Just thinking aloud here...

    Is the PAGE feature a function of the MONITOR ROM (i.e. firmware) or hardware?

    Just thinking that when you run the hello world program the screen will have the READY prompt up (first page). The program could write to the second page (assuming Falter changed the compare instruction as you stated - otherwise you will get nothing written). But - if the PAGE feature is firmware, we are no longer running the MONITOR anymore because our Hello World program has HALTed with the interrupts disabled...

    After running the Hello World program. When you press the PAGE key, does the LED work in the same way and what do you see on the screen?

    >>> I wonder why you'd set up your display that way? Seems kind of unusual for a computer.

    It is - but it is also very neat!

    If you can single step your program (for instance) the register display and any commands you entered could appear on one page and the output from the 'application program' could appear on the other page. The user could then switch between the pages to see the actual output from the program - but not messed up by the diagnostic output. Neat!

    dreNorteR: Where are you actually based? You see to have a similar time zone to me in the UK.

    Dave
    Last edited by daver2; May 21st, 2020 at 12:16 AM.

  6. Default

    Another test program, should echo anything typed to page B with scrolling (assuming the memory is actually present and read/write):

    Code:
    0400 F3          DI
    0401 21 00 0E    LD   HL,0E00H  starting cursor pos
    
    LOOP:
    0404 46          LD   B,(HL)    save char in B
    0405 36 5F       LD   (HL),'_'  show cursor
    0407 FB          EI
    0408 76          HALT           wait for input
    0409 F3          DI
    040A FE 0D       CP   0DH       is CR?
    040C 28 1B       JR   Z,+27     yes, -> NEW LINE
    040E 77          LD   (HL),A    output char
    
    CURSOR FORWARD:
    040F 23          INC  HL
    0410 7C          LD   A,H
    0411 FE 10       CP   10H       past end of screen?
    0413 38 EF       JR   C,-17     no, -> LOOP
    
    SCROLL UP:
    0415 21 20 0E    LD   HL,0E20H  from second row
    0418 11 00 0E    LD   DE,0E00H  to first row
    041B 01 E0 01    LD   BC,01E0H  copy 15 * 32 bytes
    041E ED B0       LDIR
    0420 62          LD   H,D       cursor to start of last row
    0421 6B          LD   L,E
    0422 06 10       LD   B,10H     fill 2 * 16 bytes
    0424 3E 20       LD   A,20H     with blanks
    0426 D7          RST  10H       using the ROM
    0427 18 DB       JR   -37       -> LOOP
    
    NEW LINE:
    0429 70          LD   (HL),B    restore char at cursor
    042A 7D          LD   A,L
    042B F6 1F       OR   1FH       go to last column
    042D 6F          LD   L,A
    042E 18 DF       JR   -33       -> CURSOR FORWARD
    Quote Originally Posted by daver2 View Post
    Just thinking aloud here...

    Is the PAGE feature a function of the MONITOR ROM (i.e. firmware) or hardware?

    Just thinking that when you run the hello world program the screen will have the READY prompt up (first page). The program could write to the second page (assuming Falter changed the compare instruction as you stated - otherwise you will get nothing written). But - if the PAGE feature is firmware, we are no longer running the MONITOR anymore because our Hello World program has HALTed with the interrupts disabled...

    After running the Hello World program. When you press the PAGE key, does the LED work in the same way and what do you see on the screen?

    >>> I wonder why you'd set up your display that way? Seems kind of unusual for a computer.

    It is - but it is also very neat!

    If you can single step your program (for instance) the register display and any commands you entered could appear on one page and the output from the 'application program' could appear on the other page. The user could then switch between the pages to see the actual output from the program - but not messed up by the diagnostic output. Neat!

    dreNorteR: Where are you actually based? You see to have a similar time zone to me in the UK.

    Dave
    The only OUT's in the ROM are to set up the Z80 PIO, so the page switching must be controlled directly by hardware.

    I'm in Germany

  7. #37
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,790

    Default

    >>> The only OUT's in the ROM are to set up the Z80 PIO, so the page switching must be controlled directly by hardware.

    Good thinking.

    >>> I’m in Germany.

    I used to work in Erlangen and Karlsruhe - yes, Siemens...

    Dave

  8. #38
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,896
    Blog Entries
    3

    Default

    I did a quick mod of the first program and got it to write on half of the second page. I'm not sure if I was changing the compare line wrong. I tried setting it to 01 and then backed to 0F, which gave me the half page.

    I'm going to try that new program tonight.

    I'm thinking about making a little project of this to improve it beyond it's current state. I'm still weighing the 'historical preservation' concern vs. practical use.

    But if I go that route, I'd like to expand the RAM, and maybe borrow Don Lancaster's bit boffer design, or something simpl-ish I can wrap my head around. My goal would be to get it to a state where it can load and run BASIC from tape or similar.

    Definitely I want to figure out what those empty sockets do.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •