Difference between revisions of "CSC231 Homework 3 Solutions 2010"

From dftwiki3
Jump to: navigation, search
(Created page with '--~~~~ ---- =hw3a.asm= <code><pre> ;;; ; ; Ashley Smith ;;; ; ; 231a-ae ;;; ; ; 6 October 2010 ;;; ; ; hw3a.asm (Problem #1 of Homework 3) ;;; ; ; ;;; ; ; Moves the contents of a…')
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] 14:18, 15 October 2010 (UTC)
 
--[[User:Thiebaut|D. Thiebaut]] 14:18, 15 October 2010 (UTC)
 
----
 
----
 +
<onlysmith>
 +
 
=hw3a.asm=
 
=hw3a.asm=
 
<code><pre>
 
<code><pre>
Line 47: Line 49:
 
add ah, byte[tableb] ; add "1" to ah
 
add ah, byte[tableb] ; add "1" to ah
 
mov byte[tablew], ah ; ah -> 1st B of tablew
 
mov byte[tablew], ah ; ah -> 1st B of tablew
 +
 
;; using a word
 
;; using a word
 
mov ax, word[tableb+1] ; "10" and "0xff" -> ax
 
mov ax, word[tableb+1] ; "10" and "0xff" -> ax
 
mov byte[tablew+1*2], al ; "10" -> 3rd B of tablew
 
mov byte[tablew+1*2], al ; "10" -> 3rd B of tablew
 
mov byte[tablew+2*2], ah ; "0xff" -> 5th B of tablew
 
mov byte[tablew+2*2], ah ; "0xff" -> 5th B of tablew
 +
 
;; using a double word
 
;; using a double word
 
mov eax, dword[tableb+3] ; "5", "0x0a", "01" -> eax
 
mov eax, dword[tableb+3] ; "5", "0x0a", "01" -> eax
Line 110: Line 114:
 
mov byte[tabled], al  ; "1" -> 1st B of tabled
 
mov byte[tabled], al  ; "1" -> 1st B of tabled
 
mov byte[tabled+1*4], ah ; "10" -> 4th B of tabled
 
mov byte[tabled+1*4], ah ; "10" -> 4th B of tabled
 +
 
;; using a byte
 
;; using a byte
 
mov ah, byte[tableb+2] ; "ff" -> ah
 
mov ah, byte[tableb+2] ; "ff" -> ah
 
mov byte[tabled+2*4], ah ; ah -> 8th B of tabled
 
mov byte[tabled+2*4], ah ; ah -> 8th B of tabled
 +
 
;; using a word
 
;; using a word
 
mov ax, word[tableb+3] ; "5" and "0a" -> ax
 
mov ax, word[tableb+3] ; "5" and "0a" -> ax
Line 176: Line 182:
 
mov ax, word[tabled] ; 0001 -> ax
 
mov ax, word[tabled] ; 0001 -> ax
 
mov byte[tableb], al ; 01 -> 1st B of tableb
 
mov byte[tableb], al ; 01 -> 1st B of tableb
 +
 
;; move 02 into [tableb+1]
 
;; move 02 into [tableb+1]
 
mov ax, word[tabled+4] ; 0002 -> ax
 
mov ax, word[tabled+4] ; 0002 -> ax
 
mov byte[tableb+1], al ; 02 -> 2nd B of tableb
 
mov byte[tableb+1], al ; 02 -> 2nd B of tableb
 +
 
;; move 255 into [tableb+2]
 
;; move 255 into [tableb+2]
 
mov ax, word[tabled+8] ; 00ff (hex of 255) -> ax
 
mov ax, word[tabled+8] ; 00ff (hex of 255) -> ax
 
mov byte[tableb+2], al  ; 00ff -> 3rd B of tableb
 
mov byte[tableb+2], al  ; 00ff -> 3rd B of tableb
 +
 
;;  move 256 into [tableb+3]
 
;;  move 256 into [tableb+3]
 
mov ax, word[tabled+12] ; move 0100 (hex of 256) -> ax
 
mov ax, word[tabled+12] ; move 0100 (hex of 256) -> ax
 
mov byte[tableb+3], al  ; move 00 -> 4th B of tableb
 
mov byte[tableb+3], al  ; move 00 -> 4th B of tableb
 +
 
;; move 5678 into [tableb+4]
 
;; move 5678 into [tableb+4]
 
mov ax, word[tabled+16] ; 5678 -> ax
 
mov ax, word[tabled+16] ; 5678 -> ax
 
mov byte[tableb+4], al  ; 78 -> 5th B of tableb
 
mov byte[tableb+4], al  ; 78 -> 5th B of tableb
 +
 
;; move 4321 into [tableb+5]
 
;; move 4321 into [tableb+5]
 
mov ax, word[tabled+20] ; 4321 -> ax
 
mov ax, word[tabled+20] ; 4321 -> ax
Line 197: Line 208:
 
        int    0x80 ; final system call   
 
        int    0x80 ; final system call   
 
</pre></code>
 
</pre></code>
 
+
</onlysmith>
 
<br />
 
<br />
 
<br />
 
<br />

Latest revision as of 12:20, 14 December 2010

--D. Thiebaut 14:18, 15 October 2010 (UTC)



This section is only visible to computers located at Smith College