Interrupt is pending, but my interrupt routine is not called - stm32

Summary:
I've configured a GPIO as an interrupt. I can see from all of the registers that it appears to be triggering, but my interrupt routine is never called.
Details:
I'm using a Nucleo F446 board, and the documentation specifies that PC13 should be the input for the push button. I'd like to trigger an interrupt when this happens (I know that this isn't the best way to handle a button; I was having trouble with a more complex system and reduced it to this simplified example). I'm doing this on bare metal and not using any existing libraries.
PC13 comes into EXTI13:
I see that this is interrupt #40 from the microcontroller reference manual:
I'm configuring the microcontroller as follows (using pseudo-c here for simplicity):
Enable clocks for GPIOC block, SYSCFG
RCC_AHB1ENR |= GPIOC_EN
RCC_APB2EN |= SYSCFG_EN
Enable external interrupts for GPIO C13 (it is by default an input)
SYSCFG_EXTICR4 |= (PCx << 4)
Set pin 13 of the interrupt mask, event mask, and rising trigger selection registers:
EXTI_IMR |= 1 << 13
EXTI_EMR |= 1 << 13
EXTI_RTSR |= 1 << 13
Enable IRQ 40
NVIC_ISER1 |= 1 << 8
Set up interrupt vector (here is a disassembly)
08000000 <_reset-0x124>:
...
80000e0: 08000621 .word 0x08000621
08000620 <exti15_10_handler>:
8000620: 4906 ldr r1, [pc, #24] ; (800063c <exti15_10_handler+0x1c>)
I have the main code in a loop printing a number of register values, which I will describe in a moment, to the serial port. I've implemented exti15_10_handler to turn on an LED and go into an infinite loop, so I should know when it is called, because it will also stop the printing. When I press and release the button, I see the following:
In GPIOC_IDR (the GPIO input register), I can see bit 13 change, which tells me the GPIO block is working.
In EXTI_PR (external interrupt pending), I see the value of bit 13 switch from 0 to 1 and stays there.
In NVIC_ISPR1 (interrupt set pending), bit 8 (corresponding to interrupt 40) switches from 0 to 1 and stays there.
However, NVIC_IABR0 (interrupt active bit register) does not change.
Interrupt is not called, as I see no change in the LED and the board does not hang.
I'm sure I'm forgetting to enable something, but after dredging through the reference manuals and a bunch of code examples, I'm just not seeing it. I did try the following:
asm volatile ("cpsie i" : : : "memory");
To set the interrupt flag (which I think should have been on already). I'm curious if this looks familiar to anyone.

This is a pretty unsatisfying result. While looking at the disassembly of the interrupt vector table, I noticed:
8000000: 20020000 .word 0x20020000
8000004: 08000124 .word 0x08000124
8000008: 08000595 .word 0x08000595
800000c: 08000595 .word 0x08000595
The second entry is supposed to be my reset vector
.section .interrupt_vector
.word _estack // Stack pointer
.word _reset
Although _reset is a thumb function, it is not encoded with the LSB set to indicate that. If I change the line to:
.word _reset + 1
...or put .thumb_func immediate before my reset handler in my startup code, it works correctly every time.

Related

How can i switch on LED on STM32F1 GPIO pin PA2?

How can i switch on the LED on PA2 GPIO (STM32F103C8T6), using standard registry configuration.
RCC-> APB2ENR |= (1<<2);
GPIOA->CRL |= (1<<9);
GPIOA->ODR |= (1<<3);
Does not work for me. Could you please advice where i make mistake?
As per the reference manual, the GPIOA CRL registers resets as 0x4444 4444 (See section 9.2.1 of the reference manual).
When you execute the following command:
GPIOA->CRL |= (1<<9);
you are setting the MODE bits of PA2 to 10 (Output mode, max speed 2 MHz). But due to the inital register initialization, the CNF2 bits are 01, which is open-drain configuration. You should initialize PA2 with the following instead
GPIOA->CRL &= ~(0b0000<<8);
GPIOA->CRL |= (0b0010<<8);
This ensures that both MODE2 and CNF2 are both set so the pin acts as an output with a push-pull configuration

What steps are taken at the operating system/hardware level during interrupt (e.g. keyboard shortcut)?

I'm currently learning the workings of an operating system and would like to verify if my knowledge is correct on the steps taken during an interrupt. Trying to relate to something very familiar, here's what I think would happen when I press Alt+Tab to switch programs:
An interrupt is generated by the hardware (keyboard): intr flag of the CPU is set via system bus from keyboard controller
CPU saves the current process state to the PCB to pass control to the interrupt (is kernel mode entered here?)
CPU reads interrupt to index the interrupt service routine via the interrupt vector stored in memory
The interrupt service routine (along with the interrupt details such as which keys got pressed) is processed (at which point I assume user sees the program being switched)
The interrupt is complete (mode bit set back to 1 indicating user mode now?), PCB of the interrupted process gets restored and resumes running.
Are there steps that I'm missing or did not describe correctly?
There are many many factors here that you need to take in to consideration. For example:
- Is the keyboard on the ISA bus and is of an PC/AT style keyboard?
- If so, is the PIC (programmable Interrupt Controller) involved?
- Is the keyboard a USB keyboard device?
- Is the interrupt an older style PIC, newer style APIC, or a latest style MSI interrupt?
There are many things to consider. However, to try to explain what probably happens, I will assume you have an AT style keyboard attached to the keyboard controller port (PS2 style maybe), you have an older style PIC, and a simplified single- or multi-tasking system.
What could happen when the user presses the Alt key and then the Tab key:
- The CPU is interrupted (hence the name) by the PIC
- The CPU "jumps" to the interrupt request routine (IVT, exception, whatever)
- The routine reads from the keyboard. A single byte is read which happens
to be (part of) the make code for the alt key.
- the routine then places this make code in some sort of input buffer the
operating system has set up for it, whether it be part of the OS or part
of the keyboard driver.
- the interrupt is acknowledged via the PIC (this step can and usually is
before the previous step)
- the routine gives up the CPU (iret instruction)
The process is repeated three more times (assuming a make code and a break code are single byte codes. They can be multiple-byte codes). An interrupt is created on a make and a break key. A make key is when a key is pressed. A break key is when a key is released. i.e:
- make (Alt Down)
- make (Tab Down)
- break (Tab Up)
- break (Alt Up)
You see, there are four interrupts that take place (again assuming single-byte codes), four times the interrupt routine is called, and four times the CPU is interrupted to handle the key press(es) and release(es).
As for the task switching, via an ALT-TAB key combination, this is usually not done within the interrupt handler. The OS will see the Make (or Break) key of the Tab, it will check the status of the shift state (which should include the Alt key) and go from there.
It the keyboard is a USB style keyboard, then you have a totally different process of events. The USB keyboard does not interrupt the CPU as shown above. The keyboard has an Interrupt Pipe that periodically checks to see if there is a key make or break sequence. The OS will give up a time slice to the USB driver, just enough time to check this Interrupt Pipe. However, please note that an Interrupt (PIC, MSI, or other) is not triggered for USB keyboards, unless the USB driver specifies an interrupt should happen at end of frame. Note though that this interrupt is not fired because of the key press (or release), it is triggered because of the end of frame of the USB has taken place.
There is a lot that takes place because of a simple key press and release. I would study on what style of keyboard you wish to program for, what style of interrupt controller, CPU, etc., and go from there.
If you wish, I wrote a series of books on this subject where I explain what happens for both an ISA style keyboard and a USB style keyboard. It has been a very enjoyable hobby and I hope you find the same joy in yours.

GFlags Stop on hung GUI

Today I was wondering why the GFlags option Stop on hung GUI appears in the Kernel Flags tab of the GFlags user interface. Does the kernel have a GUI which could hang?
So I tried to get some information from Microsoft, but MSDN just says:
The Stop on hung GUI flag appears in GFlags, but it has no effect on Windows.
So I wonder even more: a kernel flag for a kernel which has a GUI, but it's not the Windows kernel?
Although it seems not of practical use, can anyone explain this?
I also tried to get more information from WinDbg .hh !gflag, but it doesn't even give the statement that this won't work on Windows.
Kernel flag indicates flag takes effect immediately without requiring a reboot
Registry flag requires a reboot for the flags to take effect
the kernel does not have any gui that could hang.
the term windows doesnt mean kernel but the gui windows of the running application
check NtSetSystemInformation in your os to understand why 0x8 does not take effect
basically there are a few hardcoded magic numbers inside this api which tests each request for GlobalFlag changes and allows them or disallows them
in xp-sp3 this magic value is 0B2319BF0 so any flag that is < 0x10 will be disallowed
and stop on hung gui is 0x8 so it isnt effective and you cant set this from registry tab
so effectively no way of setting this flag
nt!NtSetSystemInformation+0x193:
80606009 8b03 mov eax,dword ptr [ebx] ds:0023:001285f8=00000008 <---- +shg
8060600b 25f09b31b2 and eax,0B2319BF0h < magic value in nt
80606010 8945a0 mov dword ptr [ebp-60h],eax ss:0010:fb569cf0=00000000
80606013 8b0d6c125580 mov ecx,dword ptr [nt!NtGlobalFlag (8055126c)] ds:0023:8055126c=00000000
80606019 81e10f64ce4d and ecx,4DCE640Fh <--another magic value both these magic values orred together
will be 0xffffffff covers the whole range of flags
8060601f 0bc1 or eax,ecx
80606021 8945a0 mov dword ptr [ebp-60h],eax ss:0010:fb569cf0=00000000
80606024 a36c125580 mov dword ptr [nt!NtGlobalFlag (8055126c)],eax ds:0023:8055126c=00000000

Need Help Turning off re-align comments after signals in port list. (Verilog-Mode)

Here's my problem, I define a port list as so:
module spi_jstk (
input clk, // System Clock (40MHz)
input reset, // Async Reset
input START, // Initialize SPI Transfer
input [39:0] DATA, // Input Data to Transfer
input SS, // Chip Select
output SCLK, // Serial Clock
input MISO, // Master In Slave Out
output MOSI ); // Master Out Slave In
Looks quite nice.
Now lets say I add a new signal to this list or just hit TAB and this is what happens:
module spi_jstk (
input clk, // System Clock (40MHz)
input reset, // Async Reset
input START, // Initialize SPI Transfer
input [39:0] DATA, // Input Data to Transfer
input SS, // Chip Select
output SCLK, // Serial Clock
output NEW, // NEW SIGNAL
input MISO, // Master In Slave Out
output MOSI ); // Master Out Slave In
Not sure why it did this to my comments, anyone know how I turn off this? Its really frustrating.
Another thing I don't understand is that if I hit TAB on a list of regular signals (not in a port list) it doesn't mess with my comments. These comments stay aligned after tab.
// Signals
reg [2:0] q_state, n_state;
reg q_clk;
reg q_sck; //1 MHz ticks
reg [7:0] q_mosi; //1 MHz ticks
reg [7:0] q_miso; //1 MHz ticks
Anyone know how can I fix this? Thanks.
This seems to be a side-effect of auto-lineup behavior. The documentation of C-hvverilog-auto-lineupenter describes the behavior
Type of statements to lineup across multiple lines.
If 'all' is selected, then all line ups described below are done.
If 'declarations', then just declarations are lined up with any
preceding declarations, taking into account widths and the like,
so or example the code:
reg [31:0] a;
reg b;
would become
reg [31:0] a;
reg b;
If 'assignment', then assignments are lined up with any preceding
assignments, so for example the code
a_long_variable <= b + c;
d = e + f;
would become
a_long_variable <= b + c;
d = e + f;
However it seems in this process it deletes the extra spaces between the code and the comments, I could not find a way to keep it from messing up with comments (you may want to report a bug to its maintainers do M-xverilog-submit-bug-reportRET). One option might be to disable this behavior by customizing the variable verilog-auto-lineup. There are a couple of ways to do so
1) You can use emacs' customize UI for doing so. Just do M-xcustomize-variableRETverilog-auto-lineupRET. And select the desired value for the variable.
2) You can add one of the following to your init file
(setq verilog-auto-lineup nil) ;; disable completely
(setq verilog-auto-lineup 'assignment) ;; disable only for declarations

CALL -151 What did it do on the APPLE ][

A long time ago I had an apple ][ .
I remember the command call – 151
But I can not remember what it did ?
CALL -151
Enter the machine code monitor -
http://www.skepticfiles.org/cowtext/apple/memorytx.htm
Update:
That link appears to be dead, here's a Wayback Machine alternative:
http://web.archive.org/web/20090315100335/http://www.skepticfiles.org/cowtext/apple/memorytx.htm
Here's the full article just in case Wayback goes away:
APPLE CALL, PEEK, POKE LIST CALL 144 SCAN THE INPUT BUFFER CALL 151 ENTER THE MONITOR NORM
APPLE CALL, PEEK, POKE LIST
------------------------------------------------------------------------------
CALL -144 SCAN THE INPUT BUFFER
CALL -151 ENTER THE MONITOR NORMALLY
CALL -155 ENTER THE MONITOR & SOUND BELL
CALL -167 ENTER MONITOR AND RESET
CALL -198 RING BELL (SIMULATE CONTROL G)
CALL -211 PRINT "ERR" AND RING BELL
CALL -259 READ FROM TAPE
CALL -310 WRITE TO TAPE
CALL -321 DISPLAYS A, S, Y, P, & S REGISTERS
CALL -380 SET NORMAL VIDEO MODE
CALL -384 SET INVERSE VIDEO MODE
CALL -415 DISASSEMBLE 20 INSTRUCTIONS
CALL -458 VERIFY (COMPARE & LIST DIFFERENCES)
CALL -468 MEMORY MOVE AFTER POKING 60,61 OLD START - 62,63 OLD END
64,65 NEW END - 66,67 NEW STAR
CALL -484 MOVE
CALL -517 DISPLAY CHARACTER & UPDATE SCREEN LOCATION
CALL -531 DISPLAY CHARACTER, MASK CONTROL CHAR., & SAVE 7 REG. & ACCU
CALL -550 DISPLAY HEX VALUE OF A-REGISTER (ACCUMULATOR)
CALL -656 RING BELL AND WAIT FOR A CARRIAGE RETURN
CALL -657 GET LINE OF INPUT, NO PROMPT, NO L/F, & WAIT(COMMA,COLON OK
CALL -662 GET LINE OF INPUT, WITH PROMPT, NO L/F, & WAIT
CALL -665 GET LINE OF INPUT, WITH PROMPT, LINE FEED, & WAIT
THE ABOVE 3 CALLS (-657, -662, -665) REFER TO THE INPUT BUFFER FROM 512-767
CALL -715 GET CHARACTER
CALL -756 WAIT FOR KEY PRESS
CALL -856 TIME DELAY (POKE 69,XX TO SET TIME OF DELAY)
CALL -868 CLEARS CURSOR LINE FROM CURSOR TO END OF LINE
CALL -912 SCROLLS TEXT UP 1 LINE
CALL -922 LINE FEED
CALL -936 CLEAR SCREEN (HOME)
CALL -958 CLEAR SCREEN FROM CURSOR TO BOTTOM OF SCREEN
CALL -998 MOVES CURSOR UP 1 LINE
CALL -1008 MOVES CURSOR BACKWARD 1 SPACE
CALL -1024 DISPLAY CHARACTER ONLY
CALL -1036 MOVES CURSOR FORWARD 1 SPACE
CALL -1063 SEND BELL TO CURRENT OUTPUT DEVICE
CALL -1216 TEXT & GRAPHICS MODE
CALL -1233 MOVE CURSOR TO BOTTOM OF SCREEN
CALL -1321 CONTROL E
CALL -1717 MOVES CURSOR DOWN 5 LINES
CALL -1840 DISASSEMBLE 1 INSTRUCTION
CALL -1953 CHANGE COLOR BY +3
CALL -1994 CLEAR LO-RES SCREEN (TOP 40 LINES)
CALL -1998 CLEAR GRAPHIC SCREEN (LO-RES)
CALL -2007 VERTICAL LINE
CALL -2023 HORIZONTAL LINE
CALL -2458 ENTER MINI ASSEMBLER
CALL -3100 TURNS ON HIRES PAGE 1, WITHOUT CLEARING IT
CALL -3776 SAVE INTEGER
CALL -3973 LOAD INTEGER
CALL -6090 RUN INTEGER
CALL -8117 LIST INTEGER
CALL -8189 ENTER BASIC & CONTINUE
CALL -8192 ENTER BASIC AND RESET (INTEGER BASIC KILL)
CALL -16303 TEXT MODE
CALL -16304 GRAPHICS MODE
CALL -16336 TOGGLE SPEAKER
CALL 42350 CATALOGS DISK
CALL 54915 CLEANS STACK, CLEARS THE "OUT OF MEMORY" ERROR
CALL 64166 INITIATES A COLD START (BOOT OF THE DISK)
CALL 64246 BRAND NEW-YOU FIGURE IT OUT
CALL 64367 SCANS MEMORY LOC 1010 & 1011 & POKES VALUE INTO LOCATIONS
1012 THAT IS EQUAL TO (PEEK(1011)-165)
------------------------------------------------------------------------------
PEEK 33 WIDTH OF TEXT WINDOW (1-40)
PEEK 34 TOP EDGE OF TEXT WINDOW (0-22)
PEEK 35 BOTTOM OF TEXT WINDOW (1-24)
PEEK 36 HORIZONTAL CURSOR POSITION (0-39)
PEEK 37 VERTICAL CURSOR POSITION (0-23)
PEEK 43 BOOT SLOT X 16 (AFTER BOOT)
PEEK 44 END POINT OF LAST HLIN, VLIN, OR PLOT
PEEK 48 LO-RES COLOR VALUE X 17
PEEK 50 TEXT OUTPUT FORMAT: 63=INVERSE 255=NORMAL
127=FLASH ( WITH PEEK 243 SET TO 64)
PEEK 51 PROMPT CHARACTER
PEEK 74,75 LOMEM ADDRESS (INT)
PEEK 76,77 HIMEM ADDRESS (INT)
PEEK 103,104 FP PROGRAM STARTING ADDRESS
PEEK 104 IF 8 IS RETURNED, THEN FP IS IN ROM
PEEK 105,106 FP VARIABLE SPACE STARTING ADDRESS
PEEK 107,108 FP ARRAY STARTING ADDRESS
PEEK 109,110 FP END OF NUMERIC STORAGE ADDRESS
PEEK 111,112 FP STRING STORAGE STARTING ADDRESS
PEEK 115,116 FP HIMEM ADDRESS
PEEK 117,118 FP LINE NUMBER BEING EXECUTED
PEEK 119,120 FP LINE WHERE PROGRAM STOPPED
PEEK 121,122 FP LINE BEING EXECUTED ADDRESS
PEEK 123,124 LINE WHERE DATA BEING READ
PEEK 125,126 DATA LOCATION ADDRESS
PEEK 127,128 INPUT OR DATA ADDRESS
PEEK 129,130 FP LAST USED VARIABLE NAME
PEEK 131,132 FP LAST USED VARIABLE ADDRESS
PEEK 175,176 FP END OF PROGRAM ADDRESS
PEEK 202,203 INT PROGRAM STARTING ADDRESS
PEEK 204,205 INT END OF VARIABLE STORAGE
PEEK 214 FP RUN FLAG (AUTO-RUN IF >127)
PEEK 216 ONERR FLAG (>127 IF ONERR IS ACTIVE)
PEEK 218,219 LINE WHERE ONERR OCCURED
PEEK 222 ONERR ERROR CODE
PEEK 224,225 X-COORDINATE OF LAST HPLOT
PEEK 226 Y-COORDINATE OF LAST HPLOT
PEEK 228 HCOLOR VALUE 0=0 85=2 128=4 213=6
42=1 127=3 170=5 255=7
PEEK 230 HI-RES PLOTING PAGE (32=PAGE 1 64=PAGE 2 96=PAGE 3)
PEEK 231 SCALE VALUE
PEEK 232,233 SHAPE TABLE STARTING ADDRESS
PEEK 234 HI-RES COLLISION COUNTER
PEEK 241 256 MINUS SPEED VALUE
PEEK 243 FLASH MASK (64=FLASH WHEN PEEK 50 SET TO 127)
PEEK 249 ROT VLAUE
PEEK 976-978 DOS RE-ENTRY VECTOR
PEEK 1010-1012 RESET VECTOR
PEEK 1013-1015 AMPERSAND (&) VECTOR
PEEK 1016-1018 CONTROL-Y VECTOR
PEEK 43140-43271 DOS COMMAND TABLE
PEEK 43378-43582 DOS ERROR MESSAGE TABLE
PEEK 43607 MAXFILES VALUE
PEEK 43616,46617 LENGTH OF LAST BLOAD
PEEK 43624 DRIVE NUMBER
PEEK 43626 SLOT NUMBER
PEEK 43634,43635 STARTING ADDRESS OF LAST BLOAD
PEEK 43697 MAXFILES DEFAULT VALUE
PEEK 43698 DOS COMMAND CHARACTER
PEEK 43702 BASIC FLAG (0=INT 64=FP ROM 128=FP RAM)
PEEK 44033 CATALOG TRACK NUMBER (17 IS STANDARD)
PEEK 44567 NUMBER OF CHARACTERS MINUS 1 IN CATALOG FILE NAMES
PEEK 44611 NUMBER OF DIGITS MINUS 1 IN SECTOR AND VOLUME NUMBERS
PEEK 45991-45998 FILE-TYPE CODE TABLE
PEEK 45999-46010 DISK VOLUME HEADING
PEEK 46017 DISK VOLUME NUMBER
PEEK 46064 NUMBER OF SECTORS (13=DOS 3.2 16=DOS 3.3)
PEEK 49152 READ KEYBOARD (IF >127 THEN KEY HAS BEEN PRESSED
PEEK 49200 TOGGLE SPEAKER (CLICK)
PEEK 49248 CASSETTE INPUT (>127=BINARY 1, 127 IF BUTTON PRESSED)
PEEK 49250 PADDLE 1 BUTTON (>127 IF BUTTON PRESSGD)
PEEK 49251 PADDLE 2 BUTTON (>127 IF BUTTON PRESSED)
PEEK 49252 READ GAME PADDLE 0 (0-255)
PEEK 49253 READ GAME PADDLE 1 (0-255)
PEEK 49254 READ GAME PADDLE 2 (0-255)
PEEK 49255 READ GAME PADDLE 3 (0-255)
PEEK 49408 READ SLOT 1
PEEK 49664 READ SLOT 2
PEEK 49920 READ SLOT 3
PEEK 50176 READ SLOT 4
PEEK 50432 READ SLOT 5
PEEK 50688 READ SLOT 6 (162=DISK CONROLLOR CARD)
PEEK 50944 READ SLOT 7
PEEK 64899 INDICATES WHICH COMPUTER YOU'RE USING
223=APPLE II OR II+, 234=FRANKLIN ACE OR ?, 255=APPLE IIE
POKE 33,33 SCRUNCH LISTING AND REMOVE SPACES IN QUOTE STATEMENTS
POKE 36,X USE AS PRINTER TAB (X=TAB - 1)
POKE 50,128 MAKES ALL OUTPUT TO THE SCREEN INVISIBLE
POKE 50,RANDOM SCRAMBLES OUTPUT TO SCREEN
POKE 51,0 DEFEATS "NOT DIRECT COMMAND", SOMETIMES DOESN'T WORK
POKE 82,128 MAKE CASETTE PROGRAM AUTO-RUN WHEN LOADED
POKE 214,255 SETS RUN FLAG IN FP & ANY KEY STROKES WILL RUN DISK PROGRA
POKE 216,0 CANCEL ONERR FLAG
POKE 1010,3 SETS THE RESET VECTOR TO INITIATE
POKE 1011,150 A COLD START (BOOT)
POKE 1010,102 MAKE
POKE 1011,213 RESET
POKE 1012,112 RUN
POKE 1014,165 SETS THE AMPERSAND (&) VECTOR
POKE 1015,214 TO LIST YOUR PROGRAM
POKE 1014,110 SETS THE AMPERSAND (&) VECTOR
POKE 1015,165 TO CATALOG A DISK
POKE 1912+SLOT,1 ON APPLE PARALLEL CARD (WITH P1-02 PROM) WILL ENABLE L/F'S
POKE 1912+SLOT,0 ON APPLE PARALLEL CARD (WITH P1-02 PROM) WILL ENABLE L/F'S
POKE 2049,1 THIS WILL CAUSE THE FIRST LINE OF PROGRAM TO LIST REPEATEDLY
POKE 40514,20 ALLOWS TEXT FILE GREETING PROGRAM
POKE 40514,52 ALLOWS BINARY FILE GREETING PROGRAM
POKE 40993,24 THIS ALLOWS
POKE 40994,234 DISK COMMANDS IN
POKE 40995,234 THE DIRECT MODE
POKE 42319,96 DISABLES THE INIT COMMAND
POKE 42768,234 CANCEL ALL
POKE 42769,234 DOS ERROR
POKE 42770,234 MESSAGES
POKE 43624,X SELECTS DISK DRIVE WITHOUT EXECUTING A COMMAND (48K SYSTEM)
POKE 43699,0 TURNS AN EXEC FILE OFF BUT LEAVES IT OPEN UNTIL A FP, CLOSE
POKE 43699,1 TURNS AN EXEC FILE BACK ON. INIT, OR MAXFILES IS ISSUE
POKE 44452,24 ALLOWS 20 FILE NAMES (2 EXTRA)
POKE 44605,23 BEFORE CATALOG PAUSE
POKE 44505,234 REVEALS DELETED FILE
POKE 44506,234 NAMES IN CATALG
POKE 44513,67 CATALOG WILL RETURN ONLY LOCKED FILES
POKE 44513,2 RETURN CATALOG TO NORMAL
POKE 44578,234 CANCEL CARRIAGE
POKE 44579,234 RETURNS AFTER CATALOG
POKE 44580,234 FILE NAMES
POKE 44596,234 CANCEL
POKE 44597,234 CATALOG-STOP
POKE 44598,234 WHEN SCREEN IS FULL
POKE 44599,234 STOP CATALOG AT EACH FILE
POKE 44600,234 NAME AND WAIT FOR A KEYPRESS
POKE 46922,96 THIS ALLOWS DISK
POKE 46923,234 INITIALATION
POKE 46924,234 WITHOUT PUTTING
POKE 44723,4 DOS ON THE DISK
POKE 49107,234 PREVENT LANGUAGE
POKE 49108,234 CARD FROM LOADING
POKE 49109,234 DURING RE-BOOT
POKE 49168,0 CLEAR KEYBOARD
POKE 49232,0 DISPLAY GRAPHICS
POKE 49233,0 DISPLAY TEXT
POKE 49234,0 DISPLAY FULL GRAPHICS
POKE 49235,0 DISPLAY TEXT/GRAPHICS
POKE 49236,0 DISPLAY GRAPHICS PAGE 1
POKE 49237,0 DISPLAY GRAPHICS PAGE 2
POKE 49238,0 DISPLAY LORES
POKE 49239,0 DISPLAY HIRES
------------------------------------------------------------------------------
48K MEMORY MAP
DECIMAL HEX USAGE
------------------------------------------------------------------------------
0-255 $0-$FF ZERO-PAGE SYSTEM STORAGE
256-511 $100-$1FF SYSTEM STACK
512-767 $200-$2FF KEYBOARD CHARACTER BUFFER
768-975 $300-$3CF OFTEN AVAILABLE AS FREE SPACE FOR USER PROGRAMS
976-1023 $3D0-3FF SYSTEM VECTORS
1024-2047 $400-$7FF TEXT AND LO-RES GRAPHICS PAGE 1
2048-LOMEM $800-LOMEM PROGRAM STORAGE
2048-3071 $800-$BFF TEXT AND LO-RES GRAPHICS PAGE 2 OR FREE SPACE
3072-8191 $C00-$1FFF FREE SPACE UNLESS RAM APPLESOFT IS IN USE
8192-16383 $2000-$3FFF HI-RES PAGE 1 OR FREE SPACE
16384-24575 $4000-$5FFF HI-RES PAGE 2 OR FREE SPACE
24576-38999 $6000-$95FF FREE SPACE AND STRING STORAGE
38400-49151 $9600-$BFFF DOS
49152-53247 $C000-$CFFF I/O HARDWARE (RESERVED)
53248-57343 $D000-$DFFF APPLESOFT IN LANGUAGE CARD OR ROM
57344-63487 $E000-$F7FF APPLESOFT OR INTEGER BASIC IN LANGUAGE CARD OR ROM
63488-65535 $F800-$FFFF SYSTEM MONITOR
PEEK: TO EXAMINE ANY MEMORY LOCATION L, PRINT PEEK (L), WHERE L IS A DECIMAL
NUMBER 0-65535. TO PEEK AT A TWO-BYTE NUMBER AT CONSEQUTIVE LOCATIONS L AND
L+1, PRINT PEEK (L) + PEEK (L+1) * 256
POKE: TO ASSIGN A VALUE X (0-255) TO LOCATION L; POKE L,X. TO POKE A TWO-BYT
NUMBER (NECESSARY IF X>255), POKE L,X-INT(X/256)*256, AND POKE L+1,INT(X/256).
CALL: TO EXECUTE A MACHINE LANGUAGE SUB ROUTINE AT LOCATION L, CALL L.
JUST FOR FUN TRY THIS: POKE 33,90. THEN TRY LISTING YOUR PROGRAM. OR TRY:
0,99 OR POKE 50,250 OR POKE 50,127. USE RESET TO RETURN TO NORMAL.
FOR TRUE RANDOM NUMBER GENERATION TRY THIS:X= RND(PEEK(78)+PEEK(79)*256)
TO LOCATE THE STARTING ADDRESS OF THE LAST BLOADED FILE USE: PEEK(-21902)+PEEK
(-21901)*256 (RESULT IS IN HEX)
TO DETERMINE THE LENGTH OF THE LAST BLOADED FILE USE: PEEK(-21920)+PEEK(-21919
*256 (RESULT IS IN HEX)
TO DETERMINE THE LINE NUMBER THAT CAUSED AN ERROR TO OCCUR, SET X TO: PEEK(218
+PEEK(219)*256
------------------------------------------------------------------------------
E-Mail Fredric L. Rice / The Skeptic Tank
Call -151 enters the monitor, 3D0G brings you back to BASIC, and typing a slot # in the monitor followed by Ctrl-P will boot that device. Amazing what one remembers after 20 years!
May I also add that -151 is apple ]['s way of expressing hex number which should mean $FF69 (hex syntax used in Apple II i.e. 0xFF68).
The CALL is an Apple Basic command that invokes an assembly subroutine given by the argument (-151 here). IIRC, this command can accept an address as negative decimal value for addresses between $8000-$FFFF using 2's complement interpretation.
For those who are interested in history, here is the Apple ]['s monitor rom listing (in 6502 assembly) and address $FF69 is having the label MONZ which is the start of the command prompt that process machine code processing commands from user. One that uses a '*' as the prompt. A very primitive command prompt.
Apple II System Monitor
Crikey, that's a blast from the past. I think it entered the monitor ROM (I was torn between this and Integer BASIC but I'm pretty certain it was the monitor).
You could download an Apple II emulator and find out.
As a side note, the reason why this is a negative number and not the proper CALL 65385 is because the very first form of BASIC for the Apple II was known as Integer BASIC. It only understood signed 16-bit Integer values from -32768 to 32767, and so it is impossible to directly address memory beyond 32767 in the normal positive value manner.
If you tried actually typing POKE 49200,0 or CALL 65385 in Integer BASIC you will get a message like ">32767 ERR"
When the replacement Microsoft Applesoft BASIC (yes, from them) with floating point numbers was introduced, they included support for the negative POKE values for some degree of backwards compatibility for the older Integer BASIC programs. Though this compatibility is limited, as Applesoft lacks other programming features of Integer like the MOD division remainder.
Due to the strong influence of early Integer BASIC programming methods, there are many PEEK POKE and CALL commands that are generally only known by their hexadecimal and negative decimal values, but not by their positive decimal values.