6502 Assembly Language Programming by Unknown
Author:Unknown
Language: eng
Format: epub
no
ADD ONE
FIGURE 13. Sample Routine
The overall function of the routine is to read characters from the terminal until a non-blank character is obtained. We add one to that character, and what happens after that is not shown.
146 6502 ASSEMBLY LANGUAGE PROGRAMMING
(a) Is JMP a conditional or unconditional instruction?
(b) Is BEQ a conditional or unconditional instruction?
(c) In the routine diagrammed in Figure 13, what happens if the user types a space?
(d) What happens if the user types a B? .
(e) Is the MIXER loop closed or open?
(a) unconditional; (b) conditional; (c) control returns to the beginning of the loop (branch to MIXER); (d) control falls through (one is added to the character); (e) open
8. These are the conditional jump instructions:
BEQ — Branch if EQusl: jump if the zero flag is on BNE — Branch if Not JEqual: jump if the zero flag is off BCS — Branch if Carry Set: jump if the carry flag is on BCC — Branch if Carry Clear: jump if the carry flag is off BMI — Branch if AfJnus: jump if the sign flag is on BPL — Branch if PLus: jump if the sign flag is off BVS — Branch if overflow Set: jump if the overflow flag is on BVC — Branch if overflow Clear: jump if the overflow flag is off
Write the appropriate jump instructions for the following situations:
(a) Jump to ENDER if the decrement below results in a zero.
DEX
(b) Jump to LOOP if the subtraction below results in a nonzero value.
SBC #10
(c) Jump to NEGVAL if the input value is negative,
JSR INPUT
■V
CONDITIONAL INSTRUCTIONS 147
(d) Jump to OK if the subtraction below results in a positive value.
SBC HIND
(e) Jump to TOOBIG if the addition below results in a carry.
ADC $10
(ft Jump to CYCLE if the addition below does not overflow.
ADC HALF
(a) BEQ ENDER; (b) BNE LOOP; (c) BMI NEGVAL; (d) BPL OK; (e) BCS TOOBIG; (f) BVC CYCLE
9. Suppose we want to branch to NOT50 if the value in the accumulator is under $50. We start with a subtraction:
SEC
SBC #$50
Now which flag do we test—carry or sign?
Let's examine the effect on the flags if A is greater than $50. The subtraction results in no borrow, so the carry flag will be set. We don't know the effect on the sign flag because we don't know the original value in A. If it's greater than $D0, the MSB will be on and the sign flag will be set. Otherwise, it will be cleared.
If A equals $50, there will be no borrow, and the carry flag will be set. The sign flag will be cleared. (The zero flag will also be set.)
If A is less than $50, there will be a borrow, so the carry flag will be cleared. The sign flag will be set because the high order bit of the remainder will always be a one.
(a) What branch instructions should be used? , —
(b) Code a routine to branch to ERROR if the value in the accumulator is less than $10.
148 6502
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Blood, Sweat, and Pixels by Jason Schreier(3473)
Dawn of the New Everything by Jaron Lanier(2675)
Godot 4 Game Development Cookbook by Jeff Johnson(2450)
The Art of Doom by Bethesda(2033)
Significant Zero by Walt Williams(1875)
Creative Character Design by Bryan Tillman(1829)
World of Warcraft Chronicle Volume 3 by Blizzard Entertainment(1650)
The Ultimate Roblox Book by David Jagneaux(1610)
Art Of Atari by Tim Lapetino(1557)
Pillars of Eternity Guidebook by Obsidian Entertainment(1530)
Dawn of the New Everything: Encounters with Reality and Virtual Reality by Jaron Lanier(1527)
1628927445Game by Unknown(1467)
Unreal Engine 4 Virtual Reality Projects by Kevin Mack(1459)
Unreal Engine Virtual Reality Quick Start Guide by Jessica Plowman(1436)
Mission Python by Sean McManus(1424)
The Ultimate Player's Guide to Minecraft by Stephen O'Brien(1413)
Learning D by 2015(1408)
Unity 2018 By Example by Alan Thorn(1387)
Road Games by Road Games(1360)
