Professional Documents
Culture Documents
8.working With Characters, Strings & Lists Type of Data
8.working With Characters, Strings & Lists Type of Data
Before starting work with this I would like to mention that you should first
learn about ASCII Encoding.
In ASCII Encoding every character has it corresponding Numeric value. Computer
processes character but not as chracters instead as a Numeric values like UpperCase
'A' = 65. Similarly you can see some of the ASCII Codes below:
A = 65
B = 66
C = 67
D = 68
E = 69
F = 70
G = 71
H = 72
I = 73
J = 74
K = 75
L = 76
M = 77
N = 78
O = 79
P = 80
Q = 81
R = 82
S = 83
T = 84
U = 85
V = 86
W = 87
X = 88
Y = 89
Z = 90
a = 97
...
z = 122
section .data
String DB "ABC",0
String2 DB "XYZ",0
section .text
global _start
_start:
MOV bl, [String]
MOV cl, [String2]
MOV eax, 1
INT 80h
Now you understand why I have pushed the Strings inside the bl and cl registers
as I explained from the
last topic. Now if we debug our code and type the command in debugger that is x/x
address[0x0..]
as 0x804a000 in my case for the first one string and if I press enter it will give
me output something like this 0x00434241 in which 43 is A in Hexa and 42 is B and
41 is C Similarly if I type command as:
x/2x address[0x804a000](in my case).
It means that show next block as well, so it will give me the output as:
Now here these zeros are the last zero that I used to specify the end of the list.
Now let me write the code for a character type as well.
section .data
Character DB 'A'
section .text
global _start
_start:
MOV bl, [Character]
MOV eax, 1
INT 80h
Now here is the code for character type of data and the output of this program
will be 65 since 65 is
the ASCII Code for A. Now next code for list.
section .data
List DB 1,2,3,4,0
section .text
global _start
_start:
MOV bl, [List]
MOV eax, 1
INT 80h
Now if I run this code indeed the output will be as 0x04030201. And if I write
the command x/2x indeed
the output will be as:
0x804a000: 0x04030201 0x00000000
And the zeros are ending zero. This is how we get to know that this is the end
of the list or string
etc in memory. Now since we are using debugger but you may find it a bit complex to
deal with. Now to make its interface a bit simpler type a command in terminal that
is follows: