9608_w20_qp_31
A paper of Computer Science, 9608
Questions:
7
Year:
2020
Paper:
3
Variant:
1

Login to start this paper & get access to powerful tools

1
2
3
4
6
7
A company has a number of lorries that deliver items around the country. The items in each lorry are its load. Each lorry has a monitoring system that provides information to the driver about the state of the load and other data from each trip. • Data is stored in three memory locations with addresses 801 to 803. • Location 801 contains the distance travelled in kilometres for the current trip, stored as a binary integer. • Location 802 contains the quantity of fuel used in litres for the current trip, stored as a fixed-point binary number with six places before the binary point and two places after the binary point. • The four most significant bits of location 803 are flags used to identify problems with the load, for example it is too heavy. A flag is set to 1 if there is a problem, or 0 if not. The problems are: • Bit 7 – load too heavy • Bit 6 – load too high • Bit 5 – load unstable • Bit 4 – load not secured (risk of the load falling off) • Bits 0 to 3 are not used The current contents of addresses 801 to 803 are: Most significant bit Least significant bit State the information that the current contents of addresses 801 to 803 will provide to the driver. A lorry has a load that is too heavy and is not secured. It has travelled 120 kilometres and used 35.25 litres of fuel. Complete the contents of the addresses to record this information. The following table shows the instructions for the lorry load monitoring system in assembly language. There is one general purpose register, the Accumulator (ACC). Table 7.1 Instruction Explanation Label Op code Operand LDM #n Load the number n to ACC LDD Load the contents of the location at the given address to ACC STO Store the contents of ACC at the given address AND #n Bitwise AND operation of the contents of ACC with the operand CMP #n Compare the contents of ACC with number n JPE Following a compare instruction, jump to or if the compare was True JMP Jump to the given address or label : Labels an instruction Note: # denotes immediate addressing B denotes a binary number, for example B01001010 & denotes a hexadecimal number, for example &4A Write assembly language instructions to set the contents of addresses 801 and 802 to zero, and set all four most significant bits of the contents of address 803 to one. Use the instruction set from Table 7.1. A program written in assembly language, continuously checks the flags. If a flag is set, the program jumps to the error-handling routine at the specified label. For example, if the load is too heavy, the program jumps to the error-handling routine with the label TOOHEAVY. The error-handling routine instructions have not been provided. A programmer has written most of the instructions for the program in the following table. There are four missing operands. Complete the assembly language program by writing the four missing operands. Label Op code Operand CHECKLOAD: LDD AND &F0 STO TEMP AND &80 CMP &80 JPE TOOHEAVY LDD TEMP AND &40 CMP JPE TOOHIGH LDD TEMP AND CMP &20 JPE UNSTABLE LDD AND &10 CMP &10 JPE NOTSECURED JMP TEMP: