Skip to content

Commit

Permalink
vamos: added locale.library (@bebbo #151)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnvogelg committed Mar 4, 2021
1 parent 7650370 commit 34db20c
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 0 deletions.
42 changes: 42 additions & 0 deletions amitools/data/fd/locale_lib.fd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##base _LocaleBase
##bias 30
##public
*--- functions in V38 or higher (Release 2.1) ---
##private
localePrivate1()()
##public
CloseCatalog(catalog)(a0)
CloseLocale(locale)(a0)
ConvToLower(locale,character)(a0,d0)
ConvToUpper(locale,character)(a0,d0)
FormatDate(locale,fmtTemplate,date,putCharFunc)(a0/a1/a2/a3)
FormatString(locale,fmtTemplate,dataStream,putCharFunc)(a0/a1/a2/a3)
GetCatalogStr(catalog,stringNum,defaultString)(a0,d0/a1)
GetLocaleStr(locale,stringNum)(a0,d0)
IsAlNum(locale,character)(a0,d0)
IsAlpha(locale,character)(a0,d0)
IsCntrl(locale,character)(a0,d0)
IsDigit(locale,character)(a0,d0)
IsGraph(locale,character)(a0,d0)
IsLower(locale,character)(a0,d0)
IsPrint(locale,character)(a0,d0)
IsPunct(locale,character)(a0,d0)
IsSpace(locale,character)(a0,d0)
IsUpper(locale,character)(a0,d0)
IsXDigit(locale,character)(a0,d0)
OpenCatalogA(locale,name,tags)(a0/a1/a2)
OpenLocale(name)(a0)
ParseDate(locale,date,fmtTemplate,getCharFunc)(a0/a1/a2/a3)
##private
localePrivate2()()
##public
StrConvert(locale,string,buffer,bufferSize,type)(a0/a1/a2,d0/d1)
StrnCmp(locale,string1,string2,length,type)(a0/a1/a2,d0/d1)
##private
localePrivate3()()
localePrivate4()()
localePrivate5()()
localePrivate6()()
localePrivate7()()
localePrivate8()()
##end
2 changes: 2 additions & 0 deletions amitools/vamos/lib/LibList.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .DosLibrary import DosLibrary
from .ExecLibrary import ExecLibrary
from .IntuitionLibrary import IntuitionLibrary
from .LocaleLibrary import LocaleLibrary
from .MathFFPLibrary import MathFFPLibrary
from .MathIEEEDoubBasLibrary import MathIEEEDoubBasLibrary
from .MathIEEEDoubTransLibrary import MathIEEEDoubTransLibrary
Expand All @@ -16,6 +17,7 @@
"dos.library": DosLibrary,
"exec.library": ExecLibrary,
"intuition.library": IntuitionLibrary,
"locale.library": LocaleLibrary,
"mathffp.library": MathFFPLibrary,
"mathieeedoubbas.library": MathIEEEDoubBasLibrary,
"mathieeedoubtrans.library": MathIEEEDoubTransLibrary,
Expand Down
133 changes: 133 additions & 0 deletions amitools/vamos/lib/LocaleLibrary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from amitools.vamos.machine.regs import *
from amitools.vamos.libcore import LibImpl
from amitools.vamos.lib.util.TagList import *
from amitools.vamos.lib.util.AmiDate import *
from amitools.vamos.log import *

import string

class LocaleLibrary(LibImpl):
def OpenLocale(self, ctx):
name = ctx.cpu.r_reg(REG_A0)
# dummy
return 0

def CloseLocale(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
# dummy - accept all

def IsUpper(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.uppercase

def IsLower(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.lowercase

def IsDigit(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.digits

def IsPrint(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.printable

def IsCntrl(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
#maybe not ok...
return character < 32 and not chr(character) in string.printable

def IsXDigit(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.hexdigits

def IsSpace(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.whitespace

def IsPunct(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.punctuation

def IsGraph(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
return chr(character) in string.printable and not chr(character) in string.whitespace

"""
def CloseCatalog(self, ctx):
catalog = ctx.cpu.r_reg(REG_A0)
print "not implemented: CloseCatalog"
def ConvToLower(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
print "not implemented: ConvToLower"
def ConvToUpper(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
character = ctx.cpu.r_reg(REG_D0)
print "not implemented: ConvToUpper"
def FormatDate(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
fmtTemplate = ctx.cpu.r_reg(REG_A1)
date = ctx.cpu.r_reg(REG_A2)
putCharFunc = ctx.cpu.r_reg(REG_A3)
print "not implemented: FormatDate"
def FormatString(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
fmtTemplate = ctx.cpu.r_reg(REG_A1)
dataStream = ctx.cpu.r_reg(REG_A2)
putCharFunc = ctx.cpu.r_reg(REG_A3)
print "not implemented: FormatString"
def GetCatalogStr(self, ctx):
catalog = ctx.cpu.r_reg(REG_A0)
defaultString = ctx.cpu.r_reg(REG_A1)
stringNum = ctx.cpu.r_reg(REG_D0)
print "not implemented: GetCatalogStr"
def GetLocaleStr(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
stringNum = ctx.cpu.r_reg(REG_D0)
print "not implemented: GetLocaleStr"
def OpenCatalogA(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
name = ctx.cpu.r_reg(REG_A1)
tagList = ctx.cpu.r_reg(REG_A2)
print "not implemented: OpenCatalogA"
def ParseDate(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
date = ctx.cpu.r_reg(REG_A1)
fmtTemplate = ctx.cpu.r_reg(REG_A2)
putCharFunc = ctx.cpu.r_reg(REG_A3)
print "not implemented: ParseDate"
def StrConvert(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
string = ctx.cpu.r_reg(REG_A1)
buffer = ctx.cpu.r_reg(REG_A2)
bufferSize = ctx.cpu.r_reg(REG_D0)
type = ctx.cpu.r_reg(REG_D1)
print "not implemented: StrConvert"
def StrnCmp(self, ctx):
locale = ctx.cpu.r_reg(REG_A0)
string1 = ctx.cpu.r_reg(REG_A1)
string2 = ctx.cpu.r_reg(REG_A2)
length = ctx.cpu.r_reg(REG_D0)
type = ctx.cpu.r_reg(REG_D1)
print "not implemented: StrnCmp"
"""

0 comments on commit 34db20c

Please sign in to comment.