Any help would be awesome. Im beyond stuck and have no clue whats going on. Any
ID: 646410 • Letter: A
Question
Any help would be awesome. Im beyond stuck and have no clue whats going on. Any help would be a beyond great. Ill put the question down below, thanks agian.
2e. The loader in Figure 8.3(shown below) executes with the following input:
04 00 05 00 00 31 00 03 39 00 03 50 00 0A 41 00
12 00 54 68 61 74 27 73 20 61 6C 6C 2E 0A 00 zz
Assume that the loop from FC5D to FC97 is executing for the 27thtime. State the values in the following registers as four hexadecimal digits:
A after ANDA at FC88
Figure 8.3
; ******* Syst em Loader
; Data must be in the following format:
; Each hex number representing a byte must contain
; exactly two characters. Each character must be
; i n 0. . 9, A. . F, or a. . f and must be followed by exact l y
; one space. There must be no leading spaces at the beginning
; of a line and no trailing spaces at the end of a line. The last two
; characters in the fi l e must be lowercase zz, which is used as t he
; terminating sentinel by the loader.
;
FC57 C80000 loader: LDX 0, i ; X : = 0
FC5A E9FC4F STX wordBuff, d ; Clear input buffer word
FC57 C80000 loader: LDX 0, i ; X : = 0
FC5A E9FC4F STX wordBuff, d ; Clear input buffer word
;
FC5D 49FC50 get Char: CHARI byteBuff, d ; Get first hex character
FC60 C1 FC4F LDA wordBuff, d ; Put ASCI I into low byte of A
FC63 B0007A CPA ' z' , i ; I f end of fi l e sentinel ' z'
FC66 0AFC9A BREQ stopLoad ; then exit loader routine
FC69 B00039 CPA ' 9' , i ; If character <= ' 9' , assume decimal
FC6C 06FC72 BRLE shift ; and right nybble is correct digit
FC6F 700009 ADDA 9, i ; else convert nybble to correct digit
FC72 1 C shift : ASLA ; Shift left by four bits to send
FC73 1 C ASLA ; the digit to the most significant
FC74 1 C ASLA ; position in the byte
FC75 1 C ASLA
FC76 F1 FC52 STBYTEA byteTemp, d ; Save the most significant nibble
FC79 49FC50 CHARI byteBuff, d ; Get second hex character
FC7C C1 FC4F LDA wordBuff, d ; Put ASCI I into low byte of A
FC7F B00039 CPA ' 9' , i ; I f character <= ' 9' , assume decimal
FC82 06FC88 BRLE combine ; and right nybble is correct digit
FC85 700009 ADDA 9, i ; else convert nybble to correct digit
FC88 90000F combine: ANDA 0x000F, i ; Mask out the left nibble
FC8B A1 FC51 ORA wordTemp, d ; Combine bot h hex digits in binary
FC8E F50000 STBYTEA 0, x ; St ore in Mem[ X]
FC91 780001 ADDX 1 , i ; X : = X + 1
FC94 49FC50 CHARI byteBuff, d ; Skip blank or <LF>
FC97 04FC5D BR get Char ;
;
FC9A 00 stopLoad: STOP ;
Explanation / Answer
Answer
Object
Addr code Symbol Mnemon Operand Comment
0000 04000D BR main ;Branch around data
0003 0000 num: .BLOCK 2 ;Storage for one integer
0005 202B20 msg: .ASCII " + 1 = "
31203D
2000
;
000D 310003 main: DECI num,d ;Get the number
0010 390003 DECO num,d ;and output it
0013 410005 STRO msg,d ;Output ' + 1 = '
0016 C10003 LDA num,d ;A := the number
0019 700001 ADDA 1,i ;Add one to it
001C E10003 STA num,d ;Store the sum
001F 390003 DECO num,d ;Output the sum
0022 00 STOP
0023 .END
Symbol table:
Symbol Value Symbol Value
main 000D msg 0005
num 0003
Input
-479
Output
-479 + 1 = -478
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.