Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

ouverson
I was thinking about going through all the examples in week 4 slideshow. I found all the slides that have machine language examples and printed them out. The first one was on slide 48, 49.

This example program computes RAM[1] = 1+...+RAM[0] where the user enter value for RAM[0].

I created a Trace Table and started going through line by line. I noticed an error on line 23 (or at least I think it's an error); I think it should be @23 and not @21.

I also didn't track with line 17 that had an unconditional jump to line 4.

Could you do me a huge favor and see if this program is legit and if so, is line 23 correct?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

WBahn
Administrator
ouverson wrote
I was thinking about going through all the examples in week 4 slideshow. I found all the slides that have machine language examples and printed them out. The first one was on slide 48, 49.

This example program computes RAM[1] = 1+...+RAM[0] where the user enter value for RAM[0].

I created a Trace Table and started going through line by line. I noticed an error on line 23 (or at least I think it's an error); I think it should be @23 and not @21.

I also didn't track with line 17 that had an unconditional jump to line 4.

Could you do me a huge favor and see if this program is legit and if so, is line 23 correct?

Thank you.
When you say "line 23" how are you counting lines. Normally this means the line in a file in which the first line is line #1. So you would need to count blank lines as well. If you mean the instruction at address 23, then you count just the instructions and you begin with 0. The instruction @23 is therefore the instruction at address 22 and is located at line 28 in the file.

I agree that this should be @23 and not @21.

The unconditional jump to address 4 is simply the bottom of the loop and so it goes back up to the top of the loop to start the next pass.

Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

ouverson
This post was updated on .
I was only counting addresses. Thanks for the confirmation on @23.

How is the C-instruction, M=0 the beginning of the loop? I thought all instructions must start with an A-instruction? Every example thus far has been: A, C, A, C, A, C...A, C

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

WBahn
Administrator
ouverson wrote
I was only counting addresses. Thanks for the confirmation on @23.
Then be sure to remember that addresses start with 0.

How is the C-instruction, M=0 the beginning of the loop?
Because the bottom of the loop jumps to it. That's what defines the top of the loop.

I thought all instructions must start with an A-instruction? Every example thus far has been: A, C, A, C, A, C...A, C

Thank you.
If an instruction "starts" with an A-instruction then it is an A-instruction.

Program code a simply a list of instructions and is whatever mix of A-instructions and C-instructions that are needed to implement the logic needed to perform the task.

In general there is no value in following an A-instruction with another A-instruction since they ONLY thing that an A-instruction does is load a literal value into the A-register. If you then immediately do another A-instruction, then you overwrite the prior A-instruction's result rendering it useless.

It is quite common to have runs of C-instructions, but it is uncommon for them to be very long because usually you need to get a literal value or load a memory address.

Programs usually start with an A-instruction because that is how we normally make it start from a well-defined state. But this is not required.

Consider a program that starts

@SP

Well, all that does is load the value 0 into the A register. This can be accomplished just fine with the C-instruction.

A=0

instead.

Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

ouverson
I'm getting a mixed message regarding the location of R0 through R15, and RAM[0] through RAM[15] memory registers.

I was under the impression that the only registers near the ALU were the A and D registers. That R0 through R15 were virtual representations of RAM[0] through R[15].

An image from slide 21 indicates that R0 through R15 are closer to the ALU and separate from RAM[0] through RAM[15].

Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

ivant
ouverson, it's more useful for everybody we keep one topic per thread. This thread is already overloaded in this sense, and adding more just makes it worse.

Please open a new one for this new question.
Reply | Threaded
Open this post in threaded view
|

Re: Why didn’t this chapter/week focus on machine language only; why introduce assembly now?

ouverson
Roger that.
12