The below code is a code I found from a site to study about assambly more.But I don't know exactly what do this section of code. For example what do .ORG 140 do? Why 140? Or in this line : .DB 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F how we write them? from where?
.ESEG ;7segment LUT
.ORG 140
.DB 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F
.ESEG
specifies the EEPROM memory section, with a comment on what's the purpose of the dataThis specifies that the following data will start at address
140
. The semantics of.org
depends on the assembler brand you are using.This are 10 bytes of data in a look-up table (LUT) that describe which segments of a 7-segment display have to be lit to show a specific digit. The digit is used as an index into the array, where indices start at an offset of 0. Hence, the 1st entry encodes which segments have to be lit to show a
0
.Written in binary, at the specified offsets we have the following values:
This means the 7-segment display(s) are "connected" / "wired" to the respective bits as follows:
For example, a
4
has bits 1, 2, 5 and 6 on, which is the following pattern that resembles a4
when lit:Some 7-segment displays feature a dot at the lower left or lower right, so that decimal fractions like
3.14
can be displayed. In this case one would wire the.
to bit 7.And in order to represent hexadecimal digits
A
,b
,c
,d
,E
andF
, one could extend the array in the obvious way likeFor negative numbers, encode
-
as