Live Coding with Gerph, Sunday 14th July
Charles Ferguson (8243) 427 posts |
Hiya, I’m doing another Live Coding stream on YouTube this Sunday – 14th July – at 1pm. For anyone who hasn’t seen them, these are where I share my screen for a few hours and code some more of a Debugger module for RISC OS. It’s not especially complicated, but it makes for an interesting project. So far we have:
I think this time I’m going to look at the CI automation, and see if we can get some automated builds working. I expect this will be a little involved, but shouldn’t be too challenging. Of course, that’s where the fun is – it might be a whole lot harder. I’m going to aim for under 3 hours this time, too. Come along if you like – https://youtube.com/live/AuF2zJIRvSI?feature=share – or you can always watch the video afterwards. |
Colin Ferris (399) 1818 posts |
Since Gerfs was/is a wizz with ARM code – was there ever a prog that would recognize loops etc in ARM code? |
Charles Ferguson (8243) 427 posts |
There are a lot of people better than I – I try to avoid working with ARM as much as possible these days. However, back at university I wrote a decompiler for Norcroft Pascal code. It could turn process a compiled Pascal program that started out like this: program test (input,output); var justin : integer; i : integer; begin justin:=2; while (justin < 75) do begin i:=0; while (i<5) do begin writeln('Justin is ', justin, ' years old'); justin := justin + 1; i := i+1; end; end; writeln('Justin is dead'); end. through some processing that looked like this: 'Real' code starts at &88f0 BEGIN 88F0 : .@.. : E3A04002 : MOV r4,#&2 ; = 2 88F4 : .`.. : E3A06000 : MOV r6,#&0 WHILE ( ) DO BEGIN 893C : K.T. : E354004B : CMP r4,#&4b ; = 75 8908 : .P.. : E1A05006 : MOV r5,r6 WHILE ( ) DO BEGIN 8934 : ..U. : E3550005 : CMP r5,#&5 ; = 5 8910 : .... : E28F0F10 : ADD r0,pc,#&40 ; = 64 8914 : .... : EBFFFFE1 : BL &88A0 ; call: _write_s 8918 : .... : E1A00004 : MOV r0,r4 891C : .... : EBFFFFB6 : BL &87FC ; call: _write_i 8920 : .... : E28F0F0F : ADD r0,pc,#&3c ; = 60 8924 : .... : EBFFFFDD : BL &88A0 ; call: _write_s 8928 : .... : EBFFFF8A : BL &8758 ; call: _writeln 892C : .@.. : E2844001 : ADD r4,r4,#&1 ; = 1 8930 : .P.. : E2855001 : ADD r5,r5,#&1 ; = 1 END; END; 8944 : .... : E28F0F09 : ADD r0,pc,#&24 ; = 36 8948 : .... : EBFFFFD4 : BL &88A0 ; call: _write_s 894C : .... : EBFFFF81 : BL &8758 ; call: _writeln 8950 : .... : E3A00000 : MOV r0,#&0 END. Assignment of register 4 to variable 0 at &88f0 Assignment of register 6 to variable 1 at &88f4 Moving register 6 to 5 as 2 at &8908 Moving register 15 to 0 as 3 at &8910 Moving register 4 to 0 as 4 at &8918 Moving register 15 to 0 as 5 at &8920 Moving register 4 to 4 as 6 at &892c Moving register 5 to 5 as 7 at &8930 Resynchronising variables for block between &8934 and &8934 Resync needed on integer6 to integer0 Last assigned at &892c Resync needed on integer7 to integer2 Last assigned at &8930 Resynchronising variables for block between &893c and &893c Moving register 15 to 0 as 8 at &8944 Assignment of register 0 to variable 9 at &8950 Resynchronising variables for block between &88f0 and &8954 Variable 9 (integer) Assigned : &8950 as r0 Used : 0 Variable 8 (char^) Assigned : &8944 as r0 Used : 0 Variable 5 (char^) Assigned : &8920 as r0 Used : 0 Variable 4 (integer) Assigned : &8918 as r0 Used : 0 Variable 3 (char^) Assigned : &8910 as r0 Used : 0 ... more lines truncated... into a program like this: PROGRAM pascal (input,output); VAR integer3 : integer; integer1 : integer; integer2 : integer; integer0 : integer; BEGIN integer0 := 2; integer2 := 0; WHILE (integer0 < 75) DO BEGIN integer1 := integer2; WHILE (integer1 < 5) DO BEGIN write('Justin is '); write(integer0); write(' years old'); writeln; integer0 := integer0 + 1; integer1 := integer1 + 1; END; END; write('Justin is dead'); writeln; integer3 := 0; END. Of course, that was just some stuff I wrote for my final year project, and not very useful beyond very small programs. More recently, I experimented with tracing execution through ARM code as it executes with Pyromaniac, part of which involves identifying how many times blocks are executed and linking the entry and exit sequences together.
I don’t recommend trying to open them on RISC OS as they’re large (1MB and 14MB respective). I’ve got two sections I’ve grabbed from that trace: First, the execution of the entry sequence of the AIF header and initialisation code, with a loop to initialise memory: Second, a part of the SCL which executes _main, where it loops through a section of code 16 times, with a slightly different sequence so it doesn’t quite spot it right. Realistically, though, your bests bet for tools to recognise code and interpret it for you are Ghidra and IDA, I believe. |
Charles Ferguson (8243) 427 posts |
Live stream is over. It was rather disjointed this week, as I was trying to do multiple things whilst waiting for the results of some tests. This week we had:
You can find the releases here: https://github.com/gerph/darm/releases The release archive includes the Debugger module, and the DisFile tool which disassembles files. IF you find any bugs, or have feature requests, please file issues on the repository – reproduction cases are always useful, if you have them. https://github.com/gerph/darm/issues |