Thursday, 9 February 2017

BASIC ARM LPC2148 ASSEMBLY CODES-II

PROGRAM 1:


PROGRAM TO FIND FIBONACCI SERIES     
  
       area fbnc,code,readonly
entry
         mov r5,#10
         ldr r0,=0x40000000
                    mov r1,#01
                    mov r2,#00

back     add r3,r1,r2
                    str r3,[r0],#04
                    mov r2,r1
                    mov r1,r3
                    subs r5,r5,#01
                    cmp r5,#00
                    bne back
stop     b  stop
         end

PROGRAM 2:

PROGRAM TO FIND MAXIMUM OF GIVEN NUMBERS

      area max,code,readonly
entry
      ldr r0,=numbers
            mov r1,#06
            ldr r2,[r0],#04
loop  ldr r3,[r0],#04
            cmp r2,r3
            bhi next
            mov r2,r3

next  subs r1,r1,#01
           cmp r1,#00
            bne loop
stop  b  stop
    
         area max1,code
numbers dcd 0x04, 0x08, 0x15, 0x07, 0x24, 0x74, 0x18
      end

PROGRAM 3:

PROGRAM TO FIND MINIUM OF GIVEN NUMBER

      area minimum,code,readonly
Entry
      ldr r0,=numbers
            mov r1,#06
            ldr r2,[r0],#04
loop  ldr r3,[r0],#04
      cmp r2,r3
            bls next
            mov r2,r3

next  subs r1,r1,#01
      cmp r1,#00
            bne loop
stop  b  stop
    
         area minimum,code
numbers dcd 0x04, 0x08, 0x15, 0x07, 0x24, 0x74, 0x18
      end   
       
 PROGRAM 4:

PROGRAM TO FIND PRIME NUMBERS

       area prim,code,readonly
entry
main    
      mov r0,#01
            ldr r6,=0x40000000
            mov r8,#0x64

start mov r1,r0
            add r0,r0,#01
            lsr r9,r1,#01
            mov r5,r9
            mov r4,#02
            bl subb

back   cmp r3,#01
       bge prime
      
goo    subs r8,r8,#01
       cmp r8,#00
             bne start
             b stop

prime  str r1,[r6],#04
       subs r8,r8,#01
       cmp r8,#00
             bne start
             b stop

subb   mov r3,r1
loop   subs r3,r3,r4
             cmp r3,r4
             bge loop
             cmp r3,#00
             beq goo
             cmp r4,r5
             beq back
             add r4,r4,#01
             subs r9,r9,#01
             cmp r9,#00
             bgt subb
             mov pc,lr
stop   b  stop
       end

PROGRAM 5:

PROGRAM TO IMPLEMENT MULTIPLICATION OF TWO 8bit NUMBERS

          area multiplication,code,readonly
entry
    mov r0,#06
          mov r1,#02
          mul r2,r1,r0
          end

PROGRAM 6:

PROGRAM TO IMPLEMENT MULTIPLICATION OF TWO NUMBERS WITHOUT USING mul INSTRUCTION

          area multiplication,code,readonly
entry
    mov r0,#13
          mov r1,#04
loop
    add r3,r3,r0
          add r2,#01
          cmp r2,r1
          bne loop
          mov r4,r3
          end

PROGRAM 7:

PROGRAM TO SORT POSITIVE AND NEGATIVE NUMBERS

       area positive_negative,code,readonly
entry
       ldr r0,=0x40000000
             ldr r1,=0x40000038
             ldr r2,=0x40000054
       mov r3,#10

back   ldr r4,[r0],#04
             movs r5,r4,lsl#01
             movcs r6,r4;
             strcs r6,[r1],#04;negative no stored in memory location ;
             addcs r8,r8,#01;no of negative no's;          
             movcc r7,r4;
             strcc r7,[r2],#04;positive no stored in memory location;
             addcc r9,r9,#01;no of positive no's;                              
             subs r3,r3,#01
             cmp r3,#00
             bne back
stop   b stop
             end

PROGRAM 8:

PROGRAM TO DISPLAY 0-9 ON 7 SEGMENT

             area seven_segment,code,readonly
entry
main  
       mov r0,#07
             mov r4,#04
             ldr r1,=value
             mul r3,r0,r4
             add r1,r1,r3
             ldr r2,[r1]
       b stop
   
             area seven_segment,code,readonly
value  dcd 0xbf,0x86,0xbb,0x8f,0xe6,0xab,0xfb
       dcd 0x87,0xff,0xef
stop   b stop
       end

2 comments:

  1. How to check ouput to find prime number ??
    What are the input values given ??

    ReplyDelete
  2. can u please provide linear search and binary search programs for LPC2148.i coudn't find it anywhere.
    actual questions:
    1.to perform linear search and store FF in memory if element is found else store 00
    2.to perform binary search and store FF in memory if element is found else store 00

    ReplyDelete

we are hear to discuss your queries ,so please feel free to ask any of your queries.

Wikipedia

Search results