Computer Systems and Assembly Language - Homework 3 | EECS 388, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Class: Computer Systems&Assembly Lang; Subject: Elect Engr & Computer Science; University: University of Kansas; Term: Unknown 2009;

Typology: Assignments

Pre 2010

Uploaded on 03/10/2009

koofers-user-e9r-1
koofers-user-e9r-1 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 388 HW #3
Due: March 4
Problems from textbook
Q1: Page 70: Challenging โ€“ 7 (20 points)
Write a program segment starting at $C100 that checks bits 0 and 2 of address $D000 and
jumps to $C0CC if both bits are clear.
This task is easily accomplished using the BRCLR instruction. We are interested in bits 0
and 2, which gives us the 8-bit mask 00000101 ($05). Therefore:
ORG $C100
LDX #$D000
BRCLR 0,X,$05,$C0CC
SWI
Q2: Page 116: Advanced โ€“ 3 (25 points)
Write a program using a subroutine to copy a table from one location to another. A
partially completed program is given next. Write a program by filling in locations where
only comments appear.
Note 1: when we save the CPU registers, we have to make sure to restore them in reverse
order to align the values properly and to make sure they go back to their proper places.
Note 2: FDB and FCB are not identical to EQU; when you load the values into a register,
you do not use the immediate operator โ€˜#โ€™.
* Copying a table using a subroutine
Data Section
ORG $0000
TAB1 FDB $D100 ; address of the first table
TAB2 FDB $D300 ; address of the second table
TABL FCB $FF ; table length
* main program
ORG $C100
LDS #$8000 ; initialize the stack pointer
LDAA TABL ; load the table length to acc A
LDX TAB1 ; load table 1 address to X
LDY TAB2 ; load table 2 address to Y
JSR COPYT ; call the subroutine
SWI ; stop subroutine
ORG $4500
pf3

Partial preview of the text

Download Computer Systems and Assembly Language - Homework 3 | EECS 388 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 388 HW

Due: March 4 Problems from textbook Q1: Page 70: Challenging โ€“ 7 (20 points) Write a program segment starting at $C100 that checks bits 0 and 2 of address $D000 and jumps to $C0CC if both bits are clear. This task is easily accomplished using the BRCLR instruction. We are interested in bits 0 and 2, which gives us the 8-bit mask 00000101 ($05). Therefore: ORG $C LDX #$D BRCLR 0,X,$05,$C0CC SWI Q2: Page 116: Advanced โ€“ 3 (25 points) Write a program using a subroutine to copy a table from one location to another. A partially completed program is given next. Write a program by filling in locations where only comments appear. Note 1: when we save the CPU registers, we have to make sure to restore them in reverse order to align the values properly and to make sure they go back to their proper places. Note 2: FDB and FCB are not identical to EQU; when you load the values into a register, you do not use the immediate operator โ€˜#โ€™.

  • Copying a table using a subroutine Data Section ORG $ TAB1 FDB $D100 ; address of the first table TAB2 FDB $D300 ; address of the second table TABL FCB $FF ; table length
  • main program ORG $C LDS #$8000 ; initialize the stack pointer LDAA TABL ; load the table length to acc A LDX TAB1 ; load table 1 address to X LDY TAB2 ; load table 2 address to Y JSR COPYT ; call the subroutine SWI ; stop subroutine ORG $

COPYT PSHD ; save the CPU registers onto the stack PSHX PSHY PSHC AGAIN TSTA ; check the counter value BEQ DONE ; if zero jump to the end LDAB 1,X+ ; note the use of accumulator B STAB 1,Y+ SUBA #$01 ; adjust the counter and target addresses BRA AGAIN ; continue the loop DONE PULC ; restore the CPU registers PULY PULX PULD RTS ; IMPORTANT!!!!!!!! END Q3: Page 116: Advanced - 4 (20 points) Suppose you started with the following register contents. P-C007 Y-7892 X-FF00 A-44 B-70 SP-C04A What address is in the stack pointer and exactly what is in the stack after the following instruction sequence is executed? PSHA PSHB PSHY After the execution of the above instructions, the stack pointer points to address $C and the stack contains Address Content C045 โ€ฆ C04 6 78 C047 92 C048 70 C049 44 As you can see, accumulator A is at the bottom of the stack, at address $C049, because it was pushed first. It is followed by accumulator B, and then register Y. Q4: Page 117, Challenging - 1 (25 points) Stack Pointer