Skip to content

Commit

Permalink
implemented * pseudo-var, just truncate 16 bit values and don't compl…
Browse files Browse the repository at this point in the history
…ain about overflow
  • Loading branch information
landondyer committed Nov 10, 2013
1 parent c063a6d commit 3e22cc3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def parseTerm():
tokenizer.advance()
parseHelper( len(self.m_operators) - 1)
tokenizer.expect( ')' )
elif tokenizer.curTok() == '*':
self.m_postfix.append( self.doPushSym )
self.m_postfix.append( '*' )
tokenizer.nextTok()
else:
raise Exception( str.format( "unexpected token {0}", tokenizer.curTok() ) )

Expand Down
7 changes: 5 additions & 2 deletions kasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ def fn_dw( tokenizer, phaseNumber ):

value = expr.eval()
if phaseNumber > 0:
if value > 0xffff or value < -32768:
raise Exception( "value too large for a word" )
depositWord( value )

else:
Expand Down Expand Up @@ -473,6 +471,11 @@ def assembleLine( line, phaseNumber=0 ):
clearLineBytes()
tokenizer = tok.Tokenizer( line )

#
# Set '*' psuedo-symbol at the start of each line
#
symbols.set( '*', gLoc )

#
# SYMBOL = VALUE
#
Expand Down
4 changes: 4 additions & 0 deletions test.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ gMyGlobal = $40

org $200

dw *
dw *
dw * + 0xffff
db 1,2,3

db gronk


gronk = 0xfe

db 'this is a test\n'
Expand Down

0 comments on commit 3e22cc3

Please sign in to comment.