grendrake / ggasm Goto Github PK
View Code? Open in Web Editor NEWBasic assembler for producing glulx files. (depreciated in favour of glulx-assemble)
License: GNU General Public License v3.0
Basic assembler for producing glulx files. (depreciated in favour of glulx-assemble)
License: GNU General Public License v3.0
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.
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) ??
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.
The opcodes for callf up to callfiii are incorrect (looks like copy error)
The 'words' directive is not listed in README.md where all other directives are documented.
; 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
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.
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.