ASSEMBLY CODE I\'m having trouble figuring out some code in assembly. So I made
ID: 1715736 • Letter: A
Question
ASSEMBLY CODE
I'm having trouble figuring out some code in assembly. So I made a program where I add two numbers and store them to GPR register. Then I put it in a loop to add 5 to the sum and save it as the new sum until the counter goes down to zero. Now I want to edit the program so that it adds all of those sums up in the sequene they were generated. The results should be stored in 0x4a(High byte) and 0x4b(Low byte). At the end of the program the contents of the status register should be stored in 0x4c.
Here's my main program code so far:
COUNT EQU 0X20
ID EQU 0X06
TODAY EQU 0X09
MOVLW 0X09
MOVWF COUNT
MOVLW ID
ADDLW TODAY
MOVWF 0X21
MOVLW 0X21
MOVWF FSR0
LOOP
MOVWF INDF0
ADDLW 0X05
INCF FSR0
MOVWF INDF0
DECFSZ COUNT
GOTO LOOP
END
Explanation / Answer
tens_index equ 0x27 ; index into the powers-of-ten table divi equ 0x28 ; power of ten (32 bits) divi_hi equ 0x28 ; same as 'divi' : HIGH byte divi_mh equ 0x29 ; MEDIUM HIGH byte divi_ml equ 0x2A ; MEDIUM LOW byte divi_lo equ 0x2B ; LOW byte timer0_old equ 0x2C ; previous reading from timer0 register gatecnt_hi equ 0x2D ; 16-bit counter (msb first) gatecnt_lo equ 0x2E ; 16-bit counter (lsb last) bTemp equ 0x2F ; temporary 8-bit register, ; may be overwritten in ALL subroutines freq equ 0x30 ; frequency in binary (32 bits).... freq_hi equ 0x30 ; same location, begins with HIGH byte freq_mh equ 0x31 ; ... medium high byte freq_ml equ 0x32 ; ... medium low byte freq_lo equ 0x33 ; ... low byte freq2 equ 0x34 ; frequency too, copied for programming mode freq2_hi equ 0x34 ; same location, begins with HIGH byte freq2_mh equ 0x35 ; ... medium high byte freq2_ml equ 0x36 ; ... medium low byte freq2_lo equ 0x37 ; ... low byte foffs equ 0x38 ; frequency too, copied for programming mode foffs_hi equ 0x38 ; same location, begins with HIGH byte foffs_mh equ 0x39 ; ... medium high byte foffs_ml equ 0x3A ; ... medium low byte foffs_lo equ 0x3B ; ... low byte menu_index equ 0x3C ; menu item for programming mode menu_timer equ 0x3D ; used to detect how long a key was pressed digits equ 0x40 ; frequency as decimal digits (8 bytes)... digit_0 equ 0x40 ; same location as MOST SIGNIFICANT digit, 10-MHz digit_1 equ 0x41 ; usually the 1-MHz-digit digit_2 equ 0x42 ; usually the 100-kHz-digit digit_3 equ 0x43 ; usually the 10-kHz-digit digit_4 equ 0x44 ; usually the 1-kHz-digit digit_5 equ 0x45 ; usually the 100-Hz-digit digit_6 equ 0x46 ; usually the 10-Hz-digit digit_7 equ 0x47 ; usually the 1-Hz-digit digit_8 equ 0x48 ; must contain a blank character (or trailing zero) display0 equ 0x49 ; display #0 data display1 equ 0x4A ; display #1 data display2 equ 0x4B ; display #2 data display3 equ 0x4C ; display #3 data display4 equ 0x4D ; display #4 data disp_index equ 0x4E ; index of the enabled display (0 to 4 for 5-digit display) disp_timer equ 0x4F ; display multiplex timer (5 bits) adjust_shifts equ 0x50 ; count of 'left shifts' to compensate prescaler+gate time blinker equ 0x51 ; prescaler for the flashing 1-kHz-dot psave_timer equ 0x52 ; timer for power-save mode (incremented every 0.25 seconds) psave_freq_lo equ 0x53 ; low-byte of frequency to detect changes for power-save mode psave_flags equ 0x54 ; power-saving flags with the following bits: #define PSFLAG_ACTIVE psave_flags,0 ; clear:normal mode, set:power-saving in action (display blanked) options equ 0x55 ; display options with the following flag-bits: #define OPT_PWRSAVE options,0 ; clear:normal mode, set:power-saving mode enabled tx_reg equ 0x56 bit_count equ 0x57 baud_divider equ 0x58 delay_counter equ 0x59 print_flags equ 0x5A temp equ 0x5B