Sign in to follow this  
Followers 0
308guru

How do I use half of a data location?

5 posts in this topic

If I'm doing a math function (Ex. [= D0 H3132]) and 21 is in D0, this statement is true. How do I use just half of the data location? Say I wanted just the 1. I want to us a math function and look at just the first half of data location. Can somebody tell me how that's done? Thanks!

Share this post


Link to post
Share on other sites
FMOV D0 D1 K2 // copy D0 to two registers starting from D1 WAND D1 H00FF // clear upper half of D1 so only h0032 remains WAND D2 HFF00 // clear lower half of D2 so only h3100 remains SWAP D2 // swap upper and lower bytes in D2 (h0031)

Share this post


Link to post
Share on other sites
I'm not sure how that would work for me. Here's the application: I scan a barcode. It puts the barcode string in D0-D18. My first four characters are a description (D0-D1). My 5th through 9th characters are a customer number. (D2-D4.5) Yes that 4.5 looks strange. I'm not sure how to deal with it. The first half of D4 contains the last digit of the customer number. The second half of D4 contains a different characteristic of my barcode. I want to enable some functions later in the program based on the customer number. That means for an example of a barcode string like: 123456789ABCDEFGH etc. 1234 is my description. All is good here. 56789 is my customer number. 56 is in D2. 78 is in D3. 9A is in D4. My functions later on would look like this: [= D2 H3635]-----[=D3 H3837]-----[here is where i'm stuck]----(y001) How do I only look at the first half of D4? All help is greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites
I have done these not so straight way, than panic mode: DIS D4 D20 k4 //disunits D40 to help registers D20-d23 UNI D22 D4 k2 //higher side of the original D4 to D4 or UNI D20 D4 k2 //lower side of the original D4 to D4 Or with mov... Mov d4 k4m0 //register to bits m0-m15 Mov mov k2m8 D4 or Mov mov k2m0 D4 ? Tmu ps. Thanks panic mode, next time I'll use WAND.

Share this post


Link to post
Share on other sites
take the D4 and extract the character you want. for example you don't care what is after 9 (in your example it is the 'A'). so simply get rid of the other byte. before you modify it, it is probably good idea to make a copy. in example above i was copying both upper and lower bytes to D1 and D2 before processing them. since this is part of your string, pick some other memory like: MOV D4 D104 // I hope this is far enough D104='9A' WAND D104 hFF00 D104 // remove one byte ---> D104 = '90' This way it doesn't matter what is in the other half, it is always removed. for example '9A' or '9F' or '99' would always turn into '90' so you can do comparison like: ---[= D104 h3900 ]--- if you prefer to have the '9' in lover half of the register, use SWAP instruction. that would cange the '90' to '09'. in that case detecting character '9' would look like ---[= D104 h0039 ]--- or simply ---[= D104 h39 ]--- (no leading zeros) there are many ways to do what you ask. this is the simplest way to fix code you already have. When I deal with barcodes, I simply create teach function. you scan the label and save it as barcode1, scan another one and save it as barcode2 etc. once you have "library" of different codes, you can compare new barcode with the ones in the library to find the match. this is probably the easiest way to handle "model selection" using barcode scanner. if you have to parse the received strings, you will have to do something similar to what you do. i would strongly recommend learning AND, OR and XOR operators and masking.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0