is there an opcode for LDA on the 6502 microprocessor,
and if so, what was the opcode?
LDA by itself does not have an opcode.
the following have opcodes:
- LDA #00
- LDA $01
- LDA $0002
and these opcodes are different!!!
it is important to remember that the mnemonic only has meaning in the
context of what follows it.
lenient marking: 1/2 mark for a wrong answer that was nevertheless
one of the above.
last year,
one group referred to LEDs as "bulbs".
does everyone realize that LEDs are diodes (e.g. only light up when correct
polarity?
TTL can sink more than it can source, therefore reference to +5 rather than
ground.
invert in the calling program.
additional notes:
userspace versus kernelspace device drivers: gpm and X are examples of userspace
device drivers.
usleep often used in device drivers.
usleep may keep the CPU busy (waiting loop) in some implementations.
usleep may be dangerous in kernel if interrupts disabled; many times you don't
know whether or not interrupts are disabled.
may cause clock ticks to be lost. however, even chvt can disable
interrupts for up to 1/10 sec causing
clock loss, especially on smaller (e.g. 486) wearcomps.
many times you don't know whether or not interrupts are disabled.
another counter called "jiffy" has timer tick granularity of 100Hz on most
non alpha computers.
1/1024 on alpha (since it has low context switching overhead, even
1/4096 sec was considered).
1/100 sec on others.
HZ returns number of time ticks per second.
#include
int main(argc,argv)
int argc;
char *argv[];
{
int base;
if(argc<2) {
fprintf(stderr, "Use: %s usleep long_number_of_microseconds\n",
argv[0]), exit(1);
}
// if (argc==2) usleep(strtol(argv[1],(char **)NULL,10));
if (argc==2) usleep(strtol(argv[1],(char **)NULL,0));
if (argc==3) usleep(strtol(argv[1],(char **)NULL,strtol(argv[2],(char **)NULL,0
)));
exit(0);
}
further additional note:
don't bother trying to tell the compiler exactly what to do; instead focus
on making your code easy to read.
for example "register int x = 5"
gcc ignores the "register" directive.
x=x/2 is no worse than x=x>>1
x=x/4 is no worse than x=x>>2
when x is an unsigned integer.
a note on portability and the merits of kernelspace device drivers:
inb and outb are macros.
inb and outb expand to assembly language commands inb and outb on x86.
inb and outb expand to memory references on SA1100, therefore won't work
from userspace because (recall that) USERSPACE SEES MEMORY AS VIRTUALIZED.