0% found this document useful (0 votes)
35 views6 pages

Move A Block of 8 Dat Words From 0010 To 0030

The document contains examples of assembly language programs (ALPs) that perform various operations: 1) Moving blocks of data and bytes between memory locations. 2) Multiplying numbers by powers of two. 3) Exchanging blocks of words in memory. 4) Finding the largest number in an array. 5) Arranging numbers in ascending order. 6) Calculating the cube of a 16-bit number. 7) Multiplying and dividing 16-bit numbers. 8) Setting and clearing individual bits in a given word. 9) Computing logical and bitwise operations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views6 pages

Move A Block of 8 Dat Words From 0010 To 0030

The document contains examples of assembly language programs (ALPs) that perform various operations: 1) Moving blocks of data and bytes between memory locations. 2) Multiplying numbers by powers of two. 3) Exchanging blocks of words in memory. 4) Finding the largest number in an array. 5) Arranging numbers in ascending order. 6) Calculating the cube of a 16-bit number. 7) Multiplying and dividing 16-bit numbers. 8) Setting and clearing individual bits in a given word. 9) Computing logical and bitwise operations.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

1. move a block of 8 dat words from 0010 to 0030 mov.w #0010h, r5 mov.w #0030h, r6 mov #08, r7 up: mov.

w @r5, 0 r6! incd.w r5 incd.w r6 dec.w r7 &n' up ; point r5 to 0010 ; point r6 to 0030 ; couter for number of words ; mov d"t" from @r5 to @r6 ; point to ne#t memor$ %oc"tion ; point to ne#t memor$ %oc"tion ; decrement counter ; &ump up

2. move a block of 8 dat bytes from 0010 to 0030 mov.w #0010h, r5 mov.w #0030h, r6 mov #08, r7 up: mov.b @r5, 0 r6! incd.w r5 incd.w r6 dec.w r7 &n' up ; point r5 to 0010 ; point r6 to 0030 ; couter for number of b$tes ; mov d"t" from @r5 to @r6 ; point to ne#t memor$ %oc"tion ; point to ne#t memor$ %oc"tion ; decrement counter ; &ump up

3.ALP to multiply a number by 2, ,8... mov.w #0(h, r5 mov.w #3h, r6 up: r%" r5 dec.w r6 &n' up ; t")e the number to be mu%tip%ied b$ * + ..in r5 ; counter for * + ... r6 , r6-r5, 0(-3 , 1.h ; mu%tip%$ b$ * ; dec the counter ; repe"t unti% the counter is 'ero

.!"c#an$e 2 block of % words at 0020 and 0030 mov.w #00*0h, r5 mov.w #0030h, r6 mov.w #05h, r7 up: mov @r5, r8 mov @r6, 0 r5! mov r8, 0 r6! incd.w r5 incd.w r6 dec r7 &n' up ; point r5 to 00*0 ; point r6 to 0030 ; counter for number of words ; /")e @r5 content to temp re0ister ; mov @r6 content into @r5 ; mov temp re0 content into @r6 ; point r5 to ne#t memor$ %oc"tion ; point r6 to ne#t memor$ %oc"tion ; decrement the counter ; repe"t unti% the counter is 'ero

%.ALP to find lar$est number in an array of 10 elements at 00 0 mov.w #00+0h, r5 mov.w @r5, r6 mov.w #0(h, r7 up: incd.w r5 cmp.w @r5, r6 &hs 1234 mov @r5, r6 1234: dec r7 &n' up ; point r5 to 0iven memor$ %oc"tion ; r6 wi%% be used to ho%d %"r0est num ; counter for number of words ; /")e @r5 content to temp re0ister ; mov @r6 content into @r5 ; do nothin0 if r6 5 @r5 ; t")e hi0her num in r6 ; decrement the counter ; repe"t unti% the counter is 'ero

&.ALP to arran$e numbers in ascendin$ order mov.w #0(h, r7 up1: mov.w #00+0h, r5 mov.w #06h, r8 up*: cmp.w @r5, * r5! &hs 1234 ; counter for number of words ; point r5 to 0iven memor$ %oc"tion ; counter for inner %oop ; comp"re r5 "nd r57*! ; &ump down

mov @r5, r6 mov * r5!, 0 r5! mov r6, * r5! 1234: incd.w r5 dec r8 &n' up* dec r7 &n' up1

; move @r5 to temp ; move r57*! to @r5 ; move temp to r57*! ; r5 points to ne#t word memor$ %oc"tion ; decrement the inner counter ; repe"t unti% the counter is 'ero ; decrement the outer counter ; &ump to up1

'. ALP to determine cube of a 1& bit number ( r8 is used #old t#e )* word and r& #olds t#e L* word of t#e result ( for a $iven number+00AA t#e result is r8+ A r&+,'&8 mov.w #0000h, r8 mov.w #00((h, r5 mov.w #0*h, r6 up1: mov.w #00((h, r7 mov.w #0000h, r6 up*: "dd.w r5, r6 &nc 1234 inc.w r8 1234: dec.w r7 &n' up* mov.w r6, r5 dec.w r6 &n' up1 ; for 89 word resu%t ; t")e 0iven number in r5 ; counter for outer %oop ; counter for inner %oop ; c%e"r r6 ; "dd r5 to r6 ; &ump on no c"rr$ to 1234 ; increment 89 word ; decrement the inner counter ; repe"t unti% the counter is 'ero ; t")e the sum in r5 ; decrement the outer counter ; repe"t unti% the counter is 'ero

8a. multiply 2 1&-bit numbers ( r% and r& #old t#e 2 1&- bit numbers and result will be in r8 and r&

( e"ample+. r% + 0"aaaa and r&+%%#, result is 38AA'2 r8+38 and r&+AA'2 mov.w #0000h, r8 mov.w #0#((((, r5 mov.w #55h, r7 mov.w #0000h, r6 up: "dd.w r5, r6 &nc 1234 inc.w r8 1234: dec.w r7 &n' up ; for 89 word resu%t ; t")e 0iven number in r5 ; t")e "nother number in r7, counter for inner %oop ; c%e"r r6 ; "dd r5 to r6 ; &ump 1234 ; increment 89 3ord ; decrement the inner counter ; repe"t unti% the counter is 'ero

8b./ivision of 2 1&-bit numbers ( r%+ '8d and r&+ ( r8+r%0r&+ 8'0 d + 11 ; t")e 0iven dividend number in r5 which is # for #:$ ; divider i.e $ for #:$ oper"tion ; initi"%i'e resu%t ; c%e"r r7 ; chec) if r5 5 r6 ; &ump to 1234 ; subtr"ct r6 from r6 ; increment the counter ; chec) if r5 5 r6 ; &ump up if r5 5 r6 ; move resu%t to r8

mov.w #+87d, r5 mov.w #++d , r6 mov.w #0001h, r8 mov.w #0000h, r7 cmp.w r5, r6 &hs 1234 up: subc.w r6, r5 inc.w r7 cmp r6, r5 &hs up mov r7, r8 1234

1a. ALP to set individual bits in a $iven word 20030 and stote result into 0032 ( 2r% #as $iven number

( r& #as info on w#ic# bit is to be set (e"ample 2r% + 0A and %t# bit is to be set, t#en result 2r' + 1A mov.w #0030h, r5 mov.w #003*h, r7 mov.w #0(h, 0 r5! mov.w #05h, r6 mov.w #01h,r8 up: dec r6 &' down r%" r8 &mp up down: bis.w r8, 0 r5! mov.w @r5, 0 r7! ; point r5 to 0#0030 ; point r7 to 0#003* ; t")e 0iven number in @r5 ; 0ive 1 for 0th bit * for 1st bit, 3 for *rd bit... ; bit set p"ttern ; decrement the counter ; &ump down ; rot"te r8 %eft ; &ump up ; set re;uired bit in @r5 ; mov resu%t to 003*

1b. ALP to set or clear individual bits in a $iven word 20030 and store result into 0032 ( 2r% #as $iven number ( r& #as info on w#ic# bit is to be cleared ( e"ample 2r% + 0A and
t#

bit is to be cleared, t#en result 2r' + 02

mov.w #0030h, r5 mov.w #003*h, r7 mov.w #0(h, 0 r5! mov.w #0+h, r6 mov.w #01h,r8 up: dec r6 &' down r%" r8 &mp up

; point r5 to 0#0030 ; point r7 to 0#003* ; t")e 0iven number in @r5 ; 0ive 1 for 0th bit * for 1st bit, 3 for *rd bit... ; bit c%e"r p"ttern ; decrement the counter ; &ump down ; rot"te r8 %eft ; &ump up

down: bic.w r8, 0 r5! mov.w @r5, 0 r7!

; c%e"r re;uired bit in @r5 ; mov resu%t to 003*

10a. ALP to compule A 3 45 ( r% + 0A#, r& + 0%#, r'+0A# (result +. r' 6 7r& 8 r%9 +0A# mov.w #0(h, r5 mov.w #05h, r6 mov.w #0(h, r7 "nd.w r5,r6 bis.w r7, r6 ; t")e < in r5 ; t")e = in r6 ; t")e ( in r7 ; perform =< ; perform ( 7 =<

10b. ALP to compute :A5 3 : A4 ( r% + 0A#, r& + 0%#, r'+0A# ( result +. :7r' 8r&9 6 :7r' 8 r%9 +,,,,# mov.w #0(h, r5 mov.w #05h, r6 mov.w #0(h, r7 "nd.w r7,r5 inv.w r5 "nd.w r7,r6 inv.w r6 bis.w r5, r6 ; t")e < in r5 ; t")e = in r6 ; t")e ( in r7 ; perform (< ; perform >(< ; perform (= ; perform >(= ; perform >(=7>(<

You might also like