|
|
Hi all! My name is lightning_missile. Nice to be here.
I am a totally blind programmer. I use a screen reading software to read texts on the screen, but not images. Sometimes I have some trouble reading pdf files, like a table in chapter 4 ...
So I am currently on the hack machine language specification (unit 4.4), and I am currently on the part where professor Schocken is discussing the c instruction. The whole specification seem to be inside a table, so I need to use the course's resources to read that table. The book chapter seems to put the table in an image or scanned so my screen reader can't get through it. On the other hand the lecture notes actually displayed it as text, but it seems as I have trouble reading that as well. Here is how my screen reader rendered the table on the lecture notes (page 105).
C-instruction specification
comp c1 c2 c3 c4 c5 c6
0 1 0 1 0 1 0
1 1 1 1 1 1 1
-1 1 1 1 0 1 0
D 0 0 1 1 0 0
A M 1 1 0 0 0 0
!D 0 0 1 1 0 1
!A !M 1 1 0 0 0 1
-D 0 0 1 1 1 1
-A -M 1 1 0 0 1 1
D+1 0 1 1 1 1 1
A+1 M+1 1 1 0 1 1 1
D-1 0 0 1 1 1 0
A-1 M-1 1 1 0 0 1 0
D+A D+M 0 0 0 0 1 0
D-A D-M 0 1 0 0 1 1
A-D M-D 0 0 0 1 1 1
D&A D&M 0 0 0 0 0 0
D|A D|M 0 1 0 1 0 1
a==0 a==1
Now, I am not sure if my screen reader rendered the table correctly, but it looks like the spacing is lost. Anyway, this seems to be mostly understandable. I guess that the mnemonic symbols are on the left while the binary representations are on the right. What killed me are the A bits, which seems to be at the very bottom, and I have no idea how it maps to the symbols. I can guess how some rows are mapped, like on row 7, that looks like this:
!A !M 1 1 0 0 0 1
now, I cannot be sure, but it seems that the A bit of !A is 0 while the A bit of !M is 1? This is based on the ordering:
a==0 a==1
but what about something like in row 2:
D 0 0 1 1 0 0
I have no idea what the A bit of d is.
Can someone help me interpret this table? Thanks all!
P.S. Is there a place where someone can send suggestions for the course?
|
|
I posted to the other, now deleted thread. I again apologize for not understanding what you needed. I will be happy to help with some type of useful conversion of the table if you can give me some direction regarding what will be helpful.
|
|
Here is a table with 3 columns. The first column shows the 6 control bits. The next 2 columns show the operation depending upon whether the "a" bit is 0 or 1.
control bits a=0 a=1
101010 0
111111 1
111010 -1
001100 D
110000 A M
001101 !D
110001 !A !M
001111 -D
110011 -A -M
011111 D+1
110111 A+1 M+1
001110 D-1
110010 A-1 M-1
000010 D+A D+M
010011 D-A D-M
000111 A-D M-D
000000 D&A D&M
010101 D|A D|M
|
|
No worries. In hindsight, my first post is actually not that clear anyway, so I deleted it. Anyway, @ashort already provided the textual table.
Actually, I am currently looking for a way to see if I can convert all the mathematical formulas and tables in html or textual form in the book chapters. You see, all the math formulas, truth tables and other tables are rendered as scanned images in the book, but luckily they are in textual form in the lecture notes. The c instruction table is the only exception because my screen reader totally messed up the table formatting. Do you know some tips where I can go about doing this? This course is very very accessible to blind programmers like me, I think it would be even more approachable if there is at least an alternative to scanned images in the book.
|
|
Thanks! I finally got it.
|
|
This post was updated on .
I will be happy to help with conversion of tables or mathematical formulas into a screen readable format. Please continue to post the need here. I monitor this site several times daily.
I am a retired programmer/analyst with a special interest in computer education. I would like to work on the problem of reading scanned images. I am starting to learn how to create and edit articles for the Wikipedia, and I would like to do as much as possible to make them accessible to everyone.
|
|
You are probably going to need the table for the 3 "destination" bits, so here it is. It has 2 columns and 8 rows. The first, row, 000, has no destination.
000
001 M
010 D
011 MD
100 A
101 AM
110 AD
111 AMD
And you are probably going to need the table for the 3 "jump" bits, so here it is. It also has 2 columns and 8 rows. The first row, 000, has no jump.
000
001 JGT
010 JEQ
011 JGE
100 JLT
101 JNE
110 JLE
111 JMP
|
|
The destination and jump tables in the lecture notes are already readable. Thanks anyway because I have been able to confirm/compare my understanding of those tables using your translation.
In general, the notes are really quite readable, it's just the A bits in the comp field are extremely elusive to my screen reader. I am curious, do you have an idea why that is the case? How does the table look like to you in the screen? It is stated by professor Schocken that the A bits are located at the bottom of the table, but my screen reader identifies the "a==0" and "a==1" columns as totally outside of the table. Also, why didn't they format the table like how you formatted the table for me? It would be a lot easier to read, isn't it?
I am actually finding ways to check how the table is constructed using pdftotext ( https://www.xpdfreader.com/pdftotext-man.html) so I can interpret these types of tables in the future.
|
|
When you refer to the lecture notes, are you talking about the PowerPoint slides that are provided on the Projects page of the web site?
The "a==0" and "a==1" refers to column headers for the first two column tables but that appear at the bottom of the columns rather than the top. Together these two columns are labeled "comp" at the top of the table. The first column rows give the computation mnemonics when the value of the "a" bit is zero. The column label "a==0" appears at the bottom of this column. The second column rows give the computation mnemonics when the value of the "a" bit is one. The column label "a==1" appears at the bottom of this column.
I also thought the table you refer to is non-traditional and somewhat non-intuitive. I think it was possibly done like this to clearly separate the specification of the ALU computation by the c-bits from the identification of the source of the second ALU operand by the a-bit when it is needed. The c-bits specify the computation and the a-bit specifies the addressing mode.
|
|
Yes, you are absolutely right. I am referring to the powerpoint slides, which interestingly enough, have there tables and formulas rendered as text where I can read them. It is a little odd that they are rendered as images in the book chapters.
Also, I completely agree with you! The table is somewhat unusual indeed. A few minutes ago, I just finished tracing the columns "A==0" and "A==1" through painstakingly tracking the spacing between the columns using the pdftotext command line tool. Using that tracing, I pretty much came to the same conclusion to what you mentioned just now about separating the specification of the ALU computation because the column "A==1" is optional.
It would be nice if we can at least add some details before the table stating something like: "All computations using M (ram[A]) uses the A==1" or something like that. Or would it be too detailed?
|
|
Perhaps part of the problem is that the screen reader is not differentiating upper and lower case. The book uses case extensively, in context, to allow alphanumeric symbols differentiated by case to refer to different things.
For example, it uses uppercase A to refer to the CPU address register and lowercase a to refer to the thirteenth significant bit of the C instruction word. Both of these symbols appear in the table in question, but they refer to different things.
I thought the table was so confusing, but also to avoid copyright questions, that I put each of the 28 separate C instruction possibilities on a separate line of the table I created for the Wikipedia article on the Hack computer. I have copied the text from the article for the C instruction following this paragraph. I would be curious about how your screen reader renders this. It also uses uppercase and lowercase to distinguish the meaning of symbols. I notice in the preview that the columns headings do not line up with the columns very well.
C-instructions
The other instruction type, known as C-instructions (computation instructions), have “1” as the most significant bit. The remaining 15 bits are bit-field encoded to define the operands, computation performed, and storage location for the specified computation result. This instruction may also specify a program branch based on the most recent computation result. The C-instruction is bit-field encoded as follows:
1x1x0ac5c4c3c2c1c0d2d1d0j2j1j0
1 – the most significant bit of a C-instruction is “1”
x1x0 – these bits are ignored by the CPU and, by convention, are each always set to “1”
a – this bit specifies the source of the “y” operand of the ALU when it is used in a computation
c0-c5 – these six control bits specify the operands and computation to be performed by the ALU
d2-d0 – these three bits specify the destination(s) for storing the current ALU output
j2-j0 – these three bits specify an arithmetic branch condition, an unconditional branch (jump), or no branching
The Hack computer encoding scheme of the C-instruction is shown in the following tables.
In these tables,
A represents the value currently contained in the A-register
D represents the value currently contained in the D-register
M represents the value currently contained in the data memory register whose address is contained in the A-register; that is, M == RAM[A]
Hack machine language computation function codes and assembly language mnemonics
a c5 c4 c3 c2 c1 c0 ALU Output: f(x,y) Mnemonic
0 1 0 1 0 1 0 Outputs 0; ignores all operands 0
0 1 1 1 1 1 1 Outputs 1; ignores all operands 1
0 1 1 1 0 1 0 Outputs -1; ignores all operands -1
0 0 0 1 1 0 0 Outputs D; ignores A and M D
0 1 1 0 0 0 0 Outputs A; ignores D and M A
1 1 1 0 0 0 0 Outputs M; ignores D and A M
0 0 0 1 1 0 1 Outputs bitwise negation of D; ignores A and M !D
0 1 1 0 0 0 1 Outputs bitwise negation of A; ignores D and M !A
1 1 1 0 0 0 1 Outputs bitwise negation of M; ignores D and A !M
0 0 0 1 1 1 1 Outputs 2's complement negative of D; ignores A and M -D
0 1 1 0 0 1 1 Outputs 2's complement negative of A; ignores D and M -A
1 1 1 0 0 1 1 Outputs 2's complement negative of M; ignores D and A -M
0 0 0 1 1 1 1 Outputs D + 1 (increments D); ignores A and M D+1
0 1 1 0 1 1 1 Outputs A + 1 (increments A); ignores D and M A+1
1 1 1 0 1 1 1 Outputs M + 1 (increments M); ignores D and A M+1
0 0 0 1 1 1 0 Outputs D - 1 (decrements D); ignores A and M D-1
0 1 1 0 0 1 0 Outputs A - 1 (decrements A); ignores D and M A-1
1 1 1 0 0 1 0 Returns M-1 (decrements M); ignores D and A M-1
0 0 0 0 0 1 0 Outputs D + A; ignores M D+A
1 0 0 0 0 1 0 Outputs D + M; ignores A D+M
0 0 1 0 0 1 1 Outputs D - A; ignores M D-A
1 0 1 0 0 1 1 Outputs D - M; ignores A D-M
0 0 0 0 1 1 1 Outputs A - D; ignores M A-D
1 0 0 0 1 1 1 Outputs M - D; ignores A M-D
0 0 0 0 0 0 0 Outputs bitwise logical And of D and A; ignores M D&A
1 0 0 0 0 0 0 Outputs bitwise logical And of D and M; ignores A D&M
0 0 1 0 1 0 1 Outputs bitwise logical Or of D and A; ignores M D|A
1 0 1 0 1 0 1 Outputs bitwise logical Or of D and M; ignores A D|M
Hack machine language computation result storage codes and assembly language mnemonics
d2 d1 d0 Store ALU output in Mnemonic
0 0 0 Output not stored none
0 0 1 M M
0 1 0 D D
0 1 1 D and M DM
1 0 0 A A
1 0 1 A and M AM
1 1 0 A and D AD
1 1 1 A and D and M ADM
Hack machine language branch condition codes and assembly language mnemonics
j2 j1 j0 Branch if Mnemonic
0 0 0 No branch none
0 0 1 Output greater than 0 JGT
0 1 0 Output equals 0 JEQ
0 1 1 Output greater than or equal 0 JGE
1 0 0 Output less than JLT
1 0 1 Output not equal 0 JNE
1 1 0 Output less than or equal 0 JLE
1 1 1 Unconditional branch JMP
|
|
I like your table much better than the table in the slides. Although might I suggest that you remove the ALU output or the function f(x,y) in the comp fields? This column almost gave away one of the challenges in my CPU implementation :)
Regarding the character casing, it is not my screen reader, I'm just stupid enough to ignore the meaning of the upper case and lower case. Thanks for pointing it out.
|
|