.ORG 100H ; CP/M programs start address JP START ; Go to program start ; ; Variable storage space ; Stack1 .DW 0 ; Place to save old stack Sbot .DS 64 ; Temp stack for us to use ; ; Constants ; STOP .EQU $-1 ; Top of our stack BDOS .EQU 5 ; Address of BDOS entry LEDS .EQU 00H ; Digital I/O board ; ; Start of code segment ; ; ------------------------------------------------------------ ; Starting sequence for CP/M programs START: LD HL, 0000H ; HL = 0 ADD HL, SP ; HL = SP LD (Stack1), HL ; Save original stack LD HL, STOP ; HL = address of new stack LD SP, HL ; Stack pointer = our stack LD C, 7 ; BDOS function 7 - Get I/O byte PUSH HL ; Save HL register CALL BDOS ; Call BDOS function POP HL ; Restore HL register OUT (LEDS), A ; Send the pattern to the port ; ------------------------------------------------------------ ; Finish and return to CP/M EXIT: LD HL, (Stack1) ; HL = entry stack address LD SP, HL ; SP = value on entry RET ; Return control back to CP/M .END