-1

I'll do a "SIMPLE program" on IJVM, but it asks:

You must get on input ONLY numeric characters ( 0x30 to 0x39).

So if I'll insert for example (A or b or g etc.. ) it will stop with "HALT". How can I make a condition that take the value from 0x30 to 0x39 without alphabetic characters?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Paolo
  • 1

1 Answers1

0

You will need two separate tests.

  1. First, test if the input is not less than 0x30.
  2. Second, test that the input is less than 0x40.

If it meets both conditions, then it is input that you want.


Response to comment about three types of 'if':

Each conditional branch has two possible jump targets, one for when the condition is true, the other for when the condition is false.

For the n < 0 test, the TRUE address will be taken when n < 0, the FALSE address will be taken when n >= 0. The n < 0 test can also test for n >= 0, depending on the address taken.

downeyt
  • 1,206
  • 2
  • 12
  • 23
  • Yes,but how can resolve if there is 3 type of "IF". 1) n < 0 IFLT 2) n = 0 IFEQ 3) n = n IF_ICMPEQ How can resolve n < 0x40 ( @ ) ?? – Paolo Mar 25 '16 at 10:12
  • @Paolo did you read the manual or do some thinking? `IFEQ` and `IF_ICMPEQ` jump if the operands are **equal**, so how are they useful in this case? here you need to check for **less than** – phuclv Apr 10 '16 at 04:54
  • I had fixed. 1) method of INPUT and it was passed for value on main, and it was stored on local variables. 2) after i loaded 0x30 ( 0 HEX ) and i did "ISUB". 3) IFLT label GOTO label2. Thank's for your time! – Paolo May 02 '16 at 08:30