Commit Graph

2180 Commits

Author SHA1 Message Date
Michael Munday
54199bd9bc Clean up test file and add script to run tests.
./run.sh will now execute the tests. It is a very simple setup
currently, and is limited to linux on s390x. Enough to get started
with.
2016-12-05 14:02:58 -05:00
Michael Munday
d7f7509894 Minor indentation fixes. 2016-12-05 12:35:13 -05:00
Michael Munday
9745e9df26 Get DASM_SECTION argument from the correct place. 2016-12-05 12:35:13 -05:00
ketank-new
17d91e2f0c Update test_z_inst.c
changed code to in the form of a test table
currently handles RR based , addition, subtraction and multiply test
2016-12-05 13:46:44 +05:30
Michael Munday
1dd736f09a Auto-format dasm_s390x.h (again).
This time explicitly ban tabs.

indent -i2 -brs -cli0 -br -ce -npcs -nbc -di1 -npsl -ncs -nut dasm_s390x.h
2016-12-02 15:14:37 -05:00
Michael Munday
3ec573e750 Add support for .align directive. 2016-12-02 15:13:04 -05:00
Michael Munday
7181c391bd Add C code to handle IMM16. 2016-12-02 14:20:59 -05:00
Michael Munday
2324be897e Reduce indentation level of big switch statement.
A style thing. I find it easier to read this way.

i.e. do:

while(1) {
  if (blah) {
    ...
    continue;
  }
  ... // big switch statement
}

instead of:

while(1) {
  if (blah) {
    ...
  } else {
    ... // big switch statement
  }
}
2016-12-02 13:50:09 -05:00
Michael Munday
fc2b633532 Auto-format dasm_s390x.h.
I did this mostly to get rid of the annoying tabs/spaces mix in this
file. It has the side effect of forcing newlines before statements
which I think is a better style (and not particularly inconsistent
with the original which used both styles). Other than that I've tried
to match the original style as closely as possible.

Generated with this command:

indent -i2 -brs -cli0 -br -ce -npcs -nbc -di1 -npsl -ncs dasm_s390x.h
2016-12-02 13:41:45 -05:00
Michael Munday
621ae87058 Cleanup and fix compilation. 2016-12-02 13:06:03 -05:00
niravthakkar
3d5c692e13 Minor change: Cleanup 2016-12-02 17:39:00 +05:30
niravthakkar
f0dd40dc50 Adding support for Immediate add mode
The masking in immediate mode might not be proper. I could understand that you had masked 12bits and then 8bits to get the displacement in place for 20-bit displacement ( cp[-2] |= n&0xfff;          cp[-1] |= (n>>4)&0xff00;)  But in my case I need all the 32bits, so not sure how to go about it. Currently I have just used "n" since no point in "and with 0xffff" But I am getting core dump. Please Let me know your comments on these.
2016-12-02 17:37:20 +05:30
niravthakkar
b97a7f7b44 Minor cleanup and modified 32 bit signed check
Modified 32 bit signed check  for the immediate value
2016-12-02 17:19:29 +05:30
ketank-new
f0cc29436c Update test_z_inst.c
added functionality to test different modes of same instruction type
2016-12-02 15:46:45 +05:30
ketank-new
1d960f2286 Create test_z_inst.c
Added examples folder 
Added test code to test basic instructions like add , sub and msr
This code is in processes of further expansion and tuning
2016-12-02 15:21:18 +05:30
niravthakkar
45553891da Minor change , missed out brace 2016-12-02 14:13:55 +05:30
niravthakkar
4c7e494e0a Added support for Immediate addressing mode
Adding support for Immediate add mode, need to check how 32 bits is returned, currently followed the displacement method.
2016-12-02 12:55:43 +05:30
Michael Munday
1b7ded5474 Add support for RS-a and RSY-a instructions like stm and stmg. 2016-12-01 19:45:06 -05:00
Michael Munday
6ae327df75 Add support for RXY instructions (20-bit displacements). 2016-12-01 19:26:30 -05:00
Michael Munday
77f283c328 Allow symbols to be used for 12-bit displacements.
The parse_mem_bx function now returns a function to call to add an
action to the action list to handle the evaluation of the
displacement. This allows us to delay adding said action until
after we have emitted the actions for the instruction encodings
themselves.

Code like this should now work:

int x = 24
| st r1, x(sp)
2016-12-01 17:09:45 -05:00
Michael Munday
c71a6189bb Fix indentation.
I miss gofmt.
2016-12-01 14:43:23 -05:00
niravthakkar
dd6448ff1e Changed the templates based on no of arguments
Have changed the templates based on number of parameters passed, mainly the memory and immediate ones are modified.
2016-12-01 15:15:06 +05:30
Michael Munday
575c907544 Minor cleanup of regular expressions. 2016-11-30 17:07:17 -05:00
Michael Munday
a34bcf9ef4 Add initial support for D(B,X) memory operands (12-bit only).
Most RX instructions don't specify the correct number of operands
so this won't work on many yet. It also won't yet emit an action
if D is a variable rather than a constant.
2016-11-30 16:05:36 -05:00
Michael Munday
cf225d27cc Fix C code in header file and handle br template.
This means that code like this can now be generated on s390x:

| ar r2, r3
| br r14

Still need to add support for immediates, memory, labels, other
instructions and so on.
2016-11-30 14:11:01 -05:00
Michael Munday
000b1a84f0 Breakup instructions and action list into halfword chunks.
This should allow us to encode the instructions relatively naturally
and efficiently. For now I've escaped halfwords with a value <=
the maximum action. This means that 0 is escaped which probably
isn't ideal, so we may want to revisit that decision at some point.
2016-11-29 18:06:59 -05:00
Michael Munday
d97dea2e3f Add a description of how immediate actions should be encoded.
Also sets the action list type to unsigned short (uint16_t) which
I think is the most appropriate type for s390x (x86 uses uint8_t
and other platforms use uint32_t).
2016-11-29 16:29:42 -05:00
Michael Munday
36479af87a Add stubs for parsing memory operands and delete unwanted code.
Each memory operand will be a single parameter so we also need
to update the instruction encoding nargs field.
2016-11-29 15:24:11 -05:00
Michael Munday
89ca41cca5 Add sp -> r15 mapping and don't special case or_2
It's convenient for sp to be a pseudonym for r15 (the stack pointer).
'or_2' doesn't need to be special cased ('or' did because it is a
keyword).
2016-11-29 13:59:37 -05:00
Michael Munday
0e3241180f Various cleanup of dasm_s390x.lua
- Fix syntax errors
 - Fix whitespace (use two-space indentation to match surrounding code)
2016-11-29 13:45:59 -05:00
niravthakkar
7a49be07be Added the required character for encoding
I have added the number depending on the number of operands, pls check for the ones which access memory.
Also For base register and displacement, should I assume that it will be passed in the same order as it is expected, since I dont have any means to see the output, I am confused a bit for those add modes.
Since we decided to test RR first, thats in progress, but would like to add others as well.
2016-11-29 19:00:28 +05:30
niravthakkar
538a4afee2 Updated size of the instruction word
We can discuss if we need to keep it 6 bytes or 8 bytes long, Not clear enough to me as well
2016-11-28 15:29:58 +05:30
niravthakkar
203006579f Removed the extra check in parse_reg
The extra check for register is currently ignored, and trying to see what value does the encode function return. Its still to be worked out, how this value is used later, after decoding.
2016-11-28 13:32:30 +05:30
Michael Munday
cac5d4f2fb Add extended mnemonics for branches. 2016-11-25 16:38:32 -05:00
niravthakkar
9b01b4dc6f Added s390x instructions with their encoding 2016-11-25 19:44:04 +05:30
ketank-new
3288e547bf Update vm_s390x.dasc
added definations to macros to test operand type refeered x86 definations
no JUMP instruction found for s390x used BRANCH RELATIVE on CONDITION instead (brc)
Not sure how the condition will be checked , need to discuss this
2016-11-24 14:58:52 +05:30
ketank-new
4ea7607e02 Update vm_s390x.dasc
added instructions to macros, referring macro defination of x86
for macro ins_ANDdid not find equivalent s390x replacement  instruction for 'Not' hence have currently marked the place as '????'

'????' has to be replaced with s390x complement instruction
2016-11-24 14:02:50 +05:30
ketank-new
372f721e60 Update vm_s390x.dasc
used MOVE LONG EXTENDED in place of mov and
MOVE LONG instead of movzx
2016-11-24 11:25:07 +05:30
Michael Munday
5887962b0e Add assembly for decoding instructions.
Still guessing at this point. This code will need to be changed.
2016-11-23 18:02:00 -05:00
Michael Munday
dbf789536c Fix stack frame layout.
f8-f15 are callee-saved (not f0,f2,f4 and f6). There isn't space
for them in the caller's stack frame so we need to increase the
size of the interpreter's stack frame.
2016-11-23 17:30:10 -05:00
Michael Munday
5a69b4638a Fixup the save/restore register macros.
I believe these macros obey the C calling convention, so we need to
allocate our stack frame and save all callee-save registers. We
can tune it later if it turns out we don't need all the registers.
2016-11-22 13:58:10 -05:00
Michael Munday
d505a0e0ba Cleanup. 2016-11-22 13:47:35 -05:00
Michael Munday
d50f8aa92b Add preliminary frame offsets.
These are educated guesses at this point. We might need more stack space because
we don't have many free registers available.
2016-11-22 13:36:46 -05:00
ketank-new
31c0e6016a Update vm_s390x.dasc
Added definitions to macros savereg and restreg
used Store and Load instructions 
to store and load register contents to n from memory
2016-11-22 10:20:56 +05:30
Michael Munday
e90d985d08 Look for s390x file rather than S390x file. 2016-11-18 13:06:31 -05:00
ketank-new
3ac644ecee Update vm_s390x.dasc
Assigned general purpose register to existing macros
2016-11-18 17:09:20 +05:30
ketank-new
4aa1099d6a Update vm_s390x.dasc
Referred arm dasc file have created slots wherein i have to replace them with s390x registers and instructions
2016-11-17 14:58:17 +05:30
ketank-new
c36895a872 Update lj_frame.h
Added CFrame definations for S390X
values un assigned as i am unsure of the values
2016-11-16 17:19:10 +05:30
ketank-new
547b158ba4 Update vm_s390x.dasc
made some changes like mentioning arch from x86 to S390x
removed some x86 specific code
2016-11-16 15:34:32 +05:30
ketank-new
777b0671d3 Update lj_target_s390x.h
Added s390x specific condition codes
2016-11-16 15:09:59 +05:30