Skip to content

Instantly share code, notes, and snippets.

@petemoore
Created June 19, 2018 08:50
Show Gist options
  • Save petemoore/8684c6e4c651f66dd357a5d9b594f30f to your computer and use it in GitHub Desktop.
Save petemoore/8684c6e4c651f66dd357a5d9b594f30f to your computer and use it in GitHub Desktop.
Dump register contents, RISC OS
00009208 : E92DFFFF : STMDB R13!,{R0-PC}
0000920C : E3A02010 : MOV R2,#&10
00009210 : E3A03000 : MOV R3,#0
00009214 : E3A01102 : MOV R1,#&80000000
00009218 : E353000A : CMP R3,#&0A
0000921C : 4F000120 : SWIMI OS_WriteI+" "
00009220 : EF000152 : SWI OS_WriteI+"R"
00009224 : 5F000131 : SWIPL OS_WriteI+"1"
00009228 : 42830030 : ADDMI R0,R3,#&30
0000922C : 52830026 : ADDPL R0,R3,#&26
00009230 : EF000000 : SWI OS_WriteC
00009234 : EF00013A : SWI OS_WriteI+":"
00009238 : E8BD0001 : LDMIA R13!,{R0}
0000923C : E1100001 : TST R0,R1
00009240 : 0F000130 : SWIEQ OS_WriteI+"0"
00009244 : 1F000131 : SWINE OS_WriteI+"1"
00009248 : E1B010A1 : MOVS R1,R1,LSR #1
0000924C : 1AFFFFFA : BNE &0000923C
00009250 : EF000003 : SWI OS_NewLine
00009254 : E2522001 : SUBS R2,R2,#1
00009258 : E2833001 : ADD R3,R3,#1
0000925C : 1AFFFFEC : BNE &00009214
00009260 : E1A0F00E : MOV PC,R14
@petemoore
Copy link
Author

petemoore commented Jun 20, 2018

   10 REM Perform R0=R1+R2 and then display status flags and register contents
   20 REM for R1, R2 in [-2,-1,0,1]<<30
   30 REM Written in BBC Basic, running RISC OS Open running on a raspberry pi
   40 REM Pete Moore, June 2018
   50 :
   60 DIM code% 10240
   70 FOR pass%=0 TO 3 STEP 3
   80 P%=code%
   90 [
  100 OPT pass%
  110 .start
  120 ADDS R0, R1, R2
  130 .showallregisters
  140 ; preserve registers
  150 STMFD SP!, {R0-R15}
  160 ; preserve flags in case case SWI calls change them
  170 MOV R9, #0
  180 EORCS R9,R9,#1<<0
  190 EOREQ R9,R9,#1<<1
  200 EORVS R9,R9,#1<<2
  210 EORMI R9,R9,#1<<3
  220 TST R9,#1<<0
  230 SWINE 256+ASC"C"
  240 TST R9,#1<<1
  250 SWINE 256+ASC"Z"
  260 TST R9,#1<<2
  270 SWINE 256+ASC"V"
  280 TST R9,#1<<3
  290 SWINE 256+ASC"N"
  300 SWI "OS_NewLine"
  310 MOV R2,#16
  320 MOV R3,#0
  330 .printone
  340 MOV R1,#1<<31
  350 CMP R3, #10
  360 SWIMI 256+ASC" "
  370 SWI 256+ASC"R"
  380 SWIPL 256+ASC"1"
  390 ADDMI R0,R3,#ASC"0"
  400 ADDPL R0,R3,#ASC"0"-10
  410 SWI "OS_WriteC"
  420 SWI 256+ASC":"
  430 LDMFD SP!, {R0}
  440 .bits
  450 TST R0,R1
  460 SWIEQ 256+ASC"0"
  470 SWINE 256+ASC"1"
  480 MOVS R1,R1,LSR #1
  490 BNE bits
  500 SWI "OS_NewLine"
  510 SUBS R2,R2,#1
  520 ADD R3,R3,#1
  530 BNE printone
  540 MOV R15,R14
  550 ]
  560 NEXT pass%
  570 FOR B%=-2<<30 TO 1<<30 STEP 1<<30
  580 FOR C%=-2<<30 TO 1<<30 STEP 1<<30
  590 CALL start
  600 NEXT C%
  610 NEXT B%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment