MedVision ad

Understanding assembly question (1 Viewer)

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
I've been studying for my sdd trial with some papers our teacher provided, but there's this one assembly question im stuck on:
1692509019387.png1692509048460.png
1692509080433.png

Is the dissassembler section of "assembler code" not just each section of assembly code in order? I thought the output would start with 48 because that's the value put into R1 but that's not even close to the answer, so I don't think I'm understanding this question at all, is someone able to please explain it?
 

dav53521

Well-Known Member
Joined
Mar 23, 2022
Messages
320
Gender
Male
HSC
2022
Is the dissassembler section of "assembler code" not just each section of assembly code in order
The code execution is not in a linear order because of the jumpnz instructions jump to a label if the register given is not equal to 0 and as you can see one jumpnz goes to to the label "next" and the other goes to the label "loop" which creates a loop that will continue until R5 or R4 is are equal to 0.
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
The code execution is not in a linear order because of the jumpnz instructions jump to a label if the register given is not equal to 0 and as you can see one jumpnz goes to to the label "next" and the other goes to the label "loop" which creates a loop that will continue until R5 or R4 is are equal to 0.
Yes but is it the order in which the original assembly code was written? Not necessarily order of execution but in terms of the order that it will go in unless affected by the jumps to 'next' or 'loop'.

I'm a bit confused because why does the output not start at 48? R1 is initially set to 48, R0 is 0, R3 is 2.
0 mod 2 is zero, so the program does not jump to 'next' because it is not a non-zero value, so R1 is stored to the register displayed in the console and it was never changed from 48 in that initial sequence
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
What i understand from the code is that it is printing every second number, a multiple of 2, from R1 upwards repeating n-1 times if the value of R2 is 2n. But would this not make it go 48, 50, 52, 54, 56? In the answer it says it prints 0, 2, 4, 6, 8
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
wait i think i get it.
by "treated as an ascii value" it means the decimal value will be converted to the ascii character associated with that number. ascii value of 0 is 48 and so on.
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,516
Location
Sydney <3
Gender
Male
HSC
2023
I've been studying for my sdd trial with some papers our teacher provided, but there's this one assembly question im stuck on:
View attachment 39387View attachment 39388
View attachment 39389

Is the dissassembler section of "assembler code" not just each section of assembly code in order? I thought the output would start with 48 because that's the value put into R1 but that's not even close to the answer, so I don't think I'm understanding this question at all, is someone able to please explain it?
I find this post hilarious because I posted the exact same question like a month ago https://boredofstudies.org/threads/help-with-trials-question-interpreting-a-disassembler.404105/
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
like we don't really learn it... we have to understand it :p
Another question relating to the cpu, thought i would post it here instead of making a new thread: When is the program counter incremented? Is it immediately after it is fetched or after the process from the ALU is complete? Or is it both, as in it is set to/points to the next address in line unless/until a new address is sent to it after ALU processing?
 

dav53521

Well-Known Member
Joined
Mar 23, 2022
Messages
320
Gender
Male
HSC
2022
Another question relating to the cpu, thought i would post it here instead of making a new thread: When is the program counter incremented? Is it immediately after it is fetched or after the process from the ALU is complete? Or is it both, as in it is set to/points to the next address in line unless/until a new address is sent to it after ALU processing?
I believed it is after the current instruction is read in as after that the PC will be able to get the memory address of the next instruction which will increment the PC
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
I believed it is after the current instruction is read in as after that the PC will be able to get the memory address of the next instruction which will increment the PC
So if there's a conditional jump statement returned true by the ALU, then this address will be overwritten before the next instruction is fetched?
 

dav53521

Well-Known Member
Joined
Mar 23, 2022
Messages
320
Gender
Male
HSC
2022
So if there's a conditional jump statement returned true by the ALU, then this address will be overwritten before the next instruction is fetched?
From what I hastily read if the condition for a jump is true then the instruction pointer is redirected to the label of the jump destination
 

SadCeliac

done hsc yay
Joined
Sep 23, 2021
Messages
2,516
Location
Sydney <3
Gender
Male
HSC
2023
I had a question about the Fetch-Execute cycle in my trial paper --will send here once my teacher releases the paper (I think on Thursday??)
 

sumum

New Member
Joined
Jul 28, 2021
Messages
6
Gender
Male
HSC
2023
From what I hastily read if the condition for a jump is true then the instruction pointer is redirected to the label of the jump destination
Hey someone forwarded me to you @dav53521 . I understand from your posts on bored of studies that you do Comp Sci at uts but specifically the IDeA course. Can you give me some info on it. Some specific Questions are:

1. What atar did you need to get in?
2.What companies do you generally get paired with?
3. Is the jobs software development and software engineering (Because thats whatIm intrested in and NOT the business analytics of "boring" [to me atleast] side of stuff)
4. How is the pay?
5. How many times a week do you work for the company and is the balance good or do you feel overwhelmed with the Job Placement and the Uni work at the same time.

I may need to ask more questions abit later on if I get accepted after interview and atars.

Thanks alot!
 

sumum

New Member
Joined
Jul 28, 2021
Messages
6
Gender
Male
HSC
2023
From what I hastily read if the condition for a jump is true then the instruction pointer is redirected to the label of the jump destination
Also I made a conversation with you so you can reply there or here, Im not too sure how this app works
 

jc7726

Active Member
Joined
Aug 6, 2023
Messages
183
Gender
Male
HSC
2023
I had a question about the Fetch-Execute cycle in my trial paper --will send here once my teacher releases the paper (I think on Thursday??)
thanks, exam is tmrw though 😔 (i really want to top bc my friend is beating me by 1 mark overall from the first exam)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top