commit
						c2604dbb04
					
				
					 9 changed files with 102 additions and 1 deletions
				
			
		
							
								
								
									
										13
									
								
								lang/cem/libcc.ansi/core/printf/itoa.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								lang/cem/libcc.ansi/core/printf/itoa.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
void itoa(long value, char* buffer, int radix)
 | 
			
		||||
{
 | 
			
		||||
	if (value < 0)
 | 
			
		||||
	{
 | 
			
		||||
		*buffer++ = '-';
 | 
			
		||||
		value = -value;
 | 
			
		||||
	}
 | 
			
		||||
	buffer = _i_compute(value, 10, buffer, 0);
 | 
			
		||||
	*buffer++ = '\0';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -75,6 +75,7 @@ extern void	perror(const char *_s);
 | 
			
		|||
 | 
			
		||||
/* Internal function used in several places which is approximately itoa(). */
 | 
			
		||||
extern char *_i_compute(unsigned long val, int base, char *s, int nrdigits);
 | 
			
		||||
extern void itoa(long val, char* buffer, int radix);
 | 
			
		||||
 | 
			
		||||
#if ACKCONF_WANT_EMULATED_FILE
 | 
			
		||||
#include <ack/emufile.h>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,8 +77,8 @@ name led
 | 
			
		|||
		(.e:{TAIL}={PLATFORMDIR}/libem.a \
 | 
			
		||||
		           {PLATFORMDIR}/libsys.a \
 | 
			
		||||
				   {PLATFORMDIR}/libc.a \
 | 
			
		||||
		           {PLATFORMDIR}/libsys.a \
 | 
			
		||||
				   {PLATFORMDIR}/libem.a \
 | 
			
		||||
		           {PLATFORMDIR}/libsys.a \
 | 
			
		||||
		           {PLATFORMDIR}/libend.a)
 | 
			
		||||
	linker
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,6 +83,9 @@ extern uint8_t cpm_read_random_safe(FCB* fcb);
 | 
			
		|||
/* Extends cpm_ramtop over the CCP, for a little extra space. */
 | 
			
		||||
extern void cpm_overwrite_ccp(void);
 | 
			
		||||
 | 
			
		||||
/* Like cpm_printstring, but uses C-style strings terminated with a \0. */
 | 
			
		||||
extern void cpm_printstring0(const char* s);
 | 
			
		||||
 | 
			
		||||
/*  0 */ extern void cpm_warmboot(void);
 | 
			
		||||
/*  1 */ extern uint8_t cpm_conin(void);
 | 
			
		||||
/*  2 */ extern void cpm_conout(uint8_t b);
 | 
			
		||||
| 
						 | 
				
			
			@ -126,4 +129,8 @@ extern void cpm_overwrite_ccp(void);
 | 
			
		|||
#define cpm_get_user() cpm_get_set_user(0xff)
 | 
			
		||||
#define cpm_set_user(u) cpm_get_set_user(u)
 | 
			
		||||
 | 
			
		||||
extern uint8_t bios_conin(void);
 | 
			
		||||
extern uint8_t bios_const(void);
 | 
			
		||||
extern void bios_conout(uint8_t c);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								plat/cpm/libsys/bios_conin.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								plat/cpm/libsys/bios_conin.s
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
#
 | 
			
		||||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
.define _bios_conin
 | 
			
		||||
_bios_conin:
 | 
			
		||||
	lhld 1
 | 
			
		||||
	lxi d, 6
 | 
			
		||||
	dad d
 | 
			
		||||
	push b
 | 
			
		||||
	call .pchl
 | 
			
		||||
	pop b
 | 
			
		||||
	mov e, a
 | 
			
		||||
	mvi d, 0
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										21
									
								
								plat/cpm/libsys/bios_conout.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								plat/cpm/libsys/bios_conout.s
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
#
 | 
			
		||||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
.define _bios_conout
 | 
			
		||||
_bios_conout:
 | 
			
		||||
	pop h			! pop return address
 | 
			
		||||
	pop d           ! pop parameter into DE
 | 
			
		||||
	push d
 | 
			
		||||
	push h
 | 
			
		||||
	
 | 
			
		||||
	push b
 | 
			
		||||
	mov c, e
 | 
			
		||||
 | 
			
		||||
	lhld 1
 | 
			
		||||
	lxi d, 9
 | 
			
		||||
	dad d
 | 
			
		||||
	call .pchl
 | 
			
		||||
 | 
			
		||||
	pop b
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								plat/cpm/libsys/bios_const.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								plat/cpm/libsys/bios_const.s
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
#
 | 
			
		||||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
.define _bios_const
 | 
			
		||||
_bios_const:
 | 
			
		||||
	lhld 1
 | 
			
		||||
	lxi d, 3
 | 
			
		||||
	dad d
 | 
			
		||||
	push b
 | 
			
		||||
	call .pchl
 | 
			
		||||
	pop b
 | 
			
		||||
	mov e, a
 | 
			
		||||
	mvi d, 0
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#include <stdlib.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <cpm.h>
 | 
			
		||||
#include "cpmsys.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										27
									
								
								plat/cpm/libsys/cpm_printstring0.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								plat/cpm/libsys/cpm_printstring0.s
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
#
 | 
			
		||||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
! Prints a \0-terminated string.
 | 
			
		||||
 | 
			
		||||
.define _cpm_printstring0
 | 
			
		||||
_cpm_printstring0:
 | 
			
		||||
	pop h		   ! pop return address
 | 
			
		||||
	pop d          ! pop parameter (possibly junk)
 | 
			
		||||
	push d
 | 
			
		||||
	push h
 | 
			
		||||
    
 | 
			
		||||
.1:
 | 
			
		||||
    ldax d         ! fetch byte
 | 
			
		||||
    ora a
 | 
			
		||||
    rz             ! exit if zero
 | 
			
		||||
    inx d
 | 
			
		||||
 | 
			
		||||
    push b         ! save FP as the BDOS will corrupt it
 | 
			
		||||
    push d
 | 
			
		||||
    mov e, a
 | 
			
		||||
    mvi c, 2       ! conout
 | 
			
		||||
    call 0x0005
 | 
			
		||||
    pop d
 | 
			
		||||
    pop b
 | 
			
		||||
 | 
			
		||||
    jmp .1
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue