分类
所有文章

ROM解包

$ brotli -d system.new.dat.br
$ sdat2img system.transfer.list system.new.dat system.img

./simg2img system.img system.img.raw
mkdir my_mount_point
mount -t ext4 -o loop system.img.raw my_mount_point
apt install brotli
git clone https://github.com/xpirt/sdat2img.git

分类
所有文章

Proutes下使用51单片机实现计时器(含汇编和C语言代码)

初始化

暂停

清零

汇编代码

ORG 0000H
LJMP START 
ORG 000BH
LJMP TIMER0
ORG 0003H
LJMP ButtonStart
ORG 0013H
LJMP ButtonPause
ORG 0030H


START:MOV SP,#5FH
MOV TCON,#00H
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB EA  ;MOV IE,#82H      ;不建议这种写法 以后改的话就要重新算
SETB ET0
SETB EX0
SETB EX1
SETB PX0  ;start 优先
SETB IT1      ;管脚的电平从高到低的负跳变有效
SETB IT0
MOV R4,#2
MOV R3,#0FFH  ;start pause flag
MOV R1,#00H
MOV R0,#00H
SETB TR0
MAIN:LCALL DISDP
SJMP MAIN

DISDP:MOV A,R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P2,A
MOV A,R1
MOVC A,@A+DPTR
ANL A,#7FH ;01111111
MOV P0,A
RET
ORG 0110H
TIMER0:PUSH ACC
PUSH PSW
CJNE R3,#00H,EXIT ;CPL 00 == 255 255EXIT
DJNZ R4,EXIT
MOV R4,#2
INC R0
CJNE R0,#0AH,EXIT
MOV R0,#00H 
INC R1
CJNE R1,#0AH,EXIT
MOV R1,#00H

EXIT:POP PSW
POP ACC
RETI

;ORG 0003H
ButtonStart:PUSH ACC
PUSH PSW
MOV A,R3
CPL A
MOV R3,A
MOV R0,#00H 
MOV R1,#00H
POP PSW
POP ACC
RETI

;ORG 0013H
ButtonPause:PUSH ACC
PUSH PSW
MOV A,R3
CPL A
MOV R3,A
POP PSW
POP ACC
RETI
 

TAB:DB  0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
    DB  80H,90H,88H,83H,0C6H,0A1H,86H,8EH
END

c语言实现

#include<reg51.h>

const unsigned char LED_TAB[10] ={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0x0F8,0x80,0x90};
char runing;
int count;
char clear;
void main(){
    unsigned char i,j;
    TMOD=0x01;
    TCON=0x00;
    TH0=0x3c;
    TL0=0xb0;
    EA=1;
    ET0=1;
    EX0=1;
    EX1=1;
    PX0=1; //start 优先
    IT1=1;  //管脚的电平从高到低的负跳变有效
    IT0=1;
    TR0=1; 



    while(1){
        if(clear)
        {
            i=0;
            j=0;
            P0= (0x7f&LED_TAB[i]);
            P2= LED_TAB[j];
            clear=0;
        }
        if (!runing) continue;
        for(;count-2>=0;count-=2){  ///类似汇编里的disdp
            j++;
            if (j==10){
                i++;
                j=0;
            }
            P0= (0x7f&LED_TAB[i]);
            P2= LED_TAB[j];
            if (i==10) i=0;
        }   
    }

}

void a(void) interrupt 1
{
    TH1=0x3c;
    TL1=0xb0;
    if (runing==0) return;
    count++;
}



void buttonStart(void) interrupt 0
{
    runing=runing?0:1;
    count=0;
    clear=1;
}

void buttonPause(void) interrupt 2
{
    runing=runing?0:1;
}
分类
所有文章 编程

winows下golang编译流程

golang编译流程
go run xxx
go tool: no such tool “compile”
go tool: no such tool “asm”
go tool: no such tool “link”

go tool compile hello.go
go tool link hello.o

或者
C:\Go\pkg\tool\windows_amd64\compile.exe
C:\Go\pkg\tool\windows_amd64\link.exe hello.o

main.ctxt.loadlib()->loadlib->loadobjfile->ldobj->loadpe

ctxt.Out写文件

生成流程图

go-callvis github.com/syncthing/syncthing/cmd/syncthing | dot -Tpng -o syncthing.png