guide for assembly

Embed Size (px)

Citation preview

  • 8/18/2019 guide for assembly

    1/7

      CS  40A FINAL HOWARD DACHSLAGER

    ASSUME NO SYNTAX ERRORS AND THE LOGIC IS CORRECT. NONE OF THE

    PROGRAMS ARE COMPLETE.

    Unless otherwise indicated, all numbers are assume unsigned (natural ). 

    NAME __ STUDENT #

    1. For the finite ring R 2 = {00000000, 00000001, ...,

    } find:

    11010111!10101010 = N2 = _00101101__  

    2. Compute (2354327* 25517 )mod(3117) =  N7 = _15_____  

    For the finite BYTE of octal numbers R 8 = {0, 1, 2,3,4,5,6,7, 10, 11, ...,, N } ,

    answer question 3, and 4:

    3.  N = _377 _____  

    4. The number in the BYTE R 8 : N8 = (78)5 M0D(4008) = __67_____

    5. For the dword : 

    The additive inverse in hexadecimal is

    6. Assume in an AL program:

    x DWORD

    The additive inverse of x is

    2B 07 FC FF

    15 39 04 01

    0011 0101 1110 1010 1000 1101 0110 1101

  • 8/18/2019 guide for assembly

    2/7

     

    7. Complete the following tables using hexidecimal numbers only :

    8.

    Let R = {0,1,2,3,..., 255}be decimal byte ring. For this ring find the following value of

     N = 100 + (- 235*59 + 222)*133 = _24________

    9.

    Complete the following table (Make sure all celled are filled):

    mov eax , 278901d

    EAX

    10. Complete the following table using binary numbers only. (Make sure all celled are filled):

    1101 1011 0010 0110 1000 0011 1010 0011

      32 25  24 17  16 9  8   1

    INSTRUCTIONS

    mov eax, 3F293567h 3 F 2 9 3 5 6 7

    mov ax, 9BCh 3 F 2 9 0 9 B C

    mov ax, 3D32h 3 F 2 9 3 D 3 2

    mov ax, 5h 3 F 2 9 0 0 0 5

    mov ax, 3h 3 F 2 9 0 0 0 3

    mov eax, 1267h 0 0 0 0 1 2 6 7

    BASE

    16:

    0 0 0 4 4 1 7 5

    BASE 2: 0 0 0 0 0 0 0 0 0 0 0 0 0100 0100 0001 0111 0101

    BASE 8: 0 1 0 4 0 5 6 5

  • 8/18/2019 guide for assembly

    3/7

     

    11.

    Complete the following table with HEXADECIMAL NUMBERS ONLY:

    For problems 12, 13 complete the following tables using hexadecimal numbers only :

    32 25 24 17  16 9  8 1

    INSTRUCTIONS

    mov eax, 112937234d 0000 0110 1011 1011 0100 1001 0001 0010

    mov ax, 9BCh 0000 0110 1011 1011 0100 1001 1011 1100

    mov al, 5 0000 0110 1011 1011 0100 1001 0000 0101

    mov ah, 0Eh 0000 0110 1011 1011 0000 1110 0000 0101

    mov al, 2d 0000 0110 1011 1011 0000 1110 0000 0010

    AL PSEUDO CODE AL CODE X Y EAX EBX

    X := 23o mov x, 23o 13 - - -

    Y := 57o mov y, 57o 13 2F - -

    EAX := X mov eax, x 13 2F 13 -

    EBX := Y mov ebx, y 13 2F 13 2F

    X := EBX mov x, ebx 2F 2F 13 2F

     Y := EAX mov y, eax 2F 13 13 2F

    Make sure all cells are filled.

    12.  BASE 16

  • 8/18/2019 guide for assembly

    4/7

    14. The largest signed integer number, base 8, that can be store in a variable of type BYTE is

     ____127__________

    The smallest  signed integer number, base 8, that can be store in a variable of type BYTE is

     ___-127____  

    15. Assume the decimal byte ring {0, 1, 2, ..., 255} is considered signed numbers.

    Then the relation 210 < 4 is (a). true (b) false

    32

    25

    24

    17

    16

    9

    8 1

    INSTRUCTIONS

    mov eax, 293567h 0 0 2 9 3 5 6 7

    mov ax, 9BCh 0 0 2 9 0 9 B C

    mov ax, 3D32h 0 0 2 9 3 D 3 2

    mov ax, 5h 0 0 2 9 0 0 0 5

    mov ax, 3h 0 0 2 9 0 0 0 3

    mov eax, 1267 0 0 0 0 1 2 6 7

    13. 32 25  24 17  16 9  8 1

    INSTRUCTIONS

    mov eax, 112937234d 0 6 B B 4 9 1 2

    mov ax, 9BCh 0 6 B B 0 9 B C

    mov al, 5 0 6 B B 0 9 0 5mov ah, 0Eh 0 6 B B 0 E 0 5

    mov al, 2 0 6 B B 0 E 0 2

  • 8/18/2019 guide for assembly

    5/7

     ____false_______  

    16. K := 0 

    R := 2259 

    WHILE R > 0

    BEGIN

    K := K +1

    R :=2258 - K*100 

    END

    R := R + 55 

    For the above program, the final value stored in R is __-7________  

    17.

    For the instruction: mov ecx , 725715041d complete the following table below:

    ECX  .

    18. Complete the following table USING HEXADECIMAL NUMBERS ONLY :

    BASE 2: 1010 1101 0000 0110 0010 0001 1000 0001

    BASE 16: 2 B 4 1 8 8 6 1

      BASE 9: 1 7 7 6 5 0 3 7 8 5

    AL PSEUDO CODE AL CODE X Y EAX EBX

    X := 29d mov x, 29 1D - - -

  • 8/18/2019 guide for assembly

    6/7

    19. Complete the following table using BINARY NUMBERS ONLY (Make sure all cells

    that have numbers are filled)

    20. Complete the following table in DECIMAL NUMBERS ONLY. (Make sure all cells that

    have numbers are filled)

    Y := 59d mov y, 59 1D 3B - -

    EAX := X mov eax, x 1D 3B 1D -

    EBX := Y mov ebx, y 1D 3B 1D 3B

    X := EBX mov x, ebx 3B 3B 1D 3B

     Y := EAX mov y, eax 3B 1D 1D 3B

      32 25 24 17 16 9 8 1

    INSTRUCTIONS

    mov eax, 293567h 0000 0000 0010 1001 0011 0101 0110 0111

    mov ax, 9BCh 0000 0000 0010 1001 0000 1001 1011 1100

    mov ax, 3D32h 0000 0000 0010 1001 0011 1101 0011 0010

    mov ax, 5h 0000 0000 0010 1001 0000 0000 0000 0101

    mov ax, 3h 0000 0000 0010 1001 0000 0000 0000 0011

    mov eax, 1267 0000 0000 0000 0000 0001 0010 0110 0111

  • 8/18/2019 guide for assembly

    7/7

     

    INSTRUCTIONS CYCLE OF INSTRUC-

    TIONS

    N10 A N7 K  

     N10 := 489 N10 := 489 1E9 - - -

    K : = 1 K : = 1 1E9 - - 1

     N7 := 0 N7 := 0 1E9 - 0 1

    WHILE N10 0 WHILE N10 0

    BEGIN BEGIN

    A := N10 MOD 7 A := N10 MOD 7 1E9 6 0 1

     N7 := N7 + A*K N7 := N7 + A*K  1E9 6 6 1

     N10 := N10÷7  N10 := N10÷7 45 6 6 1

    K := 10*K K := 10*K 45 6 6 10

    A := N10 MOD 7 45 6 6 10

     N7 := N7 + A*K  45 6 42 10

     N10 := N10÷7 9 6 42 10

    K := 10*K 9 6 42 64

    A := N10 MOD 7 9 2 42 64

     N7 := N7 + A*K  9 2 10A 64

     N10 := N10÷7 1 2 10A 64

    K := 10*K 1 2 10A 3E8

    A := N10 MOD 7 1 1 10A 3E8

     N7 := N7 + A*K  1 1 4F2 3E8

     N10 := N10÷7 0 1 4F2 3E8

    K := 10*K 0 1 4F2 2710

    END END