Jump to content
xisto Community
Sign in to follow this  
abimanyu

Assembly Language Tutorials Assembly Language Tutorials

Recommended Posts

The attached file is in MS Word format it's some what old tutorials but i help new comers alotTutorials Information :Assembler Tutorial1996 Edition University of Guadalajara Information Systems General Coordination.Culture and Entertainment Web

Share this post


Link to post
Share on other sites
computer architectureAssembly Language Tutorials

how to write a MIPS assembly language program to request two numbers from the user and compute the following formula: C = B*B ? (4*A*B), where A and B are the two numbers that the user entered, and C is the result. Your program should output C.

-question by ollyboy1

Share this post


Link to post
Share on other sites
2 questions,please answer them:(Assembly Language Tutorials

1. Switch statements are particularly challenging to reverse engineer fromThe object code. You are given the following scenario,The Turkish alphabet is composed of 29 letters based on Latin alphabet. Six of theLowercase letters (I.E., ?c, ˘g, ı, ?o, ?s, ?u) are encoded as Unicode characters but theRest alphabet is encoded as ASCII characters. The table below illustrate Unicode ofEach one and the location in the alphabet.Table 1: Lowercase Turkish AlphabetLetter ?c ˘g ı ?o ?s ?uUnicode 231 240 253 246 254 252LetterNumber4 9 11 19 23 26Based on the preceding information, the code below is partially given. In the followingProcedure, the body of the switch statement has been removed but the correspondingAssembly code is given below:Typedef enum{C04=231 ,C09=240 ,C11=253 ,C19=246 ,C23=254 ,C26=252} Lowercase ;Int identify_six_lowercase ( Lowercase letter ){Int result ;Switch ( letter ){:/ body of the swi t c h /:}Return result ;}Assembly code for the given functionLC6: .Ascii "invalid letter0"LC4: .Ascii "23th letter in the alphabet0"LC0: .Ascii "Fourth letter in the alphabet0"LC1: .Ascii "Nineth letter in the alphabet0"LC3: .Ascii "19th letter in the alphabet0"LC5: .Ascii "26th letter in the alphabet0"LC2: .Ascii "11th letter in the alphabet0"_identify_six_lowercase:Pushl %ebpMovl %esp, %ebpPushl %ebxSubl $4, %esp

movl 8(%ebp), %ebxLeal -231(%ebx), %eaxCmpl $23, %eaxJa L9Jmp *L10(,%eax,4).Section .Rdata,"dr".Align 4L10:.Long L3.Long L9 .Long L9 .Long L9 .Long L9 .Long L9 .Long L9 .Long L9 .Long L9.Long L4.Long L9 .Long L9 .Long L9 .Long L9 .Long L9.Long L6.Long L9 .Long L9 .Long L9 .Long L9 .Long L9.Long L8.Long L5.Long L7.Text .P2align 4,,7L9:Movl $LC6, (%esp)Call _putsPopl %edxXorl %eax, %eaxPopl %ebxPopl %ebpRetL7:Movl $LC4, (%esp)Call _putsPopl %edxMovl %ebx, %eaxAndl $3, %eaxPopl %ebxPopl %ebpRetL3:Movl $LC0, (%esp)Call _putsPopl %edxLeal 0(,%ebx,4), %eaxPopl %ebxPopl %ebpRetL4:Movl $LC1, (%esp)Call _putsPopl %edx

movl %ebx, %eaxShrl $2, %eaxPopl %ebxPopl %ebpRetL6:Movl $LC3, (%esp)Call _putsPopl %edxLeal -4(%ebx), %eaxPopl %ebxPopl %ebpRetL8:Movl $LC5, (%esp)Call _putsPopl %edxMovl %ebx, %eaxPopl %ebxPopl %ebpRetL5:Movl $LC2, (%esp)Call _putsPopl %edxLeal 4(%ebx), %eaxPopl %ebxPopl %ebpRetFill in the body of the switch statement with C code that will have the same behaviorAs the assembly code.

 

question2:

2. Assume that you are charged with maintaining a C program and you come acrossThe following code:Typedef struct {Int left ;A_struct a [ and ] ;B_struct b [ M ] ;Int right ;} c_struct ;Void test ( int I , int j , c_struct c ){Int and = c−>left + c−>right ;Int m = c−>left − c−>right ;A_struct a = &c−>a [ I ] ;B_struct b = &c−>b [ j ] ;A−>x [ a−>ix]= and ;B−>y [ b−>iy]= m ;}You are unable to access the C code segment in which the compile?time constant andAnd M and structures a_struct and b_struct were defined. However, you have anAccess to disassembled code given below. Using the reverse engineering skills, deduceThe following:(a) The value of and and M.(B) Complete declaration of structure a_struct and b_struct. AssumeThat there are two fields in a_struct are idx and x. Similarly there are two fieldsIn b_struct (I.E., idy and y).Explicitly indicate each step in your solutions.

Disassebled Code:01-00000000 <_test>:02- 0: 55 push %ebp03- 1: 89 e5 mov %esp,%ebp04- 3: 83 ec 0c sub $0xc,%esp05- 6: 89 1c 24 mov %ebx,(%esp)06- 9: 8b 5d 10 mov 0x10(%ebp),%ebx07- c: 8b 45 08 mov 0x8(%ebp),%eax08- f: 89 7c 24 08 mov %edi,0x8(%esp)09- 13: 8b 4d 0c mov 0xc(%ebp),%ecx10- 16: 89 74 24 04 mov %esi,0x4(%esp)11- 1a: 8b 93 ac 00 00 00 mov 0xac(%ebx),%edx12- 20: 8d 04 c0 lea (%eax,%eax,8),%eax13- 23: 8b 33 mov (%ebx),%esi14- 25: 8d 04 83 lea (%ebx,%eax,4),%eax15- 28: 8d 0c 89 lea (%ecx,%ecx,4),%ecx16- 2b: 8d 0c 8b lea (%ebx,%ecx,4),%ecx17- 2e: 8d 3c 16 lea (%esi,%edx,1),%edi18- 31: 29 d6 sub %edx,%esi19- 33: 8b 50 04 mov 0x4(%eax),%edx20- 36: 89 7c 90 08 mov %edi,0x8(%eax,%edx,4)21- 3a: 8b 41 70 mov 0x70(%ecx),%eax21- 3d: 89 74 81 74 mov %esi,0x74(%ecx,%eax,4)22- 41: 8b 1c 24 mov (%esp),%ebx23- 44: 8b 74 24 04 mov 0x4(%esp),%esi24- 48: 8b 7c 24 08 mov 0x8(%esp),%edi25- 4c: 89 ec mov %ebp,%esp26- 4e: 5d pop %ebp27- 4f: c3 ret

-reply by erdem kaya

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.