URL
https://opencores.org/ocsvn/light8080/light8080/trunk
Subversion Repositories light8080
[/] [light8080/] [trunk/] [tools/] [c80/] [c80.lib] - Rev 73
Go to most recent revision | Compare with Previous | Blame | View Log
#asm;;------------------------------------------------------------------; Small-C Run-time Librray;; V4d As of July 16, 1980 (gtf); Added EXIT() function;------------------------------------------------------------------;;Fetch a single byte from the address in HL and sign extend into HLccgchar:ld a,(hl)ccsxt:ld l,arlcasbc ald h,aret;Fetch a full 16-bit integer from the address in HLccgint:ld a,(hl)inc hlld h,(hl)ld l,aret;Store a single byte from HL at the address in DEccpchar:ld a,lld (de),aret;Store a 16-bit integer in HL at the address in DEccpint:ld a,lld (de),ainc deld a,hld (de),aret;Inclusive "or" HL and DE into HLccor:ld a,lor eld l,ald a,hor dld h,aret;Exclusive "or" HL and DE into HLccxor:ld a,lxor eld l,ald a,hxor dld h,aret;"And" HL and DE into HLccand:ld a,land eld l,ald a,hand dld h,aret;Test if HL = DE and set HL = 1 if true else 0cceq:call cccmpret zdec hlret;Test if DE ~= HLccne:call cccmpret nzdec hlret;Test if DE > HL (signed)ccgt:ex de,hlcall cccmpret cdec hlret;Test if DE <= HL (signed)ccle:call cccmpret zret cdec hlret;Test if DE >= HL (signed)ccge:call cccmpret ncdec hlret;Test if DE < HL (signed)cclt:call cccmpret cdec hlret; Signed compare of DE and HL; Performs DE - HL and sets the conditions:; Carry reflects sign of difference (set means DE < HL); Zero/non-zero set according to equality.cccmp:ld a,esub lld e,ald a,dsbc hld hl,1jp m,cccmp1or e ;"OR" resets carryretcccmp1:or escf ;set carry to signal minusret;Test if DE >= HL (unsigned)ccuge:call ccucmpret ncdec hlret;Test if DE < HL (unsigned)ccult:call ccucmpret cdec hlret;Test if DE > HL (unsigned)ccugt:ex de,hlcall ccucmpret cdec hlret;Test if DE <= HL (unsigned)ccule:call ccucmpret zret cdec hlret;Routine to perform unsigned compare;carry set if DE < HL;zero/nonzero set accordinglyccucmp:ld a,dcp hjp nz,$+5ld a,ecp lld hl,1ret;Shift DE arithmetically right by HL and return in HLccasr:ex de,hlld a,hrlald a,hrrald h,ald a,lrrald l,adec ejp nz,ccasr+1ret;Shift DE arithmetically left by HL and return in HLccasl:ex de,hladd hl,hldec ejp nz,ccasl+1ret;Subtract HL from DE and return in HLccsub:ld a,esub lld l,ald a,dsbc hld h,aret;Form the two's complement of HLccneg:call cccominc hlret;Form the one's complement of HLcccom:ld a,hcplld h,ald a,lcplld l,aret;Multiply DE by HL and return in HLccmult:ld b,hld c,lld hl,0ccmult1:ld a,crrcajp nc,$+4add hl,dexor ald a,brrald b,ald a,crrald c,aor bret zxor ald a,erlald e,ald a,drlald d,aor eret zjp ccmult1;Divide DE by HL and return quotient in HL, remainder in DEccdiv:ld b,hld c,lld a,dxor bpush afld a,dor acall m,ccdenegld a,bor acall m,ccbcnegld a,16push afex de,hlld de,0ccdiv1:add hl,hlcall ccrdeljp z,ccdiv2call cccmpbcdejp m,ccdiv2ld a,lor 1ld l,ald a,esub cld e,ald a,dsbc bld d,accdiv2:pop afdec ajp z,ccdiv3push afjp ccdiv1ccdiv3:pop afret pcall ccdenegex de,hlcall ccdenegex de,hlretccdeneg:ld a,dcplld d,ald a,ecplld e,ainc deretccbcneg:ld a,bcplld b,ald a,ccplld c,ainc bcretccrdel:ld a,erlald e,ald a,drlald d,aor eretcccmpbcde:ld a,esub cld a,dsbc bret#endasm
Go to most recent revision | Compare with Previous | Blame | View Log
