UMBC CMSC 313 -- Assembly Language Segment  


datatypes.lst


     1                                  ;; 	 [ The .data section ]		
     2                                  	
     3                                  section .data
     4 00000000 FE                      junkb:    db    -2
     5 00000001 FFFF                    junkw:    dw	-1
     6 00000003 FCFFFFFF                junkd:    dd    -4
     7 00000007 00000000000020C0        junkq:    dq    -8.0  
     8 0000000F 1000                    junk1:    dw    10h
     9 00000011 1000                    junk2:    dw    0x10
    10                                  
    11                                  ;; [ The .bss section ]
    12                                  section .bss
    13 00000000           foob:	resb	1
    14 00000001           foow:	resw 	1
    15 00000003           food:	resd	1
    16 00000007           fooq:	resq	1
    17                                  
    18                                  ;; [ The .text section ]
    19                                  section .text
    20                                      global main                       ;must be declared for linker (ld)
    21                                  ;; just like main in C -- if linking with gcc, must be main, otherwise does not have to.
    22                                  
    23                                  main:                                 ;tell linker entry point
    24                                  
    25                                  ;; put your code here
    26                                  
    27 00000000 90                      	nop
    28 00000001 B805000000              	mov	eax, 5
    29 00000006 40                      	inc	eax
    30 00000007 A3[01000000]            	mov	[foow], eax
    31 0000000C 66C705[01000000]10-     	mov	[foow], word 10h
    32 00000014 00                 
    33 00000015 C705[03000000]2000-     	mov	[food], dword 0x20
    34 0000001D 0000               
    35 0000001F C605[00000000]30        	mov	[foob], byte 48
    36 00000026 668B1D[01000000]         	mov	bx, [junkw]
    37 0000002D 664B                    	dec	bx
    38 0000002F 66891D[01000000]        	mov	[junkw], bx
    39                                  
    40                                  
    41                                  
    42                                  
    43                                  
    44                                  
    45                                  
    46                                  
    47                                  ;; The final part of the program must be a call to the operating system to exit
    48                                  ;;; the program.
    49 00000036 BB00000000                      mov     ebx,0   ;successful termination of program
    50 0000003B B801000000                      mov     eax,1   ;system call number (sys_exit)
    51 00000040 CD80                            int     0x80    ;call kernel
    52                                  
    53                                  ;; Notice the file just ends.


©2004, Gary L. Burt