Git Product home page Git Product logo

ggasm's People

Contributors

grendrake avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

ggasm's Issues

numeric value as param for streamnum

When I change the example basic.asm in line 32

32 streamnum #0 ; -> streamnum 2
33 streamchar ' ' ; character blank (32)

then the lexer throws an exception:
ERROR: asm/basic.asm(33): Lexer: unexpected ' (39)
Errors occured during assembly.

If instead decimal 2 is defined $02 (hex value) same error message.

Handling of addressing mode 0 (Constant zero)

I use callf to call global functions without parameters and without return value.

In my own implementation of Glulx code generation (I have a kind of cross compiler) this produces

8160 01 67 callf init

whereby 00000067 is the address of function init

In Glulx spec callf is defined as callf L1 S1

How should I tell the assembler, that S1 is address mode 0.
Simply ommitting S1 doesn't work ( -> Bad operand count for callf)
callf init 0 is accepted

Simular situation with return

31 00 return

Is it needed to write

return 0 instead to fulfill the spec ( return L1) ??

named local variables

Do you have plans to allow identifiers for local variables and parameters?
I think readability of code would benefit a lot.

Example of ggasm code generated (not working at this time):
; Function move2Loc( adr loc this )
function move2Loc 3
div adr 4 sp
add sp 8 sp
astore 0 sp loc
return 0

For correct working i currently have to change to
function move2Loc 3
div #0 4 sp
add sp 8 sp
astore 0 sp #1
return 0

which makes it much harder to understand.

Wrong address mode chosen

Here a small test program:

; include the glulx header file
include "glk.asm"

; set the stack size to 2048 bytes; this must be a multiple of 256
stackSize 2048

;Global variables:

bytesFixed mainwin 4

;Global Functions are put to ROM
toROM

; Function main( this )
function main 0
setiosys 2 0
copy 0 sp
copy 3 sp
copy 0 sp
copy 0 sp
copy 0 sp
glk 35 5 mainwin
copy mainwin sp
glk 47 1 sp
callf floyd_main 0
return 0

; Function floyd_main
function floyd_main 0
streamstr S0
streamstr "Text output"

return 0

endROM
;end of Global Functions

;Strings
string S0 "MyString"

This compiles without error, here the symbols table:

00000104 String S0
00000100 BuiltIn _startOfRAM
0000006a String _string0
00000059 LocalFunction floyd_main
00000028 LocalFunction main
00000100 Data mainwin

Correctly the functions are in ROM as specified, the variable mainwin (int) and the string S0 are in RAM as expected.

But when starting the compiled ulx the interpreter complains "Constant addressing mode in store operand"

Having a closer look to the generated code shows

glk 35 5 mainwin 8130 1103 23 05 0000 0000

So mainwin is considered to be a constant value instead of an address in RAM and value is simply 0 (int value)

Similar problems occur later for

callf floyd_main 0

and the streamstr statements.

The example basic.asm compiles without problem and runs in interpreter, so correct compilation can be assumed.

Example asm files?

Hi GrenDrake,
your project is very intresting for me. Can you give test / example files for your asm format. Extracting this from the source is hard to do.

Glulx code generated to RAM

I wonder why the code (functions) is generated into RAM. I would have expected this in ROM block.
Any reason for this?

See start of codedump.txt
256/0: [LABEL:_startOfRAM type:BuiltIn localCount:0 @null:0]
256/3: [LABEL:setup type:LocalFunction localCount:0 @null:0]
259/4: [INST 329:[value:2 size:1 name:null mode:Constant][value:0 size:0 name:null mode:Constant]]

This is in line with the size definitions of ROM / RAM of the header.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.