News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hutch's chtble: Need a teensy weensy hint

Started by noman9607, April 06, 2006, 09:31:39 PM

Previous topic - Next topic

noman9607

I have stolen a snippet of code from a posting that I found. I can't figure out how it works but it looks like it should be simple. I guess there is simple and there is a simple enough for me simple. It is from a word replacing algo that Hutch posted. I will only post here the part I can't figure out. How does a 16x16 table work out to chars?
chtbl:
    ! db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    ! db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0     ' 31
    ! db 0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0     ' 47
    ! db 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1     ' 63   ' numbers
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1     ' 79   ' upper case
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1     ' 95
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1     ' 111  ' lower case
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1     ' 127
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
    ! db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

    ' characters     ! # $ % & ? @ _
    ' numbers        0123456789
    ' upper case     ABCDEFGHIJKLMNOPQRSTUVWXYZ
    ' lower case     abcdefghijklmnopqrstuvwxyz
    ' high ansi set  128 to 255


hutch--

noman,

That is a piece of inline assembler from a powerbasic compiler but the only difference is the leading "!" before the DB.

A table like this can be used in a couple of different ways. It can be written in the initialised data section (.DATA) or it can be written inline in a procedure as long as you don't try to run it like normal executable code. This means in a procedure you must JMP over it.

The 16 * 16 gives you the 256 characters possible in the ANSI character set and it forms what you would normally call a table. The advantage of this technique is you can preset a table with different values and then compare each character in text to that table  and evaluate each character accordingly. to do this you must set up an algorithm that scans each character and as you have each character you test the BYTE value of each character against the matching location in the table and in this instance, you evaluate it depending if it matches a zero or one.

They can look a bit complicated but once you are used to them, they are straight forward enough and very useful.

If you have the current version of masm32, look in the example code in exampl09 at an app called tables which will create character tables for you with characters of your choice. Note that it will only run on a late OS version and will not run on ME, win98 or earlier.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php