TUM-LRR / Jasmin

Java Assembler Interpreter
GNU General Public License v2.0
64 stars 22 forks source link

PUSH label returns an error #10

Open atar-axis opened 8 years ago

atar-axis commented 8 years ago

The following code returns "Operand must be at 2 two bytes large" on line 4. It's a bug, isn't it?

miau:
DW 0x1234

miau:
DW 1234

the following works btw, but I think DWORD is normally not necessary because an address should always be 32bit at 80x86

DW DWORD 1234

meyerm commented 8 years ago

The first example dw 0x1234 as well as the second one dw 1234 should both work - both values can be extended to a full data word. The third, on the other hand, is wrong, as dw only declares a 2-byte date while dword refers to a 4-byte date.

Trying them out in Jasmin 1.5.8 as well as the current HEAD shows that Jasmin handles all cases correctly. Did I misunderstand something?

atar-axis commented 8 years ago

Sorry, I forgot the most important thing and confused DD with DW yesterday. This is the example i wanted to show you:

miau:
DD 0x1234

PUSH miau

miau in PUSH miau should be replaced by a 32-bit address, right? but jasmin complains that the operand is too short ("error: operand must be at least two bytes large")!

If I insert a DWORD before miau, like PUSH DWORD miau, it works. Shouldn't it also work without the DWORD thing?

meyerm commented 8 years ago

You are right. In the "real world" a push LABEL puts that address onto the stack and in Jasmin this should be the case, too.

Even though we probably should also think about our Harvard approach (as already mentioned in #5) in case somebody want to push a code line onto the stack... But first things first.