How can I implement PIN Block Format 01? so I could get the output like this:
accnum pin1 pin2
---------------- ----- ----------------
6034000001234562 92389 0592789FFFEDCBA9
I don't know how to implement xor bitwise.
Thank you.
There is not built-in XOR. However:
logical XOR operator in Progress
might be helpful.
For PIN Block formats there are many resources. This might be a good place to start:
https://www.eftlab.co.uk/index.php/site-map/knowledge-base/261-complete-list-of-pin-blocks-in-payments
Related
When I run parse"select from trade where date=max date,price=(max;price) fby sym"
I get the following parse tree:
</br>
?
`trade
,((=;`date;(max;`date));(=;`price;(k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x..
0b
()
I tried interpreting this in functional form as:
?[trade;((=;`date;(max;`date));(=;`price;(k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x..;0b;()]
but I get an error pointing to the final. What is wrong with my syntax?
You have two issues here. First is that your display window is not wide enough to show the full output. To adjust this window use \c (console size) command:
q)\c 25 200
q)parse"select from trade where date=max date,price=(max;price) fby sym"
?
`trade
,((=;`date;(max;`date));(=;`price;(k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x[1]g:.=y];'length]};(enlist;max;`price);`sym)))
0b
()
However, you will still have an issue using this because parse displays the full underlying k definition of fby:
q)fby
k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x[1]g:.=y];'length]}
Note that the definition is prefixed with "k)", which causes the error. To get around this you'll want to entirely replace the the k definition above with fby so that you have
?[trade;((=;`date;(max;`date));(=;`price;(fby;(enlist;max;`price);`sym)));0b;()]
rather than
?[trade;((=;`date;(max;`date));(=;`price;(k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x[1]g:.=y];'length]};(enlist;max;`price);`sym)));0b;()]
You can use fby rather than the k definition from parse:
?[trade;(((=;`date;(max;`date));(=;`price;(fby;(enlist;max;`price);`sym))));0b;()!()]
As suggested by Aaron Davies in a KxCon talk a few years ago, you could use wrapper functions to make the code a bit easier to read:
q)trade:([]date:(.z.D-1),3#.z.D;sym:(3#`AA),`BB;price:1+til 4);
q)w:{(parse"select from t where ",x). 2 0}
q)?[trade;w"date=max date,price=(max;price)fby sym";0b;()]
date sym price
--------------------
2020.09.24 AA 3
2020.09.24 BB 4
This "w" won't cover all possible use-cases but it can be expanded to cover the more general cases.
I think your second parameter is getting cut off in your output. Notice how it ends with an ellipsis '..'. When you copy and paste it, you're only picking up part of the code.
,((=;date;(max;date));(=;`price;(k){$[(#x 1)=#y;#[(#y)#x[0]0#x 1;g;:;x[0]'x.. <- ellipsis here
On the web i have found a nice LCD library for use with a PIC16F877A. I worked with a sample but I need to change the output ports of the PIC.
The lib indicates a possibility but that does not work. So no other way then trying to understand the lib.
#define LCD_DATA_TRIS D
#define LCD_DATA_POS 0
//LCD_DATA_TRIS &=(~(0x0F<<LCD_DATA_POS));
TRISD &=(~0x0F);
The above brings me to a reduced and working macro but I want to eliminate it completely. Somehow that does not succeed. It has to do with the ~. I can not find the working of it.
Help appreciated
In the meanwhile I have found the answer.
TRISD &= 0xF0 since the ~ reverses all the bits in the hex value.
I have to program in assembly the 6502.
I was forced to use the emulator Vice 128
I was told that the Commodore 128 is compatible with the instructions of 6502
I am a novice and I was made a practical demonstration but I did not understand anything.
There was an interface of 80 columns which passed with a command (which one?)
The instructions in machine language or assembly (the program)
were entered directly on this matrix of 80 columns.
Also the data are entered in this matrix.
So is this matrix the memory? Each line represents what?
I was told that this is disassembled code 6502. But I do not know what it means
I'm very confused
I want to run this simple program that
performs the sum of two numbers.
The two numbers are stored in the first page to the word zero and to the word one. I want to store the result in the second word of the first page.
I imagined that the first line contains 80 words. Is that right?
So I put here the data in hexadecimal (3 and 2).
$03 $02
LDA $00
ADC $01
STA $02
But I have a syntax error.
I hope someone can help me because it escapes me how things work.
Thanks in advance
Fir'st, in 6502, we use we deal with bytes, not words. (it's an 8 bit architecture)
You don't mention which macro assembler you are using, but I assume that its trying to interpret $03 as an op code, not data. I looked up two options
in ca65 you can use
.BYTE $03 $02
in dasm you use
HEX 03 02
In addition, 6502 has no concept of 80 anything (words, lines whatever). The only 80 I can think of is the old terminals that had 80 columns. I don't see how this is relevant here.
How to run a disassembled code 6502?
You have to assemble back the code.
Each 6502 instruction stands for 1, 2, or 3 bytes, the first is called the opcode, the optional second or third is the data used by the instruction (the operand).
You need a program to translate the instruction mnemonics to bytes. There were many such programs on the Commodore.
The Commodore 128 had a built-in monitor that let you enter instructions to assemble directly. You can enter it by typing MONITOR at the BASIC prompt. You would need to first set the address, then use "assemble" commands. Then use the "go" command at the starting address to run it. Use BASIC POKE command to set locations containing data, before you enter the monitor. The address 0B00 is a good address to use as it's the tape buffer which is unused except during tape I/O.
Good luck.
When working with unpack, I had hoped that b3 would return a bitstring, 3 bits in length.
The code that I had hoped to be writing (for parsing a websocket data packet) was:
my($FIN,$RSV1, $RSV2, $RSV3, $opcode, $MASK, $payload_length) = unpack('b1b1b1b1b4b1b7',substr($read_buffer,0,2));
I noticed that this doesn't do what I had hoped.
If I used b16 instead of the template above, I get the entire 2 bytes loaded into first variable as "1000000101100001".
That's great, and I have no problem with that.
I can use what I've got so far, by doing a bunch of substrings, but is there a better way of doing this? I was hoping there would be a way to process that bit string with a template similar to the one I attempted to make. Some sort of function where I can pass the specification for the packet on the right hand side, and a list of variables on the left?
Edit: I don't want to do this with a regex, since it will be in a very tight loop that will occur a lot.
Edit2: Ideally it would be nice to be able to specify what the bit string should be evaluated as (Boolean, integer, etc).
If I have understood correctly, your goal is to split the 2-bytes input to 7 new variables.
For this purpose you can use bitwise operations. This is an example of how to get your $opcode value:
my $b4 = $read_buffer & 0x0f00; # your mask to filter 9-12 bits
$opcode = $b4 >> 8; # rshift your bits
You can do the same manipulations (maybe in a single statement, if you want) for all your variables and it should execute at a resonable good speed.
I am trying to read a text file in matlab and convert it into bits. I then want to access and store them in a register in my module in verilog. I then use these bits inside the module. Can I do this? If yes, how? Thank you.
There are a couple of ways to read a text file into Verilog and strore numeric values into a variable. The easiest way is to use the $readmemb system task and store the values into a reg array.
Another way which is a little more work, but is also more flexible, is to use the $fopen system task. Refer to the IEEE Verilog Std (1800-2009, for example).