⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paulmon1.asm

📁 MCS51系列单片机的汇编器
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        acall   pstr        acall   newline        pop     dph        pop     dpl        sjmp    help0help_2: mov     dptr,#help2txt        acall   pstr        pop     dph        pop     dpl        RETrun:        push    dpl        push    dph        mov     dptr,#prompt6        acall   pstr        acall   cin        acall   upper        cjne    a,#27,run1        mov     dptr,#abort             ;if they press <ESC>        acall   pstr        pop     dph        pop     dpl        retrun1:   cjne    a,#'?',run3        mov     dptr,#help3txt          ;if they pressed ?        acall   pstr        mov     dptr,#prompt7        acall   pstr        acall   cin        cjne    a,#27,run2        pop     dph        pop     dpl        retrun2:   mov     dptr,#help4txt        acall   pstr        mov     dptr,#help5txt        acall   pstr        pop     dph        pop     dpl        retrun3:   cjne    a,#'S',run4        mov     dptr,#runss        acall   pstr        ajmp    ssrunrun4:   mov     dptr,#runstd        acall   pstr        mov     dptr,#prompt8              ;run the user's program        acall   pstr        pop     dph        pop     dpl        acall   phex16        push    dpl        push    dph        mov     dptr,#prompt4        acall   pstr        pop     dph        pop     dpl        acall   ghex16        jnc     run5        mov     dptr,#abort        acall   pstr        retrun5:   mov     a,#'\r'        acall   cout        push    dpl        push    dph        mov     dptr,#runs1        acall   pstr        pop     dph        pop     dpl        mov     a,#rst & 0xFF                   push    acc        mov     a,#rst        push    acc        push    dpl        push    dph        ret                     ;<-- actually jumps to user's program        ssrun:  mov     dptr,#prompt8              ;run single step        acall   pstr        pop     dph        pop     dpl        push    dpl        push    dph        acall   phex16        mov     dptr,#prompt4        acall   pstr        pop     dph        pop     dpl        acall   ghex16        push    dpl        push    dph        jnc     ssrun1        mov     dptr,#abort        acall   pstr        acall   newline        pop     dph        pop     dpl        retssrun1: clr     tcon.2        jnb     p3.3,ssrun2        mov     dptr,#sserr1      ;give error msg if int1 not grounded        acall   pstr        pop     dph        pop     dpl        retssrun2: mov     dptr,#prompt9           ;ask for priority        acall   pstr        acall   cin        acall   upper        cjne    a,#27,ssrun3        mov     dptr,#abort        acall   pstr        pop     dph        pop     dpl        retssrun3: cjne    a,#'L',ssrun4        mov     ip,#00000000b        sjmp    ssrun5ssrun4: mov     ip,#00000100bssrun5: mov     dptr,#ssmsg     ;tell 'em it now time, remind to        acall   pstr            ;to hit <RET> for next inst        pop     dph        pop     dpl        mov     sp,#38h        mov     a,#rst & 0xFF                   push    acc        mov     a,#0        push    acc        clr     a        clr     c        mov     r0,#0        mov     r1,#1        mov     r2,#0        mov     r3,#0        mov     r4,#0        mov     r5,#0        mov     r6,#0        mov     r7,#0        clr     tcon.2        setb    p3.3        mov     ie,#10000100b        jmp     @a+dptrdump:           mov     r2,#16          ;number of lines to print        acall   newlinedump1:  mov     r0,#20h         ;pointer to memory to store bytes        acall   phex16        mov     a,#':'        acall   cout        mov     a,#' '        acall   coutdump2:  clr     A                  ;<--acquire 16 bytes        movc    a,@a+dptr          ;and store from 20 to 2F        mov     @r0,a        acall   phex        mov     a,#' '        acall   cout        inc     dptr        inc     r0        cjne    r0,#30h,dump2        acall   cout        mov     r0,#20h           ;now we'll print it in asciidump3:  mov     a,@r0        anl     a,#01111111b      ;avoid unprintable characters        mov     b,a        clr     c        subb    a,#20h        jnc     dump4        mov     b,#' 'dump4:  mov     a,b        acall   cout        inc     r0        cjne    r0,#30h,dump3        acall   newline        acall   esc        jc      dump5        djnz    r2,dump1        ;loop back up to print next linedump5:  acall   newline        retnew_loc:push    dph        push    dpl        acall   newline        mov     dptr,#prompt5        acall   pstr        pop     dpl        pop     dph        push    dph        push    dpl        acall   ghex16        acall   newline        jc      newloc1        acall   newline        pop     acc        pop     acc        retnewloc1:mov     dptr,#abort        acall   pstr        pop     dpl        pop     dph        acall   newline        retedit:      ;edit external ram...        push    dpl        push    dph        mov     dptr,#edits1        acall   pstr        pop     dph        pop     dpledit1:  acall   phex16        mov     a,#':'        acall   cout        acall   space        mov     a,#'('        acall   cout        movx    a,@dptr        acall   phex        push    dpl        push    dph        mov     dptr,#prompt10        acall   pstr        acall   ghex        jb      psw.5,edit2        jc      edit2        pop     dph        pop     dpl        movx    @dptr,a        acall   newline        inc     dptr        ajmp    edit1edit2:  mov     dptr,#edits2        acall   pstr        pop     dph        pop     dpl        retlist:       ;prints out dis-assembly list of memory        mov     r2,#18  ;# of lines to list        acall   newlinelist1:  mov     a,r2        push    acc        acall   disasm          ;this obviously does all the work        pop     acc        mov     r2,a        acall   esc        jc      list2        djnz    r2,list1list2:  acall   newline        retCIN:        JNB     RI,cin  ; wait for character        CLR     RI        MOV     A,SBUF        RETCOUT:    ;note, improved... much faster transmission        jnb     ti,*       ;wait if a character is still sending        MOV     SBUF,A        CLR     TI         ;note: hardware will set ti when the        RET                ;      character finishes sending... esc:  ;checks to see if <ESC> is waiting on serial port.      ;C=clear if no <ESC>, C=set if <ESC> pressed, buffer flushed        push    acc        clr     c        jnb     ri,esc1        mov     a,sbuf        cjne    a,#27,esc1        setb    c        clr     riesc1:   pop     acc        retNEWLINE:        PUSH    ACC        MOV     A,#'\r'        ACALL   COUT        POP     ACC        RETg1hex:     ;gets one character.  Converts to hex and places in Acc           ;C=1 if <ESC> pressed, 0 otherwise           ;PSW.5=1 if <RET> pressed, 0 otherwise           ;PSW.2=1 if backspace or delete, 0 otherwise  (not yet)        acall   cin        acall   upper        clr     c        clr     psw.5        clr     psw.2        cjne    a,#13,g1hex2        setb    psw.5        retg1hex2: cjne    a,#27,g1hex2a        cpl     c        retg1hex2a:cjne    a,#8,g1hex2cg1hex2b:setb    psw.2        retg1hex2c:cjne    a,#127,g1hex3        sjmp    g1hex2bg1hex3: push    b        mov     b,a        acall   asc2hex                jc      g1hex4           ;they typed a bad char, so go back        xch     a,b        acall   cout        xch     a,b        pop     b        retg1hex4: pop     b        sjmp    g1hexghex:      ; gets an 8-bit hex value from keyboard, returned in A.           ; C=1 if <ESC> pressed, 0 otherwise           ; PSW.5 if <RET> pressed w/ no input, 0 otherwise        acall   g1hex        jnb     psw.5,ghex1        retghex1:  jnc     ghex2        retghex2:  swap    a        mov     b,aghex3:  acall   g1hex        jb      psw.2,ghex6        jnb     psw.5,ghex4        clr     psw.5        mov     a,b        swap    a        retghex4:  jnc     ghex5        retghex5:  orl     a,b        retghex6:  mov     a,#8        acall   cout        sjmp    ghex        ghex16:    ; gets a 16-bit hex value from keyboard, returned in DPTR.           ; C=0 if normal <RET>, C=1 if <ESC> pressed        push    acc        mov     a,r0        push    acc        mov     a,r1        push    acc        mov     a,r2        push    acc        mov     a,r3        push    accghex16a:acall   g1hex           ;get first character        mov     r0,a        jc      ghex16z        jb      psw.5,ghex16z        jb      psw.2,ghex16aghex16e:acall   g1hex           ;get second character        mov     r1,a        jc      ghex16z        jb      psw.5,ghex16s        jnb     psw.2,ghex16i        mov     a,#8        acall   cout        sjmp    ghex16aghex16i:acall   g1hex           ;get third character        mov     r2,a        jc      ghex16z        jb      psw.5,ghex16t        jnb     psw.2,ghex16m        mov     a,#8        acall   cout        sjmp    ghex16eghex16m:acall   g1hex           ;get fourth character        mov     r3,a        jc      ghex16z        jb      psw.5,ghex16u        jnb     psw.2,ghex16v        mov     a,#8        acall   cout        sjmp    ghex16i        ghex16s:mov     dph,#0          ;one digit entered        mov     dpl,r0        sjmp    ghex16zghex16t:mov     dph,#0          ;two digit entered        mov     a,r0        swap    a        orl     a,r1        mov     dpl,a        sjmp    ghex16zghex16u:mov     dph,r0          ;three digit entered        mov     a,r1        swap    a        orl     a,r2        mov     dpl,a        sjmp    ghex16zghex16v:mov     a,r0            ;all four digit entered        swap    a        orl     a,r1        mov     dph,a        mov     a,r2        swap    a        orl     a,r3        mov     dpl,a ghex16z:pop     acc             ;exit, at last...        mov     r3,a        pop     acc        mov     r2,a        pop     acc        mov     r1,a        pop     acc        mov     r0,a        pop     acc        ret        PHEX:        PUSH    ACC        SWAP    A        ACALL   PHEX1        POP     ACC        ACALL   PHEX1        RETPHEX1:  ANL     A,#0FH        ADD     A,#3        MOVC    A,@A+PC        ACALL   COUT        RET        .DB     "0123456789ABCDEF"asc2hex:             ;carry set if invalid input        clr     c        push    b        subb    a,#'0'        mov     b,a        subb    a,#10        jc      a2h1        mov     a,b        subb    a,#7        mov     b,aa2h1:   mov     a,b        clr     c        anl     a,#11110000b     ;just in case...        jz      a2h2        setb    ca2h2:   mov     a,b        pop     b        retupper:  ;converts the ascii code in Acc to uppercase, if it is lowercase        push    b        mov     b,a        clr     c        subb    a,#61h        jc      upper1;   not a lowercase character        subb    a,#26        jnc     upper1        clr     c        mov     a,b        subb    a,#20h        mov     b,aupper1: mov     a,b        pop     b        retspace:  push    acc        mov     a,#' '        acall   cout        pop     acc        retPHEX16:        PUSH    ACC        MOV     A,DPH        ACALL   PHEX        MOV     A,DPL        ACALL   PHEX        POP     ACC        RETPSTR:                  ;print string        PUSH    ACCPSTR1:  CLR     A        MOVC    A,@A+DPTR        jb      ri,pstr3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -