COMP1721 - Higher Computing 1B

Computing 1B - Week 06 Tutorial Questions

  1. Interpret these hexadecimal constants as signed 16-bit integers.

  2. Write a function which given as argument the opcode of an AVR LSR instruction returns the number of its operand register.

    It should check its argument is indeed the opcode of an LSR instruction and return -1 if it is not.

  3. Translate these EMU opcodes to assembler.

    Work out what the program does.

    
    0xe000
    0xe081
    0x2fa0
    0xe7f0
    0xe0e0
    0x9509
    0xe011
    0x0f01
    0xe01a
    0x1b10
    0xf7b1
    0xe080
    0xe7f0
    0xe0e0
    0x9509
    

  4. Write EMU assemble to sum the value in the SRAM buyes 600 and 700 and store the result in the SRAM byte at 800.

  5. Write a C code which takes reads a single line of input containing words separated by commas, places the words separately in an char[][] array and then prints out the words.

    You can assume there at most 100 words on the line and no word is more than 10 characters long.

  6. A bank has a database holding information about customer accounts, stored as an array of structs.

    Note, a single customer may have multiple bank accounts, so an array is needed to holds the amount of money in each account.

    enum {
    	MAX_ACCOUNTS = 5,
    	N_CUSTOMERS = 1000
    };
    
    struct customer {
    	char   name[20];
    	int    numberOfAccounts;
    	double balance[MAX_ACCOUNTS];
    };
    
    struct customer customers[N_CUSTOMERS];
    

    One day, around Christmas, the manager asks you who is the customer with the largest balance in a single account, so that he can send them a nice Christmas card (ok, suspend disbelief). Write a piece of C code that will print the name of the relevant customer.


Andrew Taylor (andrewt@cse.unsw.edu.au)
Higher Computing 1B, Computer Science & Engineering, UNSW