Started by ced64k, 12:18, 08 February 14
0 Members and 1 Guest are viewing this topic.
OUTPUT "Generated/Main.bin" LD HL,#C000 LD DE,#C001 LD BC,#3FFF LD (HL),56 LDIR
OUTPUT "Generated/Main.bin" LD A,83 ADD A,1 CALL #BB5A RET
3E53 C601 CD5A BBC9
QuoteIt seems normal to me. Because the system is gone! If you look at the scripts/snapshot.cfg file, you see that the only thing that the CPC has in memory is... nothing at all except your own code. Only the CRTC is initialized, the stack, as well as some colors for the Gate Array. If you want to use the system, you could create a snapshot with Winape after the CPC has booted, and use it as a starting point, instead of creating a "blank" one with createsnapshot like in my scripts. It won't work like that directly, because the system has its own "life" and I won't expect your final "RET" to work as you will expect (where would the system "go" anyway?). So my suggestion is this. If you program starts at &4000, we will poke something two bytes before (#3ffe). - Run Winape. In Basic: - poke &3ffe,&18 - poke &3fff,&fe - call &3ffe We have poked a "JR $" in memory, so an infinite loop is performed. Note that the system is still OK because the interruptions are still on. Open the Winape debugger and put a breakpoint at #3ffe. Click on "Play" to be sure the Z80 is really at the location (this is to be sure the Program Counter is really inside your program, and not somewhere in the ROM because the system wants to do its job (changing the colors, checking the keyboard, and so on.)). Save this as a snapshot (baseSnapshot.sna). In your scripts/snapshot.cfg file, remove all the lines, and type this: -i <path to my baseSnapshot.sna> -l Generated\Main.bin 0x3ffe --> load here you main.bin, exactly where we have poked the two bytes before. In your main code, make it start at #3ffe instead of #4000, beginning with two NOPS, so that it will clear the infinite loop, allowing your real program to start. Example: org #4000 - 2 nop ;Clear the infinite loop nop ;The real code starts here. LD A,83 ADD A,1 CALL #BB5A RET I haven't tested this but it should work . Remember that since you want to use the system and return from your program gracefully, that you must NOT modify some auxiliary registers (AF' and BC' only, actually) or modify the stack. If you want to do so, you must stop the interruption (EI), save AF', BC', SP, do your stuff, restore AF', BC' and SP, and the interruptions (EI). Nothing to be afraid of! Keep me posted of your progress!
ORG &5000 LD HL,TEXT LOOP LD A,(HL) CP 0 RET Z CALL &BB5A INC HL JP LOOP;TEXT DB "Hello!",0
iDSK $project_path/generated/$file_base_name.dsk -i $project_path/generated/$file_base_name.bin -e 8000 -c 8000 -t 1 -f;
Quote from: ced64k on 21:57, 13 February 14If I assemble that in Maxam under Arnold emulator, then CALL &5000 in Basic, it works, I see the text "Hello!".If I assemble with Pasmo, load the bin with Arnold, the emulator reset. Really reset, if I type CALL &5000, I see only "Ready".
Quote from: ced64k on 14:04, 14 February 14So to stay in the program I have to add a CALL &BB06 before the RET Z ?
ORG &5000 LD HL,TEXTLOOP LD A,(HL) OR A CALL &BB5A INC HL JP LOOP CALL LOOP CALL &BB06 RET;TEXT DB "Hello!",0
Quote from: ced64k on 16:16, 14 February 14I don't understand where to put that. I presume that the loop starts with the LOOP label and ends with JP LOOP.I removed the RET Z and tried with :
ORG &5000 LD HL,text.loop LD A,(HL) CP 0 JR Z,finished CALL &BB5A INC HL JP loop.finished CALL &BB06 RET.text DB "Hello!",0
ORG &5000 LD HL,TEXT CALL LOOP CALL &BB06 RETLOOP LD A,(HL) CP 0 RET Z CALL &BB5A INC HL JP LOOP;TEXT DB "Hello!",0
Quote from: arnoldemu on 16:56, 14 February 14I would do it like this:
ORG &5000 LD HL,TEXT ;; location of string to display CALL LOOP ;; display a string (what happens here is it is like a GOSUB in BASIC. We execute code and when a RET or RET with condition is seen, return back to the instruction after this call) CALL &BB06 ;; wait for key press so we can see the message RET ;; and quit.LOOP LD A,(HL) ;; read character CP 0 ;; is it zero (the special character which comes after the last character of the string and marks it's end) RET Z ;; return if we found 0, else continue. CALL &BB5A ;; print character INC HL ;; update HL so it points at the next character JP LOOP ;; and perform the loop;TEXT DB "Hello!",0 ;; Text to display, 0 indicates end.
ld a,(Height) ; loading Height into A
Page created in 0.100 seconds with 47 queries.